/* =========================================================
   NEON TETRIS — interface
   ========================================================= */
:root {
  --bg: #05070d;
  --bg-soft: #09101c;
  --panel: rgba(12, 19, 33, 0.76);
  --panel-strong: #0c1424;
  --line: rgba(148, 163, 184, 0.14);
  --line-bright: rgba(148, 163, 184, 0.24);
  --text: #eaf6ff;
  --muted: #7c8da6;
  --dim: #52637b;
  --cyan: #22d3ee;
  --cyan-soft: #8ceafb;
  --violet: #a78bfa;
  --pink: #f472b6;
  --yellow: #facc15;
  --green: #4ade80;
  --danger: #fb7185;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --display: "Arial Black", "Segoe UI Black", "Microsoft YaHei", sans-serif;
  --body: "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--body);
  background:
    radial-gradient(circle at 50% -20%, rgba(34, 211, 238, 0.16), transparent 34%),
    radial-gradient(circle at 6% 24%, rgba(167, 139, 250, 0.1), transparent 25%),
    radial-gradient(circle at 94% 70%, rgba(244, 114, 182, 0.07), transparent 24%),
    linear-gradient(180deg, #05070d 0%, #070b14 48%, #04060b 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

a {
  color: inherit;
}

::selection {
  color: #041018;
  background: var(--cyan);
}

.ambient {
  position: fixed;
  z-index: 0;
  width: 34vw;
  height: 34vw;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.13;
  pointer-events: none;
}

.ambient-cyan {
  top: 12%;
  left: -14%;
  background: var(--cyan);
  animation: float-a 18s ease-in-out infinite;
}

.ambient-violet {
  right: -16%;
  bottom: 4%;
  background: var(--violet);
  animation: float-b 23s ease-in-out infinite;
}

.page-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.3;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 38%, #000 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 38%, #000 10%, transparent 72%);
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 28px 18px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
}

.brand-badge {
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(2, 5px);
  gap: 3px;
  place-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  border-radius: 9px;
  background: linear-gradient(150deg, rgba(34, 211, 238, 0.13), rgba(167, 139, 250, 0.08));
  box-shadow: inset 0 0 18px rgba(34, 211, 238, 0.08), 0 0 26px -10px rgba(34, 211, 238, 0.6);
}

.brand-badge i {
  display: block;
  border-radius: 1px;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.8);
}

.brand-badge i:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.brand-badge i:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.brand-badge i:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
  background: var(--violet);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.8);
}

.brand-badge i:nth-child(4) {
  grid-column: 2;
  grid-row: 2;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-copy strong {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0.22em;
  line-height: 1;
  background: linear-gradient(100deg, #fff 5%, var(--cyan-soft) 48%, var(--violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.25));
}

.brand-copy small {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.29em;
}

.tagline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
}

.tagline b {
  color: rgba(34, 211, 238, 0.55);
  font-weight: 400;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(13, 21, 36, 0.6);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(20, 33, 54, 0.8);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(0);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.icon-btn .icon-off {
  display: none;
}

.icon-btn.is-muted .icon-on {
  display: none;
}

.icon-btn.is-muted .icon-off {
  display: block;
}

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-areas: "left stage right";
  grid-template-columns: 220px minmax(290px, 330px) 220px;
  align-items: start;
  justify-content: center;
  gap: clamp(18px, 2.6vw, 34px);
  margin-top: clamp(22px, 4vh, 38px);
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.rail-left {
  grid-area: left;
}

.rail-right {
  grid-area: right;
}

.stage {
  grid-area: stage;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* ---------- stage / board ---------- */
.stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 9px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.meta-label b {
  color: var(--muted);
  font-weight: 600;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  transition: color 200ms ease;
}

.status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 7px currentColor;
}

.status[data-state="playing"] {
  color: var(--green);
}

.status[data-state="playing"] i {
  animation: status-pulse 1.7s ease-in-out infinite;
}

.status[data-state="paused"] {
  color: var(--yellow);
}

.status[data-state="over"] {
  color: var(--danger);
}

.stage-meta-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.pause-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 25px;
  padding: 0 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.12em;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(13, 21, 36, 0.62);
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 120ms ease;
}

.pause-button svg {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  fill: currentColor;
}

.pause-button .icon-play {
  display: none;
}

.pause-button[data-mode="paused"] {
  color: var(--yellow);
  border-color: rgba(250, 204, 21, 0.32);
  background: rgba(250, 204, 21, 0.07);
}

.pause-button[data-mode="paused"] .icon-pause {
  display: none;
}

.pause-button[data-mode="paused"] .icon-play {
  display: block;
}

.pause-button:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(20, 33, 54, 0.86);
}

.pause-button:active:not(:disabled) {
  transform: scale(0.97);
}

.pause-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.board-frame {
  position: relative;
  width: clamp(280px, 36vh, 330px);
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(29, 43, 66, 0.85), rgba(7, 12, 21, 0.94)),
    #080d16;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.55),
    0 0 42px -14px rgba(34, 211, 238, 0.4),
    0 30px 70px -28px rgba(0, 0, 0, 0.95),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.board-frame::after {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 2;
  border-radius: 3px;
  pointer-events: none;
  box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.55);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 2;
  border-radius: 3px;
  background: #050810;
}

