:root {
  color-scheme: dark;
  --bg: #080910;
  --panel: #111521;
  --panel-2: #1b2030;
  --ink: #f4f7ff;
  --muted: #9ea8bd;
  --cyan: #44d9ff;
  --green: #83f35a;
  --yellow: #ffd447;
  --red: #ff3f4e;
  --violet: #b16cff;
  --border: #394157;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(68, 217, 255, 0.08), transparent 30%),
    radial-gradient(circle at top left, rgba(131, 243, 90, 0.12), transparent 32rem),
    var(--bg);
  font-family: "Courier New", Courier, monospace;
}

button,
canvas {
  font: inherit;
}

.page {
  width: min(1120px, calc(100vw - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 0 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 2px solid var(--border);
  background: rgba(17, 21, 33, 0.92);
  box-shadow: 0 0 0 2px #05060a, 0 8px 22px rgba(0, 0, 0, 0.32);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.05rem, 3vw, 1.55rem);
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #000;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 6px;
  margin: 0;
}

.scoreboard div {
  min-width: 0;
  padding: 5px 8px;
  border: 2px solid #2b3448;
  background: #0b0f19;
}

.scoreboard dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.1;
  text-transform: uppercase;
}

.scoreboard dd {
  margin: 0;
  color: var(--green);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1;
}

.arcade-button {
  min-height: 36px;
  padding: 0 12px;
  border: 3px solid #06070b;
  border-radius: 0;
  color: #071014;
  background: var(--yellow);
  box-shadow: inset -4px -4px 0 rgba(0, 0, 0, 0.26), 0 0 0 2px #f8f3d5;
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
}

.arcade-button:hover,
.arcade-button:focus-visible {
  background: #ffe77a;
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}

.arcade-button:active {
  transform: translateY(2px);
  box-shadow: inset 4px 4px 0 rgba(0, 0, 0, 0.24), 0 0 0 2px #f8f3d5;
}

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

.arcade-button.primary {
  min-width: 148px;
  background: var(--green);
}

.arcade-button.utility {
  background: var(--green);
}

.arcade-button.utility:hover,
.arcade-button.utility:focus-visible {
  background: #a0ff7e;
}

.game-actions {
  display: flex;
  gap: 8px;
}

.play-area {
  position: relative;
  align-self: start;
  border: 4px solid #05060a;
  background: #05060a;
  box-shadow: 0 0 0 3px var(--border), 0 24px 50px rgba(0, 0, 0, 0.45);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  background: #05060a;
  image-rendering: pixelated;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 6, 10, 0.42);
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  width: min(460px, 100%);
  padding: 22px;
  border: 4px solid var(--cyan);
  background: rgba(12, 16, 25, 0.96);
  box-shadow: 8px 8px 0 #000;
  text-align: center;
}

.overlay h2 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: clamp(1.5rem, 7vw, 3rem);
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #000;
}

.overlay p {
  margin: 0 0 18px;
  color: #dce6ff;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .page {
    width: min(100vw - 16px, 720px);
    padding-top: 8px;
  }

  .top-bar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

  .arcade-button {
    width: 100%;
  }

  .game-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 420px) {
  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .scoreboard div {
    padding: 7px 8px;
  }

  .overlay-panel {
    padding: 18px 14px;
  }
}
