:root {
  color-scheme: light;
  --hall: #e9e5da;
  --paper: #fffdf4;
  --metal: #f4f1e8;
  --ink: #172131;
  --ink-soft: #344154;
  --vermilion: #cf4024;
  --vermilion-dark: #9f2d1c;
  --cobalt: #235493;
  --cobalt-dark: #16375f;
  --mustard: #edbd42;
  --mustard-light: #ffe497;
  --screen: #101923;
  --line: #172131;
  --white: #ffffff;
  --shadow: #9d988c;
  --focus: #ffd454;
  --header-height: 64px;
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--hall);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--hall);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input {
  touch-action: manipulation;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  min-height: 44px;
  padding: 11px 16px;
  border: 3px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100%, 1160px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px clamp(12px, 2.4vw, 28px) 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  min-height: var(--header-height);
  margin-bottom: 12px;
  border-bottom: 3px solid var(--line);
}

.back-link {
  grid-column: 1;
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 4px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
}

.back-link > span:first-child {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--shadow);
  font-size: 1.2rem;
}

.title-lockup {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 10px;
  min-width: 0;
  text-align: left;
}

.cabinet-token {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border: 3px solid var(--line);
  background: var(--vermilion);
  color: var(--white);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: Bahnschrift, "Arial Black", sans-serif;
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.title-lockup h1,
.title-lockup p {
  margin: 0;
}

.title-lockup h1 {
  font-family: Bahnschrift, "Arial Black", "Noto Sans TC", sans-serif;
  font-size: clamp(1.16rem, 2.4vw, 1.65rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

.title-lockup p {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
}

.utility-button {
  grid-column: 3;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 88px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--shadow);
  font-size: 0.88rem;
  font-weight: 850;
}

.utility-button:active,
.back-link:active > span:first-child {
  box-shadow: 1px 1px 0 var(--shadow);
  transform: translate(2px, 2px);
}

.utility-icon {
  font-size: 1.1rem;
}

.arcade-layout {
  display: grid;
  grid-template-columns: minmax(340px, 500px) minmax(300px, 380px);
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vw, 52px);
  min-width: 0;
}

.cabinet {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto;
  width: min(100%, 500px);
  min-width: 0;
  margin-inline: auto;
  border: 4px solid var(--line);
  background: var(--vermilion);
  box-shadow: 8px 8px 0 var(--ink);
  transform-origin: 50% 85%;
}

.cabinet::before,
.cabinet::after {
  position: absolute;
  z-index: -1;
  top: 9%;
  bottom: 7%;
  width: 12px;
  border: 3px solid var(--line);
  background: var(--metal);
  content: "";
}

.cabinet::before {
  left: -15px;
}

.cabinet::after {
  right: -15px;
}

.cabinet-cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 5px 12px;
  border-bottom: 3px solid var(--line);
  background: var(--metal);
  color: var(--ink);
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.marquee {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 86px;
  padding: 8px 16px 10px;
  border-bottom: 4px solid var(--line);
  background: var(--mustard);
  color: var(--ink);
  font-family: Bahnschrift, "Arial Black", sans-serif;
  font-size: clamp(2rem, 5.2vw, 3.45rem);
  font-weight: 950;
  letter-spacing: -0.055em;
  line-height: 0.85;
  text-transform: uppercase;
}

.marquee-break {
  justify-self: end;
}

.marquee-out {
  justify-self: start;
  color: var(--cobalt);
}

.marquee-slash {
  margin-inline: 0.09em;
  color: var(--vermilion);
  font-weight: 500;
}

.monitor-bezel {
  position: relative;
  display: flex;
  min-height: 0;
  align-items: stretch;
  justify-content: center;
  padding: 18px clamp(18px, 5.5%, 28px) 20px;
  border-bottom: 4px solid var(--line);
  background: var(--ink);
}

.playfield-shell {
  position: relative;
  width: min(100%, 410px);
  aspect-ratio: 720 / 920;
  min-width: 0;
  overflow: hidden;
  border: 4px solid #080d13;
  background: var(--screen);
  box-shadow:
    0 0 0 3px #55606d,
    0 0 0 6px #080d13;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--screen);
  cursor: crosshair;
  outline: none;
  touch-action: none;
}

#game-canvas:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: -7px;
  box-shadow: inset 0 0 0 10px var(--focus);
}

.screen-rivets span {
  position: absolute;
  z-index: 2;
  width: 7px;
  height: 7px;
  border: 1px solid #070a0f;
  border-radius: 50%;
  background: #8f99a4;
}

