:root {
  --ink: #171824;
  --deck: #c9c6b7;
  --deck-light: #e3dfcf;
  --deck-shadow: #918d82;
  --screen: #14213c;
  --accent: #b82951;
  --accent-dark: #721b3a;
}

* {
  box-sizing: border-box;
}

/* `hidden` must win over the layout display rules below. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 10%, #34364d, #12131d 58%),
    #12131d;
  font-family: Arial, Helvetica, sans-serif;
}

button {
  font: inherit;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

.shell {
  width: min(100%, 440px);
  height: 100svh;
  margin: 0 auto;
  display: block;
  overflow: hidden;
  background: var(--deck);
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.55);
}

.masthead,
.hardware-mark,
.controls {
  display: none;
}

.game-wrap {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 74fr) minmax(0, 26fr);
}

.screen-bezel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--screen);
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  outline: none;
  background: var(--screen);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: none;
}

.game-wrap[data-game="starfall"] canvas {
  image-rendering: auto;
}

.screen-glare {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.08), transparent 18%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 3px,
      rgba(255, 255, 255, 0.012) 4px
    );
  mix-blend-mode: screen;
}

.arcade-menu {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: max(18px, 3.5svh) 18px 18px;
  color: #effbff;
  background:
    linear-gradient(rgba(8, 15, 38, 0.86), rgba(4, 8, 24, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(89, 235, 255, 0.08) 4px);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.arcade-menu[hidden] {
  display: none;
}

.arcade-menu-head {
  display: grid;
  justify-items: center;
  gap: 5px;
  font-family: "Arial Narrow", Arial, sans-serif;
  letter-spacing: 0.16em;
}

.arcade-menu-head span {
  color: #62efff;
  font-size: 9px;
  font-weight: 900;
}

.arcade-menu-head strong {
  font-size: clamp(22px, 7vw, 32px);
  text-shadow: 0 3px #192256;
}

/* ---------------------------------------------------- profile + boards */

