:root {
  --app-height: 100dvh;
  --bg: #05070d;
  --panel: rgba(9, 16, 29, 0.82);
  --panel-border: rgba(111, 234, 255, 0.26);
  --text: #e8fbff;
  --muted: #8ab8c4;
  --blue: #28d7ff;
  --red: #ff5a38;
  --amber: #ffb23e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overscroll-behavior: none;
}

body {
  min-height: var(--app-height, 100dvh);
  color: var(--text);
  font-family: "Segoe UI", "Arial Narrow", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(40, 215, 255, 0.18), transparent 34%),
    radial-gradient(circle at 80% 0%, rgba(255, 90, 56, 0.16), transparent 32%),
    linear-gradient(135deg, #03040a, #07111c 48%, #0c0612);
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body.intro-active {
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

body.intro-active .game-shell {
  opacity: 0;
  pointer-events: none;
}

body.modal-open {
  height: var(--app-height, 100dvh);
  overflow: hidden;
}

body.modal-open .touch-controls,
body.modal-open canvas {
  pointer-events: none;
}

body.modal-open .touch-controls {
  display: none !important;
}
body.modal-open .run-status-panel {
  display: none !important;
}

button {
  position: relative;
  border: 1px solid rgba(111, 234, 255, 0.34);
  border-radius: 4px;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(40, 215, 255, 0.12), rgba(6, 16, 31, 0.92) 18%, rgba(11, 23, 42, 0.96) 82%, rgba(255, 90, 56, 0.12));
  box-shadow: 0 0 18px rgba(40, 215, 255, 0.16), inset 0 0 18px rgba(40, 215, 255, 0.05);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  min-height: 42px;
  padding: 0 18px;
  text-transform: uppercase;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(40, 215, 255, 0.95);
  background:
    linear-gradient(90deg, rgba(40, 215, 255, 0.2), rgba(10, 30, 54, 0.98) 24%, rgba(15, 35, 57, 0.98) 76%, rgba(255, 90, 56, 0.18));
  outline: none;
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(40, 215, 255, 0.28), 0 0 18px rgba(255, 90, 56, 0.12), inset 0 0 20px rgba(40, 215, 255, 0.09);
}

button:active {
  transform: translateY(0) scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

button.danger {
  border-color: rgba(255, 90, 56, 0.4);
}

button.audio-test {
  border-color: rgba(255, 178, 62, 0.7);
  background: rgba(82, 48, 14, 0.92);
  box-shadow: 0 0 22px rgba(255, 178, 62, 0.26);
}

.game-shell {
  width: min(1120px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.top-bar,
.info-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
}

.top-bar h1,
.overlay h2 {
  margin: 0;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(40, 215, 255, 0.7), 0 0 28px rgba(255, 90, 56, 0.24);
}

.top-bar h1 {
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.title-word {
  display: inline;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  min-width: min(340px, 100%);
}

.scoreboard div,
.info-bar {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: inset 0 0 22px rgba(40, 215, 255, 0.06);
}

.scoreboard div {
  display: grid;
  place-items: center;
  min-height: 68px;
}

.scoreboard span {
  color: white;
  font-size: 1.8rem;
  font-weight: 950;
  line-height: 1;
}

.scoreboard small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.run-status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(111, 234, 255, 0.22);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--muted);
  background: linear-gradient(90deg, rgba(6, 14, 25, 0.86), rgba(13, 20, 34, 0.68));
  box-shadow: inset 0 0 22px rgba(40, 215, 255, 0.05), 0 0 18px rgba(40, 215, 255, 0.08);
}

.run-status-primary,
.run-status-meta {
  display: flex;
  align-items: center;
  min-width: 0;
}

.run-status-primary {
  gap: 10px;
  flex: 1 1 auto;
}

.run-status-primary b,
.run-status-meta span {
  white-space: nowrap;
}

.run-status-primary b {
  color: var(--text);
  font-weight: 950;
}

.run-status-primary span {
  min-width: 0;
  overflow: hidden;
  color: rgba(232, 251, 255, 0.82);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-status-meta {
  justify-content: flex-end;
  gap: 8px;
  flex: 0 1 auto;
  flex-wrap: wrap;
  font-size: 0.78rem;
  font-weight: 800;
}

.run-status-meta span {
  border-left: 1px solid rgba(111, 234, 255, 0.2);
  padding-left: 8px;
}

.run-status-meta span:first-child {
  border-left: 0;
  padding-left: 0;
  color: var(--amber);
}
  .arena-wrap {
  position: relative;
  margin-top: 18px;
  border: 1px solid rgba(40, 215, 255, 0.45);
  border-radius: 8px;
  background: #02050c;
  box-shadow:
    0 0 34px rgba(40, 215, 255, 0.25),
    0 0 56px rgba(255, 90, 56, 0.14),
    inset 0 0 42px rgba(40, 215, 255, 0.08);
  overflow: hidden;
}

.arena-wrap.shake {
  animation: shake 260ms linear 2;
}

.arena-wrap.close-warning {
  border-color: rgba(255, 178, 62, 0.95);
  box-shadow:
    0 0 34px rgba(255, 178, 62, 0.42),
    0 0 56px rgba(255, 90, 56, 0.22),
    inset 0 0 44px rgba(255, 178, 62, 0.12);
}

.arena-wrap.boss-intro {
  animation: bossPulse 620ms ease-in-out infinite alternate, shake 260ms linear 1;
  border-color: rgba(255, 64, 64, 0.95);
  box-shadow:
    0 0 42px rgba(255, 64, 64, 0.48),
    0 0 82px rgba(255, 178, 62, 0.22),
    inset 0 0 54px rgba(255, 64, 64, 0.16);
}

.arena-wrap.boost-ready-pulse {
  box-shadow:
    0 0 34px rgba(40, 215, 255, 0.25),
    0 0 56px rgba(255, 178, 62, 0.18),
    inset 0 0 42px rgba(255, 178, 62, 0.11);
}

.arena-wrap.city-scenario {
  border-color: rgba(157, 96, 255, 0.72);
  box-shadow:
    0 0 36px rgba(93, 184, 255, 0.3),
    0 0 68px rgba(157, 96, 255, 0.24),
    inset 0 0 46px rgba(56, 83, 181, 0.16);
}

.audio-status {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px 12px;
  border: 1px solid rgba(111, 234, 255, 0.2);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  background: rgba(4, 10, 20, 0.55);
  font-size: 0.78rem;
}

.audio-status b {
  display: block;
  color: var(--text);
  font-size: 0.86rem;
}

.level-select-grid button.locked-level {
  border-color: rgba(255, 255, 255, 0.12);
  opacity: 0.45;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 10;
  max-height: calc(100vh - 250px);
  min-height: 320px;
  touch-action: none;
}

.overlay,
.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.overlay {
  align-items: start;
  overflow: auto;
  padding: 12px;
  isolation: isolate;
}

.overlay::before,
.overlay::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.overlay::before {
  z-index: -2;
  background:
    radial-gradient(circle at 30% 20%, rgba(40, 215, 255, 0.18), transparent 34%),
    radial-gradient(circle at 74% 72%, rgba(255, 90, 56, 0.16), transparent 36%),
    linear-gradient(180deg, rgba(2, 7, 14, 0.26), rgba(1, 3, 8, 0.72));
}

.overlay::after {
  z-index: -1;
  background:
    repeating-linear-gradient(0deg, rgba(232, 251, 255, 0.035) 0, rgba(232, 251, 255, 0.035) 1px, transparent 1px, transparent 5px),
    linear-gradient(90deg, transparent 0 18%, rgba(40, 215, 255, 0.12) 20%, transparent 22% 77%, rgba(255, 90, 56, 0.11) 79%, transparent 82%);
  opacity: 0.36;
  animation: overlayScan 2.2s linear infinite;
}

.ai-debug-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  display: grid;
  gap: 4px;
  min-width: 220px;
  border: 1px solid rgba(255, 178, 62, 0.42);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(3, 8, 17, 0.88);
  font-size: 0.78rem;
  line-height: 1.25;
  pointer-events: none;
}

.test-mode-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 4;
  display: grid;
  gap: 8px;
  width: min(270px, calc(100% - 24px));
  border: 1px solid rgba(40, 215, 255, 0.42);
  border-radius: 6px;
  padding: 10px 12px 12px;
  color: var(--muted);
  background: rgba(3, 8, 17, 0.88);
  font-size: 0.78rem;
  line-height: 1.25;
}

.test-mode-panel strong {
  color: var(--text);
}

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

.level-select-grid button {
  min-height: 30px;
  min-width: 0;
  padding: 0;
}

.ai-debug-panel.hidden {
  display: none;
}

body:not(.dev-mode) .dev-only,
body:not(.dev-mode) .test-mode-panel,
body:not(.dev-mode) .ai-debug-panel {
  display: none;
}

.ai-debug-panel strong {
  min-height: 1em;
  color: #ff6a63;
}

.ai-debug-panel b {
  color: var(--text);
}

.overlay.hidden {
  display: none;
}

.hidden {
  display: none;
}

.title-screen,
.title-screen-prompt {
  display: none;
}

.overlay-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100% - 36px));
  max-height: min(680px, calc(100% - 24px));
  overflow: hidden;
  border: 1px solid rgba(111, 234, 255, 0.32);
  border-radius: 6px;
  padding: 28px 30px 24px;
  text-align: center;
  background:
    linear-gradient(135deg, rgba(3, 8, 17, 0.94), rgba(6, 14, 27, 0.88)),
    linear-gradient(90deg, rgba(40, 215, 255, 0.07), transparent 32% 68%, rgba(255, 90, 56, 0.07));
  box-shadow:
    0 0 52px rgba(40, 215, 255, 0.26),
    0 0 80px rgba(255, 90, 56, 0.12),
    inset 0 0 34px rgba(255, 255, 255, 0.045);
  clip-path: polygon(0 10px, 10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px));
  pointer-events: auto;
}