.screen-rivets span:nth-child(1) {
  top: 7px;
  left: 8px;
}

.screen-rivets span:nth-child(2) {
  top: 7px;
  right: 8px;
}

.screen-rivets span:nth-child(3) {
  bottom: 7px;
  left: 8px;
}

.screen-rivets span:nth-child(4) {
  right: 8px;
  bottom: 7px;
}

.game-panel {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  width: min(82%, 300px);
  padding: clamp(18px, 5vw, 30px) clamp(16px, 4vw, 26px);
  border: 4px solid var(--paper);
  background: var(--mustard-light);
  color: var(--ink);
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.78);
  text-align: center;
  transform: translate(-50%, -50%);
  animation: panel-arrive 220ms ease-out both;
}

.game-panel h2,
.game-panel p {
  margin: 0;
}

.game-panel h2 {
  margin-top: 14px;
  font-family: Bahnschrift, "Arial Black", "Noto Sans TC", sans-serif;
  font-size: clamp(1.45rem, 4.5vw, 2rem);
  font-weight: 950;
  line-height: 1;
}

.game-panel p {
  margin-top: 12px;
  font-size: clamp(0.82rem, 2.3vw, 0.96rem);
  font-weight: 650;
  line-height: 1.55;
}

.game-panel small {
  display: block;
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 750;
}

.result-panel strong {
  margin-left: 5px;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 1.2em;
  font-variant-numeric: tabular-nums;
}

.panel-stamp {
  display: inline-block;
  padding: 3px 7px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  transform: rotate(-2deg);
}

.panel-stamp--red {
  background: var(--vermilion);
  color: var(--white);
}

.panel-stamp--blue {
  background: var(--cobalt);
  color: var(--white);
}

.primary-action {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  padding: 10px 16px;
  border: 3px solid var(--line);
  background: var(--vermilion);
  color: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 900;
}

.primary-action:hover {
  background: var(--vermilion-dark);
}

.primary-action:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(3px, 3px);
}

.event-label {
  position: absolute;
  z-index: 4;
  top: 44%;
  left: 50%;
  max-width: 85%;
  padding: 8px 14px;
  border: 3px solid var(--white);
  background: var(--vermilion);
  color: var(--white);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.78);
  font-family: Bahnschrift, "Arial Black", "Noto Sans TC", sans-serif;
  font-size: clamp(0.82rem, 3vw, 1.15rem);
  font-weight: 950;
  letter-spacing: 0.04em;
  text-align: center;
  transform: translate(-50%, -50%);
  animation: event-pop 480ms ease-out both;
}

.cabinet-kickplate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 8px 14px;
  background: var(--metal);
  color: var(--ink-soft);
}

.coin-door {
  position: relative;
  width: 26px;
  height: 32px;
  border: 3px solid var(--line);
  background: var(--ink);
}

.coin-door::after {
  position: absolute;
  top: 5px;
  left: 50%;
  width: 9px;
  height: 3px;
  background: var(--mustard);
  content: "";
  transform: translateX(-50%);
}

.service-mark {
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.59rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.control-deck {
  position: relative;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  border: 4px solid var(--line);
  background: var(--cobalt);
  color: var(--white);
  box-shadow: 8px 8px 0 var(--ink);
}

.control-deck::before {
  display: block;
  height: 12px;
  border-bottom: 3px solid var(--line);
  background: var(--mustard);
  content: "";
}

.run-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 10px 16px;
  border-bottom: 3px solid var(--line);
  background: var(--cobalt-dark);
}

.run-strip > div {
  display: grid;
  gap: 3px;
}

.run-label {
  color: #cbdcf4;
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.62rem;
  font-weight: 850;
  letter-spacing: 0.14em;
}

#run-status {
  font-size: 1rem;
  line-height: 1.1;
}

.status-lamp {
  width: 18px;
  height: 18px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--mustard);
  box-shadow: 0 0 0 3px #fbdb80;
}

[data-phase="playing"] .status-lamp {
  background: #83c76e;
  box-shadow: 0 0 0 3px #d3efca;
  animation: status-pulse 1.2s steps(2, end) infinite;
}

[data-phase="paused"] .status-lamp {
  background: var(--mustard);
  box-shadow: 0 0 0 3px #fbdb80;
}

[data-phase="gameover"] .status-lamp,
[data-phase="game-over"] .status-lamp {
  background: var(--vermilion);
  box-shadow: 0 0 0 3px #ffb6a6;
}

