:root {
  color-scheme: light;
  --page: #dfeee5;
  --page-2: #fbf1dc;
  --panel: #0f2b33;
  --panel-2: #173f48;
  --ink: #f8ffe9;
  --muted: #93cad1;
  --line: rgba(23, 53, 60, 0.2);
  --metal: #e8e0c8;
  --teal: #00d7cf;
  --cyan: #5de9ff;
  --coral: #ff654f;
  --gold: #ffd45a;
  --green: #91d644;
  --violet: #b56dff;
  --radius: 8px;
  --ui-frame-medium: url("./assets/ui/modern-menus/frame-box-medium.png");
  --ui-frame-small: url("./assets/ui/modern-menus/frame-box-small.png");
  --ui-bar-frame: url("./assets/ui/modern-menus/bar-frame-angled.png");
  --ui-bar-bg: url("./assets/ui/modern-menus/bar-frame-angled-bg.png");
  --ui-bar-medium: url("./assets/ui/modern-menus/bar-medium.png");
  --ui-glow: url("./assets/ui/modern-menus/fx-glow-01.png");
  --ui-glow-circle: url("./assets/ui/modern-menus/fx-glow-circle.png");
  --ui-glow-horizontal: url("./assets/ui/modern-menus/fx-glow-horizontal.png");
  --ui-gradient-horizontal: url("./assets/ui/modern-menus/gradient-horizontal-solid.png");
  --ui-gradient-vertical: url("./assets/ui/modern-menus/gradient-vertical.png");
  --ui-hazard: url("./assets/ui/modern-menus/hazard-stripes.png");
  --ui-indicator: url("./assets/ui/modern-menus/indicator-line-angled.png");
  --ui-ring: url("./assets/ui/modern-menus/ring-small.png");
  --ui-shield: url("./assets/ui/modern-menus/shield.png");
  --ui-triangle: url("./assets/ui/modern-menus/triangle-small.png");
  --ui-arrow: url("./assets/ui/modern-menus/arrow-clean.png");
  --ui-play: url("./assets/ui/modern-menus/icon-play.png");
  --ui-sound-on: url("./assets/ui/modern-menus/icon-sound-on.png");
  --ui-sound-off: url("./assets/ui/modern-menus/icon-sound-off.png");
  --ui-settings: url("./assets/ui/modern-menus/icon-settings.png");
  --ui-confirm: url("./assets/ui/modern-menus/icon-confirm.png");
  --ui-cancel: url("./assets/ui/modern-menus/icon-cancel.png");
  --ui-trophy: url("./assets/ui/modern-menus/icon-trophy.png");
  --ui-crown: url("./assets/ui/modern-menus/icon-crown.png");
  --ui-back: url("./assets/ui/modern-menus/icon-arrow-back.png");
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  overscroll-behavior: none;
}

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 247, 205, 0.72), transparent 28%),
    radial-gradient(circle at 86% 82%, rgba(74, 208, 208, 0.34), transparent 34%),
    linear-gradient(90deg, rgba(27, 92, 94, 0.08), transparent 18%, rgba(197, 166, 91, 0.08) 80%, transparent),
    linear-gradient(135deg, var(--page), var(--page-2));
  color: #14323a;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(12, 67, 74, 0.06) 1px, transparent 1px),
    linear-gradient(180deg, rgba(12, 67, 74, 0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 42%, black, transparent 78%);
}

button {
  font: inherit;
}

.game-shell {
  width: min(100vw, 1680px);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: clamp(82px, 10vh, 122px) minmax(0, 1fr);
  padding: clamp(8px, 1.2vw, 18px);
  gap: clamp(8px, 1vw, 14px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.95fr) minmax(480px, 1.7fr) auto;
  align-items: stretch;
  gap: clamp(8px, 1vw, 14px);
  isolation: isolate;
}

.brand,
.readouts,
.controls {
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    0 12px 26px rgba(22, 54, 58, 0.22),
    inset 0 0 0 1px rgba(2, 255, 245, 0.18),
    inset 0 12px 22px rgba(93, 233, 255, 0.05);
}

.brand::before,
.readouts::before,
.controls::before {
  content: "";
  position: absolute;
  inset: 6px;
  pointer-events: none;
  border-top: 2px solid rgba(248, 255, 233, 0.16);
  border-radius: calc(var(--radius) - 2px);
}

.brand {
  min-width: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 1.2vw, 18px);
  padding: 0 clamp(12px, 1.6vw, 24px);
  background:
    linear-gradient(90deg, rgba(93, 233, 255, 0.14), transparent 22%, rgba(255, 212, 90, 0.08) 72%, transparent),
    linear-gradient(180deg, rgba(12, 79, 84, 0.98), rgba(12, 48, 55, 0.98)),
    var(--panel);
  color: var(--ink);
  border-radius: var(--radius);
  text-transform: none;
  letter-spacing: 0;
  font-size: clamp(30px, 3.25vw, 50px);
  font-weight: 850;
  line-height: 1;
  text-shadow: 0 0 18px rgba(92, 239, 255, 0.52);
  overflow: hidden;
}

.brand::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -28%;
  width: 26%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-18deg);
  animation: chromeSweep 5200ms linear infinite;
}

.brand span:nth-child(2) {
  white-space: nowrap;
}

.brand-spark {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  transform: rotate(45deg);
  background: var(--cyan);
  box-shadow: 0 0 16px var(--cyan);
}

.readouts {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(93, 233, 255, 0.08), transparent 18%, rgba(255, 212, 90, 0.06) 82%, transparent),
    linear-gradient(180deg, rgba(17, 45, 55, 0.98), rgba(13, 33, 42, 0.98)),
    var(--panel);
  box-shadow:
    0 14px 26px rgba(22, 54, 58, 0.2),
    inset 0 0 0 1px rgba(2, 255, 245, 0.18),
    inset 0 -14px 24px rgba(0, 0, 0, 0.22);
}

.readouts > div {
  position: relative;
  min-width: 0;
  display: grid;
  align-content: center;
  padding: 10px clamp(12px, 1.6vw, 28px) 15px;
  border-left: 2px solid rgba(122, 221, 229, 0.34);
  overflow: hidden;
}

.readouts > div::before {
  content: "";
  position: absolute;
  inset: 8px 10px auto 10px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(93, 233, 255, 0.65), transparent);
  opacity: 0.48;
}

.readouts > div::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(93, 233, 255, 0.62);
  box-shadow: 0 0 10px rgba(93, 233, 255, 0.56);
  opacity: 0.72;
}

.readouts > div:first-child {
  border-left: 0;
}

dt {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: clamp(13px, 1.35vw, 21px);
  font-weight: 800;
  line-height: 1;
  text-transform: uppercase;
}