.screen-scan {
  position: absolute;
  inset: 8px;
  z-index: 3;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0.24;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.05) 0,
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

.frame-corner {
  position: absolute;
  z-index: 4;
  width: 15px;
  height: 15px;
  pointer-events: none;
  border-color: var(--cyan);
  opacity: 0.7;
}

.corner-tl {
  top: 3px;
  left: 3px;
  border-top: 1px solid;
  border-left: 1px solid;
}

.corner-tr {
  top: 3px;
  right: 3px;
  border-top: 1px solid;
  border-right: 1px solid;
}

.corner-bl {
  bottom: 3px;
  left: 3px;
  border-bottom: 1px solid;
  border-left: 1px solid;
}

.corner-br {
  right: 3px;
  bottom: 3px;
  border-right: 1px solid;
  border-bottom: 1px solid;
}

.stage-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.stage-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 19px;
  padding: 0 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-bottom-color: rgba(148, 163, 184, 0.33);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 8px;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  overflow: hidden;
  text-align: center;
  border-radius: 3px;
  background:
    radial-gradient(circle at 50% 16%, rgba(34, 211, 238, 0.12), transparent 38%),
    linear-gradient(180deg, rgba(5, 10, 18, 0.9), rgba(3, 6, 12, 0.97));
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.4;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(34, 211, 238, 0.12) 50%, transparent 50.3%),
    linear-gradient(0deg, transparent 49.7%, rgba(34, 211, 238, 0.08) 50%, transparent 50.3%);
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay[data-kind="paused"] {
  background:
    radial-gradient(circle at 50% 16%, rgba(34, 211, 238, 0.09), transparent 38%),
    linear-gradient(180deg, rgba(5, 10, 18, 0.95), rgba(3, 6, 12, 0.99));
}

.overlay-card {
  position: relative;
  z-index: 1;
  width: 100%;
  animation: overlay-in 500ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.overlay-kicker {
  margin: 0 0 14px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.overlay h2 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(32px, 4.6vh, 44px);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 0.06em;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.2);
}

.overlay h2 em {
  color: var(--cyan-soft);
  font-style: normal;
  text-shadow: 0 0 22px rgba(34, 211, 238, 0.55), 0 0 60px rgba(34, 211, 238, 0.25);
}

.overlay-copy {
  margin: 0 auto 20px;
  max-width: 230px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.75;
}

.overlay-score {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 auto 12px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.overlay-score strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.overlay-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 15px;
  padding: 5px 10px;
  color: var(--yellow);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.15em;
  border: 1px solid rgba(250, 204, 21, 0.22);
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.06);
}

.overlay-badge i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.btn-primary,
.btn-ghost {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  cursor: pointer;
  border-radius: 7px;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.btn-primary {
  color: #031019;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  border: 1px solid #bff7ff;
  background: linear-gradient(100deg, #e8fdff 0%, #9beaf8 55%, #7dd3fc 100%);
  box-shadow: 0 0 30px -6px rgba(34, 211, 238, 0.6);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 38px -4px rgba(34, 211, 238, 0.75);
}

.btn-primary kbd {
  color: #0a2733;
  border-color: rgba(3, 16, 25, 0.22);
  background: rgba(3, 16, 25, 0.08);
  box-shadow: none;
}

.btn-ghost {
  min-height: 38px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.06);
}

.overlay-tip {
  margin: 13px 0 0;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.overlay-tip b {
  color: var(--muted);
  font-weight: 500;
}

/* ---------- panels ---------- */
.panel {
  position: relative;
  padding: 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background:
    linear-gradient(150deg, rgba(18, 28, 47, 0.82), rgba(8, 13, 23, 0.72)),
    var(--panel);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.045),
    0 22px 55px -35px rgba(0, 0, 0, 0.95);
}

.panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.35), transparent);
  opacity: 0.55;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.panel-title kbd {
  min-width: 0;
  height: 17px;
  color: var(--dim);
  font-size: 8px;
  letter-spacing: 0.04em;
}

.label {
  display: block;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.18em;
}

/* stats */
.stats-panel {
  padding: 18px;
}

.stat-score .label {
  margin-bottom: 5px;
}

.stat strong {
  display: block;
  color: var(--text);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.stat-score strong {
  font-size: 32px;
  line-height: 1.05;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.24);
}

.stat-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.stat-pair strong {
  margin-top: 4px;
  font-size: 17px;
}

.level-meter {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.meter-copy {
  display: flex;
  justify-content: space-between;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.12em;
}

.meter-track {
  height: 3px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.12);
}

.meter-track i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
  transition: width 260ms ease;
}

/* previews */
.mini-canvas-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 86px;
  border-radius: 7px;
  background:
    linear-gradient(rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.035) 1px, transparent 1px),
    rgba(0, 0, 0, 0.16);
  background-size: 13px 13px;
}

#hold {
  display: block;
  width: 130px;
  max-width: 100%;
  height: auto;
}

.panel-note {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.02em;
  text-align: center;
}

.panel-note.is-used {
  color: var(--yellow);
}

