@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Mono:wght@400;700&display=swap");

:root {
  --page-bg: #050611;
  --panel-bg: rgba(8, 11, 26, 0.92);
  --panel-line: rgba(88, 106, 166, 0.55);
  --ink: #f5f7ff;
  --muted: #8c91b2;
  --cyan: #31e7ff;
  --pink: #ff3ca6;
  --yellow: #ffe066;
  --green: #5dffb2;
  --board-w: 320px;
  --board-h: 640px;
  --shadow: 0 0 32px rgba(49, 231, 255, 0.14);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Space Mono", "Courier New", monospace;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  z-index: 20;
  opacity: 0.18;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.035) 4px);
  mix-blend-mode: screen;
}

body::after {
  z-index: 0;
  opacity: 0.72;
  background:
    radial-gradient(circle at 35% 48%, rgba(49, 231, 255, 0.12), transparent 28%),
    radial-gradient(circle at 68% 55%, rgba(255, 60, 166, 0.1), transparent 30%),
    linear-gradient(180deg, #070817 0%, var(--page-bg) 65%);
  animation: ambient-bloom 18s ease-in-out infinite alternate;
}

@keyframes ambient-bloom {
  from { opacity: 0.56; transform: scale(1); }
  to { opacity: 0.78; transform: scale(1.06); }
}

#ui {
  position: fixed;
  z-index: 1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

#ui .button,
#ui .overlay {
  pointer-events: auto;
}

.game-shell {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  width: 100%;
  max-width: 920px;
  min-height: 100%;
  margin: 0 auto;
  padding: 24px;
}

.game-header {
  width: 100%;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  color: var(--pink);
  font-size: 29px;
  line-height: 1;
  text-shadow: 3px 3px 0 #7f195b;
}

.brand-name,
.title {
  font-family: "Press Start 2P", monospace;
  letter-spacing: 0.08em;
}

.brand-name {
  color: var(--cyan);
  font-size: 18px;
  text-shadow: 3px 3px 0 var(--pink), 0 0 18px rgba(49, 231, 255, 0.4);
}

.game-layout {
  display: grid;
  grid-template-columns: 190px minmax(240px, 320px) 190px;
  grid-template-areas:
    "hud board preview"
    "hud board utility";
  gap: 18px 24px;
  align-items: start;
  justify-content: center;
}

.hud {
  grid-area: hud;
  display: grid;
  gap: 10px;
}

.stat,
.preview-card {
  border: 1px solid var(--panel-line);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(14, 18, 42, 0.96), var(--panel-bg));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.stat {
  min-height: 86px;
  padding: 15px 16px;
}

.stat-value {
  display: block;
  color: var(--yellow);
  font-size: 24px;
  line-height: 1.2;
}

.stat-label,
.preview-label,
.eyebrow,
.board-frame-header,
.board-frame-footer {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.stat-label { margin-top: 7px; }

.stat.extra {
  border-color: rgba(49, 231, 255, 0.4);
}

.stat.extra .stat-value { color: var(--cyan); }

.board-frame {
  grid-area: board;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: 12px;
  border: 1px solid rgba(49, 231, 255, 0.75);
  border-radius: 18px;
  background: rgba(4, 7, 18, 0.96);
  box-shadow:
    8px 8px 0 rgba(255, 60, 166, 0.28),
    0 0 42px rgba(49, 231, 255, 0.16),
    inset 0 0 28px rgba(49, 231, 255, 0.04);
}

.board-frame-header,
.board-frame-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  color: var(--cyan);
}

.board-frame-header { padding: 1px 1px 10px; }
.board-frame-footer { padding: 10px 1px 1px; color: var(--muted); }

.board-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--green);
}

.board-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

#game {
  display: block;
  width: min(var(--board-w), calc((100vh - 180px) / 2));
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 2;
  border-radius: 8px;
  image-rendering: pixelated;
}

.score-burst {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 48%;
  min-width: 170px;
  padding: 10px 14px;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--green);
  background: rgba(5, 7, 20, 0.9);
  box-shadow: 0 0 28px currentColor;
  font: 700 13px "Press Start 2P", monospace;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.78);
}