.overlay-panel::before,
.overlay-panel::after {
  position: absolute;
  left: 28px;
  right: 28px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(40, 215, 255, 0.9), rgba(255, 90, 56, 0.56), transparent);
  pointer-events: none;
}

.overlay-panel::before {
  top: 48px;
}

.overlay-panel::after {
  bottom: 48px;
  opacity: 0.45;
}

.overlay h2 {
  font-size: clamp(2rem, 6.4vw, 4.2rem);
  line-height: 1.02;
  text-transform: uppercase;
}

.overlay p {
  color: var(--muted);
  line-height: 1.55;
}

.round-summary {
  margin-top: 14px;
  border-top: 1px solid rgba(111, 234, 255, 0.16);
  padding-top: 12px;
  max-height: 170px;
  overflow-y: auto;
  text-align: left;
}

.round-summary.round-summary--compact {
  max-height: none;
  overflow: hidden;
}

.menu-panel {
  margin-top: 18px;
  border-top: 1px solid rgba(111, 234, 255, 0.16);
  padding-top: 16px;
  max-height: min(430px, 48vh);
  overflow-y: auto;
  text-align: left;
}

#levelSelectMenu {
  max-height: min(430px, 56vh);
  overflow-y: auto;
  padding-right: 6px;
}

#levelSelectMenuGrid {
  display: block;
}

.selected-level-row {
  margin: 6px 0 12px;
}

.level-select-start {
  width: 100%;
  margin-top: 12px;
  border-color: rgba(40, 215, 255, 0.65);
}

.level-select-division {
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid rgba(111, 234, 255, 0.14);
  border-radius: 8px;
  background: rgba(4, 12, 24, 0.52);
}

.level-select-division h4 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.level-select-division-grid {
  grid-template-columns: repeat(6, minmax(34px, 1fr));
}

.level-select-grid button.selected-level {
  border-color: rgba(255, 178, 62, 0.95);
  background: rgba(92, 55, 18, 0.96);
  box-shadow: 0 0 20px rgba(255, 178, 62, 0.28);
}

.menu-panel h3 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 0.96rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.menu-panel p,
.menu-panel li {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.menu-panel ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.menu-panel label {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(140px, 1.5fr) 48px;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.menu-panel input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.menu-panel b {
  color: var(--text);
  text-align: right;
}

.menu-panel .check-row {
  grid-template-columns: auto 1fr;
  justify-content: start;
}

.menu-panel .check-row input {
  inline-size: 18px;
  block-size: 18px;
  accent-color: var(--amber);
}

.arcade-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option-toggle {
  min-height: 64px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 10px 14px;
  border-color: rgba(40, 215, 255, 0.58);
}

.option-toggle span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0.18em;
}

.option-toggle b {
  color: white;
  font-size: 1.35rem;
  text-align: center;
  text-shadow: 0 0 16px rgba(40, 215, 255, 0.75);
}

.option-toggle[aria-pressed="false"] {
  border-color: rgba(255, 90, 56, 0.52);
  background:
    linear-gradient(90deg, rgba(255, 90, 56, 0.16), rgba(25, 12, 17, 0.94), rgba(8, 16, 28, 0.9));
}

.option-toggle[aria-pressed="false"] b {
  color: #ffb1a2;
  text-shadow: 0 0 16px rgba(255, 90, 56, 0.72);
}

.option-back {
  grid-column: 1 / -1;
}

.mix-console {
  margin-top: 16px;
  border-top: 1px solid rgba(111, 234, 255, 0.14);
  padding-top: 12px;
}

.round-summary h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.86rem;
}

.round-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  color: var(--muted);
  font-size: 0.76rem;
}

.round-summary-grid span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.round-summary-grid b {
  color: var(--text);
  text-align: right;
}

.round-summary.round-summary--compact .round-summary-grid span:nth-child(3),
.round-summary.round-summary--compact .round-summary-grid span:nth-child(7),
.round-summary.round-summary--compact .round-summary-grid span:nth-child(9),
.round-summary.round-summary--compact .round-summary-grid span:nth-child(10),
.round-summary.round-summary--compact .round-summary-grid span:nth-child(11),
.round-summary.round-summary--compact .round-summary-grid span:nth-child(12) {
  display: none;
}

.difficulty,
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

body[data-overlay-mode="menu"] .overlay-panel {
  width: min(680px, calc(100% - 36px));
}

body[data-overlay-mode="menu"] .actions {
  display: grid;
  width: min(100%, 500px);
  margin: 22px auto 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body[data-overlay-mode="menu"] #startBtn,
body[data-overlay-mode="menu"] #settingsBtn {
  min-height: 58px;
  border-color: rgba(40, 215, 255, 0.72);
  font-size: 1.08rem;
  box-shadow: 0 0 28px rgba(40, 215, 255, 0.22), inset 0 0 20px rgba(40, 215, 255, 0.08);
}

body[data-overlay-mode="menu"] #settingsBtn {
  border-color: rgba(255, 90, 56, 0.6);
}

body[data-overlay-mode="menu"] #continueBtn,
body[data-overlay-mode="menu"] #levelSelectBtn,
body[data-overlay-mode="menu"] #howToPlayBtn,
body[data-overlay-mode="menu"] #newGameBtn,
body[data-overlay-mode="menu"] #ascensionBtn {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.72rem;
  opacity: 0.86;
}

body[data-overlay-mode="gameOver"] .difficulty {
  display: none;
}

.difficulty button {
  min-width: 92px;
}

.difficulty button.active {
  border-color: rgba(255, 178, 62, 0.95);
  background: rgba(89, 48, 18, 0.95);
  box-shadow: 0 0 18px rgba(255, 178, 62, 0.3);
}

button.secondary {
  background:
    linear-gradient(90deg, rgba(255, 90, 56, 0.1), rgba(28, 25, 40, 0.94), rgba(40, 215, 255, 0.08));
}

body[data-presentation-state="main_menu"],
body[data-presentation-state="options"] {
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #010309;
}

body[data-presentation-state="main_menu"] .game-shell,
body[data-presentation-state="options"] .game-shell {
  display: grid;
  width: 100%;
  max-width: none;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  margin: 0;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  place-items: center;
}

body[data-presentation-state="main_menu"] .top-bar,
body[data-presentation-state="main_menu"] .run-status-panel,
body[data-presentation-state="main_menu"] .info-bar,
body[data-presentation-state="main_menu"] .touch-controls,
body[data-presentation-state="main_menu"] canvas,
body[data-presentation-state="options"] .top-bar,
body[data-presentation-state="options"] .run-status-panel,
body[data-presentation-state="options"] .info-bar,
body[data-presentation-state="options"] .touch-controls,
body[data-presentation-state="options"] canvas {
  display: none !important;
}

