:root {
  color-scheme: dark;
  --bg-dark: #1a1a1a;
  --panel-dark: #2b2b2b;
  --panel-border: #4f4f4f;
  --text-red: #dd2d2d;
  --button-dark: #333333;
  --button-dark-hover: #3f3f3f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #111111 0%, #1f1f1f 70%, #0a0a0a 100%);
  color: var(--text-red);
  font-family: "Press Start 2P", "VT323", "Courier New", monospace;
  letter-spacing: 0.04em;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  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));
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 0.5625));
  max-height: 100vh;
  aspect-ratio: 9 / 16;
  border: 4px solid var(--panel-border);
  box-shadow: 0 0 0 2px #0f0f0f, 0 16px 40px rgba(0, 0, 0, 0.55);
  background: #070707;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.panel {
  background: rgba(43, 43, 43, 0.9);
  border: 2px solid var(--panel-border);
  color: var(--text-red);
  text-shadow: 1px 1px 0 #300909;
}

#hud {
  position: absolute;
  top: 16px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
  pointer-events: none;
  color: #ffffff;
  text-shadow: 2px 2px 0 #101010;
  font-size: clamp(14px, 3.2vw, 20px);
  font-weight: 700;
  z-index: 2;
}

#hud.hidden {
  display: none;
}

.hud-item {
  display: inline-flex;
  gap: 10px;
  align-items: baseline;
}

.label {
  color: #ffffff;
}

.overlay {
  position: absolute;
  inset: 12% 8%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  text-align: center;
  padding: 16px;
}

#gameover-screen {
  background: transparent;
  border: 0;
  box-shadow: none;
  text-shadow: 2px 2px 0 #101010;
}

#tap-retry-text {
  animation: blink-retry 0.9s steps(1, end) infinite;
}

.overlay p,
.overlay h1,
.overlay h2 {
  margin: 0;
  line-height: 1.4;
}

.overlay h1 {
  font-size: clamp(16px, 4.6vw, 24px);
}

.overlay h2 {
  font-size: clamp(15px, 4.2vw, 22px);
}

.ui-button {
  margin-top: 4px;
  border: 2px solid #5b5b5b;
  background: var(--button-dark);
  color: var(--text-red);
  padding: 10px 18px;
  font-family: inherit;
  font-size: clamp(12px, 3vw, 14px);
  cursor: pointer;
}

.ui-button:active,
.ui-button:hover {
  background: var(--button-dark-hover);
}

@keyframes blink-retry {
  0%,
  49.9% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

.hidden {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  html,
  body {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: auto;
  }

  #app {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 0;
    place-items: start stretch;
  }

  #game-shell {
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    aspect-ratio: 9 / 16;
    height: auto;
    max-height: none;
    border: 0;
    box-shadow: none;
  }

  #game-canvas {
    touch-action: none;
  }
}