.profile-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(111, 240, 255, 0.32);
  border-radius: 9px;
  background: linear-gradient(150deg, #1c2a5c, #101733);
  color: #eaf6ff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.profile-strip:active,
.profile-strip:hover {
  border-color: #65f3ff;
}

.profile-strip.is-nudging {
  border-color: #ffd166;
  animation: profile-nudge 1.4s ease-in-out infinite;
}

.profile-strip.is-nudging .profile-copy small { color: #ffd166; }

@keyframes profile-nudge {
  50% { box-shadow: 0 0 16px rgba(255, 209, 102, 0.4); }
}

.profile-emblem {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(111, 240, 255, 0.5);
  background: #0d1430;
  font-size: 15px;
}

.profile-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.profile-copy strong {
  font: 900 11px Arial, sans-serif;
  letter-spacing: 0.12em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-copy small {
  color: rgba(209, 236, 255, 0.6);
  font-size: 7px;
  letter-spacing: 0.11em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-edit {
  flex: none;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.14em;
}

.game-best {
  display: block;
  margin-top: 3px;
  color: #70efff;
  font: 900 6px Arial, sans-serif;
  letter-spacing: 0.12em;
  min-height: 8px;
}

.profile-sheet,
.boards {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px;
  background: linear-gradient(180deg, #101a3d, #080b1c);
  color: #eaf6ff;
  overflow: hidden;
}

.profile-sheet-head,
.boards-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex: none;
}

.profile-sheet-head span,
.boards-head span {
  display: block;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.18em;
}

.profile-sheet-head h2,
.boards-head h2 {
  margin: 3px 0 0;
  font: 900 15px Arial, sans-serif;
  letter-spacing: 0.1em;
}

.profile-close,
.boards-close {
  flex: none;
  border: 1px solid rgba(111, 240, 255, 0.4);
  border-radius: 7px;
  background: #131c42;
  color: #cfe9ff;
  font: 900 8px Arial, sans-serif;
  letter-spacing: 0.14em;
  padding: 8px 11px;
  cursor: pointer;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: none;
}

.profile-form label,
.profile-label {
  color: rgba(209, 236, 255, 0.7);
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.18em;
}

.profile-form input {
  border: 1px solid rgba(111, 240, 255, 0.4);
  border-radius: 8px;
  background: #0b1130;
  color: #eaf6ff;
  font: 900 16px "Courier New", monospace;
  letter-spacing: 0.16em;
  text-align: center;
  text-transform: uppercase;
  padding: 9px 8px;
  outline: none;
}

.profile-form input:focus { border-color: #65f3ff; }

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

.emblem-option {
  aspect-ratio: 1;
  border: 1px solid rgba(111, 240, 255, 0.28);
  border-radius: 7px;
  background: #0b1130;
  color: #cfe9ff;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.emblem-option.is-selected {
  border-color: #65f3ff;
  background: #16255c;
  box-shadow: 0 0 10px rgba(101, 243, 255, 0.35);
}

#profile-save {
  margin-top: 2px;
  border: 1px solid #65f3ff;
  border-radius: 8px;
  background: linear-gradient(180deg, #1d4d78, #122c52);
  color: #f2fbff;
  font: 900 11px Arial, sans-serif;
  letter-spacing: 0.16em;
  padding: 10px;
  cursor: pointer;
}

.profile-status {
  margin: 0;
  min-height: 10px;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.12em;
  text-align: center;
}

.profile-bests {
  border-top: 1px solid rgba(111, 240, 255, 0.18);
  padding-top: 8px;
  overflow-y: auto;
  min-height: 0;
}

.profile-bests h3 {
  margin: 0 0 6px;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.18em;
}

.best-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(111, 240, 255, 0.08);
  font: 700 9px Arial, sans-serif;
  letter-spacing: 0.08em;
  color: rgba(220, 238, 255, 0.75);
}

.best-row strong { color: #eaf6ff; }

.boards-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  flex: none;
}

.boards-tab {
  border: 1px solid rgba(111, 240, 255, 0.26);
  border-radius: 7px;
  background: #0d1430;
  color: rgba(220, 238, 255, 0.72);
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.08em;
  padding: 8px 2px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}

.boards-tab.is-active {
  border-color: #65f3ff;
  background: #16255c;
  color: #f2fbff;
}

.boards-status {
  margin: 0;
  flex: none;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.14em;
  text-align: center;
}

.boards-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.boards-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(111, 240, 255, 0.14);
  border-radius: 7px;
  background: rgba(13, 20, 48, 0.85);
  font: 700 10px Arial, sans-serif;
  letter-spacing: 0.06em;
}

.boards-row.is-me {
  border-color: #65f3ff;
  background: #16255c;
}

.boards-rank {
  color: #70efff;
  font: 900 9px "Courier New", monospace;
}

.boards-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boards-score {
  color: rgba(220, 238, 255, 0.85);
  font: 900 9px "Courier New", monospace;
  white-space: nowrap;
}

.game-library {
  align-self: center;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.game-library::-webkit-scrollbar {
  display: none;
}

.game-card {
  position: relative;
  min-width: 0;
  padding: 7px 7px 10px;
  overflow: hidden;
  border: 2px solid rgba(111, 240, 255, 0.38);
  border-radius: 8px;
  color: #f7fbff;
  background: linear-gradient(150deg, #243164, #111737);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.28);
  text-align: left;
  text-decoration: none;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.game-card:active,
.game-card.is-current {
  border-color: #65f3ff;
  background: linear-gradient(150deg, #304781, #15204c);
}

.game-number {
  display: block;
  margin-bottom: 7px;
  color: #70efff;
  font: 900 7px Arial, sans-serif;
  letter-spacing: 0.14em;
}

.game-art {
  position: relative;
  display: block;
  height: clamp(72px, 15svh, 116px);
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background-color: #132440;
}

.bramble-art {
  background:
    radial-gradient(circle at 28% 60%, #f8f4ee 0 5%, #273561 5.5% 10%, transparent 10.5%),
    repeating-linear-gradient(90deg, rgba(39, 126, 71, 0.6) 0 1px, transparent 1px 24px),
    repeating-linear-gradient(0deg, rgba(39, 126, 71, 0.6) 0 1px, transparent 1px 20px),
    #58ca63;
}

.bramble-art::before,
.bramble-art::after {
  content: "";
  position: absolute;
  width: 21%;
  aspect-ratio: 1.25;
  border-top: 5px solid #e3f8ff;
  border-right: 5px solid #66a9ce;
  border-bottom: 5px solid #3974a6;
  background: #e3f8ff;
}

.bramble-art::before {
  left: 48%;
  top: 14%;
}

.bramble-art::after {
  right: 8%;
  bottom: 12%;
}

.copter-art {
  background:
    linear-gradient(168deg, #197832 0 27%, transparent 28%),
    linear-gradient(12deg, transparent 0 61%, #197832 62%),
    #020805;
}

.copter-art::before {
  content: "";
  position: absolute;
  left: 28%;
  top: 45%;
  width: 29%;
  height: 12%;
  background: #68ff7f;
  box-shadow:
    9px -5px 0 -2px #68ff7f,
    -14px -8px 0 -5px #68ff7f,
    31px 3px 0 -4px #68ff7f;
}

.copter-art::after {
  content: "";
  position: absolute;
  left: 17%;
  top: 34%;
  width: 49%;
  height: 2px;
  background: #b6ffc0;
}

.starfall-art {
  background:
    radial-gradient(ellipse at 50% 82%, rgba(118, 192, 222, 0.88) 0 22%, transparent 23%),
    linear-gradient(#010206 0 45%, #21455f 46% 74%, #17191f 75%);
}

.starfall-art::before {
  content: "";
  position: absolute;
  left: 37%;
  bottom: 6%;
  width: 26%;
  height: 17%;
  clip-path: polygon(44% 0, 56% 0, 60% 38%, 100% 80%, 78% 100%, 22% 100%, 0 80%, 40% 38%);
  background: linear-gradient(90deg, #c981dd, #5d337e);
  box-shadow: 0 4px 6px #000;
}

.starfall-art::after {
  content: "✦ ✦ ✦ ✦\A ✦ ✦ ✦ ✦";
  position: absolute;
  left: 0;
  right: 0;
  top: 18%;
  color: #7eda68;
  font: 900 9px/1.8 "Courier New", monospace;
  text-align: center;
  white-space: pre;
  text-shadow: 0 0 5px #a947ff;
}

.wargrid-art {
  background:
    linear-gradient(rgba(7, 9, 7, 0.08), rgba(7, 9, 7, 0.2)),
    url("assets/wargrid-preview.jpg") center / cover no-repeat;
  image-rendering: pixelated;
}

.wargrid-card {
  border-color: rgba(221, 160, 43, 0.52);
  background: linear-gradient(150deg, #4b3a1d, #171813);
}

.wargrid-card:active {
  border-color: #f6c44f;
  background: linear-gradient(150deg, #665024, #22231a);
}

.wargrid-card .game-number {
  color: #f6c44f;
}

.ironwake-card {
  grid-column: 1 / -1;
  border-color: rgba(100, 230, 196, 0.5);
  background: linear-gradient(150deg, #123a3f, #0a1620);
}

.ironwake-card:active {
  border-color: #64e6c4;
  background: linear-gradient(150deg, #1a5152, #101f2c);
}

.ironwake-card .game-number {
  color: #64e6c4;
}

.ironwake-art {
  height: clamp(56px, 9svh, 84px);
  background:
    radial-gradient(circle at 18% 34%, rgba(240, 250, 252, 0.85) 0 2.2%, transparent 3.4%),
    radial-gradient(circle at 30% 66%, rgba(240, 250, 252, 0.75) 0 2.2%, transparent 3.4%),
    radial-gradient(circle at 62% 30%, rgba(255, 95, 95, 0.95) 0 2.6%, transparent 3.8%),
    radial-gradient(circle at 70% 30%, rgba(255, 95, 95, 0.95) 0 2.6%, transparent 3.8%),
    radial-gradient(circle at 86% 62%, rgba(240, 250, 252, 0.7) 0 2.2%, transparent 3.4%),
    repeating-linear-gradient(90deg, rgba(76, 156, 186, 0.28) 0 1px, transparent 1px 12.5%),
    repeating-linear-gradient(0deg, rgba(76, 156, 186, 0.28) 0 1px, transparent 1px 25%),
    linear-gradient(180deg, #0e2c42, #071523);
}

.ironwake-art::before {
  content: "";
  position: absolute;
  left: 56%;
  top: 24%;
  width: 22%;
  height: 16%;
  border-radius: 999px;
  background: linear-gradient(180deg, #90a7b8, #4c5f6d);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55);
}

.ironwake-art::after {
  content: "";
  position: absolute;
  left: 33%;
  top: 52%;
  width: 13%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 196, 107, 0.9);
  border-radius: 50%;
  background:
    linear-gradient(rgba(255, 196, 107, 0.9) 0 0) center / 100% 2px no-repeat,
    linear-gradient(rgba(255, 196, 107, 0.9) 0 0) center / 2px 100% no-repeat;
}

.grubfire-card {
  grid-column: 1 / -1;
  border-color: rgba(255, 178, 74, 0.5);
  background: linear-gradient(150deg, #3d2a12, #171009);
}

.grubfire-card:active {
  border-color: #ffb24a;
  background: linear-gradient(150deg, #54391a, #211609);
}

.grubfire-card .game-number {
  color: #ffb24a;
}

.grubfire-art {
  height: clamp(56px, 9svh, 84px);
  background:
    /* worm on the ridge */
    radial-gradient(ellipse 7% 26% at 24% 44%, #f2b3c4 0 98%, transparent 100%),
    /* sky */
    linear-gradient(180deg, #7ec8f2 0 52%, transparent 52%),
    /* ridge with a blasted crater */
    radial-gradient(circle 26px at 62% 78%, #2b1a0e 0 62%, transparent 63%),
    linear-gradient(172deg, transparent 0 46%, #6e4426 47% 78%, #4a2c18 79%),
    #7ec8f2;
}

.grubfire-art::before {
  content: "";
  position: absolute;
  left: 20%;
  top: 22%;
  width: 11%;
  height: 7%;
  border-radius: 4px;
  background: #3e7fe0;
}

.grubfire-art::after {
  content: "";
  position: absolute;
  right: 14%;
  top: 26%;
  width: 13%;
  aspect-ratio: 1;
  border: 2px dashed rgba(255, 217, 74, 0.95);
  border-radius: 50%;
  background:
    linear-gradient(rgba(255, 217, 74, 0.95) 0 0) center / 100% 2px no-repeat,
    linear-gradient(rgba(255, 217, 74, 0.95) 0 0) center / 2px 100% no-repeat;
}

.game-card strong,
.game-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-card strong {
  font-size: clamp(10px, 3.1vw, 14px);
  letter-spacing: 0.04em;
}

.game-card small {
  margin-top: 4px;
  color: rgba(220, 235, 255, 0.56);
  font-size: 6px;
  letter-spacing: 0.13em;
}

.menu-hint {
  color: rgba(209, 236, 255, 0.54);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.menu-actions {
  display: grid;
  justify-items: center;
  gap: 11px;
}

.open-leaderboard,
.leaderboard button,
.score-prompt {
  border: 1px solid #5df275;
  border-radius: 4px;
  color: #bcffc3;
  background: #06150a;
  box-shadow: inset 0 0 0 1px rgba(129, 255, 143, 0.12);
  font: 900 8px "Courier New", monospace;
  letter-spacing: 0.1em;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.open-leaderboard {
  padding: 8px 17px;
}

.leaderboard {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 20px 18px max(18px, env(safe-area-inset-bottom));
  color: #baffc0;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(116, 255, 130, 0.045) 4px),
    #010a04;
  font-family: "Courier New", monospace;
  touch-action: pan-y pinch-zoom;
}

.leaderboard[hidden] {
  display: none;
}

.leaderboard-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid #35d950;
}

.leaderboard-head span {
  color: #52d967;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.leaderboard-head h2 {
  margin: 3px 0 0;
  font-size: clamp(22px, 7vw, 30px);
  line-height: 1;
  text-shadow: 0 0 9px rgba(77, 255, 96, 0.3);
}

.leaderboard-close {
  padding: 7px 10px;
}

.leaderboard-status {
  min-height: 12px;
  margin: 0;
  color: #62db72;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.leaderboard-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  list-style: none;
  counter-reset: score-rank;
}

.leaderboard-list li {
  counter-increment: score-rank;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 32px;
  border-bottom: 1px solid rgba(81, 232, 99, 0.18);
  font-size: 10px;
  font-weight: 900;
}

.leaderboard-list li::before {
  content: counter(score-rank, decimal-leading-zero);
  color: #3aab4a;
}

.leaderboard-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list b {
  color: #e0ffe3;
}

.leaderboard-list .empty-score {
  display: block;
  padding-top: 40px;
  border: 0;
  color: rgba(117, 230, 129, 0.55);
  text-align: center;
}

.leaderboard-list .empty-score::before {
  content: none;
}

.score-form {
  padding-top: 11px;
  border-top: 1px solid rgba(81, 232, 99, 0.35);
}

.score-form label {
  display: block;
  margin-bottom: 6px;
  color: #52d967;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.score-form > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
}

.score-form input {
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #3dd755;
  border-radius: 3px;
  outline: none;
  color: #e2ffe5;
  background: #031107;
  font: 900 16px "Courier New", monospace;
  text-transform: uppercase;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

.score-form input:focus {
  border-color: #a7ffaf;
  box-shadow: 0 0 0 2px rgba(103, 255, 119, 0.16);
}

.score-form button {
  min-width: 104px;
  padding: 0 10px;
}

.score-entry {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  padding: 18px;
  color: #c8ffcd;
  background:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(116, 255, 130, 0.045) 4px),
    rgba(1, 9, 4, 0.94);
  font-family: "Courier New", monospace;
  touch-action: pan-y pinch-zoom;
}

.score-entry[hidden] {
  display: none;
}

.score-entry-panel {
  width: min(100%, 350px);
  padding: 20px 18px 18px;
  border: 2px solid #46e361;
  border-radius: 8px;
  background: rgba(1, 14, 6, 0.96);
  box-shadow:
    inset 0 0 0 2px rgba(128, 255, 142, 0.08),
    0 12px 30px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.score-entry-kicker {
  display: block;
  color: #55dc69;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.score-entry-value {
  display: block;
  margin-top: 6px;
  color: #e3ffe6;
  font-size: clamp(34px, 11vw, 48px);
  line-height: 1;
  text-shadow: 0 0 12px rgba(83, 255, 104, 0.25);
}

.score-entry-status {
  min-height: 18px;
  margin: 11px 0;
  color: #6fda7c;
  font-size: 8px;
  font-weight: 900;
  line-height: 1.4;
  letter-spacing: 0.06em;
}

.score-entry-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  text-align: left;
}

.score-entry-form label {
  grid-column: 1 / -1;
  color: #55dc69;
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.score-entry-form input {
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  border: 1px solid #46df5d;
  border-radius: 4px;
  outline: none;
  color: #e2ffe5;
  background: #031107;
  font: 900 16px "Courier New", monospace;
  text-transform: uppercase;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
}

.score-entry-form input:focus {
  border-color: #c3ffc8;
  box-shadow: 0 0 0 2px rgba(103, 255, 119, 0.18);
}

.score-entry-form button,
.score-entry-restart {
  border: 1px solid #5df275;
  border-radius: 4px;
  color: #bcffc3;
  background: #06150a;
  box-shadow: inset 0 0 0 1px rgba(129, 255, 143, 0.12);
  font: 900 8px "Courier New", monospace;
  letter-spacing: 0.08em;
  touch-action: manipulation;
}

.score-entry-form button {
  min-width: 104px;
  padding: 0 10px;
}

.score-entry-form button:disabled {
  opacity: 0.48;
}

.score-entry-restart {
  width: 100%;
  min-height: 40px;
  margin-top: 10px;
  border-color: #9de7ff;
  color: #d7f5ff;
  background: #07151a;
}

.score-prompt {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 3;
  padding: 9px 13px;
  transform: translateX(-50%);
}

.score-prompt[hidden] {
  display: none;
}

.game-wrap:not([data-game="copter"]) .score-prompt {
  display: none;
}

/* Game-select is open: the controls belong to a game, not to a menu. Drop the
   dock entirely and give the menu the whole screen. The canvas keeps its
   internal resolution throughout — syncCanvasResolution defers while the menu
   is open — so nothing shifts under a running game. */
.game-wrap.is-menu-open {
  grid-template-rows: minmax(0, 1fr) 0;
}

.game-wrap.is-menu-open .touch-controls {
  display: none;
}

.touch-controls {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  padding: 0 max(14px, env(safe-area-inset-left))
    max(8px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-right));
  overflow: hidden;
  background:
    linear-gradient(115deg, transparent 0 67%, rgba(255, 255, 255, 0.14) 67.2% 67.5%, transparent 67.7%),
    linear-gradient(165deg, #dedbcc, var(--deck) 52%, #b5b1a5);
  border-top: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow:
    inset 0 5px 12px rgba(90, 86, 78, 0.1),
    0 -2px 0 rgba(23, 24, 36, 0.12);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.platform-strip {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid rgba(23, 24, 36, 0.18);
  color: rgba(23, 24, 36, 0.65);
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.15em;
  white-space: nowrap;
}

.platform-brand {
  color: var(--accent);
}

.game-identity {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
}

.control-layout {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  padding: 5px 4px 4px;
}

.touch-controls button {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8f5ed;
  background: linear-gradient(145deg, #40404b, #20212b);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.22),
    0 4px 0 #101119,
    0 7px 12px rgba(38, 35, 33, 0.25);
  font: 900 14px Arial, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button.is-pressed {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.42),
    0 1px 0 #101119;
  filter: brightness(1.14);
}

.touch-stick {
  --stick-x: 0px;
  --stick-y: 0px;
  position: relative;
  justify-self: start;
  width: clamp(86px, 25vw, 104px);
  aspect-ratio: 1;
  touch-action: none;
  -webkit-touch-callout: none;
  filter: drop-shadow(0 4px 4px rgba(37, 34, 32, 0.24));
}

.stick-gate {
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #252631 0 27%, transparent 28%),
    conic-gradient(from 45deg, #3b3c47, #181922, #41424c, #181922, #3b3c47);
  box-shadow:
    inset 0 6px 10px rgba(0, 0, 0, 0.55),
    inset 0 -4px 8px rgba(255, 255, 255, 0.12),
    0 2px 0 #77736c;
}

.stick-gate::before {
  content: "";
  position: absolute;
  inset: 13%;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, #575864 0 8%, #353641 35%, #1d1e27 72%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.18),
    inset 0 -6px 9px rgba(0, 0, 0, 0.42),
    0 5px 0 #11121a,
    0 8px 12px rgba(0, 0, 0, 0.38);
  transform:
    translate(-50%, -50%)
    translate(var(--stick-x), var(--stick-y));
  transition: transform 60ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

.touch-stick.is-active .stick-knob {
  transition: none;
}

.touch-controls[data-game="copter"] .touch-stick {
  display: none;
  pointer-events: none;
}

.touch-controls[data-game="starfall"] .touch-stick {
  display: none;
  pointer-events: none;
}

.touch-controls[data-game="starfall"] {
  background:
    linear-gradient(112deg, transparent 0 62%, rgba(95, 225, 255, 0.09) 62.2% 62.5%, transparent 62.7%),
    linear-gradient(180deg, #2b303c, #131722 56%, #090d15);
  border-top-color: rgba(154, 231, 255, 0.36);
  box-shadow:
    inset 0 1px rgba(218, 247, 255, 0.14),
    inset 0 7px 18px rgba(0, 0, 0, 0.28),
    0 -2px 0 rgba(42, 164, 204, 0.2);
}

.touch-controls[data-game="starfall"] .platform-strip {
  border-bottom-color: rgba(115, 218, 255, 0.16);
  color: rgba(212, 235, 247, 0.66);
}

.touch-controls[data-game="starfall"] .control-layout {
  grid-template-columns: 1fr;
  place-items: center;
  padding: 8px 2px 6px;
}

.touch-controls[data-game="starfall"] .control-layout::after {
  content: "HOLD + SLIDE THE GAME SCREEN TO STEER";
  position: absolute;
  right: 8px;
  bottom: 2px;
  left: 8px;
  color: rgba(157, 211, 230, 0.42);
  font: 900 6px/1 "Arial Narrow", Arial, sans-serif;
  letter-spacing: 0.14em;
  text-align: center;
  pointer-events: none;
}

.stick-shine {
  position: absolute;
  inset: 18%;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
}

.stick-caption {
  position: absolute;
  left: 50%;
  bottom: -2px;
  color: rgba(23, 24, 36, 0.48);
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.16em;
  transform: translateX(-50%);
  pointer-events: none;
}

.system-buttons {
  display: flex;
  align-items: center;
  gap: 5px;
}

.touch-pause,
.touch-menu {
  min-width: 50px;
  min-height: 25px;
  padding: 5px 8px 4px;
  border-radius: 7px !important;
  color: rgba(248, 245, 237, 0.84) !important;
  font-size: 7px !important;
  letter-spacing: 0.12em;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.2),
    0 2px 0 #101119,
    0 3px 6px rgba(38, 35, 33, 0.22) !important;
}

.touch-menu {
  color: #74edff !important;
}

.touch-pause.is-pressed,
.touch-menu.is-pressed {
  transform: translateY(2px) !important;
}

.touch-bomb {
  width: clamp(72px, 20vw, 84px);
  aspect-ratio: 1;
  border-radius: 50% !important;
  background: linear-gradient(145deg, #db4b65, var(--accent)) !important;
  border-color: rgba(255, 255, 255, 0.35) !important;
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.32),
    0 5px 0 var(--accent-dark),
    0 9px 16px rgba(73, 26, 44, 0.3) !important;
}

.action-buttons {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.touch-special {
  display: none;
  width: clamp(56px, 15vw, 64px);
  aspect-ratio: 1;
  border-radius: 50% !important;
  transform: translateY(13px);
  background: linear-gradient(145deg, #576cbd, #334682) !important;
  border-color: rgba(255, 255, 255, 0.34) !important;
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.28),
    0 5px 0 #202c59,
    0 9px 15px rgba(22, 31, 70, 0.32) !important;
}

.touch-controls[data-game="starfall"] .touch-special {
  display: block;
  transform: translateY(8px);
}

.touch-controls[data-game="starfall"] .touch-bomb {
  width: clamp(62px, 17vw, 72px);
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.34), transparent 18%),
    linear-gradient(145deg, #ff5d4f, #a71e2f) !important;
  border-color: rgba(255, 212, 202, 0.45) !important;
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.27),
    0 5px 0 #5a0c18,
    0 0 18px rgba(235, 46, 57, 0.14) !important;
}

.touch-controls[data-game="starfall"] .action-buttons {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
  width: 78px;
  height: 100%;
  justify-content: center;
  gap: 0;
}

.touch-controls[data-game="starfall"] .touch-special {
  position: absolute;
  right: -14px;
  top: 3px;
  z-index: 3;
  width: clamp(38px, 10vw, 44px);
  transform: none;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.24), transparent 18%),
    linear-gradient(145deg, #6476d2, #30396f) !important;
}

.touch-controls[data-game="starfall"] .touch-special strong {
  font-size: clamp(15px, 4vw, 18px);
}

.touch-controls[data-game="starfall"] .touch-special span {
  margin-top: 2px;
  font-size: 4px;
}

.touch-controls[data-game="starfall"] .touch-special.is-pressed {
  transform: translateY(4px) !important;
}

.touch-special.is-pressed {
  transform: translateY(17px) !important;
  box-shadow:
    inset 0 3px 7px rgba(8, 18, 60, 0.45),
    0 1px 0 #202c59 !important;
}

.touch-special strong,
.touch-special span {
  display: block;
}

.touch-special strong {
  font-size: clamp(19px, 5vw, 23px);
  line-height: 1;
}

.touch-special span {
  margin-top: 3px;
  font-size: 5px;
  letter-spacing: 0.1em;
}

.touch-bomb.is-pressed {
  transform: translateY(4px) !important;
  box-shadow:
    inset 0 3px 7px rgba(74, 7, 30, 0.42),
    0 1px 0 var(--accent-dark) !important;
}

.touch-bomb strong,
.touch-bomb span {
  display: block;
}

.touch-bomb strong {
  font-size: clamp(23px, 6vw, 28px);
  line-height: 1;
}

.touch-bomb span {
  margin-top: 4px;
  font-size: 7px;
  letter-spacing: 0.14em;
}

.touch-controls[data-game="copter"] .control-layout {
  grid-template-columns: 1fr;
  padding: 8px 2px 7px;
}

.touch-controls[data-game="copter"] .action-buttons {
  width: 100%;
  height: 100%;
}

.touch-controls[data-game="copter"] .touch-bomb {
  width: 100%;
  height: 100%;
  min-height: 70px;
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  gap: 12px;
  border-radius: 18px !important;
  background:
    linear-gradient(90deg, rgba(157, 255, 169, 0.08), transparent 22% 78%, rgba(157, 255, 169, 0.08)),
    linear-gradient(180deg, #15331d, #071c0d) !important;
  border-color: rgba(91, 240, 112, 0.68) !important;
  box-shadow:
    inset 0 1px rgba(210, 255, 214, 0.18),
    inset 0 0 0 3px rgba(55, 220, 78, 0.08),
    0 4px 0 #031006,
    0 8px 14px rgba(12, 45, 18, 0.28) !important;
  color: #caffcf;
}

.touch-controls[data-game="copter"] .touch-bomb strong {
  font: 900 clamp(30px, 9vw, 40px) "Courier New", monospace;
  line-height: 0.8;
}

.touch-controls[data-game="copter"] .touch-bomb span {
  margin: 0;
  font: 900 clamp(10px, 3vw, 13px) "Courier New", monospace;
  letter-spacing: 0.12em;
}

.touch-controls[data-game="copter"] .touch-bomb.is-pressed {
  transform: translateY(4px) !important;
  background:
    linear-gradient(90deg, rgba(204, 255, 211, 0.13), transparent 22% 78%, rgba(204, 255, 211, 0.13)),
    linear-gradient(180deg, #20502b, #0b2b14) !important;
  box-shadow:
    inset 0 4px 12px rgba(0, 0, 0, 0.42),
    0 1px 0 #031006 !important;
}

.screen-bezel:fullscreen {
  width: 100vw;
  height: 100vh;
  background: #111827;
}

@media (min-width: 700px) {
  body {
    padding-block: 18px;
  }

  .shell {
    height: calc(100svh - 36px);
    max-height: 900px;
    border-radius: 18px;
    outline: 1px solid rgba(255, 255, 255, 0.14);
  }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .shell {
    height: 100dvh;
  }
}

@media (max-height: 640px) {
  .touch-controls {
    grid-template-rows: 32px minmax(0, 1fr);
    padding-bottom: max(5px, env(safe-area-inset-bottom));
  }

  .platform-strip {
    font-size: 6px;
  }

  .touch-stick {
    width: 80px;
  }

  .touch-bomb {
    width: 66px;
  }

  .touch-controls[data-game="copter"] .touch-bomb {
    min-height: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}

/* iOS shows the text loupe on a long press over selectable content. The
   buttons already opt out, but the labels inside them are their own text
   nodes and were still selectable — which is what raised the magnifier
   mid-flight. Nothing inside the control dock is ever selectable. */
.touch-controls,
.touch-controls * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button,
.touch-controls button * {
  touch-action: manipulation;
  -webkit-user-drag: none;
}