body[data-presentation-state="main_menu"] .arena-wrap,
body[data-presentation-state="options"] .arena-wrap {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 46%, rgba(40, 215, 255, 0.18), transparent 31%),
    radial-gradient(circle at 86% 45%, rgba(255, 48, 46, 0.18), transparent 34%),
    linear-gradient(180deg, #010207 0%, #030817 43%, #030207 100%);
  box-shadow: none;
}

body[data-presentation-state="main_menu"] .arena-wrap::before,
body[data-presentation-state="main_menu"] .arena-wrap::after,
body[data-presentation-state="options"] .arena-wrap::before,
body[data-presentation-state="options"] .arena-wrap::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

body[data-presentation-state="main_menu"] .arena-wrap::before,
body[data-presentation-state="options"] .arena-wrap::before {
  z-index: 0;
  background:
    radial-gradient(ellipse at 42% 45%, rgba(40, 215, 255, 0.18), transparent 22%),
    radial-gradient(ellipse at 61% 46%, rgba(255, 55, 48, 0.14), transparent 20%),
    linear-gradient(90deg, rgba(40, 215, 255, 0.12), transparent 22% 76%, rgba(255, 66, 56, 0.13)),
    repeating-linear-gradient(0deg, rgba(232, 251, 255, 0.035) 0 1px, transparent 1px 5px);
  opacity: 0.78;
}

body[data-presentation-state="main_menu"] .arena-wrap::after,
body[data-presentation-state="options"] .arena-wrap::after {
  top: auto;
  bottom: -22%;
  z-index: 0;
  height: 58%;
  background:
    linear-gradient(rgba(40, 215, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 215, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, transparent 0 54%, rgba(255, 66, 56, 0.16) 55%, transparent 57%);
  background-size: 58px 58px, 58px 58px, 100% 100%;
  mask-image: linear-gradient(to top, black 0%, rgba(0, 0, 0, 0.75) 54%, transparent 100%);
  opacity: 0.5;
  transform: perspective(620px) rotateX(66deg);
  transform-origin: 50% 100%;
  animation: titleGridDrift 7s linear infinite;
}

body[data-presentation-state="main_menu"] .overlay,
body[data-presentation-state="options"] .overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  align-items: center;
  overflow: hidden;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: transparent;
}

body[data-presentation-state="main_menu"] .overlay::before,
body[data-presentation-state="main_menu"] .overlay::after,
body[data-presentation-state="options"] .overlay::before,
body[data-presentation-state="options"] .overlay::after {
  opacity: 0.28;
}

body[data-presentation-state="main_menu"] .overlay-panel,
body[data-presentation-state="options"] .overlay-panel {
  width: min(92vw, 940px);
  height: min(84dvh, 690px);
  max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 44px 56px 38px;
  border-color: rgba(116, 238, 255, 0.36);
  background:
    linear-gradient(180deg, rgba(3, 8, 17, 0.42), rgba(4, 7, 15, 0.7)),
    radial-gradient(ellipse at 50% 35%, rgba(40, 215, 255, 0.08), transparent 44%),
    linear-gradient(90deg, rgba(40, 215, 255, 0.06), transparent 45% 56%, rgba(255, 72, 55, 0.055));
  box-shadow:
    0 0 54px rgba(40, 215, 255, 0.18),
    0 0 90px rgba(255, 66, 56, 0.08),
    inset 0 0 60px rgba(40, 215, 255, 0.055),
    inset 0 0 110px rgba(0, 0, 0, 0.64);
}

body[data-presentation-state="main_menu"] .overlay-panel::before,
body[data-presentation-state="main_menu"] .overlay-panel::after,
body[data-presentation-state="options"] .overlay-panel::before,
body[data-presentation-state="options"] .overlay-panel::after {
  left: 6%;
  right: 6%;
}

body[data-presentation-state="main_menu"] .overlay-panel::before,
body[data-presentation-state="options"] .overlay-panel::before {
  top: 28px;
}

body[data-presentation-state="main_menu"] .overlay-panel::after,
body[data-presentation-state="options"] .overlay-panel::after {
  bottom: 28px;
}

body[data-presentation-state="main_menu"] .overlay-panel > .eyebrow,
body[data-presentation-state="main_menu"] .overlay-panel > h2,
body[data-presentation-state="main_menu"] .overlay-panel > #overlayMessage,
body[data-presentation-state="main_menu"] .difficulty,
body[data-presentation-state="main_menu"] .menu-panel,
body[data-presentation-state="main_menu"] .round-summary,
body[data-presentation-state="options"] .overlay-panel > .eyebrow,
body[data-presentation-state="options"] .overlay-panel > h2,
body[data-presentation-state="options"] .overlay-panel > #overlayMessage,
body[data-presentation-state="options"] .difficulty,
body[data-presentation-state="options"] .actions,
body[data-presentation-state="options"] .title-screen,
body[data-presentation-state="options"] .title-screen-prompt,
body[data-presentation-state="options"] .round-summary {
  display: none !important;
}

body[data-presentation-state="main_menu"] .title-screen,
body[data-presentation-state="main_menu"] .title-screen-prompt {
  display: grid;
}

.title-screen {
  width: min(100%, 820px);
  max-width: 100%;
  justify-items: center;
  align-content: center;
  text-align: center;
}

.title-screen-studio {
  margin: 0 0 clamp(24px, 4.8dvh, 38px);
  color: rgba(176, 242, 255, 0.74);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(40, 215, 255, 0.32);
}

.title-screen-mark {
  position: relative;
  display: grid;
  justify-items: center;
  width: min(100%, 800px);
  isolation: isolate;
  line-height: 0.88;
  text-transform: uppercase;
  animation: titleGlowBreath 4.8s ease-in-out infinite, titleMicroFlicker 8.5s steps(1, end) infinite;
}

.title-screen-mark::before {
  position: absolute;
  inset: -10% 4% 2%;
  z-index: 0;
  content: "";
  background:
    radial-gradient(ellipse at 50% 54%, rgba(255, 58, 44, 0.24), transparent 58%),
    radial-gradient(ellipse at 50% 40%, rgba(40, 215, 255, 0.15), transparent 52%);
  filter: blur(18px);
  opacity: 0.9;
  pointer-events: none;
}

.title-screen-mark::after {
  position: absolute;
  top: 6%;
  bottom: 1%;
  width: 32%;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  filter: blur(10px);
  opacity: 0;
  transform: translateX(-220%);
  animation: titleLightSweep 5.8s ease-in-out infinite;
  pointer-events: none;
}

.title-screen-main,
.title-screen-sub {
  position: relative;
  z-index: 2;
  display: block;
  max-width: 100%;
  color: #e8fbff;
  font-weight: 950;
  white-space: nowrap;
  text-shadow:
    0 1px 0 white,
    0 0 10px rgba(232, 251, 255, 0.95),
    0 0 22px rgba(40, 215, 255, 0.88),
    0 0 42px rgba(40, 215, 255, 0.52),
    0 0 36px rgba(255, 64, 48, 0.5),
    0 0 74px rgba(255, 64, 48, 0.34);
}

.title-screen-main {
  font-size: clamp(3.6rem, min(8.4vw, 10dvh), 6.25rem);
  letter-spacing: 0.018em;
}

.title-screen-sub {
  margin-top: 4px;
  font-size: clamp(2.85rem, min(6.8vw, 7.6dvh), 4.8rem);
  letter-spacing: 0.055em;
}

.title-energy-line {
  position: relative;
  z-index: 1;
  width: min(430px, 78%);
  height: 2px;
  margin-top: clamp(14px, 2.2dvh, 20px);
  background:
    radial-gradient(circle, rgba(255, 220, 184, 0.98) 0 2px, transparent 3px),
    linear-gradient(90deg, transparent, rgba(255, 74, 54, 0.18), rgba(255, 74, 54, 0.9), rgba(255, 74, 54, 0.18), transparent);
  box-shadow: 0 0 14px rgba(255, 74, 54, 0.9), 0 0 38px rgba(255, 74, 54, 0.34);
}

