/* ═══════════════════════════════════════════════════════════════════════════
   Super Mario World / SNES map-screen aesthetic
   Palette sampled from SMW overworld: bright sky-blue sea, grass green,
   orange cliffs, cream paths, thick dark outlines. No modern glass/gradients.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* SMW map core */
  --sea: #4aa8e8;
  --sea-deep: #3a90d0;
  --sea-light: #6bc0f0;
  --grass: #5cbc48;
  --grass-lite: #78d060;
  --grass-dark: #3e9430;
  --cliff: #e89848;
  --cliff-dark: #c87830;
  --cliff-edge: #a05820;
  --sand: #e8d078;
  --sand-dark: #c8a848;
  --ice: #e8f0f8;
  --wave: #ffffff;
  --path: #f8e868;
  --path-outline: #c8a020;

  /* HUD (SMW status / coin box energy) */
  --hud-yellow: #f8d830;
  --hud-red: #e03020;
  --hud-white: #f8f0e0;
  --hud-black: #181010;
  --hud-panel: #f8e8a0;
  --hud-panel-edge: #c8a040;
  --hud-blue: #3060c8;
  --pink: #f06098;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--sea);
  color: var(--hud-black);
  font-family: "Press Start 2P", monospace;
  /* Force chunky pixels everywhere — no browser anti-alias on UI chrome */
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Full-bleed game stage ───────────────────────────────────────────────── */
.game {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--sea);
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  z-index: 0;
  /* size/position set by JS for integer pixel scale */
  cursor: crosshair;
  touch-action: none;
}

/* ── HUD ─────────────────────────────────────────────────────────────────── */
.hud {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.5vw, 12px);
  padding: max(8px, var(--safe-top)) 10px 0;
  pointer-events: none;
  text-align: center;
}

/* Mario logo energy: solid yellow block letters, red outline, black drop */
.title {
  font-size: clamp(9px, 2.4vw, 16px);
  line-height: 1.55;
  letter-spacing: 0.02em;
  color: var(--hud-yellow);
  max-width: 22ch;
  text-shadow:
    3px 0 0 var(--hud-red),
    -3px 0 0 var(--hud-red),
    0 3px 0 var(--hud-red),
    0 -3px 0 var(--hud-red),
    2px 2px 0 var(--hud-red),
    -2px 2px 0 var(--hud-red),
    2px -2px 0 var(--hud-red),
    -2px -2px 0 var(--hud-red),
    4px 4px 0 var(--hud-black);
  animation: title-wobble 2.2s steps(2) infinite;
}

@keyframes title-wobble {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

/* Cream SMW-style info box with hard bevel (no soft shadow glow) */
.timer {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(3px, 1vw, 10px);
  background: var(--hud-panel);
  border: 4px solid var(--hud-black);
  box-shadow:
    inset 3px 3px 0 var(--hud-white),
    inset -3px -3px 0 var(--hud-panel-edge),
    4px 4px 0 var(--hud-black);
  padding: clamp(8px, 1.8vw, 14px) clamp(8px, 2vw, 18px);
  /* hard corners — SNES UI is blocky */
  border-radius: 0;
  max-width: calc(100vw - 20px);
}

.unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: clamp(34px, 9.5vw, 68px);
}

.unit .value {
  font-size: clamp(16px, 6vw, 36px);
  line-height: 1;
  color: var(--hud-blue);
  text-shadow: 2px 2px 0 var(--hud-black);
  font-variant-numeric: tabular-nums;
}

.unit .label {
  margin-top: 6px;
  font-size: clamp(6px, 1.5vw, 8px);
  color: var(--hud-black);
  letter-spacing: 0.06em;
}

.colon {
  font-size: clamp(14px, 4.5vw, 28px);
  color: var(--hud-red);
  line-height: 1;
  padding-top: 0;
  text-shadow: 2px 2px 0 var(--hud-black);
  animation: colon-blink 1s steps(1) infinite;
}

@keyframes colon-blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.2;
  }
}

.subtitle {
  font-size: clamp(6px, 1.6vw, 9px);
  color: var(--hud-black);
  background: var(--hud-panel);
  border: 3px solid var(--hud-black);
  box-shadow: 3px 3px 0 var(--hud-black);
  padding: 5px 8px;
  letter-spacing: 0.04em;
}

/* ── Girlfriend Day marquee (between countdown + map) ────────────────────── */
.marquee {
  /* full-bleed strip under the timer, still inside the HUD stack */
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-top: 4px;
  overflow: hidden;
  pointer-events: none;
  background: var(--pink);
  border-top: 3px solid var(--hud-black);
  border-bottom: 3px solid var(--hud-black);
  box-shadow: 0 3px 0 var(--hud-black);
  padding: 7px 0;
}

.marquee__track {
  display: flex;
  width: max-content;
  gap: 0;
  animation: marquee-slide 18s linear infinite;
  will-change: transform;
}