@font-face { font-family: "Press Start 2P"; src: url("./fonts/press-start-2p.ttf") format("truetype"); font-style: normal; font-weight: 400; font-display: swap; }
[hidden] { display: none !important; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 4px; }
.title-screen { position: absolute; inset: 0; z-index: 2; padding: 7% 5% 4%; display: flex; flex-direction: column; align-items: center; gap: 2%; background: #000; }
.title-screen.hidden { display: none; }
.title-screen h1 { margin: 0; width: 100%; flex: 0 0 auto; line-height: 0; }
.game-title-logo { display: block; width: 100%; height: auto; }
.title-art { width: 96%; flex: 1; min-height: 0; object-fit: contain; image-rendering: pixelated; }
.title-menu { display: grid; width: 100%; justify-items: center; gap: 0; }
.title-menu button, .title-menu a { display: block; border: 0; background: transparent; color: #fff; text-decoration: none; padding: 12px 8px; min-height: 44px; font: inherit; font-size: clamp(12px, 2.9vw, 19px); line-height: 1.2; cursor: pointer; }
.title-menu button:hover, .title-menu a:hover { color: #ed3434; }
#play-button { animation: blink-retry 1.25s steps(1, end) infinite; }
.brand-logos { width: 100%; min-height: 66px; height: 10%; display: flex; justify-content: space-around; align-items: center; gap: 5%; }
.brand { display: block; background: #fff; mask-size: contain; mask-position: center; mask-repeat: no-repeat; -webkit-mask-size: contain; -webkit-mask-position: center; -webkit-mask-repeat: no-repeat; }
.brand-nerds { width: 27%; height: 100%; mask-image: url('./brands/nerds-horizontal-clean.svg'); mask-mode: luminance; }
.brand-shady { width: 28%; height: 88%; mask-image: url('./brands/shady-records.webp'); }
.brand-fanarcade { width: 34%; height: 65%; mask-image: url('./brands/fanarcade.png'); }
.ui-button { min-height: 44px; line-height: 1.5; }
.text-button { border: 0; background: transparent; color: #ddd; font: inherit; font-size: 10px; line-height: 1.7; min-height: 44px; padding: 10px 4px; cursor: pointer; }
#leaderboard-dialog { position: fixed; inset: var(--dialog-center-y, 50dvh) 0 auto; margin: 0 auto; transform: translateY(-50%); width: min(92vw, 440px); max-height: min(calc(var(--dialog-height, 100dvh) - 24px), 830px); padding: 0; background: #191919; color: #f7f7f7; border: 3px solid #585858; box-shadow: 0 0 0 3px #050505, 8px 8px 0 #000; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; letter-spacing: 0; }
#leaderboard-dialog::backdrop { background: rgb(0 0 0 / 85%); }
.modal-top { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; border-bottom: 2px solid #3b3b3b; color: #c0c0c0; font-size: 8px; line-height: 1.6; }
.close-button { padding: 0; width: 44px; height: 44px; border: 0; background: none; color: #fff; font: 30px Arial, sans-serif; cursor: pointer; flex-shrink: 0; }
.modal-content { padding: 20px 22px; }
.modal-content h2 { margin: 0 0 20px; color: #ed3434; font-size: clamp(14px, 3.5vw, 19px); line-height: 1.65; font-weight: 400; }
.status { font: 14px/1.5 Arial, sans-serif; margin: 0 0 12px; color: #ddd; }
.status:empty { display: none; }
.status.error { color: #ff9b9b; }
.run-score { display: flex; align-items: center; justify-content: space-between; padding: 18px 12px; border: 2px solid #555; font-size: 12px; }
.run-score strong { font-size: 23px; color: #fff; font-weight: 400; }
.form-intro, .privacy-note, .opt-in { font-family: Arial, sans-serif; line-height: 1.45; font-size: 14px; color: #ccc; }
.form-intro { margin: 18px 0; }
#score-form { display: flex; flex-direction: column; }
#score-form > label { font-size: 10px; margin: 12px 0 8px; line-height: 1.5; }
#score-form input:not([type=checkbox]) { width: 100%; min-height: 48px; font: 16px/1.3 Arial, sans-serif; padding: 12px; background: #080808; color: #fff; border: 2px solid #555; border-radius: 0; user-select: text; -webkit-user-select: text; touch-action: manipulation; }
.privacy-note { font-size: 12px; margin-bottom: 0; }
#score-form > .opt-in { display: flex; align-items: flex-start; gap: 10px; font: 12px/1.45 Arial, sans-serif; margin: 18px 0; cursor: pointer; }
.opt-in input { width: 18px; height: 18px; flex-shrink: 0; margin: 0; accent-color: #dd2d2d; }
.primary-button { width: 100%; font-size: 12px; margin: 10px 0; background: #3a2020; color: #ff5757; border-color: #b22c2c; }
button:disabled { opacity: .55; cursor: wait; }
#skip-score, #refresh-leaderboard { display: block; width: 100%; text-align: center; font-size: 9px; }
.board-caption { font: 10px/1.6 Arial, sans-serif; letter-spacing: .12em; color: #aaa; margin: 0 0 14px; }
#score-board table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10px; line-height: 1.6; }
#score-board th { color: #aaa; font-size: 8px; font-weight: 400; padding: 10px 5px; text-align: left; border-bottom: 2px solid #555; }
#score-board th:first-child { width: 20%; }
#score-board th:last-child { width: 25%; text-align: right; }
#score-board td { padding: 12px 5px; border-bottom: 1px solid #333; overflow-wrap: anywhere; }
#score-board td:last-child { text-align: right; }
#score-board tr.is-you { color: #ff6969; background: #291b1b; }
.personal-score { border: 2px solid #b22c2c; padding: 14px 12px; margin-bottom: 16px; color: #ff7777; font-size: 10px; line-height: 1.9; }
.personal-score strong { display: block; font-weight: 400; color: #fff; margin-top: 6px; }
.empty-board { text-align: center; color: #aaa; font: 14px/1.8 Arial, sans-serif; padding: 24px 0; }
@media (hover: none) and (pointer: coarse) {
  #game-shell { height: min(177.7778vw, 100dvh); max-height: 100dvh; }
}
@media (prefers-reduced-motion: reduce) { #play-button { animation: none; } }

.modal-top { position: sticky; top: 0; z-index: 1; background: #191919; }
@media (hover: none) and (pointer: coarse) { html, body { background: #000; } }
@media (hover: hover) and (pointer: fine) {
  #game-shell { width: min(calc(100vw - 16px), calc((100dvh - 16px) * .5625)); max-height: calc(100dvh - 16px); }
}

/* The original logo slots stay aligned; artwork is 30% smaller in both dimensions. */
.brand { transform: scale(.7); transform-origin: center; }
.brand-nerds { transform: scale(1.05); }
.opt-in input { appearance: none; -webkit-appearance: none; border: 2px solid #aaa; border-radius: 50%; background: #080808; cursor: pointer; display: grid; place-content: center; }
.opt-in input::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #ff5757; transform: scale(0); }
.opt-in input:checked { border-color: #ff5757; }
.opt-in input:checked::before { transform: scale(1); }
.consent-privacy { margin: 0 0 12px; font: 12px/1.5 Arial, sans-serif; color: #ccc; }
.consent-privacy a { color: #eee; text-decoration: underline; text-underline-offset: 2px; }