.title-screen-tagline {
  margin: clamp(20px, 3.6dvh, 28px) 0 0;
  color: rgba(207, 246, 255, 0.78);
  font-size: 0.98rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(40, 215, 255, 0.24);
}

.title-screen-tagline span {
  color: rgba(255, 96, 72, 0.76);
  margin: 0 0.28em;
}

.title-screen-divider {
  display: grid;
  width: min(260px, 70%);
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: clamp(22px, 3.8dvh, 30px) 0 0;
  color: rgba(213, 248, 255, 0.78);
}

.title-screen-divider span {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(126, 239, 255, 0.7));
}

.title-screen-divider span:last-child {
  background: linear-gradient(90deg, rgba(126, 239, 255, 0.7), transparent);
}

.title-screen-divider b {
  color: rgba(236, 253, 255, 0.92);
  font-size: 0.94rem;
  text-shadow: 0 0 12px rgba(40, 215, 255, 0.5);
}

body[data-presentation-state="main_menu"] .actions {
  display: grid;
  width: min(320px, 72vw);
  grid-template-columns: 1fr;
  gap: 14px;
  margin: clamp(22px, 3.8dvh, 28px) auto 0;
}

body[data-presentation-state="main_menu"] .actions button {
  display: none;
}

body[data-presentation-state="main_menu"] #startBtn,
body[data-presentation-state="main_menu"] #leaderboardBtn,
body[data-presentation-state="main_menu"] #achievementsBtn,
body[data-presentation-state="main_menu"] #settingsBtn {
  display: block;
  width: 100%;
  min-height: 54px;
  border-color: rgba(116, 238, 255, 0.74);
  color: #eafeff;
  background:
    linear-gradient(90deg, rgba(40, 215, 255, 0.13), rgba(2, 13, 26, 0.68) 18%, rgba(2, 9, 20, 0.74) 82%, rgba(255, 72, 55, 0.09));
  font-size: 1rem;
  letter-spacing: 0.11em;
  box-shadow:
    0 0 28px rgba(40, 215, 255, 0.18),
    inset 0 0 22px rgba(40, 215, 255, 0.09);
}

body[data-presentation-state="main_menu"] #startBtn {
  min-height: 60px;
  font-size: 1.05rem;
}

body[data-presentation-state="main_menu"] #leaderboardBtn,
body[data-presentation-state="main_menu"] #achievementsBtn,
body[data-presentation-state="main_menu"] #settingsBtn {
  min-height: 48px;
  border-color: rgba(116, 238, 255, 0.36);
  opacity: 0.86;
}

/* The title menu hides every secondary action; the Pro offer is the exception for free players. */
body[data-presentation-state="main_menu"] #premiumMenuBtn:not(.hidden) {
  display: block;
  width: 100%;
  min-height: 48px;
  font-size: 0.95rem;
  letter-spacing: 0.11em;
}

body[data-presentation-state="main_menu"] #startBtn:hover,
body[data-presentation-state="main_menu"] #startBtn:focus-visible,
body[data-presentation-state="main_menu"] #leaderboardBtn:hover,
body[data-presentation-state="main_menu"] #leaderboardBtn:focus-visible,
body[data-presentation-state="main_menu"] #achievementsBtn:hover,
body[data-presentation-state="main_menu"] #achievementsBtn:focus-visible,
body[data-presentation-state="main_menu"] #settingsBtn:hover,
body[data-presentation-state="main_menu"] #settingsBtn:focus-visible {
  transform: scale(1.025);
  border-color: rgba(164, 248, 255, 0.98);
  box-shadow:
    0 0 34px rgba(40, 215, 255, 0.34),
    0 0 22px rgba(255, 72, 55, 0.16),
    inset 0 0 26px rgba(40, 215, 255, 0.13);
}

body[data-presentation-state="main_menu"] .title-screen-prompt {
  margin: clamp(22px, 3.6dvh, 28px) 0 0;
  color: rgba(180, 232, 244, 0.58);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-align: center;
  animation: titlePromptPulse 2.8s ease-in-out infinite;
}

body[data-presentation-state="options"] .overlay-panel {
  width: min(92vw, 520px);
  height: auto;
  min-height: 430px;
  padding: 46px 42px 38px;
}

body[data-presentation-state="options"] #settingsPanel {
  display: grid;
  width: min(340px, 100%);
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  text-align: center;
}

body[data-presentation-state="options"] #settingsPanel h3 {
  margin: 0 0 26px;
  color: #e8fbff;
  font-size: 1.55rem;
  letter-spacing: 0.26em;
  text-shadow: 0 0 20px rgba(40, 215, 255, 0.6);
}

body[data-presentation-state="options"] .arcade-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

body[data-presentation-state="options"] .option-toggle {
  display: grid;
  min-height: 58px;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 0 20px;
  text-align: left;
}

body[data-presentation-state="options"] .option-toggle span {
  color: rgba(207, 246, 255, 0.76);
  font-size: 0.9rem;
}

body[data-presentation-state="options"] .option-toggle b {
  font-size: 1.08rem;
}

body[data-presentation-state="options"][data-overlay-mode="menu"] .mix-console {
  display: none;
}

body[data-presentation-state="callsign"],
body[data-presentation-state="profile"],
body[data-presentation-state="leaderboard"],
body[data-presentation-state="achievements"] {
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #010309;
}

body[data-presentation-state="callsign"] .game-shell,
body[data-presentation-state="profile"] .game-shell,
body[data-presentation-state="leaderboard"] .game-shell,
body[data-presentation-state="achievements"] .game-shell {
  display: grid;
  width: 100%;
  max-width: none;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  margin: 0;
  padding:
    max(14px, env(safe-area-inset-top))
    max(14px, env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  place-items: center;
}

body[data-presentation-state="callsign"] .top-bar,
body[data-presentation-state="callsign"] .run-status-panel,
body[data-presentation-state="callsign"] .info-bar,
body[data-presentation-state="callsign"] .touch-controls,
body[data-presentation-state="callsign"] canvas,
body[data-presentation-state="profile"] .top-bar,
body[data-presentation-state="profile"] .run-status-panel,
body[data-presentation-state="profile"] .info-bar,
body[data-presentation-state="profile"] .touch-controls,
body[data-presentation-state="profile"] canvas,
body[data-presentation-state="leaderboard"] .top-bar,
body[data-presentation-state="leaderboard"] .run-status-panel,
body[data-presentation-state="leaderboard"] .info-bar,
body[data-presentation-state="leaderboard"] .touch-controls,
body[data-presentation-state="leaderboard"] canvas,
body[data-presentation-state="achievements"] .top-bar,
body[data-presentation-state="achievements"] .run-status-panel,
body[data-presentation-state="achievements"] .info-bar,
body[data-presentation-state="achievements"] .touch-controls,
body[data-presentation-state="achievements"] canvas {
  display: none !important;
}

body[data-presentation-state="callsign"] .arena-wrap,
body[data-presentation-state="profile"] .arena-wrap,
body[data-presentation-state="leaderboard"] .arena-wrap,
body[data-presentation-state="achievements"] .arena-wrap {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 46%, rgba(40, 215, 255, 0.18), transparent 31%),
    radial-gradient(circle at 86% 45%, rgba(255, 48, 46, 0.18), transparent 34%),
    linear-gradient(180deg, #010207 0%, #030817 43%, #030207 100%);
  box-shadow: none;
}

body[data-presentation-state="callsign"] .overlay,
body[data-presentation-state="profile"] .overlay,
body[data-presentation-state="leaderboard"] .overlay,
body[data-presentation-state="achievements"] .overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  align-items: center;
  overflow: hidden;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background: transparent;
}

body[data-presentation-state="callsign"] .overlay-panel,
body[data-presentation-state="profile"] .overlay-panel,
body[data-presentation-state="leaderboard"] .overlay-panel,
body[data-presentation-state="achievements"] .overlay-panel {
  width: min(92vw, 720px);
  height: auto;
  max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  align-items: center;
  overflow: hidden;
  padding: 46px 42px 38px;
}

body[data-presentation-state="leaderboard"] .overlay-panel,
body[data-presentation-state="achievements"] .overlay-panel {
  width: min(94vw, 820px);
}