.marquee__item {
  flex: 0 0 auto;
  padding: 0 1.5em;
  font-size: clamp(7px, 1.8vw, 11px);
  color: var(--hud-white);
  text-shadow: 2px 2px 0 var(--hud-black);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

@keyframes marquee-slide {
  from {
    transform: translateX(0);
  }
  to {
    /* half of 6 identical items → seamless loop */
    transform: translateX(-50%);
  }
}

.timer.is-done .value {
  color: var(--hud-red);
  animation: done-flash 0.5s steps(2) infinite;
}

@keyframes done-flash {
  from {
    color: var(--hud-red);
  }
  to {
    color: var(--hud-yellow);
  }
}

/* ── Character pins (SMW level-icon squares) ─────────────────────────────── */
.pin {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Compact SNES level-icon size — must not dominate the map */
  width: clamp(36px, 8vw, 48px);
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  animation: bob 1.6s steps(2) infinite;
}

.pin:focus-visible {
  outline: 3px solid var(--hud-white);
  outline-offset: 4px;
}

/* Floating hearts that pop above a tapped character */
.pin-hearts {
  position: absolute;
  left: 50%;
  top: 0;
  width: 0;
  height: 0;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}

.pin-heart {
  position: absolute;
  left: 0;
  bottom: 0;
  font-size: clamp(14px, 4vw, 20px);
  line-height: 1;
  color: var(--pink);
  text-shadow:
    2px 0 0 var(--hud-black),
    -2px 0 0 var(--hud-black),
    0 2px 0 var(--hud-black),
    0 -2px 0 var(--hud-black),
    1px 1px 0 var(--hud-black);
  transform: translate(-50%, 0) scale(0.4);
  animation: pin-heart-pop 0.75s steps(10) forwards;
  pointer-events: none;
}

.pin-heart--alt {
  color: var(--hud-red);
}

@keyframes pin-heart-pop {
  0% {
    transform: translate(-50%, 4px) scale(0.35);
    opacity: 1;
  }
  20% {
    transform: translate(-50%, -10px) scale(1.15);
    opacity: 1;
  }
  45% {
    transform: translate(calc(-50% + var(--hx, 0px)), -28px) scale(1);
    opacity: 1;
  }
  75% {
    transform: translate(calc(-50% + var(--hx, 0px)), -48px) scale(0.95);
    opacity: 0.7;
  }
  100% {
    transform: translate(calc(-50% + var(--hx, 0px)), -64px) scale(0.8);
    opacity: 0;
  }
}

.pin-korea {
  left: 28%;
  top: 38%;
  animation-delay: 0s;
}

.pin-nj {
  left: 78%;
  top: 36%;
  animation-delay: 0.35s;
}

@keyframes bob {
  0%,
  100% {
    transform: translate(-50%, -100%) translateY(0);
  }
  50% {
    transform: translate(-50%, -100%) translateY(-4px);
  }
}

.pin-frame {
  width: 100%;
  aspect-ratio: 1;
  border: 3px solid var(--hud-black);
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.55),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2),
    3px 3px 0 var(--hud-black);
  background: #2868a8;
  overflow: hidden;
  image-rendering: pixelated;
  /* stem tip */
  position: relative;
}

.pin-frame::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  background: var(--hud-yellow);
  border: 2px solid var(--hud-black);
  z-index: 1;
}

.pin-frame--pink {
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.55),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2),
    3px 3px 0 var(--hud-black),
    0 0 0 2px var(--pink);
}

.pin-frame--yellow {
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.55),
    inset -2px -2px 0 rgba(0, 0, 0, 0.2),
    3px 3px 0 var(--hud-black),
    0 0 0 2px var(--hud-yellow);
}