dd {
  margin: 0;
  color: var(--gold);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(22px, 2.6vw, 36px);
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.readout-sub {
  display: block;
  min-width: 0;
  margin-top: 5px;
  padding-right: 12px;
  overflow: hidden;
  color: rgba(248, 255, 233, 0.78);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(9px, 1.04vw, 12px);
  font-weight: 850;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.readouts > div.is-pulsing dd {
  animation: readoutPulse 260ms ease-out;
}

.readouts > div.is-pulsing::after {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(255, 212, 90, 0.82);
}

.combo-meter {
  position: absolute;
  left: clamp(12px, 1.6vw, 28px);
  right: clamp(12px, 1.6vw, 28px);
  bottom: 8px;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.combo-meter span {
  display: block;
  width: calc(var(--combo-progress, 0) * 100%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), var(--gold), var(--cyan));
  box-shadow: 0 0 14px rgba(93, 233, 255, 0.6);
  transition: width 120ms linear;
}

.readouts > div:nth-child(2) dd {
  color: var(--coral);
}

.readouts > div:nth-child(3) dd {
  color: var(--cyan);
}

.lives {
  color: #ff6871;
  letter-spacing: 3px;
  font-family: inherit;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(8px, 1vw, 12px);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(247, 242, 219, 0.96), rgba(203, 216, 202, 0.96)),
    linear-gradient(90deg, rgba(93, 233, 255, 0.18), transparent);
}

.icon-button,
.play-button,
.secondary-button {
  border: 0;
  color: #f7ffed;
  background:
    radial-gradient(circle at 50% 18%, rgba(56, 244, 255, 0.65), transparent 36%),
    linear-gradient(180deg, #0d6671, #0b3d48);
  cursor: pointer;
  box-shadow:
    inset 0 0 0 2px rgba(233, 252, 237, 0.55),
    inset 0 -8px 14px rgba(0, 0, 0, 0.26),
    0 8px 18px rgba(4, 40, 48, 0.25);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.22);
}

.icon-button {
  width: clamp(52px, 6.1vw, 78px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
}

.icon-button svg {
  width: 64%;
  height: 64%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button .mute-slash {
  opacity: 0;
}

.icon-button.is-muted .sound-wave {
  opacity: 0;
}

.icon-button.is-muted .mute-slash {
  opacity: 1;
}

.icon-button:hover,
.play-button:hover,
.secondary-button:hover,
.level-button:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.icon-button:focus-visible,
.play-button:focus-visible,
.secondary-button:focus-visible,
.level-button:focus-visible,
.settings-panel button:focus-visible,
.settings-drawer button:focus-visible,
.settings-drawer input:focus-visible,
.feedback-panel select:focus-visible,
.feedback-panel input:focus-visible {
  outline: 3px solid #ffe46e;
  outline-offset: 4px;
}

.board-shell {
  position: relative;
  min-height: 0;
  width: min(100%, calc((100vh - clamp(106px, 13vh, 154px)) * 16 / 9));
  max-height: 100%;
  aspect-ratio: 16 / 9;
  justify-self: center;
  align-self: center;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  border: 2px solid rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(180deg, rgba(221, 232, 207, 0.88), rgba(175, 213, 202, 0.94)),
    #bfded3;
  box-shadow:
    0 18px 38px rgba(29, 54, 56, 0.18),
    0 0 0 1px rgba(16, 78, 80, 0.1),
    inset 0 0 0 2px rgba(36, 124, 121, 0.15),
    inset 0 16px 34px rgba(255, 255, 255, 0.24);
}

.board-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(248, 255, 233, 0.5),
    inset 0 -22px 42px rgba(14, 72, 72, 0.08);
}

.board-shell canvas {
  position: relative;
  z-index: 0;
}

.coach-tip {
  --tip-accent: var(--cyan);
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
  width: min(360px, calc(100% - 36px));
  padding: 12px 14px 13px;
  border: 2px solid var(--tip-accent);
  border-radius: var(--radius);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 32%),
    linear-gradient(135deg, rgba(93, 233, 255, 0.08), rgba(255, 212, 90, 0.05)),
    rgba(5, 29, 36, 0.95);
  box-shadow:
    0 16px 32px rgba(5, 29, 36, 0.26),
    0 0 18px color-mix(in srgb, var(--tip-accent), transparent 35%),
    inset 0 0 0 1px rgba(248, 255, 233, 0.14);
  pointer-events: none;
  transition: opacity 160ms ease;
}

.coach-tip[hidden] {
  display: none;
}

.coach-tip span,
.coach-tip strong,
.coach-tip em {
  display: block;
}

.coach-tip span:first-child {
  margin-bottom: 4px;
  color: var(--tip-accent);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.coach-tip strong {
  color: var(--ink);
  font-size: clamp(19px, 2.1vw, 24px);
  font-weight: 900;
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.34);
}

.coach-tip span:nth-child(3) {
  margin-top: 7px;
  color: rgba(248, 255, 233, 0.9);
  font-size: clamp(13px, 1.26vw, 15px);
  font-weight: 760;
  line-height: 1.25;
}

.coach-tip em {
  margin-top: 8px;
  color: rgba(147, 202, 209, 0.98);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.1;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.state-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 22px;
  overflow: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(circle at 50% 48%, rgba(8, 35, 43, 0.18), rgba(8, 35, 43, 0.08) 34%, rgba(222, 242, 230, 0.18) 78%),
    rgba(174, 214, 202, 0.16);
  backdrop-filter: blur(3px) saturate(0.98);
}

.state-overlay[hidden] {
  display: none;
}

.state-panel {
  position: relative;
  overflow: auto;
  width: min(680px, calc(100% - 48px));
  max-height: 100%;
  padding: clamp(20px, 3.4vw, 36px);
  text-align: center;
  border-radius: var(--radius);
  border: 2px solid rgba(255, 255, 255, 0.76);
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), transparent 28%),
    linear-gradient(90deg, rgba(93, 233, 255, 0.06), transparent 42%, rgba(255, 212, 90, 0.05)),
    radial-gradient(circle at 50% 0%, rgba(36, 218, 221, 0.42), transparent 52%),
    linear-gradient(180deg, rgba(14, 66, 74, 0.96), rgba(8, 31, 40, 0.96));
  box-shadow:
    inset 0 0 0 2px rgba(92, 239, 255, 0.18),
    inset 0 -16px 30px rgba(0, 0, 0, 0.22),
    0 18px 44px rgba(13, 55, 58, 0.36);
  scrollbar-color: rgba(112, 244, 255, 0.62) rgba(0, 14, 24, 0.4);
  scrollbar-width: thin;
}

.state-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.16));
  opacity: 0.82;
}

.state-panel > * {
  position: relative;
  z-index: 1;
}

.state-panel.is-results {
  width: min(580px, calc(100% - 48px));
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.22), transparent 46%),
    linear-gradient(180deg, rgba(16, 73, 76, 0.97), rgba(8, 31, 40, 0.97));
}

.state-panel.is-gameover {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 101, 79, 0.18), transparent 48%),
    linear-gradient(180deg, rgba(14, 58, 69, 0.97), rgba(8, 27, 37, 0.97));
}

.state-panel.is-menu {
  display: flex;
  flex-direction: column;
  width: min(780px, calc(100% - 48px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: clamp(18px, 2.8vw, 26px);
}

.state-panel h1 {
  margin: 0;
  font-size: clamp(40px, 7vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

.state-panel.is-menu h1 {
  order: 1;
  font-size: clamp(38px, 5vw, 58px);
}

.state-panel p {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: clamp(16px, 2.4vw, 24px);
  font-weight: 800;
}

.state-panel.is-menu p {
  order: 2;
  margin: 8px 0 12px;
}

.best-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
  color: #f8ffe9;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(12px, 1.7vw, 16px);
  font-weight: 850;
}

.best-stats span {
  min-width: 0;
  padding: 8px 7px;
  border: 1px solid rgba(93, 233, 255, 0.34);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.16);
  white-space: nowrap;
}

.state-panel.is-menu .best-stats {
  order: 3;
  gap: 7px;
  margin-bottom: 12px;
}

.state-panel.is-menu .best-stats span {
  padding: 7px 6px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 0 0 18px;
  text-align: left;
  scrollbar-color: rgba(112, 244, 255, 0.62) rgba(0, 14, 24, 0.4);
  scrollbar-width: thin;
}

.state-panel::-webkit-scrollbar {
  width: 10px;
}

.state-panel::-webkit-scrollbar-track {
  background: rgba(0, 14, 24, 0.38);
  border-radius: 999px;
}

.state-panel::-webkit-scrollbar-thumb {
  border: 2px solid rgba(0, 14, 24, 0.68);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(112, 244, 255, 0.78), rgba(255, 212, 90, 0.58));
}

.result-stat {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid rgba(93, 233, 255, 0.34);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 15% 0%, rgba(93, 233, 255, 0.14), transparent 50%),
    rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.result-stat strong,
.result-stat em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-stat strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.result-stat em {
  margin-top: 4px;
  color: #f8ffe9;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(15px, 2vw, 21px);
  font-style: normal;
  font-weight: 900;
}

.progress-panel {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 14px;
}

.progress-chip {
  min-width: 0;
  padding: 6px 5px;
  border: 1px solid rgba(93, 233, 255, 0.24);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(93, 233, 255, 0.08), transparent),
    rgba(0, 0, 0, 0.2);
  color: var(--muted);
  text-align: center;
  box-shadow: inset 0 1px 0 rgba(248, 255, 233, 0.08);
}

.progress-chip strong,
.progress-chip em,
.progress-chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-chip strong {
  color: #f8ffe9;
  font-size: 12px;
}

.progress-chip em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 900;
}

.progress-chip small {
  color: #f8ffe9;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 850;
}

.progress-chip.is-active {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.18), transparent 68%),
    rgba(0, 0, 0, 0.22);
  box-shadow:
    0 0 12px rgba(255, 212, 90, 0.24),
    inset 0 1px 0 rgba(248, 255, 233, 0.12);
}

.progress-chip.is-complete {
  border-color: rgba(145, 214, 68, 0.58);
}

.progress-chip.is-locked {
  opacity: 0.42;
}

.settings-panel {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin: 0 0 14px;
}

.settings-panel button {
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid rgba(93, 233, 255, 0.34);
  border-radius: var(--radius);
  color: #f8ffe9;
  background:
    linear-gradient(180deg, rgba(93, 233, 255, 0.08), transparent 58%),
    rgba(6, 34, 42, 0.78);
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 1px 0 rgba(248, 255, 233, 0.08);
}

.settings-panel button.is-enabled {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.2), transparent 58%),
    rgba(9, 58, 63, 0.9);
}

.state-panel.is-menu .progress-panel,
.state-panel.is-menu .settings-panel {
  margin-bottom: 10px;
}

.state-panel.is-menu .progress-panel {
  order: 8;
}

.state-panel.is-menu .settings-panel {
  order: 9;
}

.feedback-panel {
  display: grid;
  grid-template-columns: minmax(86px, 0.62fr) minmax(132px, 1fr) minmax(160px, 1.4fr);
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 9px;
  border: 1px solid rgba(93, 233, 255, 0.3);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(93, 233, 255, 0.08), transparent 72%),
    rgba(5, 28, 36, 0.72);
  text-align: left;
}

.feedback-panel[hidden],
#feedbackBtn[hidden] {
  display: none !important;
}

