:root {
  color-scheme: light;
  --surface-canvas: #07142f;
  --surface-shell: #f6f8fc;
  --surface-panel: #ffffff;
  --surface-inset: #edf2fa;
  --surface-blue: #e7eeff;
  --surface-orange: #fff0e9;
  --surface-complete: #173c98;
  --text-primary: #0b1835;
  --text-secondary: #53627e;
  --text-muted: #6f7d96;
  --signal-blue: #3868ff;
  --signal-orange: #ff7547;
  --signal-info: #28d9e8;
  --signal-success: #24b56a;
  --border-default: #cbd4e2;
  --ink: var(--text-primary);
  --ink-soft: var(--text-secondary);
  --mist: #dce5f4;
  --paper: var(--surface-panel);
  --paper-blue: var(--surface-inset);
  --blue: var(--signal-blue);
  --blue-deep: #153fb7;
  --blue-soft: var(--surface-blue);
  --orange: var(--signal-orange);
  --orange-deep: #bd421b;
  --orange-soft: var(--surface-orange);
  --lime: var(--signal-success);
  --lime-deep: #176b42;
  --cyan: var(--signal-info);
  --night: var(--surface-canvas);
  --night-raised: #0c1e42;
  --rose: #d94f70;
  --line: rgba(11, 24, 53, 0.13);
  --shadow: 0 18px 46px rgba(7, 20, 47, 0.15), 0 3px 10px rgba(7, 20, 47, 0.06);
  --display-font: "DIN Alternate", "Arial Rounded MT Bold", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --body-font: "Avenir Next", Avenir, "PingFang SC", "Hiragino Sans GB", sans-serif;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-family: var(--body-font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 300px;
  min-height: 100%;
  background: var(--surface-canvas);
}

body {
  min-width: 300px;
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 12%, rgba(56, 104, 255, 0.28), transparent 28%),
    radial-gradient(circle at 92% 86%, rgba(255, 117, 71, 0.2), transparent 30%),
    linear-gradient(145deg, #050d21, #0b1c3d 56%, var(--surface-canvas));
  -webkit-tap-highlight-color: transparent;
}

button,
dialog {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
[tabindex]:focus-visible,
a:focus-visible {
  outline: 3px solid var(--signal-info);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.fx-canvas {
  position: fixed;
  z-index: 110;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.ambient__ring {
  position: absolute;
  width: 42vw;
  aspect-ratio: 1;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.22;
}

.ambient__ring::before,
.ambient__ring::after {
  content: "";
  position: absolute;
  border: inherit;
  border-radius: inherit;
}

.ambient__ring::before {
  inset: 18%;
}

.ambient__ring::after {
  inset: 36%;
}

.ambient__ring--blue {
  top: -17vw;
  left: -16vw;
  color: var(--blue);
}

.ambient__ring--orange {
  right: -18vw;
  bottom: -18vw;
  color: var(--orange);
}

.game-shell {
  position: relative;
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
  isolation: isolate;
  overflow: hidden;
  border-inline: 1px solid rgba(255, 255, 255, 0.48);
  background:
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(56, 104, 255, 0.05) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(rgba(11, 24, 53, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 24, 53, 0.032) 1px, transparent 1px),
    radial-gradient(circle at 14% 2%, rgba(56, 104, 255, 0.1), transparent 28%),
    var(--surface-shell);
  background-size: auto, 28px 28px, 28px 28px, auto, auto;
  box-shadow: 0 0 90px rgba(0, 0, 0, 0.4);
}

.topbar {
  display: grid;
  grid-template-columns: auto minmax(116px, 1fr) auto;
  gap: 8px;
  min-height: 48px;
  align-items: center;
  border-bottom: 1px solid rgba(11, 24, 53, 0.1);
}

.wordmark {
  position: relative;
  display: grid;
  gap: 1px;
  padding: 3px 0 3px 15px;
  text-align: left;
  background: none;
  border: 0;
}

.wordmark::before {
  content: "";
  position: absolute;
  inset: 5px auto 5px 0;
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(var(--blue) 0 45%, var(--cyan) 45% 55%, var(--orange) 55%);
  box-shadow: 0 0 12px rgba(40, 217, 232, 0.3);
}

.wordmark__en {
  color: var(--blue-deep);
  font-family: var(--utility-font);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.19em;
}

.wordmark__zh {
  font-family: var(--display-font);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

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

.icon-button,
.level-button {
  min-width: 44px;
  height: 44px;
  border: 1px solid rgba(11, 24, 53, 0.14);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 5px 15px rgba(7, 20, 47, 0.08), inset 0 1px 0 #fff;
}

.icon-button {
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 50%;
}

.icon-button svg,
.level-button svg,
.utility-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

#soundButton svg path:first-child {
  fill: currentColor;
  stroke: none;
}

#soundButton[aria-pressed="false"] .sound-wave {
  opacity: 0;
}

.level-button {
  display: flex;
  min-width: 84px;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 0 11px 0 14px;
  border-radius: 999px;
  font-family: var(--utility-font);
  font-size: 11px;
  font-weight: 800;
  color: var(--blue-deep);
  border-color: rgba(56, 104, 255, 0.2);
  background: linear-gradient(180deg, #fff, var(--surface-blue));
  box-shadow: 0 7px 18px rgba(7, 20, 47, 0.11), inset 0 1px 0 white;
}

.level-button svg {
  width: 15px;
  height: 15px;
}

.stage-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-top: 12px;
  padding: 0 3px 10px;
  border-bottom: 1px solid rgba(11, 24, 53, 0.1);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-family: var(--utility-font);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-heading h1,
.dialog-head h2,
.result-card h2 {
  margin: 0;
  font-family: var(--display-font);
  font-weight: 800;
  letter-spacing: -0.055em;
}

.stage-heading h1 {
  font-size: clamp(23px, 7vw, 31px);
  line-height: 1.05;
}

.move-readout {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  padding-bottom: 2px;
  text-align: right;
}

.move-readout__value {
  color: var(--blue-deep);
  font-family: var(--display-font);
  font-size: 29px;
  font-weight: 900;
  line-height: 1;
}

.move-readout__label {
  margin-left: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.move-readout__par {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: var(--ink-soft);
  font-family: var(--utility-font);
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(56, 104, 255, 0.08);
}

.command-deck {
  position: relative;
  margin-top: 14px;
  padding: 11px 12px 12px;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: 18px;
  background:
    linear-gradient(90deg, rgba(56, 104, 255, 0.055), transparent 42% 58%, rgba(255, 117, 71, 0.05)),
    rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(7, 20, 47, 0.09), inset 0 1px 0 white;
  backdrop-filter: blur(10px);
}

.command-deck::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.2;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 16px, rgba(23, 33, 58, 0.05) 16px 17px);
}

.command-deck__title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 3px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.beat-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgba(36, 181, 106, 0.14), 0 0 12px rgba(36, 181, 106, 0.26);
}

.beat-light.is-pulsing {
  animation: beat-pop 320ms ease-out;
}

.command-tape {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
  gap: 7px;
  align-items: stretch;
}

.command-slot {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 51px;
  align-content: center;
  padding: 8px 10px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.76);
}

.command-slot--now {
  color: var(--blue-deep);
  border-color: rgba(56, 104, 255, 0.16);
  background: var(--surface-blue);
}

.command-slot--echo {
  color: var(--orange-deep);
  border-color: rgba(255, 117, 71, 0.17);
  background: var(--surface-orange);
}

.command-slot__actor {
  display: flex;
  gap: 5px;
  align-items: center;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.command-slot__actor i {
  width: 7px;
  height: 7px;
  background: currentColor;
}

.command-slot--now .command-slot__actor i {
  border-radius: 50%;
}

.command-slot--echo .command-slot__actor i {
  border-radius: 2px;
  background: transparent;
  border: 2px solid currentColor;
}

.command-slot__direction {
  overflow: hidden;
  font-family: var(--display-font);
  font-size: clamp(14px, 4vw, 17px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-slot.is-updating .command-slot__direction {
  animation: slot-flip 220ms ease-out;
}

.tape-transfer {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 10px;
}

.tape-transfer span {
  width: 4px;
  height: 4px;
  margin: 0 1px;
  border-radius: 50%;
  background: var(--signal-info);
  box-shadow: 0 0 7px rgba(40, 217, 232, 0.34);
  opacity: 0.72;
}

.tape-transfer b {
  position: absolute;
  right: -2px;
  bottom: 0;
  left: -2px;
  overflow: hidden;
  color: var(--orange-deep);
  font-family: var(--utility-font);
  font-size: 6px;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-tape.is-transferring .tape-transfer span {
  animation: tape-dot 360ms ease-out both;
}

.command-tape.is-transferring .tape-transfer span:nth-child(2) {
  animation-delay: 45ms;
}

.command-tape.is-transferring .tape-transfer span:nth-child(3) {
  animation-delay: 90ms;
}

.play-zone {
  position: relative;
  display: grid;
  justify-items: center;
  margin-top: 14px;
}

.board-frame {
  --board-cols: 5;
  --board-rows: 5;
  position: relative;
  width: min(86vw, 390px, 48dvh);
  min-width: 258px;
  aspect-ratio: var(--board-cols) / var(--board-rows);
  padding: 9px;
  border: 1px solid var(--border-default);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(56, 104, 255, 0.07), transparent 44%, rgba(255, 117, 71, 0.055)),
    var(--surface-inset);
  box-shadow: var(--shadow);
}

.board-frame::before,
.board-frame::after {
  content: "";
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 13px;
  height: 34px;
  transform: translateY(-50%);
  border: 1px solid var(--border-default);
  background: #dde5f1;
}

.board-frame::before {
  left: -7px;
  border-radius: 7px 0 0 7px;
}

.board-frame::after {
  right: -7px;
  border-radius: 0 7px 7px 0;
}

.board {
  --board-cols: 5;
  --board-rows: 5;
  position: relative;
  width: 100%;
  aspect-ratio: var(--board-cols) / var(--board-rows);
  overflow: hidden;
  border: 2px solid var(--night);
  border-radius: 21px;
  background:
    radial-gradient(circle at 50% 30%, rgba(56, 104, 255, 0.045), transparent 54%),
    var(--paper);
  touch-action: none;
  user-select: none;
  isolation: isolate;
}

.board::after {
  content: "";
  position: absolute;
  z-index: 20;
  inset: 0;
  pointer-events: none;
  border-radius: 18px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), inset 0 0 38px rgba(65, 80, 122, 0.055);
}

.board__grid,
.board__goals {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--board-cols), 1fr);
  grid-template-rows: repeat(var(--board-rows), 1fr);
}

.board__grid {
  z-index: 1;
}

.board__goals {
  z-index: 3;
  pointer-events: none;
}

.cell {
  position: relative;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.cell.is-last-col {
  border-right: 0;
}

.cell.is-last-row {
  border-bottom: 0;
}

.cell.is-wall::before {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(23, 33, 58, 0.38);
  border-radius: 22%;
  background:
    repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, 0.12) 7px 9px),
    linear-gradient(145deg, #162a51, #08152e);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.06), 0 3px 0 rgba(23, 33, 58, 0.2);
}

.cell.is-ice::before {
  content: "";
  position: absolute;
  inset: 9%;
  border: 1px solid rgba(77, 104, 244, 0.28);
  border-radius: 24%;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0 28%, transparent 29% 58%, rgba(255, 255, 255, 0.65) 59% 72%, transparent 73%),
    #dcecff;
}

