:root {
  color-scheme: light;
  --ink: #1d2939;
  --muted: #667085;
  --line: #d9e2ea;
  --track: #f7fafc;
  --primary: #174b8a;
  --primary-dark: #103862;
  --secondary: #2ba89b;
  --accent: #df6b3f;
  --danger: #b42318;
  --panel: #ffffff;
  --site-bg: #f7fafc;
  --soft-blue: #eaf2f8;
  --focus: #8fd8d2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, "Inter Fallback", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.game-page {
  background: transparent;
  overflow: hidden;
}

.game-widget {
  position: relative;
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.start-screen {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  min-height: 650px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #020817 url("sprites%20and%20objects/kromerun-menu-background.webp?v=1") center / cover no-repeat;
}

.start-screen[hidden] {
  display: none;
}

.start-screen.is-dissolving {
  pointer-events: none;
  animation: menu-pixel-dissolve 820ms steps(10, end) forwards;
}

.start-screen.is-dissolving::after {
  position: absolute;
  z-index: 4;
  inset: 0;
  content: "";
  background:
    repeating-conic-gradient(
      from 90deg,
      transparent 0 25%,
      #071227 0 50%,
      transparent 0 75%,
      #174b8a 0
    ) 0 0 / 32px 32px;
  mix-blend-mode: screen;
  animation: menu-pixel-scatter 820ms steps(8, end) forwards;
}

@keyframes menu-pixel-dissolve {
  0% {
    opacity: 1;
    filter: none;
    clip-path: inset(0);
  }
  20% {
    opacity: 1;
    filter: contrast(1.35) saturate(1.25);
    clip-path: inset(0 0 8% 0);
  }
  45% {
    opacity: 0.82;
    clip-path: inset(7% 0 24% 0);
  }
  70% {
    opacity: 0.48;
    clip-path: inset(19% 0 51% 0);
  }
  100% {
    opacity: 0;
    filter: contrast(2) saturate(0);
    clip-path: inset(48% 0 52% 0);
  }
}

@keyframes menu-pixel-scatter {
  0% {
    opacity: 0;
    background-position: 0 0;
    transform: scale(1);
  }
  20% {
    opacity: 0.6;
  }
  55% {
    opacity: 0.75;
    background-position: 48px -32px;
    transform: scale(1.04);
  }
  100% {
    opacity: 0;
    background-position: 128px -96px;
    transform: scale(1.12);
  }
}

.start-screen-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgb(2 8 23 / 28%) 0%, rgb(2 8 23 / 5%) 62%, rgb(2 8 23 / 18%) 100%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 2%) 0 2px, transparent 2px 5px);
}

.arcade-menu {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  width: min(90%, 620px);
  gap: 34px;
  padding: 42px 28px;
  margin-right: auto;
  margin-left: clamp(18px, 6vw, 72px);
  text-align: center;
}

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

.start-screen #mainMenu {
  position: absolute;
  top: 24px;
  left: clamp(18px, 5vw, 60px);
  width: min(46%, 520px);
  margin: 0;
  padding: 28px 20px;
}

.arcade-title,
.arcade-credits-title {
  color: #f2c94c;
  font-family: "Courier New", "Lucida Console", monospace;
  font-size: clamp(48px, 10vw, 92px);
  font-weight: 900;
  line-height: 0.82;
  letter-spacing: -0.04em;
  -webkit-font-smoothing: none;
  font-smooth: never;
  -webkit-text-stroke: 2px #ffffff;
  text-shadow:
    4px 0 0 #f2c94c,
    0 4px 0 #f2c94c,
    4px 4px 0 #174b8a,
    8px 8px 0 #174b8a,
    12px 12px 0 #0abab5,
    -3px -3px 0 #ffffff;
  transform: scaleY(1.12);
}

.arcade-menu-actions {
  display: grid;
  width: min(100%, 310px);
  gap: 16px;
}

.arcade-menu-button,
.arcade-back-button {
  border: 4px solid #ffffff;
  border-radius: 0;
  background: #174b8a;
  box-shadow:
    5px 0 0 #071227,
    0 5px 0 #071227,
    9px 9px 0 #0abab5;
  color: #ffffff;
  font-family: "Courier New", "Lucida Console", monospace;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 3px 3px 0 #071227;
}