body[data-presentation-state="callsign"] .overlay-panel > .eyebrow,
body[data-presentation-state="callsign"] .overlay-panel > h2,
body[data-presentation-state="callsign"] .overlay-panel > #overlayMessage,
body[data-presentation-state="callsign"] .difficulty,
body[data-presentation-state="callsign"] .actions,
body[data-presentation-state="callsign"] .title-screen,
body[data-presentation-state="callsign"] .title-screen-prompt,
body[data-presentation-state="callsign"] .round-summary,
body[data-presentation-state="profile"] .overlay-panel > .eyebrow,
body[data-presentation-state="profile"] .overlay-panel > h2,
body[data-presentation-state="profile"] .overlay-panel > #overlayMessage,
body[data-presentation-state="profile"] .difficulty,
body[data-presentation-state="profile"] .actions,
body[data-presentation-state="profile"] .title-screen,
body[data-presentation-state="profile"] .title-screen-prompt,
body[data-presentation-state="profile"] .round-summary,
body[data-presentation-state="leaderboard"] .overlay-panel > .eyebrow,
body[data-presentation-state="leaderboard"] .overlay-panel > h2,
body[data-presentation-state="leaderboard"] .overlay-panel > #overlayMessage,
body[data-presentation-state="leaderboard"] .difficulty,
body[data-presentation-state="leaderboard"] .actions,
body[data-presentation-state="leaderboard"] .title-screen,
body[data-presentation-state="leaderboard"] .title-screen-prompt,
body[data-presentation-state="leaderboard"] .round-summary,
body[data-presentation-state="achievements"] .overlay-panel > .eyebrow,
body[data-presentation-state="achievements"] .overlay-panel > h2,
body[data-presentation-state="achievements"] .overlay-panel > #overlayMessage,
body[data-presentation-state="achievements"] .difficulty,
body[data-presentation-state="achievements"] .actions,
body[data-presentation-state="achievements"] .title-screen,
body[data-presentation-state="achievements"] .title-screen-prompt,
body[data-presentation-state="achievements"] .round-summary {
  display: none !important;
}

.callsign-panel,
.social-panel {
  display: grid;
  width: min(100%, 560px);
  max-height: calc(var(--app-height, 100dvh) - 116px);
  gap: 14px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border: 0;
  text-align: center;
}

.social-panel {
  width: min(100%, 720px);
}

.callsign-panel.hidden,
.social-panel.hidden {
  display: none !important;
}

.callsign-panel h3,
.social-panel h3 {
  margin: 0;
  color: #e8fbff;
  font-size: clamp(1.35rem, 4vw, 2.1rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(40, 215, 255, 0.62), 0 0 24px rgba(255, 64, 48, 0.22);
}

.callsign-entry {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 8px !important;
  margin: 4px 0 !important;
  text-align: left;
}

.callsign-entry span {
  color: rgba(207, 246, 255, 0.78);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.callsign-entry input {
  width: 100%;
  min-height: 52px;
  border: 1px solid rgba(116, 238, 255, 0.46);
  border-radius: 4px;
  padding: 0 16px;
  color: #e8fbff;
  background: rgba(3, 8, 17, 0.72);
  box-shadow: inset 0 0 20px rgba(40, 215, 255, 0.08), 0 0 18px rgba(40, 215, 255, 0.1);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.callsign-entry input:focus {
  border-color: rgba(255, 178, 62, 0.92);
  outline: none;
  box-shadow: inset 0 0 20px rgba(40, 215, 255, 0.12), 0 0 22px rgba(255, 178, 62, 0.2);
}

.account-section,
.account-step {
  display: grid;
  gap: 10px;
}

.account-section {
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid rgba(116, 238, 255, 0.22);
}

.account-section h4 {
  margin: 0;
  color: #e8fbff;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.account-section p {
  margin: 0;
}

.account-step.hidden,
.google-signin.hidden {
  display: none !important;
}

.google-signin {
  display: flex;
  justify-content: center;
  min-height: 44px;
}

#accountEmailInput {
  letter-spacing: 0.02em;
  text-transform: none;
}

#accountCodeInput {
  letter-spacing: 0.4em;
  text-align: center;
}

.link-btn {
  min-height: 44px;
  border: 0;
  padding: 6px 10px;
  color: #8fdcf0;
  background: none;
  box-shadow: none;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: underline;
  text-transform: none;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.link-btn:hover,
.link-btn:focus-visible {
  border: 0;
  color: #e8fbff;
  background: none;
  box-shadow: none;
}

.form-error {
  min-height: 1.2em;
  margin: 0 !important;
  color: #ffb1a2 !important;
}

.profile-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: left;
}

.profile-summary span {
  border: 1px solid rgba(111, 234, 255, 0.18);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(4, 12, 24, 0.48);
}

.profile-summary b {
  display: block;
  color: var(--text);
  text-align: left;
}

.profile-summary button {
  grid-column: 1 / -1;
}

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

.leaderboard-list {
  display: grid;
  gap: 8px;
  width: 100%;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1.4fr) minmax(86px, 0.8fr) 64px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(111, 234, 255, 0.18);
  border-radius: 6px;
  padding: 10px 12px;
  color: rgba(232, 251, 255, 0.86);
  background: linear-gradient(90deg, rgba(40, 215, 255, 0.08), rgba(3, 8, 17, 0.7), rgba(255, 90, 56, 0.07));
  text-align: left;
}

.leaderboard-row.is-player {
  border-color: rgba(255, 178, 62, 0.74);
  box-shadow: 0 0 20px rgba(255, 178, 62, 0.14);
}

.leaderboard-row b {
  color: var(--amber);
  text-align: left;
}

.leaderboard-empty,
.own-rank-card {
  border: 1px solid rgba(111, 234, 255, 0.18);
  border-radius: 6px;
  padding: 14px;
  color: var(--muted);
  background: rgba(4, 12, 24, 0.5);
}

.own-rank-card {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  text-align: left;
}

.own-rank-card b {
  display: block;
  color: var(--text);
  text-align: left;
}

.achievements-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.achievement-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(111, 234, 255, 0.14);
  border-radius: 6px;
  padding: 12px;
  color: rgba(138, 184, 196, 0.78);
  background: rgba(4, 12, 24, 0.44);
  text-align: left;
}

.achievement-card.unlocked {
  border-color: rgba(40, 215, 255, 0.54);
  color: rgba(232, 251, 255, 0.94);
  box-shadow: 0 0 22px rgba(40, 215, 255, 0.16), inset 0 0 18px rgba(255, 90, 56, 0.05);
}

.achievement-card > b {
  color: var(--amber);
  font-size: 0.64rem;
  text-align: left;
}

.achievement-card span {
  display: grid;
  gap: 4px;
}

.achievement-card strong {
  color: var(--text);
  font-size: 0.88rem;
}

.achievement-card small,
.achievement-card em {
  color: var(--muted);
  font-size: 0.76rem;
  font-style: normal;
}

.achievement-toast {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 120;
  display: grid;
  gap: 4px;
  width: min(320px, calc(100vw - 32px));
  border: 1px solid rgba(255, 178, 62, 0.78);
  border-radius: 6px;
  padding: 14px 16px;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(255, 90, 56, 0.2), rgba(4, 12, 24, 0.96), rgba(40, 215, 255, 0.16));
  box-shadow: 0 0 26px rgba(255, 178, 62, 0.22), 0 0 38px rgba(40, 215, 255, 0.14);
  pointer-events: none;
}

.achievement-toast.hidden {
  display: none;
}

.achievement-toast span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.achievement-toast b {
  color: white;
  font-size: 1rem;
  text-shadow: 0 0 14px rgba(40, 215, 255, 0.65), 0 0 18px rgba(255, 90, 56, 0.28);
}

.cinematic-intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 24% 18%, rgba(40, 215, 255, 0.18), transparent 30%),
    radial-gradient(circle at 74% 76%, rgba(255, 48, 46, 0.16), transparent 34%),
    linear-gradient(145deg, #010207, #030813 44%, #08030b);
  color: var(--text);
}

.cinematic-intro.hidden {
  display: none;
}

