@font-face {
  font-family: "Press Start 2P";
  src: url("fonts/PressStart2P-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #140c28;
  --ink: #f6f0d8;
  --muted: #c9b8e0;
  --gold: #ffd95a;
  --gold-edge: #c45c12;
  --cyan: #5ef2e3;
  --magenta: #ff5fa8;
  --grass-a: #3fa34a;
  --grass-b: #2b7a36;
  --grass-edge: #14501c;
  --dirt: #6b3e1f;
  --dirt-dark: #3d2212;
  --hole: #1a0c08;
  --btn-red: #e23b3b;
  --btn-red-edge: #6d1010;
  --btn-red-shadow: #8a1515;
  --btn-green: #2fbf6b;
  --btn-green-edge: #0d5a2c;
  --btn-green-shadow: #157a3d;
  --safe-top: max(12px, env(safe-area-inset-top));
  --safe-right: max(12px, env(safe-area-inset-right));
  --safe-bottom: max(12px, env(safe-area-inset-bottom));
  --safe-left: max(12px, env(safe-area-inset-left));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: "Press Start 2P", ui-monospace, "Cascadia Mono", "Courier New", monospace;
  font-size: 11px;
  line-height: 1.8;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body.is-doc {
  user-select: text;
}

body.is-play {
  overflow: hidden;
  height: 100svh;
}

.skip {
  position: absolute;
  left: 8px;
  top: -100px;
  z-index: 40;
  padding: 8px 12px;
  background: var(--gold);
  color: #1a0a00;
  text-decoration: none;
}

.skip:focus {
  top: 8px;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 0%, #3a1d6e 0%, transparent 55%),
    linear-gradient(180deg, #0b0618 0%, var(--bg) 42%, #0e1a12 100%);
}

.stars {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 8% 12%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 28%, #cde 50%, transparent 51%),
    radial-gradient(2px 2px at 36% 8%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 48% 22%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 14%, #cde 50%, transparent 51%),
    radial-gradient(2px 2px at 74% 26%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 10%, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 14% 42%, #cde 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 38%, #fff 50%, transparent 51%);
  opacity: 0.7;
}

.scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.14) 0,
    rgba(0, 0, 0, 0.14) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.35;
  mix-blend-mode: multiply;
}

.screen,
.overlay,
.doc,
.noscript {
  position: relative;
  z-index: 1;
}

.screen {
  min-height: 100svh;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.screen[hidden],
.overlay[hidden],
[hidden] {
  display: none !important;
}

.top {
  text-align: center;
  width: 100%;
}

.cabinet {
  margin: 0 0 10px;
  color: var(--magenta);
  font-size: 8px;
  letter-spacing: 0.28em;
}

h1 {
  margin: 0;
  color: var(--gold);
  font-size: clamp(26px, 11vw, 64px);
  line-height: 1.15;
  letter-spacing: 0.08em;
  text-shadow:
    3px 0 var(--gold-edge),
    -3px 0 var(--gold-edge),
    0 3px var(--gold-edge),
    0 -3px var(--gold-edge),
    5px 5px 0 #000;
}

.tagline {
  margin: 14px 0 0;
  color: var(--cyan);
  font-size: clamp(8px, 2.6vw, 13px);
  letter-spacing: 0.14em;
  text-shadow: 2px 2px 0 #000;
}

.how,
.hi {
  max-width: 36em;
  margin: 16px auto 0;
  text-align: center;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.9;
}

.hi {
  color: var(--gold);
  font-size: 10px;
}

.title-actions {
  display: grid;
  gap: 12px;
  width: min(420px, 100%);
  margin: 20px auto 16px;
}

button {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  color: #fff;
  border-radius: 8px;
  padding: 16px 18px;
  min-height: 52px;
  cursor: pointer;
  appearance: none;
}

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

#start-btn,
#again-btn,
#resume-btn,
#continue-btn {
  background: var(--btn-red);
  border: 4px solid var(--btn-red-edge);
  box-shadow: 0 6px 0 var(--btn-red-shadow), 0 8px 0 #000;
}

#start-btn:active,
#again-btn:active,
#resume-btn:active,
#continue-btn:not(:disabled):active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #222, 0 3px 0 #000;
}

#reward-btn,
#continue-btn:not(:disabled) {
  background: var(--btn-green);
  border: 4px solid var(--btn-green-edge);
  box-shadow: 0 6px 0 var(--btn-green-shadow), 0 8px 0 #000;
}

#continue-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #4a4a4a;
  border-color: #222;
  box-shadow: 0 6px 0 #222, 0 8px 0 #000;
}