.cell.is-silence::before {
  content: "Ⅱ";
  position: absolute;
  inset: 15%;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(185, 70, 32, 0.52);
  border-radius: 50%;
  color: var(--orange-deep);
  background: rgba(255, 228, 216, 0.56);
  font-family: var(--utility-font);
  font-size: clamp(11px, 3.3vw, 17px);
  font-weight: 900;
}

.cell.is-oneway::before {
  content: attr(data-arrow);
  position: absolute;
  inset: 14%;
  display: grid;
  place-items: center;
  border-radius: 28%;
  color: var(--ink-soft);
  background: rgba(83, 96, 121, 0.1);
  font-family: var(--utility-font);
  font-size: clamp(14px, 4.6vw, 23px);
  font-weight: 900;
}

.goal {
  position: relative;
  grid-column: calc(var(--x) + 1);
  grid-row: calc(var(--y) + 1);
}

.goal::before,
.goal::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.goal::before {
  inset: 17%;
  border: 2px solid currentColor;
  opacity: 0.72;
}

.goal::after {
  inset: 34%;
  background: currentColor;
  opacity: 0.2;
}

.goal--blue {
  color: var(--blue);
}

.goal--orange {
  color: var(--orange-deep);
}

.goal--orange::before {
  border-style: dashed;
  border-width: 3px;
}

.goal.is-reached::before {
  animation: goal-lock 540ms ease-out;
}

.token {
  position: absolute;
  z-index: 8;
  top: 0;
  left: 0;
  width: calc(100% / var(--board-cols));
  height: calc(100% / var(--board-rows));
  display: grid;
  place-items: center;
  transform: translate(calc(var(--x) * 100%), calc(var(--y) * 100%));
  transition: transform 205ms cubic-bezier(0.22, 0.84, 0.32, 1);
  will-change: transform;
  pointer-events: none;
}

.token__body {
  position: relative;
  z-index: 2;
  width: 64%;
  height: 64%;
  display: grid;
  place-items: center;
  color: white;
  box-shadow: 0 7px 14px rgba(23, 33, 58, 0.2), inset 0 2px 2px rgba(255, 255, 255, 0.45);
  transition: transform 160ms cubic-bezier(0.22, 0.84, 0.32, 1);
}

.token--blue.is-overlapping .token__body {
  transform: translate(-22%, -22%) scale(0.8);
}

.token--orange.is-overlapping .token__body {
  transform: translate(22%, 22%) scale(0.8);
}

.token__body i {
  font-family: var(--utility-font);
  font-size: clamp(8px, 2.6vw, 12px);
  font-style: normal;
  font-weight: 900;
  opacity: 0.9;
}

.token--blue .token__body {
  border-radius: 50%;
  background: linear-gradient(145deg, #6682ff, var(--blue-deep));
}

.token--orange .token__body {
  width: 61%;
  height: 61%;
  border: 4px solid var(--orange-deep);
  border-radius: 28%;
  color: var(--orange-deep);
  background: var(--orange-soft);
  box-shadow: 0 7px 14px rgba(118, 52, 25, 0.18), inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.token__trail {
  position: absolute;
  z-index: 1;
  width: 52%;
  height: 52%;
  border: 2px solid currentColor;
  border-radius: 50%;
  opacity: 0;
}

.token--blue {
  color: var(--blue);
}

.token--orange {
  color: var(--orange);
}

.token.is-moving .token__trail {
  animation: trail-pulse 300ms ease-out;
}

.token__status {
  position: absolute;
  z-index: 5;
  top: -8%;
  right: 2%;
  display: grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
  opacity: 0;
  transform: scale(0.7);
}

.token.is-blocked .token__body {
  animation: token-blocked 200ms ease-out;
}

.token.is-blocked .token__status {
  opacity: 1;
  transform: scale(1);
  transition: opacity 90ms, transform 140ms cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

.token.is-blocked .token__status::after {
  content: "Ⅱ";
}

.token.is-waiting .token__body {
  animation: token-wait 260ms ease-out;
}

.swipe-preview {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(23, 33, 58, 0.18);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(251, 252, 255, 0.86);
  box-shadow: 0 7px 20px rgba(23, 33, 58, 0.12);
  font-family: var(--display-font);
  font-size: 28px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.75);
  transition: opacity 90ms, transform 130ms ease-out;
  pointer-events: none;
}

.swipe-preview.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.coach-hand {
  position: absolute;
  z-index: 28;
  left: 50%;
  top: 46%;
  display: grid;
  width: min(78%, 190px);
  gap: 5px;
  justify-items: center;
  place-items: center;
  color: var(--blue-deep);
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.coach-hand strong,
.coach-hand small {
  padding: 4px 8px;
  border: 1px solid rgba(11, 24, 53, 0.12);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 5px 14px rgba(7, 20, 47, 0.12);
  text-align: center;
  white-space: nowrap;
}

.coach-hand strong {
  font-size: 11px;
}

.coach-hand small {
  color: var(--text-secondary);
  font-size: 8px;
  font-weight: 800;
}

.coach-hand span {
  position: relative;
  display: grid;
  width: 46px;
  height: 58px;
  place-items: end center;
}

.coach-hand span::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 15px;
  left: 50%;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--blue), var(--cyan));
  transform: translateX(-50%);
}

.coach-hand span b {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  color: var(--blue-deep);
  font-family: var(--utility-font);
  font-size: 20px;
  font-weight: 900;
  transform: translateX(-50%);
}

.coach-hand i {
  position: relative;
  z-index: 1;
  display: block;
  width: 42px;
  height: 42px;
  border: 2px solid var(--night);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 9px rgba(40, 217, 232, 0.18), 0 10px 25px rgba(7, 20, 47, 0.18);
}

.coach-hand.is-visible {
  animation: coach-swipe-down 1.35s cubic-bezier(0.2, 0.78, 0.26, 1) infinite;
}

.board-frame__ticks {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: -5px;
  display: flex;
  gap: 4px;
  transform: translateX(-50%);
}