#next {
  display: block;
  width: 130px;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.best-panel {
  background:
    radial-gradient(circle at 100% 0%, rgba(167, 139, 250, 0.12), transparent 55%),
    linear-gradient(150deg, rgba(18, 28, 47, 0.8), rgba(8, 13, 23, 0.72));
}

.best-panel > .label {
  margin-bottom: 7px;
}

.best-panel > strong {
  display: block;
  color: #e9ddff;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.best-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 12px;
  padding-top: 11px;
  color: var(--dim);
  font-size: 9px;
  line-height: 1.5;
  border-top: 1px solid var(--line);
}

.best-line i {
  flex: 0 0 auto;
  width: 3px;
  height: 3px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 6px var(--violet);
}

/* controls list */
.keys-panel {
  padding-bottom: 14px;
}

.key-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
}

.key-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 29px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
}

.key-list > div:last-child {
  border-bottom: 0;
}

.key-list dt {
  display: flex;
  gap: 3px;
  margin: 0;
}

.key-list dd {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

/* CTA */
.cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 15px;
  color: #031019;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 1px solid #a9f0fa;
  border-radius: 9px;
  background: linear-gradient(100deg, #e4fcff, #9cebf8 58%, #7dd3fc);
  box-shadow: 0 0 28px -8px rgba(34, 211, 238, 0.65);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 36px -6px rgba(34, 211, 238, 0.85);
}

.cta kbd {
  color: #08222c;
  border-color: rgba(3, 16, 25, 0.2);
  background: rgba(3, 16, 25, 0.08);
  box-shadow: none;
}

.cta[data-mode="playing"] {
  color: var(--text);
  border-color: var(--line-bright);
  background: rgba(18, 28, 47, 0.85);
  box-shadow: none;
}

.cta[data-mode="playing"]:hover {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(24, 38, 62, 0.92);
}

/* ---------- touch controls ---------- */
.touch-controls {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  touch-action: none;
  user-select: none;
}

.touch-controls button {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 17px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(22, 34, 55, 0.85), rgba(10, 16, 28, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button:nth-child(-n + 3) {
  color: var(--cyan-soft);
}

.touch-controls button:active,
.touch-controls button.is-pressed {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.13);
  transform: scale(0.96);
}

.touch-controls button[data-action="hold"] {
  font-size: 9px;
  letter-spacing: 0.08em;
}

/* ---------- footer ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: auto;
  padding-top: 26px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.14em;
}

.footer b {
  color: var(--muted);
  font-weight: 400;
}

.footer-tip i {
  color: rgba(34, 211, 238, 0.5);
  font-style: normal;
}

/* ---------- focus ---------- */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ---------- animations ---------- */
@keyframes status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes float-a {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(6vw, 4vh, 0) scale(1.08);
  }
}

@keyframes float-b {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-5vw, -5vh, 0) scale(1.12);
  }
}

@keyframes overlay-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout {
    grid-template-areas:
      "stage right"
      "left left";
    grid-template-columns: minmax(270px, 330px) minmax(180px, 220px);
    gap: 18px;
    align-items: stretch;
  }

  .rail-left {
    display: grid;
    grid-template-columns: 1.25fr 1fr 1fr;
    align-items: stretch;
  }

  .stats-panel,
  .hold-panel,
  .best-panel {
    min-height: 100%;
  }

  .next-panel {
    height: 100%;
  }

  .keys-panel {
    display: none;
  }

  .rail-right {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  .app {
    padding: 16px 14px 14px;
  }

  .topbar {
    min-height: 44px;
  }

  .tagline {
    display: none;
  }

  .brand-copy strong {
    font-size: 18px;
  }

  .brand-badge {
    width: 36px;
    height: 36px;
  }

  .layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
  }

  .stage {
    order: 1;
    width: 100%;
  }

  .rail-left {
    order: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    max-width: 390px;
  }

  .stats-panel {
    grid-column: 1 / -1;
  }

  .best-panel {
    grid-column: 1 / -1;
  }

  .rail-right {
    order: 3;
    width: 100%;
    max-width: 390px;
  }

  .next-panel {
    height: auto;
  }

  .cta {
    display: none;
  }

  .board-frame {
    width: min(72vw, 300px);
  }

  .stage-legend {
    gap: 9px;
    font-size: 8px;
  }

  .pause-button {
    height: 32px;
    padding: 0 11px;
  }

  .touch-controls {
    display: grid;
    max-width: 300px;
  }

  .footer {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    padding-top: 22px;
    text-align: center;
  }

  .footer-tip {
    display: none;
  }

  .overlay {
    padding: 16px;
  }

  .overlay-copy {
    margin-bottom: 15px;
    font-size: 10px;
  }

  .overlay h2 {
    font-size: 34px;
  }
}

@media (max-height: 760px) and (min-width: 701px) {
  .app {
    padding-top: 16px;
  }

  .layout {
    margin-top: 16px;
  }

  .board-frame {
    width: clamp(250px, 40vh, 310px);
  }

  .panel {
    padding: 14px;
  }

  .key-list > div {
    min-height: 26px;
  }

  .best-line {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