.cinematic-intro::before,
.cinematic-intro::after,
.intro-grid {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.cinematic-intro::before {
  background:
    repeating-linear-gradient(0deg, rgba(232, 251, 255, 0.045) 0, rgba(232, 251, 255, 0.045) 1px, transparent 1px, transparent 5px),
    linear-gradient(90deg, transparent 0%, rgba(40, 215, 255, 0.12) 48%, transparent 50%, rgba(255, 90, 56, 0.1) 52%, transparent 100%);
  mix-blend-mode: screen;
  opacity: 0.35;
  animation: introScan 1.4s linear infinite;
}

.cinematic-intro::after {
  background:
    linear-gradient(transparent 42%, rgba(40, 215, 255, 0.18) 43%, rgba(40, 215, 255, 0.02) 46%, transparent 49%),
    radial-gradient(circle, transparent 42%, rgba(0, 0, 0, 0.58));
  opacity: 0.72;
}

.intro-grid {
  background:
    linear-gradient(rgba(40, 215, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(40, 215, 255, 0.1) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to top, black 0%, transparent 70%);
  transform: perspective(520px) rotateX(62deg) translateY(18%);
  transform-origin: 50% 100%;
  animation: introGridDrift 3.2s linear infinite;
}

.intro-frame {
  position: relative;
  z-index: 2;
  width: min(92vw, 860px);
  min-height: min(420px, 62dvh);
  display: grid;
  place-items: center;
  border: 1px solid rgba(111, 234, 255, 0.34);
  border-radius: 6px;
  background:
    linear-gradient(135deg, rgba(3, 8, 17, 0.8), rgba(5, 14, 28, 0.52)),
    repeating-linear-gradient(90deg, rgba(40, 215, 255, 0.05) 0 1px, transparent 1px 26px);
  box-shadow:
    0 0 70px rgba(40, 215, 255, 0.22),
    0 0 90px rgba(255, 90, 56, 0.12),
    inset 0 0 48px rgba(40, 215, 255, 0.07);
  clip-path: polygon(0 12px, 12px 0, calc(100% - 12px) 0, 100% 12px, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px));
}

.intro-frame::before,
.intro-frame::after {
  position: absolute;
  left: 7%;
  right: 7%;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(40, 215, 255, 0.85), rgba(255, 90, 56, 0.6), transparent);
}

.intro-frame::before {
  top: 18%;
}

.intro-frame::after {
  bottom: 18%;
}

.intro-beat {
  position: absolute;
  display: grid;
  gap: 10px;
  width: min(100%, 780px);
  padding: 0 28px;
  text-align: center;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
}

.intro-beat span {
  color: var(--muted);
  font-size: clamp(0.78rem, 2.2vw, 1rem);
  font-weight: 950;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.intro-beat b {
  color: white;
  font-size: clamp(2rem, 7vw, 5.2rem);
  font-weight: 950;
  letter-spacing: 0.02em;
  line-height: 0.92;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(40, 215, 255, 0.9), 0 0 36px rgba(255, 90, 56, 0.28);
}

.intro-beat small {
  color: rgba(232, 251, 255, 0.74);
  font-size: clamp(0.92rem, 2.5vw, 1.2rem);
  font-weight: 800;
}

.intro-beat-dev {
  animation: introBeat 0.82s ease both;
}

.intro-beat-studio {
  animation: introBeat 0.82s ease 0.9s both;
}

.intro-beat-title {
  animation: introTitleBeat 1.24s cubic-bezier(.2, .85, .18, 1) 1.86s both;
}

.intro-skip {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 3;
  min-height: 38px;
  padding: 0 16px;
  color: rgba(232, 251, 255, 0.72);
  font-size: 0.78rem;
}

.countdown {
  color: white;
  font-size: clamp(4rem, 14vw, 10rem);
  font-weight: 950;
  text-shadow: 0 0 22px rgba(40, 215, 255, 0.8), 0 0 44px rgba(255, 90, 56, 0.5);
}

.info-bar {
  margin-top: 14px;
  padding: 12px 14px;
  color: var(--muted);
  flex-wrap: wrap;
}

.info-bar p {
  margin: 0;
}

.info-bar strong {
  color: var(--text);
}

#difficultyLabel {
  color: var(--amber);
  font-weight: 900;
}

#divisionLabel,
#levelLabel,
#medalLabel,
#boostLabel {
  color: var(--amber);
  font-weight: 900;
}

#boostLabel.boost-ready {
  animation: boostReadyPulse 1.1s ease-in-out infinite alternate;
  text-shadow: 0 0 12px rgba(255, 178, 62, 0.9);
}

.touch-controls {
  display: none;
  grid-template-columns: auto minmax(130px, 1fr);
  align-items: end;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  touch-action: none;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 62px);
  gap: 8px;
}

.touch-actions {
  display: grid;
  gap: 8px;
}

.touch-controls button {
  min-width: 0;
  min-height: 54px;
  padding: 0 12px;
  user-select: none;
  touch-action: none;
}

@keyframes introBeat {
  0% {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(18px) scale(0.98);
  }
  16%, 72% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    filter: blur(5px);
    transform: translateY(-12px) scale(1.02);
  }
}

@keyframes introTitleBeat {
  0% {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(18px) scale(0.96);
  }
  20%, 100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes introScan {
  from { transform: translateY(-18px); }
  to { transform: translateY(18px); }
}

@keyframes introGridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 0 48px, 48px 48px; }
}

@keyframes overlayScan {
  from { transform: translateY(-12px); }
  to { transform: translateY(12px); }
}

@keyframes titleGridDrift {
  from { background-position: 0 0, 0 0, 0 0; }
  to { background-position: 0 58px, 58px 58px, 0 0; }
}

@keyframes titleGlowBreath {
  0%, 100% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.12) saturate(1.12);
  }
}

@keyframes titleLightSweep {
  0%, 48% {
    opacity: 0;
    transform: translateX(-220%);
  }
  55% {
    opacity: 0.55;
  }
  68%, 100% {
    opacity: 0;
    transform: translateX(220%);
  }
}

@keyframes titleMicroFlicker {
  0%, 93%, 100% {
    transform: translate3d(0, 0, 0);
  }
  94% {
    transform: translate3d(1px, 0, 0);
  }
  95% {
    transform: translate3d(-1px, 0, 0);
  }
}

@keyframes titlePromptPulse {
  0%, 100% {
    opacity: 0.48;
  }
  50% {
    opacity: 0.82;
  }
}

@keyframes shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-7px, 3px, 0); }
  50% { transform: translate3d(6px, -3px, 0); }
  75% { transform: translate3d(-4px, -2px, 0); }
}

@keyframes bossPulse {
  from {
    filter: saturate(1.05) brightness(1);
  }
  to {
    filter: saturate(1.35) brightness(1.15);
  }
}

@keyframes boostReadyPulse {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.45);
  }
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 1ms !important;
}

body.reduced-motion .arena-wrap.shake,
body.reduced-motion .arena-wrap.boss-intro,
body.reduced-motion .cinematic-intro::before,
body.reduced-motion .intro-grid,
body.reduced-motion .overlay::after,
body.reduced-motion #boostLabel.boost-ready,
body.reduced-motion .title-screen-mark,
body.reduced-motion .title-screen-mark::after,
body.reduced-motion .title-screen-prompt,
body.reduced-motion[data-presentation-state="main_menu"] .arena-wrap::after,
body.reduced-motion[data-presentation-state="options"] .arena-wrap::after {
  animation: none !important;
}