.board-frame__ticks span {
  width: 12px;
  height: 3px;
  border-radius: 99px;
  background: var(--blue);
  opacity: 0.7;
}

.board-frame__ticks span:nth-child(n + 3) {
  background: var(--orange);
}

.lesson {
  min-height: 26px;
  margin: 10px 0 6px;
  padding: 4px 11px;
  border: 1px solid rgba(11, 24, 53, 0.07);
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.78);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.lesson strong {
  color: var(--ink);
}

.combo-banner {
  position: absolute;
  z-index: 26;
  top: 15px;
  left: 50%;
  display: flex;
  gap: 7px;
  align-items: baseline;
  padding: 7px 11px;
  border: 1px solid rgba(23, 33, 58, 0.18);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 9px 22px rgba(7, 20, 47, 0.16), inset 0 1px 0 white;
  opacity: 0;
  transform: translate(-50%, -12px) scale(0.84);
  pointer-events: none;
}

.combo-banner strong {
  font-family: var(--utility-font);
  font-size: 9px;
  letter-spacing: 0.12em;
}

.combo-banner span {
  color: var(--lime-deep);
  font-family: var(--utility-font);
  font-size: 12px;
  font-weight: 900;
}

.combo-banner.is-visible {
  animation: combo-rise 900ms cubic-bezier(0.16, 0.88, 0.24, 1) both;
}

.direction-pad {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.direction-button,
.direction-pad__center {
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.direction-button {
  border: 1px solid rgba(11, 24, 53, 0.14);
  color: #28406e;
  background: linear-gradient(180deg, #fff, #edf2fb);
  box-shadow: 0 5px 12px rgba(7, 20, 47, 0.1), inset 0 1px 0 white;
  font-family: var(--utility-font);
  font-size: 18px;
  font-weight: 900;
  transition: transform 120ms ease, color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.direction-button:active {
  color: white;
  background: var(--blue);
  transform: translateY(2px) scale(0.96);
}

.direction-button--left {
  order: 1;
}

.direction-button--up {
  order: 2;
}

.direction-pad__center {
  order: 3;
  display: grid;
  place-items: center;
}

.direction-pad__center i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 5px rgba(40, 217, 232, 0.14), 0 0 14px rgba(40, 217, 232, 0.38);
}

.direction-button--down {
  order: 4;
}

.direction-button--right {
  order: 5;
}

.utility-bar {
  position: sticky;
  z-index: 35;
  bottom: max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding: 7px;
  border: 1px solid var(--border-default);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 30px rgba(7, 20, 47, 0.12), inset 0 1px 0 white;
  backdrop-filter: blur(14px);
}

.utility-button {
  min-height: 49px;
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

.utility-button > span {
  display: grid;
  gap: 1px;
  line-height: 1.05;
}

.utility-button small {
  color: var(--ink-soft);
  font-family: var(--utility-font);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.utility-button.is-casting {
  animation: skill-cast 420ms cubic-bezier(0.16, 0.9, 0.28, 1);
}

.utility-button svg {
  width: 18px;
  height: 18px;
}

.utility-button--hint {
  color: var(--lime-deep);
  background: rgba(36, 181, 106, 0.11);
  box-shadow: inset 0 0 0 1px rgba(36, 181, 106, 0.12);
}

.utility-button:disabled {
  opacity: 0.34;
}

.utility-button:not(:disabled):active {
  transform: translateY(1px);
  background: var(--blue-soft);
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  max-width: min(88vw, 390px);
  padding: 10px 15px;
  border: 1px solid rgba(23, 33, 58, 0.15);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(7, 20, 47, 0.2), inset 0 1px 0 white;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 160ms, transform 220ms cubic-bezier(0.2, 0.85, 0.25, 1);
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.result-sheet {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  align-items: end;
  overflow-y: auto;
  overscroll-behavior: contain;
  visibility: hidden;
  pointer-events: none;
}

.result-sheet[aria-hidden="false"] {
  visibility: visible;
  pointer-events: auto;
}

.result-sheet__scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(2, 9, 24, 0.66);
  opacity: 0;
  backdrop-filter: blur(12px) saturate(0.78);
  transition: opacity 220ms;
}

.result-sheet[aria-hidden="false"] .result-sheet__scrim {
  opacity: 1;
}

.result-card {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 20px), 450px);
  max-height: calc(100dvh - 20px);
  margin: 0 auto 10px;
  padding: 25px 22px calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto;
  scrollbar-width: none;
  overflow-x: hidden;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 30px;
  background:
    radial-gradient(circle at 12% 0, rgba(56, 104, 255, 0.13), transparent 32%),
    radial-gradient(circle at 88% 0, rgba(255, 117, 71, 0.11), transparent 33%),
    var(--surface-panel);
  box-shadow: 0 34px 100px rgba(2, 9, 24, 0.55), inset 0 1px 0 white;
  text-align: center;
  transform: translateY(calc(100% + 20px));
  transition: transform 380ms cubic-bezier(0.18, 0.9, 0.26, 1);
}

.result-card::-webkit-scrollbar {
  display: none;
}

.result-sheet[aria-hidden="false"] .result-card {
  transform: translateY(0);
}

.result-card__signal {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.result-card__signal i {
  width: 23px;
  height: 23px;
}

.result-card__signal i:first-child {
  border-radius: 50%;
  background: var(--blue);
}

.result-card__signal i:last-child {
  border: 4px solid var(--orange-deep);
  border-radius: 7px;
  background: var(--orange-soft);
}

.result-card__signal span {
  width: 56px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--cyan), var(--lime), var(--orange));
  box-shadow: 0 0 14px rgba(40, 217, 232, 0.26);
}

.result-card h2 {
  font-size: 31px;
}

.mastery-card {
  padding-top: 20px;
}

.mastery-card .result-card__signal {
  margin-bottom: 10px;
}

.mastery-record {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(56, 104, 255, 0.18);
  border-radius: 16px;
  color: var(--ink);
  background: linear-gradient(110deg, rgba(56, 104, 255, 0.1), rgba(40, 217, 232, 0.07));
  text-align: left;
}

.mastery-record[data-state="best"] {
  border-color: rgba(230, 175, 36, 0.28);
  background: linear-gradient(110deg, rgba(230, 175, 36, 0.13), rgba(255, 132, 87, 0.09));
}

.mastery-record[data-state="repeat"] {
  background: rgba(23, 33, 58, 0.045);
}

.mastery-record__mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 11px;
  color: white;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(77, 104, 244, 0.1);
  font-style: normal;
  font-weight: 900;
}

.mastery-record[data-state="best"] .mastery-record__mark {
  background: #d99b16;
  box-shadow: 0 0 0 5px rgba(230, 175, 36, 0.13);
}

.mastery-record span,
.mastery-record strong,
.mastery-record small {
  display: block;
}

.mastery-record strong {
  font-size: 13px;
}

.mastery-record small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
}

.stars {
  display: flex;
  gap: 3px;
  justify-content: center;
  margin: 0;
  color: #d0d4de;
  font-size: 17px;
  line-height: 1;
}

.stars span.is-earned {
  color: #e6af24;
  animation: star-pop 360ms cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
}

.stars span:nth-child(2) {
  animation-delay: 70ms;
}

.stars span:nth-child(3) {
  animation-delay: 140ms;
}

.result-card__summary {
  margin: 9px 0 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.result-rating {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 22px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 750;
}

.result-rating[hidden] {
  display: none;
}

.chapter-mastery {
  margin-top: 10px;
  padding: 9px 11px 10px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.58);
}

.chapter-mastery__head {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 750;
  text-align: center;
}

.chapter-mastery__head strong {
  color: var(--ink);
  font-family: var(--utility-font);
}

.chapter-mastery__track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(38px, 1fr));
  gap: 5px;
  margin-top: 7px;
}

.chapter-mastery__track span {
  display: grid;
  min-width: 0;
  min-height: 22px;
  place-items: center;
  border: 1px solid rgba(23, 33, 58, 0.12);
  border-radius: 6px;
  color: var(--ink-soft);
  background: rgba(23, 33, 58, 0.04);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
}

.chapter-mastery__track span.is-complete {
  border-color: rgba(77, 104, 244, 0.28);
  color: white;
  background: var(--blue);
}

.chapter-mastery__track span.is-current {
  box-shadow: 0 0 0 2px rgba(197, 242, 97, 0.75);
}

.signature-found {
  margin: 9px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(40, 217, 232, 0.22);
  border-radius: 12px;
  color: #087b87;
  background: linear-gradient(100deg, rgba(40, 217, 232, 0.1), rgba(36, 181, 106, 0.1));
  font-size: 11px;
  font-weight: 850;
}

.signature-found[hidden] {
  display: none;
}