.mute-btn {
  background: #2a2048;
  border: 4px solid #10081c;
  box-shadow: 0 4px 0 #0a0612;
  color: var(--ink);
  font-size: 10px;
  min-height: 44px;
}

.mute-btn[aria-pressed="true"] {
  color: var(--muted);
}

.site-foot {
  text-align: center;
  margin-top: auto;
  padding-top: 16px;
  color: var(--muted);
  font-size: 8px;
  line-height: 2;
}

.site-foot p {
  margin: 0 0 8px;
}

.site-foot a,
.doc a {
  color: var(--cyan);
}

.font-credit {
  color: #8e7aa8;
}

/* Ads — never sit on the play grid */
.ad-slot {
  width: min(520px, 100%);
  margin: 8px auto 0;
  text-align: center;
}

.ad-label {
  margin: 0 0 6px;
  color: #8e7aa8;
  font-size: 7px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.ad-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 72px;
  padding: 12px;
  border: 3px dashed #6a5a88;
  background: repeating-linear-gradient(
    -45deg,
    #1a1430,
    #1a1430 8px,
    #161028 8px,
    #161028 16px
  );
  color: #b9a8d0;
  font-size: 8px;
  line-height: 1.7;
}

.ad-box-tall {
  min-height: 160px;
}

.ad-meta,
.ad-status {
  display: block;
  color: #8e7aa8;
  font-size: 7px;
}

/* Play screen */
.screen-play {
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  height: 100svh;
  max-height: 100svh;
}

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 6px 8px;
  align-items: center;
  width: 100%;
  max-width: 900px;
  padding: 4px 0 8px;
}

.hud-cell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.hud-label {
  color: var(--muted);
  font-size: 7px;
  letter-spacing: 0.08em;
}

#hud-score,
#hud-combo,
#hud-level,
#hud-lives {
  color: var(--gold);
  font-size: clamp(10px, 3.2vw, 16px);
  letter-spacing: 0.04em;
}

#hud-combo.is-hot {
  color: var(--magenta);
}

#hud-lives {
  color: var(--btn-red);
  letter-spacing: 0.12em;
}

.hud-mute {
  min-height: 40px;
  padding: 8px 10px;
  font-size: 8px;
  white-space: nowrap;
}

.cue {
  min-height: 1.8em;
  margin: 0 0 6px;
  text-align: center;
  color: var(--cyan);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-shadow: 2px 2px 0 #000;
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: clamp(6px, 1.6vw, 14px);
  width: min(100%, calc(100svh - 9.5rem), 560px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 8px;
  border: 6px solid var(--grass-edge);
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg, var(--grass-a) 0 16px, var(--grass-b) 16px 32px);
  box-shadow: inset 0 0 0 4px #1e6a28, 0 8px 0 #000, 0 0 0 2px #000;
  touch-action: none;
}

.hole {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 72px;
  padding: 0;
  border: 0;
  border-radius: 50% 50% 46% 46%;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
  cursor: pointer;
}

.hole:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.pit {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 0;
  bottom: 12%;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2a160c 0%, var(--hole) 70%);
  box-shadow: inset 0 8px 0 rgba(0, 0, 0, 0.55);
}

.mound {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 0;
  height: 28%;
  border-radius: 50% 50% 40% 40%;
  background: radial-gradient(circle at 50% 20%, #a66a32 0%, var(--dirt) 55%, var(--dirt-dark) 100%);
  box-shadow: 0 3px 0 #1a0c08;
  z-index: 2;
  pointer-events: none;
}

.gopher {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 84%;
  aspect-ratio: 18 / 16;
  transform: translate(-50%, 140%);
  z-index: 1;
  pointer-events: none;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.4));
}

.gopher-sprite {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.gopher-sprite svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  opacity: 0;
}

.gopher-sprite svg:first-child {
  opacity: 1;
}

.hole.is-up .gopher {
  transform: translate(-50%, 0);
  transition: transform 0.12s ease-out;
}

.hole.is-up .gopher-sprite svg:nth-child(1) { animation: frame-cycle 0.48s linear infinite; animation-delay: 0s; }
.hole.is-up .gopher-sprite svg:nth-child(2) { animation: frame-cycle 0.48s linear infinite; animation-delay: -0.36s; }
.hole.is-up .gopher-sprite svg:nth-child(3) { animation: frame-cycle 0.48s linear infinite; animation-delay: -0.24s; }
.hole.is-up .gopher-sprite svg:nth-child(4) { animation: frame-cycle 0.48s linear infinite; animation-delay: -0.12s; }

.hole.is-down .gopher {
  transform: translate(-50%, 140%);
  transition: transform 0.12s ease-in;
}