@media (max-width: 760px), (pointer: coarse) and (max-width: 940px) {
  html,
  body {
    width: 100%;
    height: var(--app-height, 100dvh);
    min-height: var(--app-height, 100dvh);
    overflow-x: hidden;
  }

  .game-shell {
    width: 100%;
    max-width: 680px;
    min-height: var(--app-height, 100dvh);
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .cinematic-intro {
    padding:
      max(12px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .intro-frame {
    width: min(94vw, 560px);
    min-height: min(390px, 58dvh);
  }

  .intro-beat {
    padding: 0 18px;
  }

  .intro-beat b {
    font-size: clamp(2rem, 13vw, 4.8rem);
    overflow-wrap: anywhere;
  }

  .intro-skip {
    min-height: 42px;
  }

  .top-bar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .top-bar > div:first-child {
    width: 100%;
    min-width: 0;
  }

  .top-bar h1 {
    display: grid;
    justify-items: center;
    max-width: 100%;
    font-size: clamp(2rem, 10.5vw, 3.35rem);
    line-height: 0.9;
    text-align: center;
    overflow: visible;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .title-word {
    display: block;
    max-width: 100%;
  }

  .eyebrow {
    margin-bottom: 3px;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
  }

  .scoreboard {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .scoreboard div {
    min-height: 48px;
  }

  .scoreboard span {
    font-size: 1.2rem;
  }

  .scoreboard small {
    font-size: 0.64rem;
  }
  .run-status-panel {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 10px;
  }

  .run-status-primary {
    display: grid;
    gap: 2px;
  }

  .run-status-primary b {
    font-size: 0.82rem;
  }

  .run-status-primary span {
    font-size: 0.76rem;
  }

  .run-status-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 6px;
    font-size: 0.68rem;
  }

  .run-status-meta span {
    min-width: 0;
    overflow: hidden;
    border-left: 0;
    padding-left: 0;
    text-overflow: ellipsis;
  }
  .arena-wrap {
    width: min(100%, calc(var(--app-height, 100dvh) * 0.54));
    margin-top: 8px;
    margin-right: auto;
    margin-left: auto;
  }

  canvas {
    aspect-ratio: 16 / 10;
    max-height: none;
    min-height: 0;
  }

  .touch-controls {
    display: grid;
    width: 100%;
    max-width: 680px;
    grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
    align-items: stretch;
    gap: 8px;
    margin: 8px auto 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .info-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 10px;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .mobile-optional,
  #statusText {
    display: none;
  }

  .desktop-control,
  .dev-control {
    display: none !important;
  }

  .overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    align-items: center;
    overflow: hidden;
    padding:
      max(12px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(12px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
    background: rgba(1, 4, 10, 0.28);
  }

  .overlay-panel {
    width: min(94vw, 560px);
    max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px);
    min-height: 0;
    padding: 16px 16px 12px;
  }

  .overlay-panel > .eyebrow,
  .overlay h2,
  .overlay p,
  .difficulty {
    flex-shrink: 0;
  }

  .overlay h2 {
    font-size: clamp(2rem, 12vw, 3.2rem);
    line-height: 0.98;
  }

  .overlay p {
    margin: 8px 0 0;
    line-height: 1.35;
    font-size: 0.9rem;
  }

  .difficulty,
  .actions {
    gap: 8px;
    margin-top: 12px;
  }

  body[data-overlay-mode="menu"] .actions {
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body[data-overlay-mode="menu"] #startBtn,
  body[data-overlay-mode="menu"] #settingsBtn {
    min-height: 52px;
    font-size: 0.98rem;
  }

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

  .option-toggle {
    min-height: 58px;
  }

  body[data-overlay-mode="next"] .difficulty,
  body[data-overlay-mode="retry"] .difficulty,
  body[data-overlay-mode="trialNext"] .difficulty,
  body[data-overlay-mode="trialFailed"] .difficulty,
  body[data-overlay-mode="ascensionNext"] .difficulty,
  body[data-overlay-mode="finalVictory"] .difficulty {
    display: none;
  }

  .actions {
    order: 20;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 8px 0 0;
    background: linear-gradient(to top, rgba(3, 8, 17, 0.96) 78%, rgba(3, 8, 17, 0));
  }

  .difficulty button,
  .actions button {
    min-height: 40px;
    padding: 0 13px;
  }

  .menu-panel {
    order: 12;
    max-height: min(390px, 48dvh);
    min-height: 0;
  }

  #levelSelectMenu {
    max-height: min(380px, 48dvh);
  }

  .round-summary {
    order: 16;
    flex: 1;
    min-height: 0;
    max-height: min(160px, 24dvh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body:not(.dev-mode) .round-summary {
    display: none !important;
  }

  .round-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .game-shell {
    width: 100%;
  }

  .scoreboard div {
    min-height: 44px;
  }

  .scoreboard span {
    font-size: 1.12rem;
  }

  canvas {
    min-height: 180px;
  }

  .touch-controls {
    grid-template-columns: minmax(0, 1fr);
  }

  .touch-dpad {
    grid-template-columns: repeat(3, minmax(48px, 1fr));
    gap: 6px;
  }

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

  .touch-controls button {
    min-height: 46px;
    padding: 0 6px;
    font-size: clamp(0.82rem, 3.5vw, 1rem);
  }

  .overlay-panel {
    width: min(96vw, 520px);
    padding: 14px 12px 10px;
  }

  .overlay h2 {
    font-size: clamp(1.85rem, 11vw, 2.8rem);
  }

  body[data-overlay-mode="menu"] .actions,
  .arcade-options {
    grid-template-columns: 1fr;
  }

  body[data-overlay-mode="menu"] #startBtn,
  body[data-overlay-mode="menu"] #settingsBtn {
    min-height: 48px;
  }

  .round-summary-grid {
    font-size: 0.72rem;
  }

  .round-summary.round-summary--compact {
    max-height: 104px;
    overflow-y: auto;
  }
}

@media (max-width: 520px) and (max-height: 720px) {
  .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));
  }

  .top-bar {
    gap: 5px;
  }

  .top-bar h1 {
    font-size: clamp(1.55rem, 8.8vw, 2.25rem);
    line-height: 0.88;
  }

  .eyebrow {
    font-size: 0.58rem;
    margin-bottom: 2px;
  }

  .scoreboard {
    gap: 4px;
  }

  .scoreboard div {
    min-height: 36px;
  }

  .scoreboard span {
    font-size: 0.98rem;
  }

  .scoreboard small {
    font-size: 0.52rem;
  }
  .run-status-panel {
    margin-top: 6px;
    padding: 6px 8px;
  }

  .run-status-primary span,
  .run-status-meta {
    font-size: 0.62rem;
  }
  .arena-wrap {
    width: min(100%, calc(var(--app-height, 100dvh) * 0.5));
    margin-top: 6px;
  }

  canvas {
    min-height: 0;
  }

  .info-bar {
    gap: 4px 8px;
    margin-top: 6px;
    padding: 6px 8px;
    font-size: 0.68rem;
  }

  .touch-controls {
    gap: 6px;
    margin-top: 6px;
  }

  .touch-controls button {
    min-height: 40px;
    font-size: 0.78rem;
  }

  .overlay {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
  }

  .overlay-panel {
    max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    padding: 12px 10px 8px;
  }

  .overlay h2 {
    font-size: clamp(1.5rem, 9vw, 2.25rem);
  }

  .difficulty,
  .actions {
    margin-top: 8px;
  }

  .round-summary,
  .round-summary.round-summary--compact {
    max-height: min(90px, 17dvh);
  }
}

@media (max-width: 380px) {
  .top-bar h1 {
    font-size: clamp(1.85rem, 10vw, 2.45rem);
  }

  .info-bar {
    grid-template-columns: 1fr;
  }

  .scoreboard small {
    font-size: 0.58rem;
  }

  .touch-controls button {
    min-height: 42px;
  }
}

@media (max-height: 540px) and (orientation: landscape) {
  .game-shell {
    width: min(100vw - 16px, 1080px);
    padding-top: 8px;
  }

  .top-bar {
    flex-direction: row;
    align-items: center;
  }

  .top-bar h1 {
    font-size: clamp(1.8rem, 5vw, 3.2rem);
  }

  .eyebrow {
    margin-bottom: 2px;
  }

  canvas {
    max-height: calc(100dvh - 164px);
    min-height: 260px;
  }

  .info-bar {
    margin-top: 8px;
    padding: 8px 10px;
  }

  .touch-controls {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 5;
    grid-template-columns: auto auto;
    opacity: 0.78;
  }

  .touch-dpad {
    grid-template-columns: repeat(3, 48px);
  }

  .touch-actions {
    width: 104px;
  }

  .touch-controls button {
    min-height: 44px;
    font-size: 0.82rem;
  }
}

@media (max-width: 760px), (pointer: coarse) and (max-width: 940px) {
  body[data-presentation-state="main_menu"] .game-shell,
  body[data-presentation-state="options"] .game-shell {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body[data-presentation-state="main_menu"] .overlay,
  body[data-presentation-state="options"] .overlay {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body[data-presentation-state="main_menu"] .overlay-panel {
    width: min(94vw, 560px);
    height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    padding: 28px clamp(14px, 5vw, 22px) 24px;
  }

  .title-screen-studio {
    margin-bottom: clamp(22px, 4.4dvh, 34px);
    font-size: 0.66rem;
    letter-spacing: 0.22em;
  }

  .title-screen-mark {
    width: min(100%, 340px);
  }

  .title-screen-mark::before {
    inset: -12% -4% 2%;
    filter: blur(14px);
  }

  .title-screen-main {
    max-width: 100%;
    font-size: clamp(2.18rem, min(11.2vw, 6dvh), 3.2rem);
    letter-spacing: 0.005em;
  }

  .title-screen-sub {
    max-width: 100%;
    font-size: clamp(1.82rem, min(9.2vw, 4.9dvh), 2.56rem);
    letter-spacing: 0.045em;
  }

  .title-energy-line {
    width: min(300px, 78%);
    margin-top: clamp(12px, 2dvh, 16px);
  }

  .title-screen-tagline {
    max-width: 280px;
    margin-top: clamp(18px, 3dvh, 24px);
    font-size: 0.76rem;
    line-height: 1.45;
    letter-spacing: 0.09em;
  }

  .title-screen-divider {
    width: min(210px, 64%);
    margin-top: clamp(18px, 3dvh, 24px);
  }

  body[data-presentation-state="main_menu"] .actions {
    width: min(300px, 84vw);
    gap: 12px;
    margin-top: clamp(18px, 3dvh, 24px);
  }

  body[data-presentation-state="main_menu"] #startBtn {
    min-height: 56px;
  }

  body[data-presentation-state="main_menu"] #settingsBtn {
    min-height: 46px;
  }

  body[data-presentation-state="main_menu"] .title-screen-prompt {
    max-width: 300px;
    margin-top: clamp(18px, 3dvh, 24px);
    font-size: 0.62rem;
    line-height: 1.35;
    letter-spacing: 0.16em;
  }

  body[data-presentation-state="options"] .overlay-panel {
    width: min(92vw, 440px);
    min-height: min(430px, calc(var(--app-height, 100dvh) - 28px));
    padding: 34px 22px 26px;
  }

  body[data-presentation-state="callsign"] .game-shell,
  body[data-presentation-state="profile"] .game-shell,
  body[data-presentation-state="leaderboard"] .game-shell,
  body[data-presentation-state="achievements"] .game-shell {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body[data-presentation-state="callsign"] .overlay,
  body[data-presentation-state="profile"] .overlay,
  body[data-presentation-state="leaderboard"] .overlay,
  body[data-presentation-state="achievements"] .overlay {
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  body[data-presentation-state="callsign"] .overlay-panel,
  body[data-presentation-state="profile"] .overlay-panel,
  body[data-presentation-state="leaderboard"] .overlay-panel,
  body[data-presentation-state="achievements"] .overlay-panel {
    width: min(94vw, 560px);
    max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 20px);
    padding: 30px clamp(14px, 5vw, 22px) 22px;
  }

  .callsign-panel,
  .social-panel {
    max-height: calc(var(--app-height, 100dvh) - 92px);
  }

  .leaderboard-row {
    grid-template-columns: 42px minmax(0, 1fr) minmax(78px, 0.8fr) 46px;
    gap: 7px;
    padding: 9px 10px;
    font-size: 0.78rem;
  }

  .own-rank-card,
  .achievements-list,
  .panel-actions,
  .profile-summary {
    grid-template-columns: 1fr;
  }

  .achievement-card {
    grid-template-columns: 68px 1fr;
  }
}

@media (max-width: 380px), (max-height: 680px) {
  body[data-presentation-state="main_menu"] .overlay-panel {
    padding: 22px 14px 18px;
  }

  .title-screen-studio {
    margin-bottom: 20px;
    font-size: 0.58rem;
    letter-spacing: 0.18em;
  }

  .title-screen-mark {
    width: min(100%, 292px);
  }

  .title-screen-main {
    font-size: clamp(1.98rem, min(10.4vw, 5.6dvh), 2.72rem);
  }

  .title-screen-sub {
    font-size: clamp(1.64rem, min(8.4vw, 4.4dvh), 2.18rem);
  }

  .title-screen-tagline,
  .title-screen-divider,
  body[data-presentation-state="main_menu"] .actions,
  body[data-presentation-state="main_menu"] .title-screen-prompt {
    margin-top: 18px;
  }

  body[data-presentation-state="main_menu"] #startBtn {
    min-height: 50px;
  }

  body[data-presentation-state="main_menu"] #settingsBtn {
    min-height: 42px;
  }
}