.mastery-preview {
  display: grid;
  gap: 2px;
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--orange-deep);
  border-radius: 6px 14px 14px 6px;
  background: linear-gradient(100deg, rgba(255, 117, 71, 0.14), var(--surface-orange));
  text-align: left;
}

.mastery-preview__label {
  color: var(--orange-deep);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.mastery-preview strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mastery-preview p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.35;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 3px;
}

.result-actions .text-button {
  width: 100%;
  margin-top: 3px;
  padding-inline: 5px;
  line-height: 1.25;
}

.result-mode-link {
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  text-decoration: underline;
  text-decoration-color: rgba(23, 33, 58, 0.22);
  text-underline-offset: 3px;
}

.result-save-note {
  margin: 1px 0 0;
  color: var(--ink-soft);
  font-size: 8px;
  font-weight: 650;
}

.result-sheet[aria-hidden="false"] .mastery-record__mark {
  animation: mastery-lock 320ms cubic-bezier(0.2, 0.9, 0.25, 1.25) both;
}

.result-sheet[aria-hidden="false"] .mastery-preview {
  animation: mastery-preview-in 300ms 90ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.result-sheet[aria-hidden="false"] .chapter-mastery__track span.is-complete {
  animation: mastery-cell-in 240ms 80ms ease-out both;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  padding: 12px 18px;
  border: 0;
  border-radius: 16px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(105deg, var(--night), #16376f 70%, #2458d3);
  box-shadow: 0 10px 24px rgba(7, 20, 47, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.13);
  font-weight: 850;
  transition: transform 130ms ease, box-shadow 130ms ease, filter 130ms ease;
}

.primary-button:active {
  transform: translateY(2px) scale(0.985);
  box-shadow: 0 5px 13px rgba(7, 20, 47, 0.22), inset 0 2px 4px rgba(0, 0, 0, 0.18);
}

.text-button {
  min-height: 44px;
  margin-top: 5px;
  padding: 8px 18px;
  border: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  border-radius: 12px;
  transition: color 130ms ease, background-color 130ms ease, transform 130ms ease;
}

.text-button:active {
  color: var(--night);
  background: rgba(56, 104, 255, 0.1);
  transform: translateY(1px);
}

.mode-dialog {
  width: min(calc(100% - 18px), 500px);
  max-height: min(92dvh, 780px);
  margin: auto;
  padding: 27px 18px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(77, 104, 244, 0.09), transparent 36%),
    linear-gradient(325deg, rgba(255, 132, 87, 0.1), transparent 38%),
    var(--surface-shell);
  box-shadow: 0 38px 110px rgba(2, 9, 24, 0.54), inset 0 1px 0 white;
  text-align: center;
}

.mode-dialog::backdrop {
  background: rgba(2, 9, 24, 0.67);
  backdrop-filter: blur(12px) saturate(0.82);
}

.mode-dialog__signal {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  margin-bottom: 13px;
}

.mode-dialog__signal i {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--blue);
}

.mode-dialog__signal i:last-child {
  border: 4px solid var(--orange-deep);
  border-radius: 6px;
  background: var(--orange-soft);
}

.mode-dialog__signal span {
  width: 68px;
  height: 3px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--blue), var(--cyan) 47%, var(--lime) 50%, var(--orange) 53%);
  box-shadow: 0 0 14px rgba(40, 217, 232, 0.28);
  animation: signal-charge 1.4s ease-in-out infinite;
}

.mode-dialog > .eyebrow {
  color: var(--blue-deep);
  font-family: var(--utility-font);
  letter-spacing: 0.16em;
}

.mode-dialog h2 {
  margin-top: 3px;
  font-size: clamp(25px, 7vw, 34px);
  line-height: 1.05;
}

.mode-dialog__lead {
  max-width: 330px;
  margin: 10px auto 19px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.mode-grid {
  display: grid;
  gap: 11px;
}

.mode-card {
  min-height: 156px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 106px;
  grid-template-rows: auto auto auto 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 16px;
  overflow: hidden;
  border: 1px solid rgba(23, 33, 58, 0.14);
  border-radius: 21px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 24px rgba(7, 20, 47, 0.1), inset 0 1px 0 white;
  text-align: left;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.mode-card:active {
  transform: scale(0.992);
}

.mode-card--echo {
  border-color: rgba(56, 104, 255, 0.4);
  background: linear-gradient(110deg, rgba(56, 104, 255, 0.055), transparent 48%), var(--paper);
}

.mode-card--twin {
  border-color: rgba(255, 117, 71, 0.4);
  background: linear-gradient(110deg, rgba(56, 104, 255, 0.045), transparent 50%, rgba(255, 117, 71, 0.06)), var(--paper);
}

.mode-card__index {
  color: var(--ink-soft);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.mode-card > strong {
  grid-column: 1;
  font-family: var(--display-font);
  font-size: 23px;
  letter-spacing: -0.04em;
}

.mode-card > span:not(.mode-card__index):not(.mode-card__demo) {
  grid-column: 1;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.mode-card mark {
  grid-column: 1;
  align-self: end;
  width: max-content;
  padding: 5px 8px;
  border-radius: 999px;
  color: white;
  background: var(--signal-success);
  font-size: 9px;
  font-weight: 850;
}

.mode-card__demo {
  grid-column: 2;
  grid-row: 1 / -1;
  position: relative;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-radius: 18px;
  background: var(--surface-inset);
  box-shadow: inset 0 0 0 1px rgba(23, 33, 58, 0.09);
}

.mode-card__demo--echo::before {
  content: "";
  position: absolute;
  left: 19px;
  right: 19px;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--lime), var(--orange));
}

.demo-orb {
  z-index: 1;
  width: 24px;
  height: 24px;
}

.demo-orb--blue {
  border-radius: 50%;
  background: var(--blue);
  animation: demo-step 1.5s ease-in-out infinite;
}

.demo-orb--orange {
  border: 4px solid var(--orange-deep);
  border-radius: 7px;
  background: var(--orange-soft);
  animation: demo-step 1.5s 300ms ease-in-out infinite;
}

.mode-card__demo b,
.mode-card__demo em {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  font-family: var(--utility-font);
  font-style: normal;
  font-weight: 900;
}

.mode-card__demo--echo b {
  top: 12px;
  left: 27px;
  color: var(--blue-deep);
}

.mode-card__demo--echo em {
  right: 26px;
  bottom: 9px;
  color: var(--orange-deep);
}

.mode-card__demo--twin {
  gap: 9px;
  padding: 16px;
}

.mode-card__demo--twin i {
  width: 34px;
  height: 68px;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background:
    linear-gradient(90deg, transparent 47%, rgba(23, 33, 58, 0.14) 48% 52%, transparent 53%),
    repeating-linear-gradient(0deg, transparent 0 20px, rgba(23, 33, 58, 0.12) 21px 22px),
    var(--paper);
}

.mode-card__demo--twin b {
  top: 8px;
  left: 50%;
  color: var(--orange-deep);
  transform: translateX(-50%);
  animation: twin-command 1.2s ease-in-out infinite;
}

.rule-note {
  margin: 0 2px 15px;
  padding: 10px 12px;
  border-left: 3px solid var(--lime);
  color: var(--ink-soft);
  background: rgba(36, 181, 106, 0.08);
  font-size: 11px;
  line-height: 1.5;
}

.mode-switch-link {
  width: 100%;
}

.sheet-dialog {
  width: min(calc(100% - 20px), 470px);
  max-height: min(88dvh, 780px);
  margin: auto auto 10px;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  color: var(--ink);
  background: linear-gradient(160deg, rgba(56, 104, 255, 0.05), transparent 28%), var(--surface-shell);
  box-shadow: 0 34px 100px rgba(2, 9, 24, 0.52), inset 0 1px 0 white;
}

.sheet-dialog::backdrop {
  background: rgba(2, 9, 24, 0.67);
  backdrop-filter: blur(12px) saturate(0.82);
}

.dialog-head {
  position: sticky;
  z-index: 4;
  top: -20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -4px -2px 15px;
  padding: 4px 2px 10px;
  background: linear-gradient(var(--paper) 0 82%, transparent);
}

.dialog-head h2 {
  font-size: 25px;
}

.chapter-list {
  display: grid;
  gap: 17px;
}

.chapter-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(56, 104, 255, 0.04), transparent 55%, rgba(255, 117, 71, 0.04)), var(--surface-inset);
}

.chapter-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.chapter-card__head strong {
  font-family: var(--display-font);
  font-size: 15px;
}

.chapter-card__head span {
  color: var(--ink-soft);
  font-family: var(--utility-font);
  font-size: 9px;
  font-weight: 800;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
}