.feedback-panel label {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.feedback-panel select,
.feedback-panel input {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid rgba(93, 233, 255, 0.32);
  border-radius: 6px;
  color: #f8ffe9;
  background: rgba(4, 25, 33, 0.9);
  font: inherit;
  font-size: 12px;
  font-weight: 820;
}

.feedback-panel select {
  padding: 0 8px;
}

.feedback-panel input {
  padding: 0 10px;
}

.feedback-panel input::placeholder {
  color: rgba(147, 202, 209, 0.76);
}

.state-panel.is-menu .result-stats {
  order: 5;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 10px;
}

.state-panel.is-menu .how-to {
  order: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(93, 233, 255, 0.28);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(93, 233, 255, 0.08), transparent 70%),
    rgba(0, 0, 0, 0.15);
  text-align: left;
  font-size: clamp(12px, 1.5vw, 14px);
}

.how-to-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.how-to-steps em {
  display: block;
  min-width: 0;
  padding: 5px 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 212, 90, 0.26);
  border-radius: 6px;
  color: #f8ffe9;
  background: rgba(7, 35, 43, 0.62);
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

body.is-large-text .result-stat strong,
body.is-large-text .level-button span,
body.is-large-text .level-button small,
body.is-large-text .settings-panel button,
body.is-large-text .settings-drawer,
body.is-large-text .feedback-panel select,
body.is-large-text .feedback-panel input,
body.is-large-text .progress-chip em {
  font-size: 12px;
}

body.is-large-text .result-stat em,
body.is-large-text .how-to,
body.is-large-text .level-button strong {
  font-size: 16px;
}

body.is-large-text .state-panel.is-menu {
  width: min(840px, calc(100% - 48px));
}

body.is-large-text .readout-sub {
  font-size: clamp(10px, 1.1vw, 13px);
}

body.is-high-contrast {
  --ink: #ffffff;
  --muted: #d7fbff;
  --line: rgba(255, 255, 255, 0.46);
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 212, 90, 0.36), transparent 26%),
    radial-gradient(circle at 86% 82%, rgba(93, 233, 255, 0.32), transparent 32%),
    linear-gradient(135deg, #d3eadc, #f1e6c8);
}

body.is-high-contrast .brand,
body.is-high-contrast .readouts,
body.is-high-contrast .controls,
body.is-high-contrast .board-shell,
body.is-high-contrast .state-panel {
  border-color: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 0 0 2px rgba(3, 30, 38, 0.44),
    0 12px 28px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

body.is-high-contrast .readout-sub,
body.is-high-contrast .state-panel p,
body.is-high-contrast .how-to,
body.is-high-contrast .level-button span,
body.is-high-contrast .progress-chip,
body.is-high-contrast .result-stat strong {
  color: #dffcff;
}

body.is-high-contrast .result-stat,
body.is-high-contrast .level-button,
body.is-high-contrast .settings-panel button,
body.is-high-contrast .settings-drawer,
body.is-high-contrast .settings-group,
body.is-high-contrast .settings-save-actions button,
body.is-high-contrast .feedback-panel,
body.is-high-contrast .feedback-panel select,
body.is-high-contrast .feedback-panel input,
body.is-high-contrast .progress-chip,
body.is-high-contrast .best-stats span,
body.is-high-contrast .how-to {
  border-color: rgba(255, 255, 255, 0.54);
}

body.is-high-contrast .icon-button:focus-visible,
body.is-high-contrast .play-button:focus-visible,
body.is-high-contrast .secondary-button:focus-visible,
body.is-high-contrast .level-button:focus-visible,
body.is-high-contrast .settings-panel button:focus-visible,
body.is-high-contrast .settings-drawer button:focus-visible,
body.is-high-contrast .settings-drawer input:focus-visible,
body.is-high-contrast .feedback-panel select:focus-visible,
body.is-high-contrast .feedback-panel input:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
}

body.is-high-contrast canvas {
  filter: contrast(1.16) saturate(1.16);
}

body.is-reduced-motion .combo-meter span {
  transition: none;
}

body.is-reduced-motion .brand::after {
  animation: none;
}

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

.level-select {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 16px;
}

.level-button {
  position: relative;
  min-height: 62px;
  padding: 8px 36px 8px 8px;
  border: 1px solid rgba(93, 233, 255, 0.34);
  border-radius: var(--radius);
  color: #f8ffe9;
  background:
    linear-gradient(180deg, rgba(93, 233, 255, 0.08), transparent 64%),
    rgba(6, 34, 42, 0.72);
  cursor: pointer;
  text-align: left;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 8px 18px rgba(0, 0, 0, 0.08);
}

.level-button strong,
.level-button span,
.level-button small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-button strong {
  font-size: 13px;
  line-height: 1.15;
}

.level-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.level-button small {
  margin-top: 3px;
  color: rgba(248, 255, 233, 0.86);
  font-size: 10px;
  font-weight: 850;
}

.level-button.is-selected {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 212, 90, 0.2), transparent 52%),
    rgba(9, 58, 63, 0.9);
  box-shadow:
    0 0 16px rgba(255, 212, 90, 0.2),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -10px 18px rgba(0, 0, 0, 0.2);
}

.level-button::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(147, 202, 209, 0.55);
  transform: translateY(-50%);
}

.level-button.is-complete::after {
  border-color: var(--green);
  background: radial-gradient(circle, var(--green) 0 38%, transparent 42%);
  box-shadow: 0 0 12px rgba(145, 214, 68, 0.58);
}

.level-button.is-selected::after {
  border-color: var(--gold);
  background: radial-gradient(circle, var(--gold) 0 34%, transparent 38%);
}

.state-panel.is-menu .level-select {
  order: 7;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.state-panel.is-menu .level-button {
  min-height: 54px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.level-button:disabled,
.level-button.is-locked {
  cursor: not-allowed;
  opacity: 0.48;
  filter: saturate(0.55);
  background:
    linear-gradient(180deg, rgba(147, 202, 209, 0.04), transparent 64%),
    rgba(6, 34, 42, 0.58);
}

.how-to {
  display: grid;
  gap: 5px;
  margin: 0 0 18px;
  color: rgba(248, 255, 233, 0.9);
  font-size: clamp(13px, 1.8vw, 16px);
  line-height: 1.35;
}

.how-to strong {
  color: var(--cyan);
}

.state-panel.is-simple .best-stats,
.state-panel.is-simple .result-stats,
.state-panel.is-simple .level-select,
.state-panel.is-simple .how-to,
.state-panel.is-simple .progress-panel,
.state-panel.is-simple .settings-panel,
.state-panel.is-simple .secondary-button {
  display: none;
}

.state-panel.is-results .best-stats,
.state-panel.is-results .level-select,
.state-panel.is-results .how-to,
.state-panel.is-results .progress-panel,
.state-panel.is-results .settings-panel,
.state-panel.is-results .secondary-button,
.state-panel.is-gameover .best-stats,
.state-panel.is-gameover .level-select,
.state-panel.is-gameover .how-to,
.state-panel.is-gameover .progress-panel,
.state-panel.is-gameover .settings-panel,
.state-panel.is-gameover #menuMuteBtn {
  display: none;
}

.state-panel.has-feedback #feedbackBtn {
  display: inline-flex;
}

.state-panel.is-pause #settingsDialogBtn,
.state-panel.is-results #settingsDialogBtn,
.state-panel.is-gameover #settingsDialogBtn,
.state-panel.is-victory #settingsDialogBtn {
  display: inline-flex;
}

.menu-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.state-panel.is-menu .menu-actions {
  order: 4;
  margin-bottom: 12px;
}

.menu-actions .play-button {
  box-shadow:
    inset 0 0 0 2px rgba(233, 252, 237, 0.62),
    inset 0 -10px 16px rgba(0, 0, 0, 0.28),
    0 10px 22px rgba(4, 40, 48, 0.28),
    0 0 22px rgba(93, 233, 255, 0.18);
}

.icon-button:active,
.play-button:active,
.secondary-button:active,
.level-button:active {
  transform: translateY(1px) scale(0.99);
}

.play-button {
  min-width: 150px;
  min-height: 54px;
  padding: 0 28px;
  border-radius: var(--radius);
  font-size: 22px;
  font-weight: 850;
}

.secondary-button {
  min-width: 118px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 850;
}

.feedback-button {
  min-width: 142px;
  border-color: rgba(255, 212, 90, 0.5);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.16), transparent 60%),
    linear-gradient(180deg, rgba(93, 233, 255, 0.08), transparent 58%),
    rgba(6, 34, 42, 0.88);
}

/* Modern Menus UI pass */
.brand,
.readouts,
.controls,
.state-panel {
  border-color: rgba(248, 255, 233, 0.82);
}

.brand::before,
.readouts::before,
.controls::before {
  inset: -1px;
  border: 0;
  border-radius: inherit;
  background:
    var(--ui-gradient-horizontal) center / 100% 100% no-repeat,
    linear-gradient(90deg, rgba(93, 233, 255, 0.18), transparent 28%, rgba(255, 212, 90, 0.12) 74%, transparent);
  opacity: 0.28;
  mix-blend-mode: screen;
}

.brand {
  background:
    radial-gradient(circle at 50% 0%, rgba(93, 233, 255, 0.2), transparent 50%),
    var(--ui-gradient-vertical) center / 100% 100% no-repeat,
    linear-gradient(180deg, rgba(13, 76, 82, 0.98), rgba(7, 29, 39, 0.98));
  box-shadow:
    0 16px 30px rgba(5, 28, 35, 0.24),
    inset 0 0 0 1px rgba(93, 233, 255, 0.26),
    inset 0 -16px 26px rgba(0, 0, 0, 0.28);
}

