:root{
  --bg:#0f1115;
  --panel:rgba(255,255,255,.06);
  --panel2:rgba(255,255,255,.08);
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.62);
  --ring:rgba(255,255,255,.10);
  --shadow:rgba(0,0,0,.55);
  --accent:rgba(255,255,255,.22);
  --glow:rgba(255,255,255,.12);
  --pressDepth:10px;
  --snap:1.06;
  --rebound:1.02;
  --radius:28px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:radial-gradient(1200px 900px at 50% 35%, rgba(255,255,255,.06), transparent 55%),
             radial-gradient(900px 700px at 60% 55%, rgba(255,255,255,.045), transparent 58%),
             var(--bg);
  color:var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  overflow:hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.app{
  height:100%;
  display:grid;
  grid-template-rows:auto 1fr auto;
  padding:16px;
  gap:12px;
  max-width:900px;
  margin:0 auto;
}

/* Header */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 12px;
  background:linear-gradient(180deg, var(--panel2), var(--panel));
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  box-shadow: 0 18px 40px var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  letter-spacing:.02em;
}
.dot{
  width:10px;height:10px;border-radius:999px;
  background:rgba(255,255,255,.32);
  box-shadow:0 0 0 6px rgba(255,255,255,.06);
}
.brand b{font-weight:700}
.brand span{color:var(--muted); font-size:12px}

.controls{
  display:flex;
  gap:8px;
  align-items:center;
}

.chip{
  appearance:none;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  color:var(--text);
  border-radius:999px;
  padding:8px 10px;
  font-size:12px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  gap:8px;
  user-select:none;
}
.chip[aria-pressed="true"]{
  background:rgba(255,255,255,.12);
  border-color:rgba(255,255,255,.18);
}
.chip:focus{outline:2px solid rgba(255,255,255,.22); outline-offset:2px}

/* Stage & Canvas */
.stage{
  position:relative;
  display:grid;
  place-items:center;
  border-radius:24px;
  border:1px solid rgba(255,255,255,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
  box-shadow: 0 30px 70px rgba(0,0,0,.60);
  overflow:hidden;
  min-height:420px;
}

canvas#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none; /* Prevent browser zooming/scrolling */
  cursor: pointer;
}

.hint{
  position:absolute;
  bottom:14px;
  left:0; right:0;
  text-align:center;
  font-size:12px;
  color:var(--muted);
  letter-spacing:.02em;
  pointer-events:none;
}

/* Footer */
.footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 12px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.03);
  color:var(--muted);
  font-size:12px;
  backdrop-filter: blur(10px);
}

.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.04);
  color:rgba(255,255,255,.70);
}

/* Dialog */
dialog{
  width:min(520px, 92vw);
  border:none;
  border-radius:22px;
  background:linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.06));
  color:var(--text);
  box-shadow: 0 40px 120px rgba(0,0,0,.75);
  padding:0;
}
dialog::backdrop{ background:rgba(0,0,0,.55); backdrop-filter: blur(6px); }

.modal{
  padding:14px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:22px;
}

.modalHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 10px 12px;
}
.modalHeader b{letter-spacing:.06em}

.x{
  appearance:none;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  color:var(--text);
  border-radius:14px;
  padding:8px 10px;
  cursor:pointer;
}

.grid{
  display:grid;
  gap:12px;
  padding:0 10px 12px;
}

.row{
  padding:12px;
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.18);
}

.row label{display:flex; justify-content:space-between; color:rgba(255,255,255,.78); font-size:12px}
.row input[type="range"]{width:100%}

.seg{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
.seg button{
  appearance:none;
  border:1px solid rgba(255,255,255,.12);
  background:rgba(255,255,255,.06);
  color:rgba(255,255,255,.82);
  border-radius:999px;
  padding:8px 10px;
  font-size:12px;
  cursor:pointer;
}
.seg button[aria-pressed="true"]{
  background:rgba(255,255,255,.14);
  border-color:rgba(255,255,255,.20);
  color:rgba(255,255,255,.92);
}

.subnote{font-size:11px;color:rgba(255,255,255,.58);margin-top:6px}