.level-cell {
  position: relative;
  isolation: isolate;
  display: grid;
  min-width: 0;
  min-height: 50px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(11, 24, 53, 0.14);
  border-radius: 13px;
  color: var(--ink-soft);
  background: linear-gradient(155deg, #fff, #f1f4fa);
  box-shadow: 0 3px 8px rgba(7, 20, 47, 0.06), inset 0 1px 0 white;
  font-family: var(--utility-font);
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.level-cell.is-current {
  z-index: 2;
  border: 2px solid var(--blue);
  color: var(--blue-deep);
  background: linear-gradient(145deg, #edf2ff, #d7e2ff);
  box-shadow: 0 0 0 3px rgba(56, 104, 255, 0.13), 0 8px 18px rgba(56, 104, 255, 0.17), inset 0 1px 0 white;
}

.level-cell.is-complete {
  border-color: #173eac;
  color: rgba(255, 255, 255, 0.76);
  background:
    radial-gradient(circle at 78% 22%, rgba(40, 217, 232, 0.3), transparent 34%),
    linear-gradient(145deg, #2759e6, var(--surface-complete));
  box-shadow: 0 8px 18px rgba(21, 63, 183, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.level-cell.is-complete.is-perfect {
  border-color: rgba(36, 181, 106, 0.86);
  box-shadow: 0 8px 18px rgba(21, 63, 183, 0.25), inset 0 -4px 0 var(--signal-success);
}

.level-cell.is-current.is-complete {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 117, 71, 0.24), 0 10px 22px rgba(7, 20, 47, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.level-cell:active {
  transform: translateY(2px) scale(0.97);
}

.rule-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  justify-content: center;
  margin: 8px 0 21px;
}

.rule-demo span,
.rule-demo strong {
  padding: 8px 10px;
  border-radius: 11px;
  font-family: var(--utility-font);
  font-size: 11px;
  font-style: normal;
}

.rule-demo__blue {
  color: var(--blue-deep);
  background: var(--blue-soft);
}

.rule-demo__orange {
  color: var(--orange-deep);
  background: var(--orange-soft);
}

.rule-demo strong {
  color: var(--lime-deep);
  background: rgba(197, 242, 97, 0.32);
}

.rule-demo i {
  color: var(--ink-soft);
  font-style: normal;
  font-weight: 900;
}

.rule-list {
  display: grid;
  gap: 12px;
  margin: 0 0 22px;
  padding-left: 25px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.rule-list li::marker {
  color: var(--blue);
  font-family: var(--utility-font);
  font-weight: 900;
}

.rule-list strong:first-child {
  color: var(--ink);
}

@keyframes beat-pop {
  0% { transform: scale(1); box-shadow: 0 0 0 4px rgba(197, 242, 97, 0.22); }
  42% { transform: scale(1.55); box-shadow: 0 0 0 9px rgba(197, 242, 97, 0.08); }
  100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(197, 242, 97, 0.22); }
}

@keyframes slot-flip {
  0% { opacity: 0; transform: translateY(5px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes tape-dot {
  0% { opacity: 0.2; transform: translateX(-5px) scale(0.8); }
  50% { opacity: 1; transform: translateX(2px) scale(1.25); }
  100% { opacity: 0.28; transform: translateX(5px) scale(0.8); }
}

@keyframes trail-pulse {
  0% { opacity: 0.65; transform: scale(0.78); }
  100% { opacity: 0; transform: scale(1.55); }
}

@keyframes token-blocked {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(0.82, 1.12); }
}

@keyframes token-wait {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); }
}

@keyframes goal-lock {
  0% { transform: scale(0.75); opacity: 0.45; }
  55% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); opacity: 0.72; }
}

@keyframes star-pop {
  0% { transform: scale(0.5) rotate(-18deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes mastery-lock {
  0% { opacity: 0.35; transform: scale(0.72) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes mastery-preview-in {
  0% { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes mastery-cell-in {
  0% { opacity: 0.45; transform: scaleX(0.55); }
  100% { opacity: 1; transform: scaleX(1); }
}

@keyframes coach-swipe-down {
  0%, 12% { opacity: 0; transform: translate(-50%, -74px) scale(0.9); }
  24% { opacity: 1; }
  72% { opacity: 1; transform: translate(-50%, 52px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, 72px) scale(0.94); }
}

@keyframes combo-rise {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.74); }
  20% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  72% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -15px) scale(0.92); }
}

@keyframes skill-cast {
  0% { box-shadow: 0 0 0 0 rgba(77, 104, 244, 0.35); }
  45% { transform: translateY(-2px) scale(1.03); box-shadow: 0 0 0 8px rgba(77, 104, 244, 0); }
  100% { transform: none; }
}

@keyframes signal-charge {
  0%, 100% { transform: scaleX(0.72); opacity: 0.55; }
  50% { transform: scaleX(1); opacity: 1; }
}

@keyframes demo-step {
  0%, 18%, 100% { transform: translateY(13px); }
  55%, 78% { transform: translateY(-13px); }
}

@keyframes twin-command {
  0%, 100% { transform: translate(-50%, 7px); opacity: 0.45; }
  50% { transform: translate(-50%, -2px); opacity: 1; }
}

@media (min-width: 760px) {
  .game-shell {
    padding-top: 22px;
  }

  .sheet-dialog {
    margin: auto;
  }

  .result-card {
    margin-bottom: 20px;
  }
}

@media (max-height: 690px) {
  .game-shell {
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .topbar {
    min-height: 42px;
  }

  .icon-button,
  .level-button {
    height: 40px;
  }

  .stage-heading {
    margin-top: 4px;
  }

  .command-deck {
    margin-top: 9px;
    padding-top: 8px;
    padding-bottom: 9px;
  }

  .command-slot {
    min-height: 44px;
  }

  .play-zone {
    margin-top: 9px;
  }

  .board-frame {
    width: min(82vw, 350px, 43dvh);
  }

  .lesson {
    margin-top: 7px;
  }

  .utility-bar {
    position: relative;
    bottom: auto;
    margin-top: 8px;
  }

  .utility-button {
    min-height: 44px;
  }
}

@media (max-width: 340px) {
  .game-shell {
    padding-inline: 12px;
  }

  .level-button {
    min-width: 72px;
  }

  .command-deck {
    padding-inline: 9px;
  }

  .command-tape {
    grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr);
    gap: 4px;
  }

  .command-slot {
    padding-inline: 7px;
  }

  .board-frame {
    min-width: 250px;
  }

  .sheet-dialog {
    width: calc(100% - 8px);
    padding-inline: 10px;
  }

  .chapter-card {
    padding: 7px;
  }

  .level-grid {
    gap: 4px;
  }

  .level-cell {
    min-height: 44px;
  }

  .mode-dialog {
    width: calc(100% - 8px);
    padding-inline: 10px;
  }

  .mode-card {
    grid-template-columns: minmax(0, 1fr) 82px;
    padding: 12px;
  }

  .mode-card__demo {
    height: 96px;
  }

  .result-card {
    width: calc(100% - 10px);
    margin-bottom: 5px;
    padding-inline: 14px;
  }

  .result-actions .text-button {
    font-size: 11px;
  }
}

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

  .result-sheet[aria-hidden="false"] .mastery-record__mark,
  .result-sheet[aria-hidden="false"] .mastery-preview,
  .result-sheet[aria-hidden="false"] .chapter-mastery__track span.is-complete {
    animation: none !important;
    transform: none !important;
  }

  .result-card,
  .result-sheet[aria-hidden="false"] .result-card {
    transform: none !important;
    transition: none !important;
  }

  .result-sheet__scrim {
    transition: none !important;
  }
}

/* Structured level status: the saved state is the whole card, never a corner tick. */
.level-cell__number {
  position: absolute;
  z-index: 2;
  top: 7px;
  left: 8px;
  font-family: var(--utility-font);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
}

.level-cell__badge {
  position: absolute;
  z-index: 2;
  inset: 50% auto auto 50%;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  color: white;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 0 5px rgba(40, 217, 232, 0.11), 0 0 18px rgba(40, 217, 232, 0.24);
  font-family: var(--utility-font);
  font-size: 21px;
  font-weight: 950;
  line-height: 1;
  transform: translate(-50%, -55%);
}

.level-cell__state {
  position: absolute;
  z-index: 2;
  right: 6px;
  bottom: 5px;
  color: rgba(255, 255, 255, 0.8);
  font-size: clamp(8px, 2.2vw, 9px);
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.level-cell:not(.is-complete) .level-cell__number {
  top: 11px;
  left: 50%;
  font-size: 12px;
  transform: translateX(-50%);
}

.level-cell:not(.is-complete) .level-cell__badge {
  display: none;
}

.level-cell:not(.is-complete) .level-cell__state {
  right: auto;
  bottom: 7px;
  left: 50%;
  display: block;
  color: var(--text-muted);
  font-size: clamp(8px, 2.2vw, 9px);
  transform: translateX(-50%);
}

.level-cell.is-current:not(.is-complete) .level-cell__state {
  color: var(--blue-deep);
}

.level-cell.is-complete.is-perfect .level-cell__badge {
  border-color: rgba(255, 255, 255, 0.66);
  color: white;
  background: var(--signal-success);
  box-shadow: 0 0 0 5px rgba(36, 181, 106, 0.16), 0 0 18px rgba(36, 181, 106, 0.32);
}

.level-cell.is-complete.is-perfect .level-cell__state {
  font-size: 0;
  color: #d6ffe5;
}

.level-cell.is-complete.is-perfect .level-cell__state::after {
  content: "已精炼";
  font-size: 9px;
}

.level-cell.is-current.is-complete .level-cell__state {
  color: #ffe5dc;
}

/* Persistent mode rail. Current mode reads as a live channel, the other one
   stays available without competing with play. */
.mode-switcher {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  width: auto;
  min-width: 104px;
  margin: 0;
  padding: 3px;
  border: 1px solid rgba(11, 24, 53, 0.12);
  border-radius: 14px;
  background: rgba(11, 24, 53, 0.06);
  box-shadow: inset 0 1px 2px rgba(7, 20, 47, 0.06);
}

.mode-switcher__option {
  position: relative;
  min-height: 44px;
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
  padding-inline: 3px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #5a6680;
  background: transparent;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
  transition: color 130ms ease, background-color 130ms ease, box-shadow 130ms ease, transform 130ms ease;
}

.mode-switcher__option > span {
  color: var(--blue);
  font-family: var(--utility-font);
  font-size: 11px;
  font-weight: 900;
}

.mode-switcher__option[data-mode="twin"] > span {
  color: var(--orange-deep);
}

.mode-switcher__option.is-active,
.mode-switcher__option[aria-current="page"] {
  border-color: rgba(56, 104, 255, 0.15);
  color: var(--night);
  background: white;
  box-shadow: 0 4px 11px rgba(7, 20, 47, 0.1), inset 0 1px 0 white;
}

.mode-switcher[data-active-mode="twin"] .mode-switcher__option.is-active,
.mode-switcher[data-active-mode="twin"] .mode-switcher__option[aria-current="page"] {
  border-color: rgba(255, 117, 71, 0.2);
}

.mode-switcher__option:active {
  transform: scale(0.97);
}

/* In-board first-level guidance. It is a compact instrument readout rather
   than another blocking modal, so the requested target remains visible. */
.onboarding-card {
  display: grid;
  gap: 10px;
  margin: 4px 0 14px;
  padding: 13px;
  border: 1px solid var(--border-default);
  border-radius: 19px;
  background: var(--surface-panel);
  box-shadow: 0 10px 26px rgba(7, 20, 47, 0.08), inset 0 1px 0 white;
}

.onboarding-gesture {
  min-height: 76px;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid rgba(56, 104, 255, 0.2);
  border-radius: 15px;
  color: var(--blue-deep);
  background: var(--surface-blue);
}

.onboarding-gesture > span:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.onboarding-gesture strong,
.onboarding-gesture small {
  display: block;
}

.onboarding-gesture strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}

.onboarding-gesture small {
  color: var(--text-secondary);
  font-size: 10px;
}

.onboarding-gesture__track,
.live-guide__gesture {
  position: relative;
  display: grid;
  width: 54px;
  height: 58px;
  place-items: end center;
}

.onboarding-gesture__track::before,
.live-guide__gesture::before {
  content: "";
  position: absolute;
  top: 5px;
  bottom: 13px;
  left: 50%;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(var(--blue), var(--cyan));
  transform: translateX(-50%);
}

.onboarding-gesture__track i,
.live-guide__gesture i {
  position: relative;
  z-index: 1;
  display: block;
  width: 27px;
  height: 27px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(56, 104, 255, 0.12), 0 6px 12px rgba(21, 63, 183, 0.22);
}

.onboarding-gesture__track b,
.live-guide__gesture b {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 50%;
  color: var(--blue-deep);
  font-family: var(--utility-font);
  font-size: 19px;
  transform: translateX(-50%);
}

.onboarding-gesture__track--right,
.live-guide__gesture--right {
  width: 62px;
  height: 46px;
  place-items: center end;
}

.onboarding-gesture__track--right::before,
.live-guide__gesture--right::before {
  inset: 50% 13px auto 5px;
  width: auto;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--orange));
  transform: translateY(-50%);
}

.onboarding-gesture__track--right b,
.live-guide__gesture--right b {
  top: 50%;
  right: 0;
  left: auto;
  color: var(--orange-deep);
  transform: translateY(-50%);
}

.input-alternatives {
  min-height: 34px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 11px;
  color: var(--text-secondary);
  background: var(--surface-inset);
  font-size: 10px;
  line-height: 1.45;
}

.input-alternatives b {
  color: var(--ink);
}

.beat-demo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 7px;
  align-items: stretch;
}

.beat-demo > div {
  min-width: 0;
  display: grid;
  gap: 5px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-inset);
}

.beat-demo > div > small {
  color: var(--text-muted);
  font-family: var(--utility-font);
  font-size: 7px;
  font-weight: 900;
}

.beat-demo strong,
.beat-demo span {
  padding: 5px 6px;
  border-radius: 8px;
  font-size: 9px;
  white-space: nowrap;
}

.beat-demo strong { color: var(--blue-deep); background: var(--surface-blue); }
.beat-demo span { color: var(--orange-deep); background: var(--surface-orange); }
.beat-demo i { font-style: normal; }

.beat-demo > b {
  align-self: center;
  max-width: 47px;
  color: var(--orange-deep);
  font-family: var(--utility-font);
  font-size: 7px;
  line-height: 1.35;
  text-align: center;
}

.twin-command-demo {
  display: grid;
  grid-template-columns: 1fr auto 1.2fr;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface-inset);
  font-size: 10px;
}

.twin-command-demo > strong { color: var(--blue-deep); }
.twin-command-demo > i { color: var(--signal-info); font-style: normal; }
.twin-command-demo > span { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.twin-command-demo > span b { padding: 5px; border-radius: 7px; background: var(--surface-blue); text-align: center; }
.twin-command-demo > span b:last-child { color: var(--orange-deep); background: var(--surface-orange); }

.live-guide {
  position: relative;
  z-index: 38;
  width: 100%;
  margin: 10px 0 1px;
  padding: 12px 13px;
  overflow: hidden;
  border: 1px solid rgba(56, 104, 255, 0.24);
  border-radius: 17px;
  color: var(--ink);
  background:
    linear-gradient(100deg, rgba(56, 104, 255, 0.075), transparent 48%, rgba(255, 117, 71, 0.065)),
    rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(7, 20, 47, 0.12), inset 0 1px 0 white;
}

.live-guide[hidden] {
  display: none;
}

.live-guide::before {
  content: "GUIDED SIGNAL";
  position: absolute;
  top: 8px;
  right: 10px;
  color: var(--text-muted);
  font-family: var(--utility-font);
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.live-guide__progress {
  display: flex;
  gap: 5px;
  margin-bottom: 8px;
  padding-right: 78px;
}

.live-guide__progress > * {
  flex: 1;
  min-width: 24px;
  height: 22px;
  overflow: hidden;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-inset);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
}

.live-guide__progress > .is-complete,
.live-guide__progress > [aria-current="step"],
.live-guide__progress > .is-current {
  color: #073c43;
  background: rgba(40, 217, 232, 0.24);
  box-shadow: inset 0 0 0 1px rgba(40, 217, 232, 0.3), 0 0 9px rgba(40, 217, 232, 0.18);
}

.live-guide__progress > .is-complete {
  color: white;
  background: var(--signal-success);
  box-shadow: 0 0 9px rgba(36, 181, 106, 0.24);
}

.live-guide__step {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  justify-content: center;
  color: var(--blue-deep);
  background: var(--surface-blue);
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.live-guide__copy {
  margin: 7px 0 0;
  padding-right: 4px;
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.45;
}

.live-guide__kicker {
  display: block;
  margin-bottom: 4px;
  color: #087b87;
  font-family: var(--utility-font);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.live-guide__copy strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
}

.live-guide__copy p {
  margin: 0;
}

.live-guide__action {
  min-height: 54px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(56, 104, 255, 0.2);
  border-radius: 12px;
  background: var(--surface-blue);
}

.live-guide__gesture {
  width: 48px;
  height: 42px;
}

.live-guide__gesture--right {
  width: 56px;
  height: 40px;
}

.live-guide__gesture i {
  width: 23px;
  height: 23px;
}

.live-guide__action > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.live-guide__action strong,
.live-guide__action small {
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-guide__action strong {
  color: var(--ink);
  font-size: 11px;
}

.live-guide__action small {
  color: var(--text-secondary);
  font-size: 8px;
  white-space: nowrap;
}

.guide-proof {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
  margin-top: 7px;
}

.guide-proof > i {
  align-self: center;
  color: var(--signal-info);
  font-style: normal;
  font-weight: 900;
}

.guide-proof__signal,
.guide-proof__command,
.guide-proof__world {
  min-width: 0;
  min-height: 44px;
  display: grid;
  gap: 2px;
  align-content: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.guide-proof__signal--blue,
.guide-proof__command {
  border-color: rgba(56, 104, 255, 0.2);
  background: var(--surface-blue);
}

.guide-proof__signal--orange {
  border-color: rgba(255, 117, 71, 0.21);
  background: var(--surface-orange);
}

.guide-proof small {
  color: var(--text-muted);
  font-family: var(--utility-font);
  font-size: 7px;
  font-weight: 900;
}

.guide-proof strong {
  color: var(--ink);
  font-size: 9px;
}

.guide-proof__signal--blue strong,
.guide-proof__command strong { color: var(--blue-deep); }
.guide-proof__signal--orange strong { color: var(--orange-deep); }

.guide-proof > p {
  grid-column: 1 / -1;
  margin: -1px 0 0;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--surface-inset);
  font-size: 8px;
  font-weight: 700;
  text-align: center;
}

.guide-proof--twin {
  grid-template-columns: minmax(0, 0.9fr) auto minmax(0, 1.3fr);
}

.guide-proof__world {
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface-inset);
}

.guide-proof__world > span {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.guide-proof__world > span:first-child strong { color: var(--blue-deep); }
.guide-proof__world > span:last-child strong { color: var(--orange-deep); }

.live-guide__actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  margin-top: 9px;
}

.live-guide__actions button {
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid rgba(11, 24, 53, 0.13);
  border-radius: 10px;
  color: var(--text-secondary);
  background: var(--surface-inset);
  font-size: 10px;
  font-weight: 800;
}

.live-guide__actions .primary-button,
.live-guide__actions .text-button {
  width: auto;
  margin: 0;
}

.live-guide__actions button:last-child {
  border-color: rgba(255, 255, 255, 0.1);
  color: white;
  background: linear-gradient(105deg, var(--night), #16376f 70%, #2458d3);
}

.is-guide-target {
  position: relative;
  z-index: 37;
  outline: 3px solid var(--cyan) !important;
  outline-offset: 4px;
  box-shadow: 0 0 0 8px rgba(40, 217, 232, 0.13), 0 0 24px rgba(40, 217, 232, 0.28) !important;
}

.is-guide-focus {
  position: relative;
  z-index: 36;
  outline: 2px solid rgba(56, 104, 255, 0.62);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(56, 104, 255, 0.09) !important;
}

.is-guide-nudge {
  animation: guide-nudge 360ms ease-out;
}

.direction-button.is-guide-focus {
  color: var(--blue-deep);
  border-color: rgba(56, 104, 255, 0.34);
  background: var(--surface-blue);
}

.live-guide[data-guide-state="complete"] {
  border-color: rgba(36, 181, 106, 0.35);
  background: linear-gradient(100deg, rgba(36, 181, 106, 0.1), transparent 50%), var(--surface-panel);
}

.live-guide[data-guide-state="complete"] .live-guide__step {
  color: var(--lime-deep);
  background: rgba(36, 181, 106, 0.1);
}

#app[data-guide-active="true"] .utility-bar,
#twinApp[data-guide-active="true"] .utility-bar {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:not(:disabled):hover {
    border-color: rgba(56, 104, 255, 0.36);
    color: var(--blue-deep);
    background: white;
    box-shadow: 0 8px 20px rgba(7, 20, 47, 0.14);
  }

  .level-button:hover {
    color: var(--blue-deep);
    background: var(--surface-blue);
    transform: translateY(-1px);
  }

  .mode-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 38px rgba(7, 20, 47, 0.16);
  }

  .level-cell:hover {
    z-index: 3;
    border-color: rgba(56, 104, 255, 0.46);
    transform: translateY(-2px);
    box-shadow: 0 8px 17px rgba(7, 20, 47, 0.13), inset 0 1px 0 white;
  }

  .level-cell.is-complete:hover {
    border-color: var(--cyan);
    box-shadow: 0 10px 23px rgba(21, 63, 183, 0.3), 0 0 0 2px rgba(40, 217, 232, 0.14);
  }

  .direction-button:hover {
    color: var(--blue-deep);
    border-color: rgba(56, 104, 255, 0.3);
    box-shadow: 0 8px 18px rgba(7, 20, 47, 0.14), inset 0 1px 0 white;
    transform: translateY(-1px);
  }

  .utility-button:not(:disabled):hover {
    color: var(--blue-deep);
    background: var(--surface-blue);
  }

  .utility-button--hint:not(:disabled):hover {
    color: var(--lime-deep);
    background: rgba(36, 181, 106, 0.16);
  }

  .primary-button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(7, 20, 47, 0.29), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  }

  .text-button:hover {
    color: var(--night);
    background: rgba(56, 104, 255, 0.075);
  }

  .mode-switcher__option:hover {
    color: var(--night);
    background: rgba(255, 255, 255, 0.72);
  }

  .live-guide__actions button:hover {
    color: var(--night);
    background: var(--surface-blue);
  }

  .live-guide__actions button:last-child:hover {
    color: white;
    background: linear-gradient(105deg, #102957, #2454b3);
  }
}

@media (min-width: 760px) {
  .level-dialog {
    width: min(calc(100% - 48px), 800px);
    max-width: 800px;
    max-height: min(90dvh, 850px);
    margin: auto;
  }

  .level-dialog .chapter-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 390px) {
  .mode-switcher {
    margin-top: 6px;
  }

  .mode-switcher__option {
    font-size: 10px;
  }

  .live-guide {
    padding: 11px;
  }
}

/* First-play teaching must fit in a phone viewport without asking the player to
   discover page scrolling. The board remains the gesture target; the duplicate
   direction pad and lesson return as soon as the three-beat proof is complete. */
@media (max-width: 479px) and (min-height: 421px) {
  #app[data-guide-active="true"] .lesson,
  #twinApp[data-guide-active="true"] .twin-lesson,
  #app[data-guide-active="true"] .direction-pad,
  #twinApp[data-guide-active="true"] .direction-pad {
    display: none;
  }

  #app[data-guide-active="true"] .live-guide,
  #twinApp[data-guide-active="true"] .live-guide {
    margin-top: 7px;
    padding: 8px 9px;
  }

  #app[data-guide-active="true"] .live-guide::before,
  #twinApp[data-guide-active="true"] .live-guide::before {
    display: none;
  }

  #app[data-guide-active="true"] .live-guide__progress,
  #twinApp[data-guide-active="true"] .live-guide__progress {
    gap: 4px;
    height: 18px;
    margin-bottom: 4px;
    padding-right: 0;
  }

  #app[data-guide-active="true"] .live-guide__progress > *,
  #twinApp[data-guide-active="true"] .live-guide__progress > *,
  #app[data-guide-active="true"] .live-guide__step,
  #twinApp[data-guide-active="true"] .live-guide__step {
    min-height: 18px;
    height: 18px;
    padding-block: 2px;
  }

  #app[data-guide-active="true"] .live-guide__copy,
  #twinApp[data-guide-active="true"] .live-guide__copy {
    margin-top: 3px;
    line-height: 1.25;
  }

  #app[data-guide-active="true"] .live-guide__copy p,
  #twinApp[data-guide-active="true"] .live-guide__copy p {
    display: none;
  }

  #app[data-guide-active="true"] .live-guide__kicker,
  #twinApp[data-guide-active="true"] .live-guide__kicker {
    display: inline;
    margin: 0 6px 0 0;
  }

  #app[data-guide-active="true"] .live-guide__copy strong,
  #twinApp[data-guide-active="true"] .live-guide__copy strong {
    display: inline;
    margin: 0;
    font-size: 12px;
  }

  #app[data-guide-active="true"] .live-guide__action,
  #twinApp[data-guide-active="true"] .live-guide__action {
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 46px;
    gap: 6px;
    margin-top: 5px;
    padding: 4px 7px;
  }

  #app[data-guide-active="true"] .live-guide__gesture,
  #twinApp[data-guide-active="true"] .live-guide__gesture {
    transform: scale(0.78);
    transform-origin: center;
  }

  #app[data-guide-active="true"] .guide-proof,
  #twinApp[data-guide-active="true"] .guide-proof {
    gap: 4px;
    margin-top: 5px;
  }

  #app[data-guide-active="true"] .guide-proof__signal,
  #app[data-guide-active="true"] .guide-proof__command,
  #app[data-guide-active="true"] .guide-proof__world,
  #twinApp[data-guide-active="true"] .guide-proof__signal,
  #twinApp[data-guide-active="true"] .guide-proof__command,
  #twinApp[data-guide-active="true"] .guide-proof__world {
    min-height: 36px;
    padding: 4px 6px;
  }

  #app[data-guide-active="true"] .guide-proof > p,
  #twinApp[data-guide-active="true"] .guide-proof > p {
    padding: 3px 5px;
  }

  #app[data-guide-active="true"] .live-guide__actions,
  #twinApp[data-guide-active="true"] .live-guide__actions {
    margin-top: 5px;
  }
}