.brand-spark {
  background: var(--gold);
  box-shadow: 0 0 16px rgba(255, 212, 90, 0.82);
  -webkit-mask: var(--ui-triangle) center / contain no-repeat;
  mask: var(--ui-triangle) center / contain no-repeat;
}

.readouts {
  gap: 5px;
  padding: 6px;
  background:
    radial-gradient(circle at 50% -20%, rgba(93, 233, 255, 0.18), transparent 44%),
    linear-gradient(180deg, rgba(13, 54, 64, 0.98), rgba(6, 24, 35, 0.98));
}

.readouts::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 7px;
  height: 18px;
  pointer-events: none;
  background: var(--ui-glow-horizontal) center / 100% 100% no-repeat;
  opacity: 0.2;
}

.readouts > div {
  padding: 9px clamp(10px, 1.4vw, 22px) 14px;
  border: 1px solid rgba(93, 233, 255, 0.2);
  border-left: 1px solid rgba(93, 233, 255, 0.2);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 58%),
    rgba(0, 0, 0, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(248, 255, 233, 0.12),
    inset 0 -8px 16px rgba(0, 0, 0, 0.14);
}

.readouts > div::before {
  top: 7px;
  left: 9px;
  right: 9px;
  height: 5px;
  background: var(--ui-indicator) left center / auto 100% no-repeat;
  opacity: 0.55;
}

.readouts > div::after {
  width: 11px;
  height: 11px;
  right: 10px;
  bottom: 7px;
  background: var(--ui-ring) center / contain no-repeat;
  border-radius: 0;
  box-shadow: none;
}

dt {
  color: rgba(248, 255, 233, 0.86);
  font-size: clamp(10px, 1vw, 14px);
  letter-spacing: 0;
}

dd {
  font-size: clamp(22px, 2.75vw, 38px);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.38),
    0 0 16px rgba(255, 212, 90, 0.18);
}

.readout-sub {
  color: rgba(202, 237, 235, 0.84);
}

.controls {
  background:
    radial-gradient(circle at 50% 0%, rgba(93, 233, 255, 0.12), transparent 54%),
    linear-gradient(180deg, rgba(12, 53, 62, 0.96), rgba(6, 25, 35, 0.96));
}

.icon-button,
.play-button,
.secondary-button {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(248, 255, 233, 0.36);
  background:
    radial-gradient(circle at 50% 0%, rgba(93, 233, 255, 0.46), transparent 46%),
    var(--ui-gradient-horizontal) center / 100% 100% no-repeat,
    linear-gradient(180deg, #12828a, #0a3e4a);
  box-shadow:
    inset 0 0 0 1px rgba(233, 252, 237, 0.22),
    inset 0 -10px 16px rgba(0, 0, 0, 0.28),
    0 8px 18px rgba(4, 40, 48, 0.3);
}

.icon-button::before {
  content: "";
  position: absolute;
  inset: 4px;
  pointer-events: none;
  background: var(--ui-frame-small) center / 100% 100% no-repeat;
  opacity: 0.48;
}

.icon-button svg {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.28));
}

.play-button,
.secondary-button {
  padding-left: 52px;
  text-align: center;
}

.play-button::before,
.secondary-button::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 30px;
  height: 30px;
  pointer-events: none;
  background: var(--ui-arrow) center / contain no-repeat;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.22));
  transform: translateY(-50%);
}

.play-button::before {
  background-image: var(--ui-play);
}

#continueBtn::before {
  background-image: var(--ui-back);
  transform: translateY(-50%) scaleX(-1);
}

#menuMuteBtn::before {
  background-image: var(--ui-sound-on);
}

#settingsDialogBtn::before {
  background-image: var(--ui-settings);
}

.icon-button.is-muted + #menuMuteBtn::before,
#menuMuteBtn[aria-pressed="true"]::before {
  background-image: var(--ui-sound-off);
}

.feedback-button::before {
  background-image: var(--ui-confirm);
}

.state-panel {
  border-width: 1px;
  background:
    radial-gradient(circle at 50% -8%, rgba(93, 233, 255, 0.34), transparent 44%),
    radial-gradient(circle at 8% 95%, rgba(255, 212, 90, 0.13), transparent 30%),
    linear-gradient(180deg, rgba(12, 69, 76, 0.97), rgba(5, 22, 32, 0.98));
  box-shadow:
    inset 0 0 0 1px rgba(92, 239, 255, 0.2),
    inset 0 -18px 32px rgba(0, 0, 0, 0.26),
    0 22px 52px rgba(5, 28, 35, 0.42);
}

.state-panel::before {
  inset: 8px;
  border-radius: calc(var(--radius) - 2px);
  background:
    var(--ui-frame-medium) center / 100% 100% no-repeat,
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.14));
  opacity: 0.42;
}

.state-panel::after {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 14px;
  height: 22px;
  pointer-events: none;
  background: var(--ui-bar-medium) center / 100% 100% no-repeat;
  opacity: 0.22;
}

.state-panel.is-menu::before {
  opacity: 0.16;
}

.state-panel.is-menu::after {
  opacity: 0.18;
}

.state-panel h1 {
  color: #f8ffe9;
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.32),
    0 0 22px rgba(93, 233, 255, 0.28);
}

.best-stats span,
.result-stat,
.progress-chip,
.settings-panel button,
.feedback-panel,
.level-button {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 56%),
    radial-gradient(circle at 12% 0%, rgba(93, 233, 255, 0.13), transparent 50%),
    rgba(2, 20, 29, 0.5);
  box-shadow:
    inset 0 1px 0 rgba(248, 255, 233, 0.1),
    inset 0 -8px 16px rgba(0, 0, 0, 0.16);
}

.level-button {
  min-height: 68px;
  padding: 10px 54px 9px 12px;
  border-color: rgba(93, 233, 255, 0.3);
}

.level-button::before {
  content: "";
  position: absolute;
  inset: 5px;
  pointer-events: none;
  background: var(--ui-frame-small) center / 100% 100% no-repeat;
  opacity: 0.18;
}

.level-button::after {
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  background: var(--ui-ring) center / contain no-repeat;
  opacity: 0.68;
  box-shadow: none;
}

.level-button.is-selected {
  border-color: var(--gold);
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 212, 90, 0.24), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 56%),
    rgba(9, 58, 63, 0.9);
}

.level-button.is-selected::before {
  opacity: 0.32;
}

.level-button.is-selected::after {
  background-image: var(--ui-trophy);
  opacity: 1;
  filter: drop-shadow(0 0 10px rgba(255, 212, 90, 0.32));
}

.level-button.is-complete::after {
  background-image: var(--ui-confirm);
  opacity: 0.95;
}

.level-button.is-perfect::after {
  background-image: var(--ui-crown);
  opacity: 1;
}

.level-button.is-locked::after {
  background-image: var(--ui-cancel);
  opacity: 0.58;
  filter: grayscale(0.65);
}

.progress-chip {
  position: relative;
  overflow: hidden;
}

.progress-chip::before {
  content: "";
  position: absolute;
  inset: 4px auto auto 4px;
  width: 12px;
  height: 12px;
  background: var(--ui-ring) center / contain no-repeat;
  opacity: 0.34;
}

.progress-chip.is-complete::before {
  background-image: var(--ui-confirm);
  opacity: 0.74;
}

.progress-chip.is-perfect::before {
  background-image: var(--ui-crown);
  opacity: 0.9;
}

.settings-panel button.is-enabled {
  box-shadow:
    0 0 12px rgba(255, 212, 90, 0.2),
    inset 0 1px 0 rgba(248, 255, 233, 0.16);
}

.state-panel.is-menu .result-stat em {
  font-size: clamp(14px, 1.45vw, 18px);
}

.state-panel.is-menu .result-stat strong {
  font-size: 10px;
}

/* UI contrast QA pass */
.brand::before,
.readouts::before,
.controls::before {
  background: linear-gradient(90deg, rgba(93, 233, 255, 0.07), transparent 30%, rgba(255, 212, 90, 0.06) 74%, transparent);
  opacity: 1;
  mix-blend-mode: normal;
}

.brand {
  background:
    radial-gradient(circle at 50% -10%, rgba(93, 233, 255, 0.16), transparent 46%),
    linear-gradient(180deg, rgba(12, 65, 73, 0.99), rgba(5, 23, 33, 0.99));
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.32),
    0 0 11px rgba(93, 233, 255, 0.22);
}

.brand::after {
  opacity: 0.2;
}

.readouts {
  background:
    radial-gradient(circle at 50% -20%, rgba(93, 233, 255, 0.11), transparent 44%),
    linear-gradient(180deg, rgba(11, 45, 54, 0.99), rgba(4, 18, 28, 0.99));
}

.readouts::after {
  opacity: 0.08;
}

.readouts > div {
  border-color: rgba(93, 233, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 52%),
    rgba(0, 0, 0, 0.26);
}