.score-burst[data-lines="2"] { color: var(--cyan); }
.score-burst[data-lines="3"] { color: var(--yellow); }
.score-burst[data-lines="4"] {
  color: #ffffff;
  text-shadow:
    2px 2px 0 var(--pink),
    -2px -2px 0 var(--cyan);
}

.score-burst.is-visible {
  animation: score-burst 700ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes score-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px) scale(0.78);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.08);
  }
  68% {
    opacity: 1;
    transform: translate(-50%, -18px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -42px) scale(1.14);
  }
}

.preview-rail {
  grid-area: preview;
  display: grid;
  gap: 12px;
}

.preview-card {
  padding: 12px;
}

.preview-label {
  margin-bottom: 9px;
  color: var(--cyan);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  width: 74px;
  aspect-ratio: 1;
  margin: 0 auto;
}

.preview-grid + .preview-grid {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(88, 106, 166, 0.18);
}

.preview-cell {
  display: block;
  min-width: 0;
  min-height: 0;
  border-radius: 3px;
}

.utility {
  grid-area: utility;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-self: end;
}

.button {
  min-height: 44px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(15, 18, 42, 0.96);
  font: 700 10px "Space Mono", monospace;
  cursor: pointer;
  touch-action: manipulation;
}

.button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.button:hover,
.button:focus-visible {
  color: #080a18;
  background: var(--cyan);
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.button:active,
.button[aria-pressed="true"] {
  color: #080a18;
  background: var(--yellow);
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--pink);
}

.utility-button { padding: 0 10px; }

.touch-controls {
  display: none;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  gap: 8px;
  width: min(92vw, 380px);
  margin: 14px auto 0;
  touch-action: none;
}

.control-button { min-height: 48px; font-size: 16px; }
.control-wide { grid-column: span 2; font-size: 10px; }

.overlay {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  background: rgba(5, 6, 17, 0.64);
  backdrop-filter: blur(4px);
}

.panel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(92vw, 560px);
  padding: 38px 44px 28px;
  border: 1px solid rgba(49, 231, 255, 0.55);
  border-radius: 20px;
  background:
    linear-gradient(150deg, rgba(18, 21, 48, 0.96), rgba(6, 8, 23, 0.98));
  box-shadow:
    9px 9px 0 rgba(255, 60, 166, 0.3),
    0 0 46px rgba(49, 231, 255, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: panel-enter 240ms ease-out both;
}

@keyframes panel-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow { margin-bottom: 18px; color: var(--pink); }
.title {
  max-width: 100%;
  margin: 0 0 14px;
  color: var(--cyan);
  font-size: clamp(32px, 5.2vw, 72px);
  line-height: 1.2;
  text-shadow:
    4px 4px 0 var(--pink),
    -1px -1px 0 rgba(49, 231, 255, 0.5),
    0 0 24px rgba(49, 231, 255, 0.24);
}

.pause .title,
.game-over .title {
  font-size: clamp(28px, 4vw, 46px);
}

.panel-subtitle {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.panel-copy {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.best-metric {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  gap: 12px;
  margin-top: 18px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 224, 102, 0.25);
  border-radius: 999px;
  background: rgba(255, 224, 102, 0.05);
}

.best-label {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
}

.best-value {
  color: var(--yellow);
  font-size: 18px;
}

.best-level {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 700;
}

.mode-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 440px);
  margin-top: 18px;
}

.mode-list:empty { display: none; }