@media (max-width: 350px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .topbar .mode-switcher {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    margin-top: 3px;
  }
}

@media (max-height: 420px) and (min-width: 480px) {
  #app[data-guide-active="true"] .stage-heading,
  #twinApp[data-guide-active="true"] .twin-heading {
    display: none;
  }

  #app[data-guide-active="true"] .command-deck,
  #twinApp[data-guide-active="true"] .sync-bus {
    display: none;
  }

  #app[data-guide-active="true"] .play-zone,
  #twinApp[data-guide-active="true"] .twin-play-zone {
    grid-template-columns: minmax(174px, 0.82fr) minmax(0, 1.18fr);
    grid-template-rows: auto 1fr;
    column-gap: 10px;
    align-items: start;
    margin-top: 4px;
  }

  #app[data-guide-active="true"] .board-frame,
  #twinApp[data-guide-active="true"] .twin-boards {
    grid-column: 1;
    grid-row: 1 / 3;
    width: 100%;
    min-width: 0;
  }

  #app[data-guide-active="true"] .lesson,
  #twinApp[data-guide-active="true"] .twin-lesson {
    display: none;
  }

  #app[data-guide-active="true"] .direction-pad,
  #twinApp[data-guide-active="true"] .direction-pad {
    grid-column: 2;
    grid-row: 1;
  }

  #app[data-guide-active="true"] .live-guide,
  #twinApp[data-guide-active="true"] .live-guide {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    grid-template-rows: auto auto 1fr auto;
    gap: 4px 6px;
    margin-top: 3px;
    padding: 7px 9px;
  }

  .live-guide::before {
    display: none;
  }

  .live-guide__progress {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding: 0;
  }

  .live-guide__copy {
    grid-column: 1;
    grid-row: 2;
    margin-top: 4px;
    line-height: 1.3;
  }

  .live-guide__copy p {
    display: none;
  }

  .live-guide__action {
    grid-column: 1;
    grid-row: 3 / 5;
    grid-template-columns: 36px minmax(0, 1fr);
    min-height: 46px;
    gap: 5px;
    margin: 0;
    padding: 5px;
  }

  .live-guide__gesture {
    transform: scale(0.68);
  }

  .live-guide__action small {
    white-space: normal;
  }

  .guide-proof,
  .guide-proof--twin {
    grid-column: 2;
    grid-row: 1 / 4;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    align-self: stretch;
    margin: 0;
  }

  .guide-proof > i {
    display: none;
  }

  .guide-proof__signal,
  .guide-proof__command,
  .guide-proof__world {
    min-height: 34px;
    padding: 4px 6px;
  }

  .guide-proof > p {
    padding: 3px 5px;
    font-size: 7px;
  }

  .live-guide__actions {
    grid-column: 2;
    grid-row: 4;
    margin: 0;
  }
}