dt {
  color: rgba(230, 255, 247, 0.9);
}

.readout-sub {
  color: rgba(205, 236, 235, 0.88);
}

.controls {
  background:
    radial-gradient(circle at 50% 0%, rgba(93, 233, 255, 0.08), transparent 54%),
    linear-gradient(180deg, rgba(10, 43, 52, 0.98), rgba(4, 18, 28, 0.98));
}

.icon-button,
.play-button,
.secondary-button {
  color: #f8ffe9;
  border-color: rgba(120, 239, 246, 0.5);
  background:
    radial-gradient(circle at 50% 0%, rgba(93, 233, 255, 0.2), transparent 48%),
    linear-gradient(180deg, #0c6872, #062e3a 72%, #041c27);
  box-shadow:
    inset 0 0 0 1px rgba(233, 252, 237, 0.18),
    inset 0 -10px 18px rgba(0, 0, 0, 0.34),
    0 8px 18px rgba(4, 40, 48, 0.28);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.42),
    0 0 8px rgba(93, 233, 255, 0.18);
}

.icon-button::before {
  opacity: 0.22;
}

.play-button::before,
.secondary-button::before {
  width: 25px;
  height: 25px;
  background: currentColor;
  -webkit-mask: var(--ui-arrow) center / contain no-repeat;
  mask: var(--ui-arrow) center / contain no-repeat;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.34));
}

.play-button::before {
  background-image: none;
  -webkit-mask-image: var(--ui-play);
  mask-image: var(--ui-play);
}

#continueBtn::before {
  background-image: none;
  -webkit-mask-image: var(--ui-back);
  mask-image: var(--ui-back);
}

#menuMuteBtn::before {
  background-image: none;
  -webkit-mask-image: var(--ui-sound-on);
  mask-image: var(--ui-sound-on);
}

#menuMuteBtn[aria-pressed="true"]::before {
  background-image: none;
  -webkit-mask-image: var(--ui-sound-off);
  mask-image: var(--ui-sound-off);
}

.feedback-button::before {
  background-image: none;
  -webkit-mask-image: var(--ui-confirm);
  mask-image: var(--ui-confirm);
}

.state-panel {
  background:
    radial-gradient(circle at 50% -10%, rgba(93, 233, 255, 0.22), transparent 42%),
    radial-gradient(circle at 8% 95%, rgba(255, 212, 90, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(9, 55, 64, 0.98), rgba(3, 17, 28, 0.99));
}

.state-panel::before {
  opacity: 0.12;
}

.state-panel::after {
  opacity: 0.1;
}

.state-panel.is-menu::before {
  opacity: 0.08;
}

.state-panel h1 {
  color: #fbffe9;
  text-shadow:
    0 3px 0 rgba(0, 0, 0, 0.36),
    0 0 12px rgba(93, 233, 255, 0.18);
}

.state-panel p {
  color: rgba(181, 225, 228, 0.92);
}

.feedback-panel,
.result-stat,
.best-stats span,
.progress-chip,
.settings-panel button,
.level-button {
  border-color: rgba(93, 233, 255, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 52%),
    rgba(0, 14, 24, 0.7);
}

.feedback-panel select,
.feedback-panel input {
  color: #f8ffe9;
  border-color: rgba(93, 233, 255, 0.48);
  background: rgba(0, 13, 23, 0.94);
}

.feedback-panel input::placeholder {
  color: rgba(181, 225, 228, 0.78);
}

.play-button:hover,
.secondary-button:hover,
.icon-button:hover {
  filter: brightness(1.08) saturate(1.05);
}

.readouts > div.is-chain-active {
  border-color: rgba(255, 212, 90, 0.72);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 52%),
    rgba(22, 17, 7, 0.58);
  box-shadow:
    0 0 18px rgba(255, 212, 90, 0.22),
    inset 0 1px 0 rgba(248, 255, 233, 0.14),
    inset 0 -8px 18px rgba(0, 0, 0, 0.22);
}

.readouts > div.is-chain-active dd {
  color: var(--gold);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.5),
    0 0 16px rgba(255, 212, 90, 0.46);
}

.readouts > div.is-chain-active .readout-sub {
  color: #fff2a8;
}

.readouts > div.is-chain-active .combo-meter {
  height: 6px;
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 212, 90, 0.28);
}

.readouts > div.is-notice {
  border-color: color-mix(in srgb, var(--notice-accent, var(--gold)), rgba(255, 255, 255, 0.34) 32%);
  background:
    radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--notice-accent, var(--gold)), transparent 72%), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 52%),
    rgba(8, 26, 32, 0.68);
  box-shadow:
    0 0 20px color-mix(in srgb, var(--notice-accent, var(--gold)), transparent 72%),
    inset 0 1px 0 rgba(248, 255, 233, 0.16),
    inset 0 -8px 18px rgba(0, 0, 0, 0.24);
}

.readouts > div.is-notice::after {
  background: var(--notice-accent, var(--gold));
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--notice-accent, var(--gold)), transparent 18%));
}

.readout-sub.is-notice {
  position: absolute;
  right: 22px;
  bottom: 6px;
  left: 10px;
  z-index: 2;
  margin-top: 0;
  padding: 3px 0 3px 6px;
  border-left: 3px solid var(--notice-accent, var(--gold));
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.34), transparent 92%);
  color: #fff6b8;
  font-size: clamp(9px, 0.86vw, 12px);
  text-shadow:
    0 1px 0 rgba(0, 0, 0, 0.42),
    0 0 12px color-mix(in srgb, var(--notice-accent, var(--gold)), transparent 26%);
}

.readouts > div.is-chain-hot {
  animation: chainGlow 700ms ease-in-out infinite alternate;
}

@keyframes chromeSweep {
  0% {
    transform: translateX(0) skewX(-18deg);
  }
  42%,
  100% {
    transform: translateX(540%) skewX(-18deg);
  }
}

@keyframes chainGlow {
  from {
    box-shadow:
      0 0 14px rgba(255, 212, 90, 0.2),
      inset 0 1px 0 rgba(248, 255, 233, 0.14),
      inset 0 -8px 18px rgba(0, 0, 0, 0.22);
  }
  to {
    box-shadow:
      0 0 24px rgba(255, 212, 90, 0.36),
      inset 0 1px 0 rgba(248, 255, 233, 0.18),
      inset 0 -8px 18px rgba(0, 0, 0, 0.22);
  }
}