.score-reels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 3px solid var(--line);
}

.score-reel {
  min-width: 0;
  padding: 9px 10px 8px;
  border: 3px solid var(--line);
  background: var(--mustard-light);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.score-reel span {
  display: block;
  color: var(--ink-soft);
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.score-reel strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: clamp(1.14rem, 3vw, 1.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-overflow: ellipsis;
}

.control-copy {
  padding: 16px 18px 12px;
}

.control-copy h2,
.control-copy p {
  margin: 0;
}

.control-copy h2 {
  font-family: Bahnschrift, "Arial Black", "Noto Sans TC", sans-serif;
  font-size: 1.28rem;
  font-weight: 900;
}

.control-copy p {
  margin-top: 8px;
  color: #edf4ff;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.45;
}

.control-copy .key-hint {
  color: #cbdcf4;
  font-family: "Roboto Mono", Consolas, monospace;
  font-size: 0.71rem;
}

.button-bank {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 4px 16px 16px;
}

.deck-button {
  min-width: 0;
  min-height: 48px;
  padding: 9px 8px;
  border: 3px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
}

.deck-button--launch {
  grid-row: span 2;
  min-height: 105px;
  border-radius: 50%;
  background: var(--vermilion);
  color: var(--white);
}

.deck-button--quiet {
  background: #dce7f5;
}

.deck-button:hover {
  background: var(--mustard-light);
  color: var(--ink);
}

.deck-button:active {
  box-shadow: 1px 1px 0 var(--ink);
  transform: translate(3px, 3px);
}

.cabinet-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px 14px;
  padding: 10px 12px;
  border: 2px solid #bed2ed;
  color: #edf4ff;
}

.cabinet-note > span {
  color: var(--mustard);
  font-size: 0.72rem;
}

.cabinet-note p {
  margin: 0;
  font-size: 0.73rem;
  font-weight: 700;
  line-height: 1.35;
}

.service-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 14px;
  border-top: 3px solid var(--line);
  background: var(--metal);
  color: var(--ink);
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.11em;
}

.settings-dialog {
  width: min(calc(100% - 28px), 430px);
  max-height: min(680px, calc(100dvh - 28px));
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 4px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
}

.settings-dialog::backdrop {
  background: rgba(23, 33, 49, 0.76);
}

.settings-dialog form {
  padding: 20px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -20px -20px 20px;
  padding: 16px 18px;
  border-bottom: 4px solid var(--line);
  background: var(--mustard);
}

.dialog-header h2 {
  margin: 3px 0 0;
  font-family: Bahnschrift, "Arial Black", "Noto Sans TC", sans-serif;
  font-size: 1.38rem;
}

.dialog-kicker {
  font-family: "Arial Narrow", Bahnschrift, sans-serif;
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.dialog-close {
  display: grid;
  width: 44px;
  min-width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 3px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  font-weight: 850;
}

#language-select {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 16px;
  font-weight: 650;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  margin-top: 18px;
  padding: 12px 0;
  border-top: 2px solid #cbc6b9;
  border-bottom: 2px solid #cbc6b9;
  cursor: pointer;
}

.toggle-row span {
  display: grid;
  gap: 4px;
}

.toggle-row small {
  color: var(--ink-soft);
  line-height: 1.35;
}

#sound-toggle {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  accent-color: var(--cobalt);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.secondary-action {
  min-width: 112px;
  padding: 9px 16px;
  border: 3px solid var(--line);
  background: var(--cobalt);
  color: var(--white);
  box-shadow: 4px 4px 0 var(--ink);
  font-weight: 850;
}

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

:where(
  a,
  button,
  select,
  input,
  [tabindex]
):focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--cobalt-dark);
}

.control-deck :where(button, [tabindex]):focus-visible,
.cabinet :where(button, [tabindex]):focus-visible {
  outline-color: var(--white);
  box-shadow: 0 0 0 6px var(--focus);
}

.settings-dialog :where(button, select, input):focus-visible {
  outline-color: var(--white);
  box-shadow: 0 0 0 6px var(--cobalt);
}

.cabinet.is-hit {
  animation: cabinet-hit 130ms ease-out;
}

.cabinet.is-life-lost {
  animation: cabinet-shake 390ms ease-out;
}

.cabinet.is-level-clear {
  animation: cabinet-clear 520ms ease-out;
}