.portrait {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pin-tag {
  margin-top: 10px;
  font-size: clamp(5px, 1.2vw, 7px);
  color: var(--hud-black);
  background: var(--hud-panel);
  border: 2px solid var(--hud-black);
  box-shadow: 2px 2px 0 var(--hud-black);
  padding: 2px 4px;
  white-space: nowrap;
}

/* Pixel flags under the KOREA / USA labels */
.pin-flag {
  margin-top: 4px;
  width: clamp(28px, 7vw, 36px);
  line-height: 0;
  border: 2px solid var(--hud-black);
  box-shadow: 2px 2px 0 var(--hud-black);
  background: var(--hud-black);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  position: relative;
}

.flag {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 22 / 14;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Question block (SMB hit-from-below coin box) ────────────────────────── */
.q-stage {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: calc(48px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.q-stage .q-block {
  pointer-events: auto;
}

/* Prize images spawn into this layer (above the block) */
.prize-layer {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
}

/* Classic gold ? block — flat SNES colors, rivets, hard outline */
.q-block {
  position: relative;
  z-index: 1;
  width: clamp(44px, 12vw, 56px);
  height: clamp(44px, 12vw, 56px);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  image-rendering: pixelated;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  animation: q-idle 0.8s steps(2) infinite;
}

.q-block:focus-visible {
  outline: 3px solid var(--hud-white);
  outline-offset: 3px;
}

.q-block__face {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background: #f0b018;
  border: 3px solid #181010;
  box-shadow:
    inset 3px 3px 0 #f8d848,
    inset -3px -3px 0 #c87810,
    3px 3px 0 #181010;
  /* no rounded corners — cartridge era */
}

/* Corner rivets like SMB ? blocks */
.q-block__bolt {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #181010;
  image-rendering: pixelated;
}

.q-block__bolt--tl {
  top: 4px;
  left: 4px;
}
.q-block__bolt--tr {
  top: 4px;
  right: 4px;
}
.q-block__bolt--bl {
  bottom: 4px;
  left: 4px;
}
.q-block__bolt--br {
  bottom: 4px;
  right: 4px;
}

.q-block__mark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(18px, 5vw, 24px);
  color: #181010;
  text-shadow: 2px 0 0 #c87810;
  line-height: 1;
  /* slight vertical bounce of the ? itself (SMB shimmer) */
  animation: q-mark-pulse 0.6s steps(2) infinite;
}

/* Hit from below: block pops up then settles (classic Mario bump) */
.q-block.is-bump .q-block__face {
  animation: q-bump 0.22s steps(4) forwards;
}

/* After hit: used / empty block (brown, no ?) — then reactivates */
.q-block.is-empty .q-block__face {
  background: #b07038;
  box-shadow:
    inset 3px 3px 0 #c89050,
    inset -3px -3px 0 #805028,
    3px 3px 0 #181010;
}

.q-block.is-empty .q-block__mark {
  opacity: 0;
  animation: none;
}

.q-block.is-empty {
  animation: none;
  cursor: default;
}

.q-hint {
  font-size: clamp(6px, 1.4vw, 8px);
  color: var(--hud-black);
  background: var(--hud-panel);
  border: 2px solid var(--hud-black);
  box-shadow: 2px 2px 0 var(--hud-black);
  padding: 3px 6px;
  letter-spacing: 0.08em;
  animation: q-hint-blink 1s steps(1) infinite;
  pointer-events: none;
}

.q-stage.is-spent .q-hint {
  visibility: hidden;
}

/* Prize “coin” — photo that rockets up and fades (SMB coin pop) */
.prize {
  position: absolute;
  left: 0;
  bottom: 0;
  /* 50% larger than prior pop size */
  width: clamp(72px, 19.8vw, 102px);
  height: clamp(72px, 19.8vw, 102px);
  margin-left: calc(clamp(72px, 19.8vw, 102px) / -2);
  border: 3px solid #181010;
  box-shadow: 2px 2px 0 #181010;
  overflow: hidden;
  background: #2868a8;
  image-rendering: auto;
  pointer-events: none;
  /* SMB coin: shoot up fast, hold, fade while rising */
  animation: prize-pop 0.85s steps(12) forwards;
  z-index: 3;
}

.prize img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
  /* slight pixel feel while still readable */
  image-rendering: auto;
}

@keyframes q-idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes q-mark-pulse {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-1px);
  }
}

/* Block hit: jump up 8px then settle (matches SMB question-block bump) */
@keyframes q-bump {
  0% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-10px);
  }
  50% {
    transform: translateY(-6px);
  }
  75% {
    transform: translateY(-2px);
  }
  100% {
    transform: translateY(0);
  }
}

/* Coin-style prize path: up, slight hang, fade out while still rising */
@keyframes prize-pop {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 1;
  }
  15% {
    transform: translateY(-28px) scale(1.05);
    opacity: 1;
  }
  35% {
    transform: translateY(-52px) scale(1);
    opacity: 1;
  }
  55% {
    transform: translateY(-68px) scale(1);
    opacity: 1;
  }
  80% {
    transform: translateY(-92px) scale(0.95);
    opacity: 0.55;
  }
  100% {
    transform: translateY(-110px) scale(0.85);
    opacity: 0;
  }
}

@keyframes q-hint-blink {
  0%,
  55% {
    opacity: 1;
  }
  56%,
  100% {
    opacity: 0.25;
  }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(6px, 1.5vw, 9px);
  color: var(--hud-black);
  background: var(--hud-panel);
  border-top: 4px solid var(--hud-black);
  box-shadow: inset 0 3px 0 var(--hud-white);
  padding: 8px 12px max(10px, var(--safe-bottom));
  letter-spacing: 0.1em;
}

.coin {
  color: var(--hud-red);
  animation: coin-spin 1.2s steps(2) infinite;
}

@keyframes coin-spin {
  0%,
  60% {
    opacity: 1;
  }
  61%,
  100% {
    opacity: 0.25;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .title,
  .colon,
  .pin,
  .coin,
  .timer.is-done .value,
  .q-block,
  .q-block__mark,
  .q-hint,
  .marquee__track {
    animation: none;
  }

  .pin-heart {
    animation: pin-heart-pop-static 0.6s linear forwards;
  }

  .prize {
    animation: prize-pop-static 0.6s linear forwards;
  }
}

@keyframes pin-heart-pop-static {
  from {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -48px);
  }
}

@keyframes prize-pop-static {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-80px);
  }
}

/* Short phones: compress HUD */
@media (max-height: 560px) {
  .title {
    font-size: 8px;
  }
  .unit .value {
    font-size: 14px;
  }
  .footer {
    font-size: 6px;
    padding: 5px 8px max(6px, var(--safe-bottom));
  }
  .hud {
    gap: 6px;
  }
}