@keyframes readoutPulse {
  0% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  45% {
    transform: translateY(-1px) scale(1.08);
    filter: brightness(1.34);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .game-shell {
    min-height: 100vh;
    min-height: 100dvh;
    height: auto;
    grid-template-rows: auto auto;
    align-content: start;
  }

  .board-shell {
    width: 100%;
    max-height: none;
    align-self: start;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .brand {
    min-height: 72px;
    font-size: clamp(28px, 9vw, 46px);
  }

  .readouts {
    grid-column: 1 / -1;
    order: 3;
    grid-template-columns: repeat(4, minmax(72px, 1fr));
  }

  .readouts > div {
    padding: 9px 10px 14px;
  }

  dt {
    font-size: 12px;
  }

  dd {
    font-size: clamp(19px, 6vw, 29px);
  }

  .readout-sub {
    font-size: 9px;
  }
}

@media (max-width: 560px) {
  .game-shell {
    padding:
      max(6px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right))
      max(6px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
    gap: 6px;
    grid-template-rows: auto auto;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .brand {
    min-height: 62px;
    justify-content: flex-start;
    gap: 8px;
    padding-left: 18px;
    padding-right: 190px;
    font-size: clamp(24px, 7vw, 31px);
  }

  .brand-spark {
    width: 9px;
    height: 9px;
  }

  .controls {
    position: absolute;
    right: 12px;
    top: 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
  }

  .icon-button {
    width: 52px;
  }

  .readouts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readouts > div:nth-child(odd) {
    border-left: 0;
  }

  .state-overlay {
    position: fixed;
    z-index: 10;
    min-height: 100dvh;
    overflow: auto;
    place-items: start center;
    padding: 10px;
  }

  .state-panel {
    width: min(350px, calc(100% - 28px));
    margin: 10px auto;
    padding: 18px;
  }

  .state-panel.is-menu {
    width: min(350px, calc(100% - 28px));
    max-height: calc(100dvh - 20px);
  }

  .best-stats,
  .result-stats,
  .level-select,
  .progress-panel,
  .settings-panel,
  .feedback-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feedback-panel label {
    grid-column: 1 / -1;
  }

  .state-panel.is-menu .result-stats,
  .state-panel.is-menu .level-select {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-button {
    min-height: 58px;
  }

  .settings-panel button,
  .progress-chip {
    min-height: 42px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .icon-button {
    min-width: 52px;
    min-height: 52px;
  }

  .play-button,
  .secondary-button,
  .level-button,
  .settings-panel button,
  .feedback-panel select,
  .feedback-panel input {
    touch-action: manipulation;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .game-shell {
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
    height: 100dvh;
    overflow: hidden;
    padding: 6px;
    gap: 6px;
  }

  .topbar {
    grid-template-columns: minmax(150px, 0.75fr) minmax(0, 1.8fr) auto;
    gap: 6px;
  }

  .brand {
    min-height: 52px;
    font-size: clamp(22px, 4vw, 34px);
  }

  .readouts {
    grid-column: auto;
    order: initial;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .readouts > div {
    padding: 7px 9px;
  }

  .icon-button {
    width: 48px;
  }

  .board-shell {
    width: min(100%, calc((100dvh - 76px) * 16 / 9));
  }
}

/* Complete game title/menu pass */
.state-panel.is-menu {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(390px, 1.12fr);
  grid-template-areas:
    "title title"
    "meta meta"
    "actions actions"
    "best best"
    "leader settings"
    "mission mission"
    "levels levels";
  gap: 10px;
  width: min(920px, calc(100% - 48px));
  max-height: calc(100% - 28px);
  padding: clamp(18px, 2.4vw, 28px);
  overflow: auto;
  text-align: left;
}

.state-overlay.is-menu {
  place-items: start center;
  overflow: auto;
  padding: 14px 22px;
}

.state-panel.is-menu::before {
  opacity: 0.08;
}

.state-panel.is-menu::after {
  left: 12%;
  right: 12%;
  top: 16px;
  opacity: 0.16;
}

.state-panel.is-menu h1 {
  grid-area: title;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 0;
  color: transparent;
  background: linear-gradient(180deg, #ffffff 0%, #fbffe9 45%, #9cf8ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  font-size: clamp(44px, 5.7vw, 70px);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.9;
  text-align: center;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.38),
    0 0 26px rgba(93, 233, 255, 0.28);
}

.state-panel.is-menu h1::before {
  content: "";
  flex: 0 0 auto;
  width: 68px;
  height: 48px;
  background:
    radial-gradient(circle at 50% 50%, #fbffe9 0 11%, transparent 13%),
    radial-gradient(circle at 50% 50%, rgba(93, 233, 255, 0.45) 0 24%, transparent 25%),
    conic-gradient(from 25deg, transparent 0 18%, #5de9ff 19% 28%, transparent 29% 52%, #ffd45a 53% 62%, transparent 63% 100%);
  border: 2px solid rgba(248, 255, 233, 0.66);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(93, 233, 255, 0.3),
    inset 0 0 18px rgba(93, 233, 255, 0.22);
  transform: skewX(-10deg);
}

.state-panel.is-menu p {
  grid-area: meta;
  margin: -4px 0 0;
  color: rgba(213, 247, 242, 0.92);
  font-size: clamp(15px, 2vw, 19px);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.state-panel.is-menu .menu-actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(132px, 0.72fr));
  gap: 10px;
  margin: 0;
}

.state-panel.is-menu .play-button,
.state-panel.is-menu .secondary-button {
  width: 100%;
  min-width: 0;
  min-height: 48px;
}

.state-panel.is-menu .play-button {
  min-height: 56px;
  border-color: #ffdf69;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.34), transparent 52%),
    linear-gradient(180deg, #13848b, #073541 72%, #041c27);
  font-size: 24px;
  box-shadow:
    inset 0 0 0 2px rgba(248, 255, 233, 0.72),
    inset 0 -12px 18px rgba(0, 0, 0, 0.32),
    0 0 0 4px rgba(255, 212, 90, 0.22),
    0 12px 24px rgba(4, 40, 48, 0.32);
}

.state-panel.is-menu .best-stats,
.state-panel.is-menu .result-stats,
.state-panel.is-menu .how-to,
.state-panel.is-menu .progress-panel,
.state-panel.is-menu .settings-panel,
.state-panel.is-menu .level-select {
  margin: 0;
}

.state-panel.is-menu .best-stats {
  grid-area: best;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.state-panel.is-menu .best-stats::before,
.state-panel.is-menu .result-stats::before,
.state-panel.is-menu .level-select::before,
.state-panel.is-menu .progress-panel .leader-head,
.state-panel.is-menu .settings-panel::before {
  color: #70f4ff;
  font-family: Inter, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.state-panel.is-menu .best-stats::before {
  content: "Run Record";
  grid-column: 1 / -1;
}

.state-panel.is-menu .best-stats span {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 9px 11px;
  white-space: normal;
}

.state-panel.is-menu .best-stats strong,
.state-panel.is-menu .best-stats em {
  display: block;
  overflow-wrap: anywhere;
}

.state-panel.is-menu .best-stats strong {
  color: rgba(190, 232, 232, 0.9);
  font-family: Inter, system-ui, sans-serif;
  font-size: 11px;
  text-transform: uppercase;
}

.state-panel.is-menu .best-stats em {
  color: #fbffe9;
  font-style: normal;
  font-size: clamp(18px, 2.1vw, 25px);
  font-weight: 950;
}

.state-panel.is-menu .result-stats {
  grid-area: mission;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.state-panel.is-menu .result-stats::before {
  content: "Selected Mission";
  grid-column: 1 / -1;
}

.state-panel.is-menu .result-stat {
  min-height: 64px;
  padding: 10px 11px;
}

.state-panel.is-menu .result-stat strong,
.state-panel.is-menu .result-stat em {
  white-space: normal;
}

.state-panel.is-menu .result-stat strong {
  color: rgba(180, 225, 226, 0.92);
  font-size: 10px;
}

.state-panel.is-menu .result-stat em {
  color: #fbffe9;
  font-size: clamp(15px, 1.7vw, 20px);
  line-height: 1.12;
}

.state-panel.is-menu .how-to {
  grid-area: brief;
  display: none;
}

.state-panel.is-menu .how-to strong {
  color: #70f4ff;
  font-size: 12px;
  text-transform: uppercase;
}

.state-panel.is-menu .level-select {
  grid-area: levels;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.state-panel.is-menu .level-select::before {
  content: "Campaign";
  grid-column: 1 / -1;
}

.state-panel.is-menu .level-button {
  min-height: 76px;
  padding: 10px 34px 9px 11px;
}

.state-panel.is-menu .level-button strong,
.state-panel.is-menu .level-button span,
.state-panel.is-menu .level-button small {
  white-space: normal;
}

.state-panel.is-menu .level-button strong {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
}

.state-panel.is-menu .level-button strong b {
  color: #ffd45a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.state-panel.is-menu .level-button span {
  color: rgba(194, 232, 230, 0.92);
  font-size: 11px;
}

.state-panel.is-menu .level-button small {
  color: rgba(248, 255, 233, 0.9);
  font-size: 10px;
  line-height: 1.2;
}

.state-panel.is-menu .progress-panel {
  grid-area: leader;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  align-self: start;
  padding: 10px;
  border: 1px solid rgba(93, 233, 255, 0.38);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 212, 90, 0.12), transparent 42%),
    rgba(0, 14, 24, 0.72);
}

.leader-head,
.leader-row,
.leader-empty {
  display: grid;
  min-width: 0;
}

.leader-head {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}

.leader-head em {
  color: rgba(248, 255, 233, 0.78);
  font-style: normal;
  font-size: 11px;
}

.leader-row {
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(93, 233, 255, 0.24);
  border-radius: 7px;
  background: rgba(2, 20, 29, 0.62);
}

.leader-row.is-selected {
  border-color: rgba(255, 212, 90, 0.58);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 212, 90, 0.16), transparent 56%),
    rgba(2, 28, 34, 0.78);
}

.leader-row.is-perfect {
  box-shadow:
    inset 0 1px 0 rgba(248, 255, 233, 0.12),
    0 0 14px rgba(255, 212, 90, 0.09);
}

.leader-row strong {
  color: #ffd45a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.leader-row em,
.leader-row small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-row em {
  color: #fbffe9;
  font-style: normal;
  font-weight: 900;
}

.leader-row em b {
  margin-right: 7px;
  color: #70f4ff;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 10px;
  font-weight: 950;
}

.leader-row.is-perfect em::after {
  content: "Perfect";
  float: right;
  margin-left: 8px;
  color: #fff5b5;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
}

.leader-row small {
  grid-column: 2;
  color: rgba(194, 232, 230, 0.9);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
}

.leader-empty {
  padding: 12px;
  color: rgba(248, 255, 233, 0.84);
  border: 1px dashed rgba(93, 233, 255, 0.28);
  border-radius: 7px;
}

.state-panel.is-menu .settings-panel {
  grid-area: settings;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-self: start;
  padding-top: 6px;
}

.state-panel.is-menu .settings-panel::before {
  content: "Settings";
  grid-column: 1 / -1;
}

.state-panel.is-menu .settings-panel button {
  min-height: 40px;
  font-size: 12px;
}

.settings-modal {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  justify-items: end;
  align-items: stretch;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(0, 14, 24, 0.24), rgba(0, 14, 24, 0.74)),
    rgba(0, 14, 24, 0.2);
  backdrop-filter: blur(3px);
}

.settings-modal[hidden] {
  display: none;
}

.settings-drawer {
  width: min(440px, 100%);
  max-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  color: #f8ffe9;
  border: 1px solid rgba(120, 239, 246, 0.6);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 22% 0%, rgba(255, 212, 90, 0.18), transparent 34%),
    radial-gradient(circle at 100% 18%, rgba(93, 233, 255, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(10, 43, 52, 0.98), rgba(4, 18, 28, 0.99));
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(248, 255, 233, 0.16);
}

.settings-drawer-head,
.settings-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid rgba(93, 233, 255, 0.28);
}

.settings-footer {
  justify-content: flex-end;
  border-top: 1px solid rgba(93, 233, 255, 0.28);
  border-bottom: 0;
}

.settings-drawer-head span,
.settings-group h3 {
  color: #70f4ff;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.settings-drawer h2,
.settings-group h3 {
  margin: 0;
}

.settings-drawer h2 {
  color: #fbffe9;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 0.95;
}

.settings-close-button {
  width: 46px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #f8ffe9;
  border: 1px solid rgba(120, 239, 246, 0.5);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 101, 79, 0.2), transparent 54%),
    rgba(0, 14, 24, 0.54);
  cursor: pointer;
}

.settings-close-button svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
}

.settings-groups {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  overflow: auto;
}

.settings-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(93, 233, 255, 0.32);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 56%),
    rgba(0, 14, 24, 0.66);
}

.setting-toggle,
.setting-range {
  display: grid;
  min-width: 0;
  gap: 8px;
  color: rgba(248, 255, 233, 0.92);
  font-weight: 900;
}

.setting-toggle {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 36px;
}

.setting-toggle span,
.setting-range span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.setting-toggle input {
  width: 48px;
  height: 26px;
  margin: 0;
  accent-color: var(--gold);
  cursor: pointer;
}

.setting-range span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  text-transform: uppercase;
}

.setting-range output {
  color: #ffd45a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-weight: 950;
}

.setting-range input {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
}

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

.settings-save-actions button {
  min-height: 42px;
  padding: 0 9px;
  color: #f8ffe9;
  border: 1px solid rgba(255, 212, 90, 0.34);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.12), transparent 58%),
    rgba(0, 14, 24, 0.58);
  cursor: pointer;
  font-size: 12px;
  font-weight: 950;
}

.settings-footer .play-button {
  min-width: 132px;
  min-height: 46px;
  font-size: 18px;
}

@media (orientation: landscape) and (max-height: 560px) {
  .state-overlay.is-menu {
    padding: 10px 14px;
  }

  .state-panel.is-menu {
    grid-template-columns: minmax(220px, 0.88fr) minmax(260px, 1.12fr);
    gap: 8px;
    width: min(760px, calc(100% - 28px));
    padding: 16px;
  }

  .state-panel.is-menu h1 {
    gap: 10px;
    font-size: clamp(34px, 5.1vw, 50px);
  }

  .state-panel.is-menu h1::before {
    width: 52px;
    height: 38px;
  }

  .state-panel.is-menu .menu-actions {
    grid-template-columns: minmax(142px, 1.05fr) repeat(3, minmax(110px, 0.9fr));
    gap: 8px;
  }

  .state-panel.is-menu .play-button {
    min-height: 52px;
    padding: 0 12px 0 42px;
    font-size: 21px;
  }

  .state-panel.is-menu .secondary-button {
    min-height: 44px;
    padding: 0 8px 0 36px;
    gap: 6px;
    font-size: 12px;
  }

  .state-panel.is-menu .play-button::before,
  .state-panel.is-menu .secondary-button::before {
    left: 10px;
    width: 22px;
    height: 22px;
  }

  .state-panel.is-menu .best-stats,
  .state-panel.is-menu .result-stats,
  .state-panel.is-menu .settings-panel,
  .state-panel.is-menu .level-select {
    gap: 6px;
  }

  .state-panel.is-menu .best-stats span,
  .state-panel.is-menu .result-stat,
  .state-panel.is-menu .level-button,
  .state-panel.is-menu .settings-panel button {
    min-height: 0;
  }

  .state-panel.is-menu .best-stats span {
    padding: 7px 8px;
  }

  .state-panel.is-menu .level-button {
    padding: 9px 30px 8px 10px;
  }
}

@media (max-width: 760px) {
  .state-panel.is-menu {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "title"
      "meta"
      "actions"
      "best"
      "leader"
      "settings"
      "mission"
      "levels";
    width: min(440px, calc(100% - 28px));
    padding: 18px;
  }

  .state-panel.is-menu h1 {
    gap: 10px;
    font-size: clamp(36px, 10vw, 50px);
  }

  .state-panel.is-menu h1::before {
    width: 52px;
    height: 38px;
  }

  .state-panel.is-menu .menu-actions {
    grid-template-columns: minmax(0, 1fr);
  }

  .state-panel.is-menu .result-stats,
  .state-panel.is-menu .settings-panel,
  .state-panel.is-menu .best-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel.is-menu .level-select {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel.is-menu .level-button {
    min-height: 76px;
  }

  .settings-modal {
    align-items: end;
    justify-items: stretch;
    padding: 10px;
  }

  .settings-drawer {
    width: 100%;
    max-height: min(760px, calc(100dvh - 20px));
  }

  .settings-save-actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Complete game overlay states pass */
.state-panel.is-pause,
.state-panel.is-results,
.state-panel.is-gameover,
.state-panel.is-victory {
  display: grid;
  gap: 14px;
  width: min(660px, calc(100% - 48px));
  padding: clamp(22px, 3vw, 34px);
  text-align: center;
}

.state-panel.is-pause .best-stats,
.state-panel.is-pause .level-select,
.state-panel.is-pause .how-to,
.state-panel.is-pause .progress-panel,
.state-panel.is-pause .settings-panel,
.state-panel.is-results .best-stats,
.state-panel.is-results .level-select,
.state-panel.is-results .how-to,
.state-panel.is-results .progress-panel,
.state-panel.is-results .settings-panel,
.state-panel.is-results #continueBtn,
.state-panel.is-results #menuMuteBtn,
.state-panel.is-gameover .best-stats,
.state-panel.is-gameover .level-select,
.state-panel.is-gameover .how-to,
.state-panel.is-gameover .progress-panel,
.state-panel.is-gameover .settings-panel,
.state-panel.is-gameover #menuMuteBtn,
.state-panel.is-victory .best-stats,
.state-panel.is-victory .level-select,
.state-panel.is-victory .how-to,
.state-panel.is-victory .progress-panel,
.state-panel.is-victory .settings-panel,
.state-panel.is-victory #menuMuteBtn {
  display: none;
}

.state-panel.is-pause h1,
.state-panel.is-results h1,
.state-panel.is-gameover h1,
.state-panel.is-victory h1 {
  margin: 0;
  color: #fbffe9;
  font-size: clamp(44px, 6vw, 72px);
  line-height: 0.92;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.38),
    0 0 20px rgba(93, 233, 255, 0.22);
}

.state-panel.is-results h1 {
  color: #fff5b5;
}

.state-panel.is-gameover h1 {
  color: #ffb0a8;
}

.state-panel.is-victory h1 {
  color: #fff5b5;
  text-shadow:
    0 4px 0 rgba(0, 0, 0, 0.38),
    0 0 24px rgba(255, 212, 90, 0.28);
}

.state-panel.is-pause p,
.state-panel.is-results p,
.state-panel.is-gameover p,
.state-panel.is-victory p {
  max-width: 520px;
  margin: -4px auto 0;
  color: rgba(210, 242, 240, 0.92);
  font-size: clamp(14px, 2vw, 18px);
  line-height: 1.25;
}

.state-panel.is-pause .result-stats,
.state-panel.is-results .result-stats,
.state-panel.is-gameover .result-stats,
.state-panel.is-victory .result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin: 0;
}