.mode-button {
  display: grid;
  gap: 4px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(5, 7, 20, 0.6);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mode-button:hover,
.mode-button:focus-visible { border-color: var(--cyan); }

.mode-button[aria-pressed="true"] {
  border-color: var(--yellow);
  background: rgba(255, 224, 102, 0.08);
  box-shadow: inset 0 0 0 1px var(--yellow);
}

.mode-name {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.mode-desc,
.mode-best {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
}

.mode-best { color: var(--yellow); }

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.panel-actions .button { padding: 0 22px; }
.primary-button {
  min-width: 180px;
  color: #080a18;
  border-color: var(--cyan);
  background: var(--cyan);
  box-shadow: 4px 4px 0 var(--pink);
}
.primary-button:hover,
.primary-button:focus-visible { background: var(--yellow); }
.secondary-button { padding: 0 18px; }
.hint {
  max-width: min(80vw, 440px);
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.8;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  width: min(100%, 420px);
  margin-top: 20px;
}

.result-value {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  color: var(--yellow);
  background: rgba(5, 7, 20, 0.6);
  font-weight: 700;
}

.result-best { margin-top: 10px; color: var(--cyan); }

.new-record {
  margin: 14px 0 0;
  color: var(--pink);
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-shadow: 0 0 14px rgba(255, 60, 166, 0.5);
}

@media (max-width: 760px) {
  .game-shell {
    display: grid;
    grid-template-rows: auto 1fr auto;
    place-content: stretch;
    padding: 12px;
    overflow: hidden;
  }
  .game-header { margin-bottom: 8px; }
  .brand-name { font-size: 13px; }
  .brand-mark { font-size: 22px; }
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "hud"
      "board"
      "preview"
      "utility";
    gap: 8px;
    align-content: center;
    width: min(100%, 360px);
    margin: 0 auto;
  }
  .hud {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 6px;
  }
  .stat { min-height: 48px; padding: 7px 9px; }
  .stat-value { font-size: 14px; }
  .stat-label { margin-top: 3px; font-size: 7px; }
  .board-frame { justify-self: center; padding: 8px; border-radius: 14px; }
  .board-frame-header { padding-bottom: 6px; }
  .board-frame-footer { padding-top: 6px; }
  #game { width: min(74vw, calc((100vh - 400px) / 2), 280px); }
  .preview-rail {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .preview-card { padding: 7px; }
  .preview-card:first-child .preview-grid:nth-of-type(n + 2) { display: none; }
  .preview-grid { width: 48px; }
  .preview-label { margin-bottom: 4px; font-size: 7px; }
  .utility { grid-template-columns: 1fr 1fr; }
  .utility-button { min-height: 44px; font-size: 8px; }
  .touch-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(40px, 1fr));
    gap: 6px;
    width: min(94vw, 380px);
    margin: 8px auto 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .control-button { min-height: 44px; font-size: 13px; }
  .control-wide { grid-column: span 2; min-height: 44px; }
  .panel-card { width: min(92vw, 520px); padding: 30px 22px 24px; }
  .mode-list { gap: 6px; margin-top: 12px; }
  .mode-button { padding: 8px 10px; }
  .title { font-size: clamp(30px, 11vw, 52px); }
}

@media (max-height: 600px) and (orientation: landscape) {
  .game-shell {
    display: grid;
    grid-template-rows: 1fr;
    padding: 10px 14px;
  }
  .game-header { position: absolute; top: 10px; left: 14px; width: auto; }
  .brand-name { font-size: 11px; }
  .brand-mark { font-size: 19px; }
  .game-layout {
    grid-template-columns: minmax(130px, 180px) minmax(150px, 183px) minmax(130px, 180px);
    grid-template-areas:
      "hud board preview"
      "utility board preview";
    gap: 8px 12px;
    width: auto;
  }
  .hud { grid-template-columns: 1fr; align-self: start; margin-top: 34px; }
  .stat { min-height: 40px; padding: 4px 8px; }
  .stat-value { font-size: 16px; }
  .stat-label { margin-top: 2px; font-size: 7px; }
  #game { width: min(46vh, 183px); }
  .board-frame-header,
  .board-frame-footer { font-size: 7px; }
  .preview-rail { grid-template-columns: 1fr; align-self: center; }
  .preview-card { min-height: 72px; padding: 6px; }
  .preview-card:first-child .preview-grid:nth-of-type(n + 2) { display: none; }
  .preview-grid { width: 48px; }
  .utility {
    position: fixed;
    left: 14px;
    top: 244px;
    width: 180px;
  }
  .touch-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(40px, 1fr));
    gap: 6px;
    position: fixed;
    left: 12px;
    bottom: 6px;
    width: 250px;
    margin: 0;
    opacity: 0.96;
  }
  .control-button,
  .control-wide { min-height: 44px; }
  .panel-card { max-height: calc(100vh - 20px); padding: 20px 28px 16px; }
  .title { font-size: clamp(26px, 7vw, 44px); }
  .panel-actions { margin-top: 14px; }
  .mode-list { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 10px; }
  .mode-desc { display: none; }
  .panel.menu .panel-copy { display: none; }
  .panel.game-over .title { font-size: 24px; white-space: nowrap; }
  .result-grid { margin-top: 10px; gap: 8px; }
  .result-value { padding: 8px 10px; }
  .result-best { margin-top: 8px; }
  .new-record { margin-top: 8px; }
  .hint { margin-top: 12px; }
}