#fa-help-btn,
.fa-help-button {
  width: 48px !important;
  min-width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  border: 3px solid var(--line) !important;
  border-radius: 0 !important;
  background: var(--mustard) !important;
  color: var(--ink) !important;
  box-shadow: 4px 4px 0 var(--ink) !important;
}

#fa-help-btn:focus-visible,
.fa-help-button:focus-visible {
  outline: 3px solid var(--white) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 6px var(--cobalt-dark) !important;
}

@keyframes panel-arrive {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 16px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes event-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }
  24% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.06);
  }
  78% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 18px)) scale(0.96);
  }
}

@keyframes status-pulse {
  50% {
    opacity: 0.55;
  }
}

@keyframes cabinet-hit {
  50% {
    transform: translateY(-3px);
  }
}

@keyframes cabinet-shake {
  18% {
    transform: translateX(-7px) rotate(-0.4deg);
  }
  36% {
    transform: translateX(6px) rotate(0.4deg);
  }
  54% {
    transform: translateX(-4px);
  }
  72% {
    transform: translateX(3px);
  }
}

@keyframes cabinet-clear {
  30%,
  72% {
    box-shadow:
      8px 8px 0 var(--ink),
      0 0 0 7px var(--mustard);
  }
}

@media (max-width: 820px) {
  :root {
    --header-height: 58px;
  }

  .app-shell {
    padding: 8px 12px 24px;
  }

  .topbar {
    margin-bottom: 12px;
  }

  .back-link {
    gap: 0;
  }

  .back-link > span:last-child,
  .utility-button > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .back-link > span:first-child,
  .utility-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
  }

  .utility-button {
    box-shadow: 3px 3px 0 var(--shadow);
  }

  .cabinet-token {
    width: 36px;
    height: 36px;
    font-size: 0.82rem;
  }

  .title-lockup {
    gap: 7px;
  }

  .title-lockup h1 {
    max-width: 175px;
    overflow: hidden;
    font-size: 1.08rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .title-lockup p {
    display: none;
  }

  .arcade-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }

  .cabinet {
    width: min(calc(100% - 20px), 430px);
  }

  .marquee {
    min-height: 64px;
    font-size: clamp(1.9rem, 11.4vw, 3rem);
  }

  .monitor-bezel {
    padding: 14px clamp(14px, 5%, 22px) 16px;
  }

  .playfield-shell {
    width: min(100%, 356px);
  }

  .cabinet-kickplate {
    min-height: 44px;
  }

  .control-deck {
    width: min(calc(100% - 20px), 430px);
    margin-inline: auto;
  }

  .score-reels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 12px;
  }

  .score-reel {
    padding: 8px 5px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .score-reel span {
    font-size: 0.58rem;
  }

  .score-reel strong {
    font-size: 1rem;
  }

  .button-bank {
    grid-template-columns: 1.25fr 1fr 1fr;
    padding-inline: 12px;
  }

  .deck-button--launch {
    grid-row: auto;
    min-height: 52px;
    border-radius: 0;
  }

  .cabinet-note {
    margin-inline: 12px;
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 8px;
  }

  .title-lockup h1 {
    max-width: 142px;
  }

  .cabinet,
  .control-deck {
    width: calc(100% - 18px);
  }

  .cabinet::before,
  .cabinet::after {
    width: 8px;
  }

  .cabinet::before {
    left: -11px;
  }

  .cabinet::after {
    right: -11px;
  }

  .marquee {
    min-height: 58px;
    padding-inline: 12px;
  }

  .game-panel {
    width: 86%;
    padding: 16px 14px;
  }

  .game-panel h2 {
    margin-top: 10px;
  }

  .game-panel p {
    margin-top: 9px;
    line-height: 1.42;
  }

  .primary-action {
    margin-top: 13px;
  }

  .control-copy {
    padding-inline: 14px;
  }
}