.state-panel.is-pause .result-stat,
.state-panel.is-results .result-stat,
.state-panel.is-gameover .result-stat,
.state-panel.is-victory .result-stat {
  min-height: 78px;
  padding: 12px;
  border-color: rgba(93, 233, 255, 0.38);
  background:
    radial-gradient(circle at 20% 0%, rgba(93, 233, 255, 0.12), transparent 56%),
    rgba(0, 14, 24, 0.72);
}

.state-panel.is-pause .result-stat.is-primary,
.state-panel.is-results .result-stat.is-primary,
.state-panel.is-gameover .result-stat.is-primary,
.state-panel.is-victory .result-stat.is-primary {
  grid-column: span 2;
  border-color: rgba(255, 212, 90, 0.62);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.2), transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 52%),
    rgba(0, 14, 24, 0.82);
  box-shadow:
    0 0 20px rgba(255, 212, 90, 0.14),
    inset 0 1px 0 rgba(248, 255, 233, 0.14);
}

.result-stat.is-success {
  border-color: rgba(145, 214, 68, 0.62);
}

.result-stat.is-record {
  border-color: rgba(255, 212, 90, 0.72);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.22), transparent 62%),
    radial-gradient(circle at 100% 100%, rgba(93, 233, 255, 0.1), transparent 56%),
    rgba(0, 14, 24, 0.82);
  box-shadow:
    0 0 18px rgba(255, 212, 90, 0.16),
    inset 0 1px 0 rgba(248, 255, 233, 0.14);
}

.result-stat.is-record strong,
.result-stat.is-record em {
  color: #fff5b5;
}

.result-stat.is-warning {
  border-color: rgba(255, 212, 90, 0.64);
}

.state-panel.is-pause .result-stat strong,
.state-panel.is-results .result-stat strong,
.state-panel.is-gameover .result-stat strong,
.state-panel.is-victory .result-stat strong {
  color: rgba(187, 226, 226, 0.92);
  font-size: 11px;
}