@media (max-width: 360px) and (max-height: 650px) {
  .panel.menu .panel-copy,
  .mode-desc { display: none; }
  .game-shell { padding: 8px; }
  .game-header { margin-bottom: 4px; }
  .game-layout {
    grid-template-columns: 68px minmax(120px, 160px) 68px;
    grid-template-areas:
      "hud hud hud"
      "preview board utility";
    gap: 6px;
  }
  .hud { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .stat { min-height: 40px; padding: 4px 6px; }
  #game { width: min(50vw, calc((100vh - 210px) / 2)); }
  .board-frame-header { padding-bottom: 4px; font-size: 6px; }
  .board-frame-footer { display: none; }
  .preview-rail { grid-template-columns: 1fr; align-self: center; }
  .preview-card { padding: 5px; }
  .preview-grid { width: 40px; }
  .utility { grid-template-columns: 1fr; align-self: end; }
  .utility-button { min-height: 44px; padding: 0 4px; font-size: 7px; }
  .touch-controls { margin-top: 5px; }
  .control-button,
  .control-wide { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
  .score-burst.is-visible {
    opacity: 1;
    transform: translate(-50%, -12px);
  }
}

@media (hover: none) {
  .button:hover { color: var(--ink); background: rgba(15, 18, 42, 0.96); outline: none; }
  .button:active { color: #080a18; background: var(--yellow); outline: 2px solid var(--cyan); outline-offset: 2px; }
}

/* ---------------------------------------------------------------------------
   Settings screen (js/settings-ui.js) — one column, scroll inside the card,
   fixed title/footer, sticky group titles, no animation.
   --------------------------------------------------------------------------- */

.settings-card {
  align-items: stretch;
  width: min(94vw, 420px);
  max-height: min(92vh, 720px);
  max-height: min(92dvh, 720px);
  padding: 0;
  overflow: hidden;
  text-align: left;
  animation: none;
}

.settings-title {
  flex: 0 0 auto;
  margin: 0;
  padding: 16px 18px 12px;
  color: var(--cyan);
  font-family: "Press Start 2P", monospace;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-align: center;
  text-shadow: 3px 3px 0 var(--pink);
}

.settings-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 18px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.settings-section { padding: 4px 0 2px; }

.settings-section-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 8px 0 6px;
  color: var(--pink);
  background: #080b1a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(96px, 30%) minmax(0, 1fr);
  align-items: center;
  gap: 6px 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(88, 106, 166, 0.18);
}

.settings-row-label {
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.settings-help {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.settings-slider {
  flex: 1 1 auto;
  min-width: 0;
  accent-color: var(--cyan);
}

.settings-value {
  flex: 0 0 auto;
  min-width: 3.6em;
  color: var(--yellow);
  font-size: 10px;
  text-align: right;
  white-space: nowrap;
}

.settings-choice,
.settings-control-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-control-keys {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 220px);
}

.settings-choice-button,
.settings-key {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  font-size: 9px;
}

.settings-key {
  min-width: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.settings-key.is-capturing,
.settings-key.is-capturing:hover,
.settings-key.is-capturing:focus-visible,
.settings-key.is-capturing:active {
  color: var(--yellow);
  background: rgba(15, 18, 42, 0.96);
  border-color: var(--yellow);
  outline-color: var(--yellow);
  box-shadow: inset 0 0 0 1px var(--yellow);
  transform: none;
}

.settings-key.is-conflict,
.settings-key.is-conflict:hover,
.settings-key.is-conflict:focus-visible,
.settings-key.is-conflict:active {
  color: var(--pink);
  background: rgba(15, 18, 42, 0.96);
  border-color: var(--pink);
  outline-color: var(--pink);
  box-shadow: inset 0 0 0 1px var(--pink);
  transform: none;
}

.settings-touch-note {
  display: none;
  margin: 10px 0 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

.settings-footer {
  flex: 0 0 auto;
  padding: 8px 14px 12px;
  border-top: 1px solid var(--panel-line);
  background: linear-gradient(180deg, rgba(6, 8, 23, 0.6), rgba(6, 8, 23, 0.98));
}

.settings-status {
  min-height: 0;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.4;
  text-align: center;
}

.settings-status.is-ok { color: var(--green); }
.settings-status.is-capture { color: var(--yellow); }
.settings-status.is-error { color: var(--pink); }

.settings-footer-actions {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;
}

.settings-footer-actions .button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  font-size: 9px;
}

.settings-footer-actions .primary-button {
  flex: 1 1 0;
  min-width: 0;
  box-shadow: 3px 3px 0 var(--pink);
}

@media (max-width: 360px), (max-height: 600px) and (orientation: landscape) {
  .settings-row { grid-template-columns: 1fr; }
  .settings-row-label { font-size: 9px; }
  .settings-slider { width: 100%; }
  .settings-control { width: 100%; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .settings-card { width: min(96vw, 720px); }
}

@media (hover: none) and (pointer: coarse) {
  .settings-controls { display: none; }
  .settings-touch-note { display: block; }
}

/* Dimmed DELAY TIME while LANDING DELAY is OFF (the slider is disabled). */
.settings-row:has(.settings-slider:disabled) { opacity: 0.45; }

/* ---------------------------------------------------------------------------
   Scoring callout card + HUD chain chips (scoring-daily, T-009).
   Ported from the approved mockups; every rule is scoped to a card/chain-only
   selector so screens without a callout or an active chain stay pixel-identical.
   --------------------------------------------------------------------------- */
.score-burst.is-card {
  top: 46%;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: max-content;
  min-width: 0;
  max-width: min(calc(100vw - 24px), 300px);
  padding: 10px 16px 11px;
  border-radius: 16px;
  background: rgba(5, 7, 20, 0.92);
}

.score-burst[data-kind="tspin"] { color: var(--pink); }
.score-burst[data-kind="tspin"] .callout-name {
  color: #ffffff;
  text-shadow: 2px 2px 0 #7f195b;
}
.score-burst[data-kind="pc"] {
  color: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 28px var(--pink), 0 0 6px var(--yellow);
}

.callout-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.tag {
  padding: 3px 6px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font: 700 8px "Press Start 2P", monospace;
  letter-spacing: 0.04em;
  text-shadow: none;
}
.tag-b2b { color: var(--yellow); }
.tag-combo { color: var(--green); }

.callout-pc {
  color: var(--yellow);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-shadow: 2px 2px 0 var(--pink);
}
.callout-name { overflow-wrap: anywhere; }
.callout-pts {
  color: var(--yellow);
  font: 700 15px "Space Mono", monospace;
  text-shadow: none;
}
.score-burst:not(.is-card) .callout-pts {
  font: inherit;
  color: inherit;
  text-shadow: inherit;
}

.score-burst.is-card.is-visible { animation-duration: 1200ms; }
.score-burst.is-static.is-visible {
  animation: none;
  opacity: 1;
  transform: translate(-50%, -12px);
}

@media (max-width: 360px) {
  .score-burst[data-kind] { font-size: 10px; }
  .score-burst[data-kind]:not(.is-card) { min-width: 0; }
  .score-burst.is-card { padding: 8px 10px 9px; gap: 5px; }
  .tag { font-size: 7px; padding: 2px 5px; }
  .callout-pc { font-size: 8px; }
  .callout-pts { font-size: 12px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .score-burst[data-kind] { font-size: 10px; }
  .score-burst[data-kind]:not(.is-card) { min-width: 0; }
  .score-burst.is-card { padding: 7px 10px 8px; gap: 4px; }
  .tag { font-size: 7px; padding: 2px 5px; }
  .callout-pc { font-size: 8px; }
  .callout-pts { font-size: 12px; }
}

.chain { display: inline-flex; gap: 6px; }
/* Live region kept in the accessibility tree while no chain is active (T-021):
   never `display:none`, only taken out of the layout and clipped so it is
   invisible and occupies no space — the header looks exactly as before. */
.chain-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.chip {
  line-height: 1;
  padding: 1px 7px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.chip-combo { color: var(--green); box-shadow: 0 0 10px rgba(93, 255, 178, 0.25); }
.chip-b2b { color: var(--yellow); box-shadow: 0 0 10px rgba(255, 224, 102, 0.25); }

@media (max-height: 600px) and (orientation: landscape) {
  .chip { font-size: 7px; padding: 1px 4px; letter-spacing: 0.04em; }
}

@media (max-width: 360px) and (max-height: 650px) {
  .chip { font-size: 7px; padding: 1px 5px; letter-spacing: 0.02em; }
  .board-frame.has-chain .frame-label { display: none; }
  .board-frame.has-chain .board-frame-header { justify-content: center; }
}

/* ---------------------------------------------------------------------------
   DAILY menu entry (scoring-daily, T-018).
   Ported from the approved mockup (`mockups/mockup.css` → "Menu: DAILY entry",
   spec §5.9). Every selector is scoped to the mode list, which only the menu
   mounts, so no other screen (gameplay/pause/result/settings) is affected.
   --------------------------------------------------------------------------- */
.mode-daily {
  grid-column: 1 / -1;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name date"
    "desc best";
  column-gap: 12px;
  border-color: rgba(255, 60, 166, 0.7);
  background: linear-gradient(120deg, rgba(255, 60, 166, 0.09), rgba(5, 7, 20, 0.6) 60%);
}
.mode-daily .mode-name { grid-area: name; color: var(--pink); }
.mode-daily .mode-date {
  grid-area: date;
  color: var(--ink);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: right;
}
.mode-daily .mode-desc { grid-area: desc; }
.mode-daily .mode-best { grid-area: best; text-align: right; }
.mode-daily .mode-best.is-none { color: var(--muted); }
.mode-daily[aria-pressed="true"] {
  border-color: var(--yellow);
  background: rgba(255, 224, 102, 0.08);
  box-shadow: inset 0 0 0 1px var(--yellow);
}
.mode-date { display: block; }
.mode-button:not(.mode-daily) .mode-date { display: none; }

@media (max-height: 600px) and (orientation: landscape) {
  .mode-list { grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
  .mode-daily {
    grid-column: auto;
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "date"
      "best";
  }
  .mode-daily .mode-date { text-align: left; font-size: 9px; }
  .mode-daily .mode-best { text-align: left; }
  .mode-name { letter-spacing: 0.06em; font-size: 10px; }
  .mode-best { font-size: 8px; }
}

@media (max-width: 360px) and (max-height: 650px) {
  .mode-daily {
    grid-template-areas:
      "name date"
      "best best";
  }
  .mode-daily .mode-best { text-align: left; }
  .hint { display: none; }
}

/* ---------------------------------------------------------------------------
   DAILY in-game frame date + Daily result card (scoring-daily, T-019).
   Ported from the approved mockups (`mockups/mockup.css` → `.frame-date` and
   "Daily result", spec §5.9). Every selector is scoped to `.frame-date` or
   `.daily-result`, so other modes' headers/results stay pixel-identical.
   The mockup's unscoped `.board-frame-header { font-size: 7px }` 320 rule is
   intentionally omitted (R-4): production keeps its own 6px header size.
   --------------------------------------------------------------------------- */
.frame-date { display: none; }

@media (max-width: 760px) {
  .frame-date { display: inline; }
}

@media (max-width: 360px) and (max-height: 650px) {
  .frame-date { display: inline; }
}

.daily-result .result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 360px) and (max-height: 650px) {
  .daily-result .panel-card { padding: 22px 16px 18px; }
  .daily-result .eyebrow { margin-bottom: 10px; }
  .daily-result .title { font-size: 24px; margin-bottom: 10px; }
  .daily-result .panel-subtitle { font-size: 10px; letter-spacing: 0.08em; }
  .daily-result .panel-copy { display: none; }
  .daily-result .result-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
  }
  .daily-result .result-value { padding: 8px 4px; font-size: 11px; }
  .daily-result .result-best { font-size: 11px; }
  .daily-result .new-record { font-size: 10px; margin-top: 10px; }
  .daily-result .panel-actions { margin-top: 14px; gap: 8px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .daily-result .panel-copy { display: none; }
  .daily-result .title { white-space: nowrap; }
}