.arcade-menu-button {
  min-height: 58px;
}

.arcade-menu-button-secondary {
  background: #111b31;
}

.arcade-menu-button:hover,
.arcade-back-button:hover {
  border-color: #f2c94c;
  background: #103862;
  color: #f2c94c;
}

.arcade-menu-button.is-pressed {
  transform: translate(8px, 8px);
  box-shadow:
    1px 0 0 #071227,
    0 1px 0 #071227,
    2px 2px 0 #0abab5;
  border-color: #f2c94c;
  background: #103862;
  color: #f2c94c;
}

.credits-menu {
  gap: 24px;
  color: #ffffff;
  background: rgb(3 9 24 / 78%);
  border: 3px solid rgb(255 255 255 / 80%);
  box-shadow: 8px 8px 0 rgb(10 186 181 / 70%);
}

.arcade-credits-title {
  font-size: clamp(34px, 7vw, 60px);
}

.credits-menu p {
  max-width: 480px;
  margin: 0;
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.65;
  white-space: pre-line;
}

.credits-menu .game-version {
  color: #f2c94c;
  font-size: 15px;
  letter-spacing: 0.12em;
}

@media (max-width: 680px) {
  .start-screen {
    background-position: 64% center;
  }

  .start-screen-shade {
    background: rgb(2 8 23 / 48%);
  }

  .arcade-menu {
    width: calc(100% - 28px);
    margin-inline: auto;
    padding-inline: 16px;
  }

  .start-screen #mainMenu {
    top: 14px;
    left: 14px;
    width: min(82%, 420px);
    margin: 0;
    padding: 22px 12px;
  }

  .arcade-title {
    font-size: clamp(42px, 15vw, 68px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .start-screen.is-dissolving,
  .start-screen.is-dissolving::after {
    animation-duration: 120ms;
  }
}

.arcade-back-button {
  display: inline-flex;
  min-width: 150px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 18px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

h1,
p {
  margin: 0;
}

h1 {
  color: var(--primary-dark);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.game-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.player-silhouette {
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  background-image: url("sprites%20and%20objects/space-marine-run.png?v=2");
  background-position: 0 0;
  background-repeat: no-repeat;
  background-size: 174px 29px;
  filter: brightness(0);
  image-rendering: pixelated;
}

p {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

button {
  min-width: 104px;
  min-height: 40px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

button:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.secondary-button {
  min-width: 86px;
  min-height: 34px;
  background: #ffffff;
  color: var(--primary);
  border-color: var(--line);
}

.secondary-button:hover {
  background: var(--soft-blue);
  border-color: var(--primary);
  color: var(--primary-dark);
}

button:focus-visible,
iframe:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.scoreboard div,
.track-panel {
  background: var(--soft-blue);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scoreboard div {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px;
}

.scoreboard span {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.scoreboard strong {
  color: var(--primary);
  font-family: "Space Grotesk", "Courier New", monospace;
  font-size: 24px;
}

#levelName {
  font-family: Inter, "Inter Fallback", system-ui, sans-serif;
  font-size: 18px;
  text-transform: uppercase;
}

.track-panel {
  overflow: hidden;
  margin-bottom: 12px;
}

canvas {
  display: block;
  width: 100%;
  height: clamp(170px, 28vw, 240px);
  border-radius: 7px;
  background: var(--track);
  image-rendering: pixelated;
  touch-action: manipulation;
}

.score-modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgb(247 250 252 / 94%);
}

.score-modal.is-visible {
  display: flex;
}

.score-dialog {
  width: min(100%, 890px);
  padding: 20px 58px 54px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 22px 56px rgb(23 75 138 / 12%);
}

.final-score {
  display: flex;
  width: min(100%, 368px);
  min-height: 66px;
  align-items: center;
  justify-content: center;
  gap: 58px;
  margin: 0 auto 16px;
  padding: 10px 28px;
  color: #ffffff;
  background: var(--primary);
  border: 1px solid rgb(16 56 98 / 32%);
  border-radius: 18px;
  font-family: Inter, "Inter Fallback", system-ui, sans-serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.save-row {
  display: grid;
  grid-template-columns: minmax(0, 428px) 128px;
  align-items: end;
  justify-content: center;
  gap: 86px;
  margin: 26px auto 24px;
}

.email-field,
.codename-field {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}

input[type="email"],
input[type="text"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  background: #f8fbfd;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-transform: none;
  box-shadow: inset 0 1px 2px rgb(23 75 138 / 4%);
}

.email-field {
  position: relative;
}

.email-field span,
.codename-field span {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.2;
}

.email-field input::placeholder {
  color: #758392;
}

.codename-field {
  position: relative;
  width: min(100%, 560px);
  margin: 0 auto;
  gap: 0;
}

.codename-field span {
  position: absolute;
  left: 24px;
  top: 50%;
  z-index: 2;
  color: var(--muted);
  font-size: 22px;
  font-weight: 500;
  transform: translateY(-50%);
  pointer-events: none;
}

.codename-field input {
  min-height: 48px;
  padding: 8px 190px 8px 24px;
  color: transparent;
  caret-color: transparent;
  border-radius: 18px;
  font-family: Inter, "Inter Fallback", system-ui, sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

.initial-slots {
  position: absolute;
  right: 24px;
  top: 50%;
  display: grid;
  grid-template-columns: repeat(3, 56px);
  gap: 8px;
  transform: translateY(-50%);
  pointer-events: none;
}

.initial-slots span {
  position: relative;
  left: auto;
  top: auto;
  display: block;
  width: 56px;
  height: 22px;
  transform: none;
}

.initial-slots span::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 999px;
  background: var(--primary);
}

.initial-slots span.has-value::before {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: var(--primary-dark);
  font-family: Inter, "Inter Fallback", system-ui, sans-serif;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.initial-slots span.is-active::after {
  animation: initial-pulse 1.1s ease-in-out infinite;
}

@keyframes initial-pulse {
  0%,
  100% {
    opacity: 0.45;
    box-shadow: 0 0 0 rgb(23 75 138 / 0%);
    transform: scaleX(0.88);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 12px rgb(23 75 138 / 34%);
    transform: scaleX(1);
  }
}

.save-row button {
  min-height: 48px;
  border-color: var(--primary-dark);
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-size: 22px;
  font-weight: 500;
  text-align: center;
  text-transform: none;
}

.save-row button:hover {
  background: var(--primary-dark);
  color: #ffffff;
}

.terms-label {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(100%, 640px);
  min-height: 46px;
  margin: 0 auto 30px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.terms-label input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--primary);
}

.save-message {
  min-height: 20px;
  margin-top: 22px;
  color: var(--secondary);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

/* Arcade cabinet death screen */
.score-modal {
  z-index: 30;
  overflow-x: hidden;
  overflow-y: auto;
  background: rgb(2 8 23 / 92%);
}

.score-modal.is-visible {
  align-items: flex-start;
  animation: death-screen-pixel-in 620ms steps(8, end) both;
}

.score-modal.is-visible::before {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
  pointer-events: none;
  background:
    repeating-conic-gradient(
      from 90deg,
      #0abab5 0 25%,
      transparent 0 50%,
      #174b8a 0 75%,
      transparent 0
    ) 0 0 / 30px 30px;
  animation: death-pixels-clear 680ms steps(9, end) both;
}

@keyframes death-screen-pixel-in {
  0% {
    opacity: 0;
    clip-path: inset(48% 0 48% 0);
  }
  35% {
    opacity: 0.72;
    clip-path: inset(28% 0 27% 0);
  }
  70% {
    opacity: 0.92;
    clip-path: inset(8% 0 7% 0);
  }
  100% {
    opacity: 1;
    clip-path: inset(0);
  }
}

@keyframes death-pixels-clear {
  0% {
    opacity: 0.95;
    transform: scale(1.18);
  }
  55% {
    opacity: 0.62;
    background-position: 60px -30px;
  }
  100% {
    opacity: 0;
    background-position: 150px -90px;
    transform: scale(1);
  }
}

.score-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 820px);
  padding: 58px 54px 34px;
  overflow: visible;
  background:
    linear-gradient(#071227, #0b1730) padding-box,
    linear-gradient(135deg, #617085, #17243a 34%, #8d99a8 52%, #17243a 72%) border-box;
  border: 14px solid transparent;
  border-radius: 34px 34px 18px 18px;
  box-shadow:
    0 0 0 7px #020817,
    0 0 0 11px #0abab5,
    18px 22px 0 rgb(0 0 0 / 48%),
    inset 0 0 32px rgb(10 186 181 / 16%);
}

.score-dialog::before {
  position: absolute;
  left: 50%;
  top: -54px;
  width: min(78%, 500px);
  height: 54px;
  content: "KROMERUN";
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  border: 7px solid #020817;
  border-bottom: 4px solid #0abab5;
  background: #174b8a;
  box-shadow: 7px 7px 0 #0abab5;
  color: #f2c94c;
  font-family: "Courier New", monospace;
  font-size: clamp(24px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 3px 3px 0 #020817;
}

.score-dialog::after {
  position: absolute;
  left: -24px;
  right: -24px;
  bottom: -28px;
  height: 25px;
  content: "";
  border: 7px solid #020817;
  background:
    linear-gradient(90deg, #174b8a 0 34%, #0abab5 34% 38%, #17243a 38% 62%, #0abab5 62% 66%, #174b8a 66%);
  box-shadow: 8px 8px 0 rgb(0 0 0 / 45%);
}

.final-score {
  border: 4px solid #ffffff;
  border-radius: 0;
  background: #174b8a;
  box-shadow: 6px 6px 0 #0abab5;
  font-family: "Courier New", monospace;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-shadow: 3px 3px 0 #020817;
}

.score-dialog .email-field,
.score-dialog .codename-field,
.score-dialog .email-field span,
.score-dialog .codename-field > span {
  color: #ffffff;
  font-family: "Courier New", monospace;
  text-transform: uppercase;
}

.score-dialog input[type="email"],
.score-dialog input[type="text"],
.score-dialog .terms-label {
  border: 3px solid #315ba7;
  border-radius: 0;
  background: #020817;
  color: #ffffff;
  box-shadow: inset 4px 4px 0 rgb(0 0 0 / 45%);
  font-family: "Courier New", monospace;
}

.score-dialog .codename-field > span {
  color: #d9edf8;
}

.score-dialog .initial-slots span::after {
  border-radius: 0;
  background: #0abab5;
}

.score-dialog .initial-slots span.has-value::before {
  color: #f2c94c;
  font-family: "Courier New", monospace;
  text-shadow: 2px 2px 0 #174b8a;
}

.score-dialog .terms-label {
  color: #d9edf8;
}

.score-dialog .save-row button,
.play-again-button {
  min-height: 52px;
  border: 4px solid #ffffff;
  border-radius: 0;
  background: #174b8a;
  box-shadow: 6px 6px 0 #0abab5;
  color: #ffffff;
  font-family: "Courier New", monospace;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #020817;
}

.score-dialog .save-row button:hover,
.play-again-button:hover {
  border-color: #f2c94c;
  background: #103862;
  color: #f2c94c;
}

.score-dialog .save-message {
  margin: 8px 0 12px;
  color: #0abab5;
  font-family: "Courier New", monospace;
}

.play-again-button {
  display: block;
  width: min(100%, 310px);
  margin: 0 auto;
}

@media (max-width: 720px) {
  .score-dialog {
    padding: 48px 20px 26px;
    border-width: 9px;
    border-radius: 22px 22px 12px 12px;
  }

  .score-dialog::before {
    top: -45px;
    height: 46px;
    border-width: 5px;
  }

  .score-dialog .save-row {
    gap: 14px;
  }
}

/* Reference-inspired cabinet containing score and initials */
.score-dialog {
  width: min(100%, 540px);
  padding: 0 20px 30px;
  border: 8px solid #020817;
  border-radius: 18px;
  background: #2457a5;
  box-shadow:
    0 0 0 5px #0abab5,
    16px 18px 0 rgb(0 0 0 / 48%);
}

.score-dialog::before,
.score-dialog::after {
  display: none;
}

.arcade-score-machine {
  position: relative;
  width: min(100%, 484px);
  height: 432px;
  margin: 0 auto 8px;
  overflow: hidden;
  background: #2457a5;
  image-rendering: pixelated;
}

.arcade-reference-art {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
  filter: contrast(1.18) saturate(1.5);
}

.arcade-machine-marquee {
  position: absolute;
  left: 24.6%;
  top: 10.8%;
  display: grid;
  width: 50.8%;
  height: 10%;
  place-items: center;
  overflow: hidden;
  color: #f2c94c;
  font-family: "Courier New", monospace;
  font-size: clamp(17px, 4vw, 28px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-shadow:
    2px 2px 0 #020817,
    4px 4px 0 #0abab5;
}

.arcade-machine-screen {
  position: absolute;
  left: 27.3%;
  top: 39.6%;
  display: grid;
  width: 41.5%;
  height: 29.8%;
  align-content: center;
  gap: 8px;
  padding: 10px 12px;
  overflow: hidden;
  border-radius: 12% / 18%;
  background:
    repeating-linear-gradient(0deg, rgb(255 255 255 / 3%) 0 2px, transparent 2px 5px),
    #020817;
  box-shadow:
    inset 0 0 20px #0abab5,
    0 0 0 5px #071227;
}

.arcade-machine-screen .final-score {
  display: grid;
  width: 100%;
  min-height: 42px;
  grid-template-columns: 1fr;
  gap: 3px;
  margin: 0;
  padding: 3px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: #f2c94c;
  font-size: clamp(15px, 3.2vw, 22px);
  line-height: 1;
}

.arcade-machine-screen .final-score span:last-child {
  color: #ffffff;
  font-size: 1.35em;
}

.arcade-machine-screen .codename-field {
  width: 100%;
  height: 44px;
  margin: 0;
}

.arcade-machine-screen .codename-field > span {
  left: 8px;
  top: 2px;
  font-size: 9px;
  line-height: 1;
  transform: none;
}

.arcade-machine-screen .codename-field input {
  min-height: 44px;
  padding: 13px 8px 2px;
  border: 2px solid #315ba7;
}

.arcade-machine-screen .initial-slots {
  right: 8px;
  top: 61%;
  grid-template-columns: repeat(3, 28px);
  gap: 4px;
}

.arcade-machine-screen .initial-slots span {
  width: 28px;
  height: 18px;
}

.arcade-machine-screen .initial-slots span.has-value::before {
  font-size: 15px;
}

.arcade-machine-controls {
  position: absolute;
  left: 17%;
  top: 75%;
  width: 66%;
  height: 15%;
}

.arcade-joystick {
  position: absolute;
  left: 11%;
  bottom: 12%;
  width: 8px;
  height: 34px;
  background: #020817;
  box-shadow: 2px 0 0 #0abab5;
}

.arcade-joystick::before {
  position: absolute;
  left: 50%;
  top: -12px;
  width: 22px;
  height: 22px;
  content: "";
  transform: translateX(-50%);
  border: 3px solid #020817;
  border-radius: 50%;
  background: #df6b3f;
}

.arcade-control-slots {
  position: absolute;
  left: 39%;
  top: 26%;
  width: 24%;
  height: 8px;
  border: 3px solid #020817;
  background: #0abab5;
}

.arcade-buttons {
  position: absolute;
  right: 8%;
  top: 15%;
  width: 58px;
  height: 40px;
  background:
    radial-gradient(circle at 12px 10px, #f2c94c 0 6px, #020817 7px 9px, transparent 10px),
    radial-gradient(circle at 36px 10px, #df6b3f 0 6px, #020817 7px 9px, transparent 10px),
    radial-gradient(circle at 24px 31px, #0abab5 0 6px, #020817 7px 9px, transparent 10px);
}

@media (max-width: 600px) {
  .score-dialog {
    width: min(100%, 430px);
    padding: 16px 12px 24px;
    border-width: 5px;
  }

  .arcade-score-machine {
    height: auto;
    aspect-ratio: 484 / 432;
  }

  .arcade-machine-screen {
    padding: 6px 8px;
  }

  .arcade-machine-screen .codename-field {
    height: 36px;
  }

  .arcade-machine-screen .codename-field input {
    min-height: 36px;
  }
}

.leaderboard {
  padding: 14px;
  background: var(--soft-blue);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.leaderboard h2 {
  margin: 0;
  color: var(--primary-dark);
  font-size: 18px;
  line-height: 1.2;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-list li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--primary-dark);
  counter-increment: leaderboard-rank;
}

.leaderboard-list {
  counter-reset: leaderboard-rank;
}

.leaderboard-list li::before {
  content: counter(leaderboard-rank);
  color: var(--muted);
  font-family: "Space Grotesk", "Courier New", monospace;
  font-weight: 700;
}

.leaderboard-list strong,
.leaderboard-list span {
  font-family: "Space Grotesk", "Courier New", monospace;
  font-weight: 700;
}

.leaderboard-list span {
  text-align: right;
}

.leaderboard-list .leaderboard-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.leaderboard-list .leaderboard-score {
  min-width: 5ch;
  font-variant-numeric: tabular-nums;
}

.leaderboard-list .empty-score {
  grid-template-columns: 1fr;
  color: var(--muted);
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  text-align: center;
}

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

.demo-page {
  min-height: 100vh;
  background: var(--site-bg);
}

.demo-shell {
  width: min(1080px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.demo-header,
.demo-section {
  margin-bottom: 24px;
}

.demo-header h1 {
  font-size: 36px;
}

.demo-section {
  display: grid;
  gap: 12px;
}

.game-frame {
  display: block;
  width: 100%;
  min-height: 980px;
  border: 0;
  overflow: hidden;
}

.placeholder {
  min-height: 180px;
  padding: 24px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 640px) {
  .game-widget {
    padding: 12px;
  }

  .game-header,
  .scoreboard {
    grid-template-columns: 1fr;
  }

  .game-header {
    display: grid;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  button {
    width: 100%;
  }

  .scoreboard div {
    grid-template-columns: 1fr;
  }

  .leaderboard-list li {
    grid-template-columns: 28px minmax(0, 1fr) auto auto;
    gap: 7px;
  }

  .score-dialog {
    width: min(100%, 420px);
    padding: 18px 16px 30px;
    border-radius: 18px;
  }

  .final-score {
    width: min(100%, 300px);
    min-height: 54px;
    gap: 32px;
    font-size: 22px;
    border-radius: 14px;
  }

  .codename-field {
    width: 100%;
  }

  .save-row {
    grid-template-columns: 1fr;
    gap: 14px;
    margin: 28px 0 22px;
  }

  .save-row button {
    width: 100%;
  }

  input[type="email"],
  input[type="text"],
  .save-row button {
    font-size: 16px;
  }

  .codename-field span {
    left: 18px;
    font-size: 18px;
  }

  .codename-field input {
    padding-right: 164px;
  }

  .initial-slots {
    right: 18px;
    grid-template-columns: repeat(3, 44px);
    gap: 6px;
  }

  .initial-slots span {
    width: 44px;
  }

  .terms-label {
    gap: 12px;
    margin-bottom: 38px;
    font-size: 15px;
  }

  .terms-label input {
    width: 30px;
    height: 30px;
  }

  .game-frame {
    min-height: 1120px;
  }
}

/* Keep the death-screen cabinet proportions intact after the general mobile rules. */
@media (max-width: 600px) {
  .score-dialog {
    width: min(100%, 520px);
    padding: 16px 12px 24px;
    border-radius: 4px;
  }

  .arcade-score-machine {
    width: min(100%, 420px);
    height: 376px;
  }

  .arcade-machine-marquee {
    top: 26px;
    font-size: clamp(16px, 5vw, 24px);
  }

  .arcade-machine-screen {
    left: 27.3%;
    top: 39.6%;
    width: 41.5%;
    height: 29.8%;
    min-height: 0;
    padding: 13px 8px 10px;
  }

  .arcade-machine-screen .final-score {
    width: 100%;
    min-height: 0;
    gap: 8px;
    font-size: clamp(12px, 3.6vw, 17px);
    border-radius: 0;
  }

  .arcade-machine-screen .codename-field {
    width: 100%;
  }

  .arcade-machine-screen .codename-field span {
    left: 8px;
    font-size: 10px;
  }

  .arcade-machine-screen .codename-field input {
    height: 36px;
    padding: 0 7px 0 86px;
    font-size: 18px;
  }

  .arcade-machine-controls {
    bottom: 65px;
    width: 60%;
  }

  .save-row {
    margin-top: 18px;
  }
}

/* Compact death-screen actions so the full form fits beneath the cabinet. */
.score-dialog {
  padding-bottom: 16px;
}

.arcade-score-machine {
  margin-bottom: 0;
}

.score-dialog .save-row {
  display: flex;
  justify-content: center;
  margin: 4px auto 8px;
}

.score-dialog .save-row button {
  width: min(100%, 240px);
}

.score-dialog .email-field {
  gap: 4px;
}

.score-dialog input[type="email"],
.score-dialog .save-row button {
  min-height: 42px;
}

.score-dialog .terms-label {
  min-height: 34px;
  margin-bottom: 6px;
  padding: 5px 8px;
  font-size: 11px;
}

.score-dialog .save-message {
  min-height: 14px;
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.1;
}

.score-dialog .play-again-button {
  min-height: 42px;
}

@media (max-width: 600px) {
  .score-dialog {
    padding-bottom: 12px;
  }

  .score-dialog .save-row {
    justify-content: center;
    margin-top: 2px;
  }

  .score-dialog .save-row button {
    width: min(100%, 220px);
    font-size: 14px;
  }

  .score-dialog .terms-label {
    gap: 7px;
    margin-bottom: 4px;
    font-size: 10px;
  }

  .score-dialog .terms-label input {
    width: 18px;
    height: 18px;
  }
}

/* Smaller proportional cabinet, including the text drawn over its artwork. */
.arcade-score-machine {
  width: min(100%, 380px);
  height: auto;
  aspect-ratio: 484 / 432;
}

.arcade-machine-marquee {
  font-size: 21px;
}

.arcade-machine-screen {
  gap: 5px;
  padding: 8px 10px;
}

.arcade-machine-screen .final-score {
  min-height: 30px;
  font-size: 15px;
}

.arcade-machine-screen .final-score span:last-child {
  font-size: 1.25em;
}

.arcade-machine-screen .codename-field,
.arcade-machine-screen .codename-field input {
  height: 34px;
  min-height: 34px;
}

.arcade-machine-screen .codename-field > span {
  font-size: 8px;
}

.arcade-machine-screen .initial-slots {
  grid-template-columns: repeat(3, 24px);
}

.arcade-machine-screen .initial-slots span {
  width: 24px;
}

/* Show one centred yellow initials display inside the death-screen cabinet. */
.arcade-machine-screen .codename-field > .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.arcade-machine-screen .codename-field input {
  padding: 0;
  color: transparent;
  caret-color: transparent;
  text-shadow: none;
}

.arcade-machine-screen .initial-slots {
  left: 50%;
  right: auto;
  top: 50%;
  transform: translate(-50%, -50%);
}

@media (max-width: 600px) {
  .arcade-score-machine {
    width: min(100%, 330px);
    height: auto;
  }

  .arcade-machine-marquee {
    top: 10.8%;
    font-size: 17px;
  }

  .arcade-machine-screen {
    gap: 3px;
    padding: 6px 7px;
  }

  .arcade-machine-screen .final-score {
    font-size: 13px;
  }

  .arcade-machine-screen .codename-field,
  .arcade-machine-screen .codename-field input {
    height: 29px;
    min-height: 29px;
  }

  .arcade-machine-screen .codename-field input {
    padding: 0;
    color: transparent;
    font-size: 14px;
  }

  .arcade-machine-screen .codename-field span {
    font-size: 8px;
  }
}