.state-panel.is-pause .result-stat em,
.state-panel.is-results .result-stat em,
.state-panel.is-gameover .result-stat em,
.state-panel.is-victory .result-stat em {
  color: #fbffe9;
  font-size: clamp(17px, 2.3vw, 26px);
  line-height: 1.05;
  white-space: normal;
}

.state-panel.is-pause .result-stat.is-primary em,
.state-panel.is-results .result-stat.is-primary em,
.state-panel.is-gameover .result-stat.is-primary em,
.state-panel.is-victory .result-stat.is-primary em {
  color: #fff5b5;
  font-size: clamp(28px, 4vw, 44px);
}

.state-panel.is-pause .feedback-panel,
.state-panel.is-results .feedback-panel,
.state-panel.is-gameover .feedback-panel,
.state-panel.is-victory .feedback-panel {
  grid-template-columns: 86px minmax(120px, 1fr) minmax(160px, 1.35fr);
  margin: 0;
}

.state-panel.is-pause .menu-actions,
.state-panel.is-results .menu-actions,
.state-panel.is-gameover .menu-actions,
.state-panel.is-victory .menu-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  gap: 10px;
  margin: 0;
}

.state-panel.is-pause .menu-actions {
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
}

.state-panel.is-results .menu-actions {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.state-panel.is-pause .play-button,
.state-panel.is-results .play-button,
.state-panel.is-gameover .play-button,
.state-panel.is-victory .play-button,
.state-panel.is-pause .secondary-button,
.state-panel.is-results .secondary-button,
.state-panel.is-gameover .secondary-button,
.state-panel.is-victory .secondary-button {
  width: 100%;
  min-width: 0;
}

.state-panel.is-pause .play-button,
.state-panel.is-results .play-button,
.state-panel.is-gameover .play-button,
.state-panel.is-victory .play-button {
  border-color: #ffdf69;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 90, 0.28), transparent 52%),
    linear-gradient(180deg, #13848b, #073541 72%, #041c27);
}

@media (max-width: 640px) {
  .state-panel.is-pause,
  .state-panel.is-results,
  .state-panel.is-gameover,
  .state-panel.is-victory {
    width: min(360px, calc(100% - 28px));
    padding: 20px;
  }

  .state-panel.is-pause .result-stats,
  .state-panel.is-results .result-stats,
  .state-panel.is-gameover .result-stats,
  .state-panel.is-victory .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel.is-pause .menu-actions,
  .state-panel.is-results .menu-actions,
  .state-panel.is-gameover .menu-actions,
  .state-panel.is-victory .menu-actions,
  .state-panel.is-pause .feedback-panel,
  .state-panel.is-results .feedback-panel,
  .state-panel.is-gameover .feedback-panel,
  .state-panel.is-victory .feedback-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .state-panel.is-pause .result-stat.is-primary,
  .state-panel.is-results .result-stat.is-primary,
  .state-panel.is-gameover .result-stat.is-primary,
  .state-panel.is-victory .result-stat.is-primary {
    grid-column: 1 / -1;
  }

  .state-panel.is-pause h1,
  .state-panel.is-results h1,
  .state-panel.is-gameover h1,
  .state-panel.is-victory h1 {
    font-size: clamp(38px, 13vw, 58px);
  }

  .state-panel.is-pause .result-stat,
  .state-panel.is-results .result-stat,
  .state-panel.is-gameover .result-stat,
  .state-panel.is-victory .result-stat {
    min-height: 70px;
  }
}

@media (max-width: 760px) {
  .board-shell {
    overflow: visible;
  }

  .coach-tip {
    top: calc(100% + 10px);
    right: 0;
    left: 0;
    width: auto;
    min-height: 104px;
    padding: 13px 14px 14px;
  }

  .coach-tip strong {
    font-size: 22px;
  }

  .coach-tip span:nth-child(3) {
    font-size: 14px;
    line-height: 1.28;
  }
}

@media (min-width: 641px) and (max-height: 680px) {
  .game-shell {
    grid-template-rows: clamp(62px, 11vh, 84px) minmax(0, 1fr);
    padding: clamp(6px, 1vw, 10px);
    gap: 6px;
  }

  .topbar {
    grid-template-columns: minmax(150px, 0.75fr) minmax(0, 1.8fr) auto;
    gap: 6px;
  }

  .brand {
    gap: 10px;
    padding-inline: 12px;
    font-size: clamp(24px, 3.1vw, 38px);
  }

  .brand-spark {
    width: 9px;
    height: 9px;
  }

  .readouts {
    gap: 4px;
    padding: 4px;
  }

  .readouts > div {
    padding: 7px 8px 11px;
  }

  dt {
    font-size: clamp(10px, 1.05vw, 14px);
  }

  dd {
    font-size: clamp(17px, 2vw, 24px);
  }

  .readout-sub {
    margin-top: 3px;
    font-size: 9px;
  }

  .combo-meter {
    bottom: 5px;
    height: 3px;
  }

  .controls {
    gap: 6px;
    padding: 6px;
  }

  .icon-button {
    width: clamp(42px, 5vw, 54px);
  }

  .board-shell {
    width: min(100%, calc((100dvh - clamp(78px, 13vh, 104px)) * 16 / 9));
  }

  .state-overlay {
    padding: 10px;
    place-items: center;
  }

  .state-panel.is-pause,
  .state-panel.is-results,
  .state-panel.is-gameover,
  .state-panel.is-victory {
    width: min(640px, calc(100% - 20px));
    max-height: calc(100% - 8px);
    gap: 6px;
    padding: 10px;
  }

  .state-panel.is-pause h1,
  .state-panel.is-results h1,
  .state-panel.is-gameover h1,
  .state-panel.is-victory h1 {
    font-size: clamp(28px, 4vw, 38px);
  }

  .state-panel.is-pause p,
  .state-panel.is-results p,
  .state-panel.is-gameover p,
  .state-panel.is-victory p {
    margin: -2px auto 0;
    font-size: clamp(11px, 1.45vw, 14px);
    line-height: 1.2;
  }

  .state-panel.is-pause .result-stats,
  .state-panel.is-results .result-stats,
  .state-panel.is-gameover .result-stats,
  .state-panel.is-victory .result-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .state-panel.is-pause .result-stat,
  .state-panel.is-results .result-stat,
  .state-panel.is-gameover .result-stat,
  .state-panel.is-victory .result-stat {
    min-height: 42px;
    padding: 6px 8px;
  }

  .state-panel.is-pause .result-stat strong,
  .state-panel.is-results .result-stat strong,
  .state-panel.is-gameover .result-stat strong,
  .state-panel.is-victory .result-stat strong {
    font-size: 8px;
  }

  .state-panel.is-pause .result-stat em,
  .state-panel.is-results .result-stat em,
  .state-panel.is-gameover .result-stat em,
  .state-panel.is-victory .result-stat em {
    font-size: clamp(12px, 1.55vw, 16px);
  }

  .state-panel.is-pause .result-stat.is-primary em,
  .state-panel.is-results .result-stat.is-primary em,
  .state-panel.is-gameover .result-stat.is-primary em,
  .state-panel.is-victory .result-stat.is-primary em {
    font-size: clamp(20px, 2.6vw, 28px);
  }

  .state-panel.is-pause .feedback-panel,
  .state-panel.is-results .feedback-panel,
  .state-panel.is-gameover .feedback-panel,
  .state-panel.is-victory .feedback-panel {
    display: none;
  }

  .state-panel.is-pause .menu-actions,
  .state-panel.is-results .menu-actions,
  .state-panel.is-gameover .menu-actions,
  .state-panel.is-victory .menu-actions {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 6px;
  }

  .state-panel.is-pause .play-button,
  .state-panel.is-results .play-button,
  .state-panel.is-gameover .play-button,
  .state-panel.is-victory .play-button,
  .state-panel.is-pause .secondary-button,
  .state-panel.is-results .secondary-button,
  .state-panel.is-gameover .secondary-button,
  .state-panel.is-victory .secondary-button {
    min-height: 38px;
    padding: 0 10px 0 40px;
    font-size: 13px;
  }

  .state-panel.is-pause .play-button::before,
  .state-panel.is-results .play-button::before,
  .state-panel.is-gameover .play-button::before,
  .state-panel.is-victory .play-button::before,
  .state-panel.is-pause .secondary-button::before,
  .state-panel.is-results .secondary-button::before,
  .state-panel.is-gameover .secondary-button::before,
  .state-panel.is-victory .secondary-button::before {
    left: 10px;
    width: 22px;
    height: 22px;
  }
}

@media (min-width: 641px) and (max-height: 520px) {
  .state-panel.is-pause .result-stats,
  .state-panel.is-results .result-stats,
  .state-panel.is-gameover .result-stats,
  .state-panel.is-victory .result-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .state-panel.is-pause .result-stat.is-primary,
  .state-panel.is-results .result-stat.is-primary,
  .state-panel.is-gameover .result-stat.is-primary,
  .state-panel.is-victory .result-stat.is-primary {
    grid-column: 1 / -1;
  }
}