/* Premium: a warm gold accent so the offer reads apart from the cyan/red duel palette. */
.premium-btn {
  border-color: rgba(255, 203, 92, 0.72) !important;
  color: #ffe6a8 !important;
  background: linear-gradient(135deg, rgba(64, 42, 6, 0.86), rgba(24, 14, 2, 0.9)) !important;
  box-shadow: 0 0 18px rgba(255, 190, 64, 0.28), inset 0 0 14px rgba(255, 203, 92, 0.12) !important;
}

.premium-btn:hover,
.premium-btn:focus-visible {
  border-color: #ffd36b !important;
  box-shadow: 0 0 26px rgba(255, 190, 64, 0.46), inset 0 0 16px rgba(255, 203, 92, 0.18) !important;
}

body[data-overlay-mode="premium"] .difficulty {
  display: none !important;
}

.profile-summary span:nth-of-type(3) {
  grid-column: 1 / -1;
}

#premiumStatusLabel.premium-active {
  color: #ffd36b;
}

/* Landscape phones: the portrait-tuned title menu is taller than the screen. */
@media (orientation: landscape) and (max-height: 540px) {
  body[data-presentation-state="main_menu"] .overlay-panel,
  body[data-presentation-state="options"] .overlay-panel {
    width: min(94vw, 760px);
    height: auto;
    min-height: 0;
    max-height: calc(var(--app-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 16px);
    justify-content: safe center;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px clamp(16px, 4vw, 32px) 14px;
  }

  body[data-presentation-state="main_menu"] .title-screen-studio {
    display: none;
  }

  body[data-presentation-state="main_menu"] .title-screen-mark {
    width: min(100%, 360px);
  }

  body[data-presentation-state="main_menu"] .title-screen-main {
    font-size: clamp(1.6rem, 9dvh, 2.6rem);
  }

  body[data-presentation-state="main_menu"] .title-screen-sub {
    font-size: clamp(1.3rem, 7dvh, 2rem);
  }

  body[data-presentation-state="main_menu"] .title-energy-line {
    margin-top: 6px;
  }

  body[data-presentation-state="main_menu"] .title-screen-tagline,
  body[data-presentation-state="main_menu"] .title-screen-divider {
    margin-top: 8px;
  }

  body[data-presentation-state="main_menu"] .title-screen-tagline {
    max-width: none;
  }

  body[data-presentation-state="main_menu"] .actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(560px, 100%);
    gap: 8px;
    margin-top: 12px;
    position: static;
  }

  body[data-presentation-state="main_menu"] #startBtn,
  body[data-presentation-state="main_menu"] #premiumBuyBtn,
  body[data-presentation-state="main_menu"] #premiumMenuBtn {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  body[data-presentation-state="main_menu"] .actions button,
  body[data-presentation-state="main_menu"] #settingsBtn {
    min-width: 0;
    min-height: 40px;
    padding: 0 10px;
  }

  body[data-presentation-state="main_menu"] .title-screen-prompt {
    display: none;
  }

  body[data-presentation-state="options"] #settingsPanel {
    width: min(640px, 100%);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    align-items: start;
  }

  body[data-presentation-state="options"] #settingsPanel h3 {
    grid-column: 1 / -1;
    margin-bottom: 12px;
    font-size: 1.25rem;
  }

  body[data-presentation-state="options"] #settingsPanel .mix-console {
    grid-column: 1 / -1;
  }

  body[data-presentation-state="options"] .arcade-options {
    gap: 8px;
  }

  body[data-presentation-state="options"] .arcade-options > button {
    min-height: 44px;
  }
}