.hole.is-gold .pit {
  box-shadow: inset 0 8px 0 rgba(0, 0, 0, 0.55), 0 0 16px rgba(255, 217, 90, 0.7);
}

.hole.is-gold .gopher {
  filter: sepia(0.35) saturate(1.8) hue-rotate(8deg) brightness(1.15) drop-shadow(0 0 6px #ffd95a);
}

.hole.is-whacked .gopher {
  transform: translate(-50%, 0) scale(0.6) rotate(-20deg);
  opacity: 0;
  transition: transform 0.16s ease-in, opacity 0.16s ease-in;
}

.fx {
  position: absolute;
  left: 50%;
  top: 12%;
  z-index: 3;
  transform: translate(-50%, 0);
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.04em;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
  animation: float-fx 0.7s ease-out forwards;
  white-space: nowrap;
}

.fx.is-perfect {
  color: var(--cyan);
  font-size: 10px;
}

.fx.is-gold {
  color: var(--gold);
}

.fx.is-miss {
  color: var(--magenta);
}

@keyframes frame-cycle {
  0%,
  24.99% { opacity: 1; }
  25%,
  100% { opacity: 0; }
}

@keyframes float-fx {
  0% { opacity: 1; transform: translate(-50%, 8px); }
  100% { opacity: 0; transform: translate(-50%, -18px); }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: rgba(8, 4, 16, 0.78);
}

.overlay-card {
  width: min(520px, 100%);
  padding: 20px 16px 16px;
  border: 4px solid #10081c;
  border-radius: 10px;
  background: #1a1230;
  box-shadow: 0 8px 0 #000;
  text-align: center;
}

.overlay-kicker {
  margin: 0 0 12px;
  color: var(--gold);
  font-size: 14px;
  letter-spacing: 0.1em;
}

.overlay-card p {
  margin: 0 0 16px;
}

.overlay-card button {
  width: 100%;
  margin-top: 12px;
}

.results {
  width: min(420px, 100%);
  margin: 20px auto 8px;
}

.results div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  font-size: 11px;
}

.results dt {
  color: var(--muted);
}

.results dd {
  margin: 0;
  color: var(--gold);
}

.new-best {
  color: var(--cyan);
  font-size: 10px;
  text-align: center;
}

/* Privacy / doc */
.doc {
  max-width: 42em;
  margin: 0 auto;
  padding: var(--safe-top) var(--safe-right) calc(var(--safe-bottom) + 24px) var(--safe-left);
}

.doc h1 {
  font-size: clamp(22px, 8vw, 40px);
  margin-bottom: 8px;
}

.doc h2 {
  margin: 28px 0 10px;
  color: var(--gold);
  font-size: 12px;
  line-height: 1.6;
}

.doc p,
.doc-updated {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.9;
  user-select: text;
}

.doc-updated {
  margin-top: 0;
}

.doc-back {
  margin-top: 32px;
}

.noscript {
  margin: 0;
  padding: 16px;
  text-align: center;
  background: #3a1020;
}

@media (max-width: 520px) {
  .hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hud-mute {
    grid-column: 1 / -1;
    justify-self: stretch;
  }
}

/* Landscape: keep the 3x3 grid thumb-sized and on-screen */
@media (orientation: landscape) and (max-height: 560px) {
  .screen-title,
  .screen-over {
    min-height: auto;
  }

  h1 {
    font-size: clamp(22px, 8vw, 40px);
  }

  .how {
    display: none;
  }

  .ad-box {
    min-height: 56px;
  }

  .screen-play {
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
  }

  .hud {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 9.5rem;
    flex: 0 0 9.5rem;
    grid-template-columns: none;
  }

  .hud-mute {
    grid-column: auto;
    width: 100%;
  }

  .cue {
    position: absolute;
    left: 50%;
    top: var(--safe-top);
    transform: translateX(-20%);
    z-index: 2;
  }

  .board {
    width: auto;
    height: calc(100svh - var(--safe-top) - var(--safe-bottom) - 8px);
    max-width: calc(100vw - 11rem);
    aspect-ratio: 1;
  }

  .hole {
    min-height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hole.is-up .gopher,
  .hole.is-down .gopher,
  .hole.is-whacked .gopher,
  .fx,
  .scanlines,
  .gopher-sprite svg,
  #start-btn:active,
  #again-btn:active {
    animation: none !important;
    transition: none !important;
  }

  .gopher-sprite svg {
    opacity: 0 !important;
  }

  .gopher-sprite svg:first-child {
    opacity: 1 !important;
  }

  .fx {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  .scanlines {
    display: none;
  }
}