@media (min-width: 700px) and (max-height: 620px) {
  :root {
    --header-height: 44px;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: 4px 14px 6px;
  }

  .topbar {
    min-height: var(--header-height);
    margin-bottom: 4px;
  }

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

  .back-link > span:first-child {
    width: 29px;
    height: 29px;
  }

  .cabinet-token {
    width: 34px;
    height: 34px;
    font-size: 0.78rem;
  }

  .title-lockup h1 {
    font-size: 1.08rem;
  }

  .title-lockup p {
    font-size: 0.66rem;
  }

  .utility-button {
    min-width: 82px;
    padding-block: 4px;
  }

  .arcade-layout {
    grid-template-columns: minmax(270px, 0.88fr) minmax(310px, 1.12fr);
    align-items: stretch;
    gap: clamp(16px, 3vw, 34px);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .cabinet {
    grid-template-rows: 42px minmax(0, 1fr);
    width: 100%;
    height: 100%;
    max-width: 500px;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    justify-self: end;
    box-shadow: 6px 6px 0 var(--ink);
  }

  .cabinet::before,
  .cabinet::after {
    display: none;
  }

  .cabinet-cap,
  .cabinet-kickplate {
    display: none;
  }

  .marquee {
    min-height: 0;
    padding: 3px 12px 4px;
    font-size: clamp(1.5rem, 5vh, 2.35rem);
  }

  .monitor-bezel {
    min-height: 0;
    padding: 6px 12px;
    overflow: hidden;
  }

  .playfield-shell {
    width: auto;
    min-height: 0;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    aspect-ratio: 720 / 920;
  }

  .coin-door {
    width: 18px;
    height: 22px;
    border-width: 2px;
  }

  .service-mark {
    font-size: 0.48rem;
  }

  .control-deck {
    display: grid;
    grid-template-rows: auto auto auto auto auto minmax(0, 1fr) auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    box-shadow: 6px 6px 0 var(--ink);
    scrollbar-color: var(--mustard) var(--cobalt-dark);
    scrollbar-width: thin;
  }

  .control-deck::before {
    height: 7px;
  }

  .run-strip {
    min-height: 44px;
    padding: 6px 12px;
  }

  .run-label {
    font-size: 0.52rem;
  }

  #run-status {
    font-size: 0.84rem;
  }

  .status-lamp {
    width: 14px;
    height: 14px;
    border-width: 2px;
    box-shadow: 0 0 0 2px #fbdb80;
  }

  .score-reels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 8px 10px;
  }

  .score-reel {
    padding: 5px 6px;
    border-width: 2px;
    box-shadow: 2px 2px 0 var(--ink);
  }

  .score-reel span {
    font-size: 0.5rem;
  }

  .score-reel strong {
    margin-top: 1px;
    font-size: 0.94rem;
  }

  .control-copy {
    padding: 9px 12px 7px;
  }

  .control-copy h2 {
    font-size: 1rem;
  }

  .control-copy p {
    margin-top: 4px;
    font-size: 0.69rem;
    line-height: 1.3;
  }

  .control-copy .key-hint {
    font-size: 0.58rem;
  }

  .button-bank {
    grid-template-columns: 1.25fr 1fr 1fr;
    gap: 7px;
    padding: 2px 10px 10px;
  }

  .deck-button {
    min-height: 44px;
    padding: 5px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--ink);
    font-size: 0.7rem;
  }

  .deck-button--launch {
    grid-row: auto;
    min-height: 44px;
    border-radius: 0;
  }

  .cabinet-note {
    align-self: end;
    margin: 0 10px 8px;
    padding: 6px 8px;
  }

  .cabinet-note p {
    font-size: 0.62rem;
  }

  .service-strip {
    min-height: 27px;
    padding: 4px 10px;
    font-size: 0.52rem;
  }

  .game-panel {
    width: min(84%, 250px);
    padding: 12px 14px;
    border-width: 3px;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.78);
  }

  .game-panel h2 {
    margin-top: 7px;
    font-size: clamp(1rem, 4vh, 1.55rem);
  }

  .game-panel p {
    margin-top: 6px;
    font-size: clamp(0.62rem, 2.2vh, 0.78rem);
    line-height: 1.3;
  }

  .game-panel small {
    margin-top: 5px;
    font-size: 0.54rem;
  }

  .panel-stamp {
    padding: 2px 5px;
    border-width: 1px;
    font-size: 0.48rem;
  }

  .primary-action {
    min-height: 44px;
    margin-top: 8px;
    padding: 6px 10px;
    border-width: 2px;
    box-shadow: 3px 3px 0 var(--ink);
    font-size: 0.75rem;
  }

  #fa-help-btn,
  .fa-help-button {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --ink-soft: #172131;
  }

  .control-copy p,
  .cabinet-note,
  .run-label {
    color: var(--white);
  }

  .back-link,
  .utility-button,
  .deck-button,
  .primary-action,
  #language-select {
    border-width: 4px;
  }
}

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

  .cabinet.is-hit,
  .cabinet.is-life-lost,
  .cabinet.is-level-clear {
    animation: none;
  }
}
