:root {
  --ink: #20231f;
  --paper: #f5f0e5;
  --sun: #ef684a;
  --muted: #817f75;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Mono", monospace;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 32px);
  background-image:
    radial-gradient(circle at 12% 20%, rgba(32,35,31,.035) 0 1px, transparent 1px),
    radial-gradient(circle at 80% 70%, rgba(32,35,31,.025) 0 1px, transparent 1px);
  background-size: 11px 11px, 17px 17px;
}

button, a { -webkit-tap-highlight-color: transparent; }

.shell {
  width: min(1180px, 100%);
  border: 2px solid var(--ink);
  box-shadow: 8px 8px 0 rgba(32,35,31,.12);
  background: var(--paper);
}

.topbar {
  height: 72px;
  border-bottom: 2px solid var(--ink);
  padding: 0 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  font: 12px "Press Start 2P", monospace;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--paper);
  background: var(--ink);
  font-size: 15px;
  clip-path: polygon(0 0, 100% 0, 100% 73%, 73% 73%, 73% 100%, 0 100%);
}

.scoreboard {
  display: flex;
  gap: 30px;
  color: var(--muted);
  font: 10px "Press Start 2P", monospace;
}

.scoreboard strong {
  margin-left: 7px;
  color: var(--ink);
  font-size: 13px;
}

.game-frame {
  position: relative;
  height: clamp(390px, 58vw, 610px);
  overflow: hidden;
  cursor: pointer;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: .08;
  background: repeating-linear-gradient(to bottom, transparent 0 3px, var(--ink) 4px);
  mix-blend-mode: multiply;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(245,240,229,.28);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s, visibility .2s;
}

.overlay.visible { opacity: 1; visibility: visible; transform: none; }
.eyebrow { margin-bottom: 17px; color: var(--sun); font: 9px "Press Start 2P", monospace; letter-spacing: 2px; }

h1, h2 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  line-height: 1.25;
}

h1 { font-size: clamp(31px, 5.4vw, 66px); letter-spacing: -3px; }
h1 span { color: var(--sun); }
.overlay p { margin: 23px 0 27px; color: #565850; font-size: clamp(12px, 1.5vw, 15px); line-height: 1.8; }

.primary {
  display: flex;
  align-items: center;
  gap: 15px;
  min-height: 52px;
  padding: 0 24px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 5px 5px 0 var(--sun);
  font: 10px "Press Start 2P", monospace;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.primary:hover { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--sun); }
.primary:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--sun); }
.key-icon { padding: 6px 7px; background: var(--paper); color: var(--ink); font-size: 7px; }

.mini-controls {
  display: flex;
  gap: 22px;
  margin-top: 25px;
  color: var(--muted);
  font: 8px "Press Start 2P", monospace;
}
.mini-controls i {
  display: inline-grid;
  place-items: center;
  width: 25px; height: 25px;
  margin-right: 5px;
  border: 1px solid #aaa69a;
  font: normal 14px "DM Mono";
}

.game-over { background: rgba(245,240,229,.76); }
.game-over h2 { font-size: clamp(27px, 4.5vw, 52px); }
.result { margin: 25px 0 8px; display: grid; gap: 8px; }
.result span { color: var(--muted); font: 8px "Press Start 2P"; }
.result strong { font: 24px "Press Start 2P"; }
.new-record { height: 22px; color: var(--sun); font: 8px "Press Start 2P"; }
.new-record.hidden { visibility: hidden; }
.game-over .primary { margin-top: 10px; }
.game-over .restart-hint { margin: 18px 0 0; font: 7px "Press Start 2P"; }

.footer {
  min-height: 58px;
  border-top: 2px solid var(--ink);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font: 7px "Press Start 2P", monospace;
}

.status span { display: inline-block; width: 7px; height: 7px; margin-right: 8px; background: var(--sun); }
.tips { display: flex; gap: 24px; }
.tips b { margin-left: 6px; color: var(--ink); }
.mobile-buttons { display: none; }

@media (max-width: 700px) {
  body { padding: 0; }
  .shell { min-height: 100dvh; border-width: 0; box-shadow: none; display: flex; flex-direction: column; }
  .topbar { height: 62px; padding: 0 15px; border-width: 0 0 2px; }
  .brand { font-size: 8px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; font-size: 12px; }
  .scoreboard { gap: 12px; font-size: 6px; }
  .scoreboard strong { font-size: 8px; margin-left: 3px; }
  .game-frame { flex: 1; height: auto; min-height: 430px; }
  h1 { letter-spacing: -2px; }
  .key-icon, .mini-controls, .tips { display: none; }
  .footer { height: 98px; padding: 10px 16px; }
  .status { display: none; }
  .mobile-buttons { width: 100%; display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; }
  .mobile-buttons button {
    height: 68px;
    border: 2px solid var(--ink);
    background: transparent;
    color: var(--ink);
    font: 22px "Press Start 2P";
    touch-action: none;
  }
  .mobile-buttons button:last-child { color: var(--paper); background: var(--ink); box-shadow: 4px 4px 0 var(--sun); }
  .mobile-buttons small { display: block; margin-top: 6px; font: 7px "Press Start 2P"; }
}

@media (max-height: 620px) and (orientation: landscape) {
  body { padding: 0; }
  .shell { width: 100%; border: 0; box-shadow: none; }
  .topbar { height: 48px; }
  .game-frame { height: calc(100vh - 96px); }
  .footer { min-height: 48px; }
  .overlay p { margin: 10px 0 14px; }
  .mini-controls { margin-top: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay, .primary { transition: none; }
}