@media (max-height: 430px) and (min-width: 430px) {
  .about-dialog[open],
  .twin-tutorial[open] {
    width: min(calc(100% - 12px), 620px);
    height: calc(100dvh - 10px);
    max-height: 420px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto 44px;
    gap: 6px 8px;
    margin: auto;
    padding: 8px 10px;
    overflow: hidden;
    border-radius: 20px;
  }

  .about-dialog .dialog-head,
  .twin-tutorial .dialog-head {
    position: static;
    grid-column: 1 / -1;
    grid-row: 1;
    min-height: 44px;
    margin: 0;
    padding: 0 0 5px;
    background: transparent;
  }

  .about-dialog .dialog-head .eyebrow,
  .twin-tutorial .dialog-head .twin-eyebrow {
    display: none;
  }

  .about-dialog .dialog-head h2,
  .twin-tutorial .dialog-head h2 {
    font-size: 19px;
  }

  .about-dialog .onboarding-card,
  .twin-tutorial .onboarding-card {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
    grid-template-rows: 1fr auto;
    gap: 6px 8px;
    min-height: 0;
    margin: 0;
    padding: 7px;
  }

  .about-dialog .onboarding-gesture,
  .twin-tutorial .onboarding-gesture {
    grid-column: 1;
    grid-row: 1;
    grid-template-columns: 48px minmax(0, 1fr);
    min-height: 58px;
    gap: 6px;
    padding: 5px 7px;
  }

  .about-dialog .onboarding-gesture__track,
  .twin-tutorial .onboarding-gesture__track {
    transform: scale(0.74);
  }

  .about-dialog .onboarding-gesture strong,
  .twin-tutorial .onboarding-gesture strong {
    font-size: 10px;
  }

  .about-dialog .onboarding-gesture small,
  .twin-tutorial .onboarding-gesture small {
    font-size: 8px;
  }

  .about-dialog .input-alternatives,
  .twin-tutorial .input-alternatives {
    grid-column: 1;
    grid-row: 2;
    min-height: 27px;
    padding: 5px 7px;
    font-size: 8px;
  }

  .about-dialog .beat-demo,
  .twin-tutorial .twin-command-demo {
    grid-column: 2;
    grid-row: 1 / 3;
    min-height: 0;
    align-self: stretch;
  }

  .about-dialog .beat-demo > div {
    padding: 6px;
  }

  .about-dialog .beat-demo strong,
  .about-dialog .beat-demo span {
    padding: 4px;
    font-size: 8px;
  }

  .about-dialog .rule-note,
  .twin-tutorial .rule-note {
    grid-column: 1 / -1;
    grid-row: 3;
    min-height: 25px;
    margin: 0;
    padding: 5px 8px;
    overflow: hidden;
    font-size: 9px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .about-dialog > .primary-button,
  .twin-tutorial > .primary-button,
  .about-dialog > .tutorial-skip-button,
  .twin-tutorial > .tutorial-skip-button {
    position: sticky;
    bottom: 0;
    min-height: 44px;
    margin: 0;
  }

  .about-dialog > .primary-button,
  .twin-tutorial > .primary-button {
    grid-column: 1;
    grid-row: 4;
  }

  .about-dialog > .tutorial-skip-button,
  .twin-tutorial > .tutorial-skip-button {
    grid-column: 2;
    grid-row: 4;
    border: 1px solid var(--border-default);
    background: var(--surface-inset);
  }

  .about-dialog .mode-switch-link,
  .twin-tutorial .twin-back-link {
    display: none !important;
  }
}

@media (max-width: 350px) and (max-height: 620px) {
  #app[data-guide-active="true"] .wordmark,
  #twinApp[data-guide-active="true"] .twin-wordmark,
  #twinApp[data-guide-active="true"] #twinSoundButton,
  #app[data-guide-active="true"] .stage-heading,
  #twinApp[data-guide-active="true"] .twin-heading,
  #app[data-guide-active="true"] .lesson,
  #twinApp[data-guide-active="true"] .twin-lesson {
    display: none;
  }

  #app[data-guide-active="true"] .topbar,
  #twinApp[data-guide-active="true"] .twin-topbar {
    grid-template-columns: minmax(104px, 1fr) auto;
  }

  #app[data-guide-active="true"] .topbar .mode-switcher,
  #twinApp[data-guide-active="true"] .twin-topbar .mode-switcher {
    grid-column: 1;
    grid-row: 1;
    margin-top: 0;
  }

  #app[data-guide-active="true"] .command-deck,
  #twinApp[data-guide-active="true"] .sync-bus {
    display: none;
  }

  #app[data-guide-active="true"] .board-frame {
    width: min(72vw, 220px, 38dvh);
    min-width: 204px;
  }

  #app[data-guide-active="true"] .live-guide,
  #twinApp[data-guide-active="true"] .live-guide {
    margin-top: 6px;
    padding: 9px;
  }

  .live-guide__progress {
    margin-bottom: 5px;
  }

  .live-guide__copy {
    line-height: 1.35;
  }

  .live-guide__copy p {
    display: none;
  }

  .live-guide__action,
  .guide-proof {
    margin-top: 5px;
  }
}

@keyframes guide-nudge {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .mode-switcher__option,
  .live-guide,
  .live-guide *,
  .is-guide-target {
    animation: none !important;
    transition: none !important;
  }

  .is-guide-target {
    box-shadow: 0 0 0 5px rgba(40, 217, 232, 0.14) !important;
  }

  .is-guide-nudge,
  .is-guide-focus {
    animation: none !important;
    transition: none !important;
  }
}
