:root {
  --ink: #171a1f;
  --ink-2: #20252c;
  --stone: #3c424b;
  --cream: #f3ecdd;
  --muted: #a8b0ba;
  --copper: #c87b4a;
  --copper-hi: #e9a06e;
  --copper-lo: #8a4f2c;
  --grass: #5f9444;
  --gold: #f5c542;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a3038 0%, #14161a 55%, #0d0f12 100%);
  color: var(--cream);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow-x: hidden;
}

.shell {
  width: min(1040px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: var(--ink);
  border: 4px solid #2a3038;
  border-radius: 6px;
  box-shadow:
    0 0 0 2px #0c0e11,
    0 22px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px #4a515b;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  isolation: isolate;
}

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

/* ---------------------------------------------------------------- HUD */

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10, 12, 15, 0.72), rgba(10, 12, 15, 0));
  z-index: 3;
}

.hearts {
  display: flex;
  gap: 4px;
  padding-top: 3px;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.55));
}

.heart {
  width: 20px;
  height: 19px;
  display: block;
  clip-path: polygon(10% 0, 34% 0, 50% 18%, 66% 0, 90% 0, 100% 24%, 100% 44%, 50% 100%, 0 44%, 0 24%);
  background: #ff5a6a;
}

.heart.empty { background: #3a2c30; }

.score, .wave {
  display: flex;
  flex-direction: column;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.score span {
  font-size: clamp(20px, 3.4vw, 30px);
  font-weight: 800;
  color: var(--cream);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
  font-variant-numeric: tabular-nums;
}

.score small, .wave small {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--muted);
  text-transform: uppercase;
}

.wave {
  margin-left: auto;
  margin-right: 8px;
  align-items: flex-end;
  text-align: right;
}

.wave span {
  font-size: clamp(16px, 2.4vw, 22px);
  font-weight: 700;
  color: var(--gold);
}

.wave small { color: var(--copper-hi); letter-spacing: 0.12em; }

.hud-buttons {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-buttons button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--cream);
  background: rgba(32, 37, 44, 0.85);
  border: 2px solid #4a515b;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.hud-buttons button:hover { background: #2c333c; }
.hud-buttons button:active { transform: translateY(1px); }
.hud-buttons button.off { color: #6c7480; }

.combo {
  position: absolute;
  top: 74px;
  right: 18px;
  z-index: 3;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(14px, 2.2vw, 20px);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 2px 0 #000;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}

.combo.show { opacity: 1; transform: translateY(0); }

.toast {
  position: absolute;
  top: 22%;
  left: 50%;
  translate: -50% 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
  text-align: center;
}

.toast strong {
  font-size: clamp(26px, 5vw, 46px);
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--cream);
  text-shadow:
    0 3px 0 #6b3b1f,
    0 6px 18px rgba(0, 0, 0, 0.6);
}

.toast span {
  font-size: clamp(11px, 1.6vw, 14px);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--copper-hi);
}

.toast.show { animation: toast 1.7s ease both; }

@keyframes toast {
  0% { opacity: 0; transform: translateY(10px) scale(0.94); }
  14% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}

/* ------------------------------------------------------------- Screens */

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(80% 70% at 50% 40%, rgba(24, 28, 34, 0.45) 0%, rgba(10, 12, 15, 0.9) 100%);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.screen.hidden { display: none; }

.mark {
  width: clamp(44px, 7vw, 68px);
  height: auto;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, 0.35));
  animation: spin 9s linear infinite;
}

@keyframes spin { to { rotate: 360deg; } }

.screen h1 {
  margin: 0;
  font-size: clamp(30px, 6.6vw, 66px);
  line-height: 0.95;
  font-weight: 900;
  letter-spacing: 0.035em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow:
    0 4px 0 #7a4425,
    0 8px 0 #2a1a10,
    0 14px 30px rgba(0, 0, 0, 0.55);
}

.screen h2 {
  margin: 0;
  font-size: clamp(26px, 5vw, 44px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #7a4425, 0 6px 18px rgba(0, 0, 0, 0.5);
}

.tagline {
  margin: 0;
  font-size: clamp(13px, 1.9vw, 17px);
  line-height: 1.55;
  color: #d9d2c4;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 18px;
  margin: 2px 0 4px;
  font-size: clamp(11px, 1.6vw, 13px);
  color: var(--muted);
}

.controls div { display: flex; align-items: center; gap: 7px; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  color: var(--cream);
  padding: 3px 7px;
  border: 1px solid #59616c;
  border-bottom-width: 3px;
  border-radius: 4px;
  background: #2a3038;
}

.play {
  margin-top: 6px;
  padding: 14px 38px;
  font: inherit;
  font-size: clamp(15px, 2.2vw, 19px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #241207;
  background: linear-gradient(180deg, var(--copper-hi), var(--copper) 55%, var(--copper-lo));
  border: 2px solid #f0b98d;
  border-radius: 6px;
  box-shadow:
    0 6px 0 #5b3117,
    0 10px 24px rgba(0, 0, 0, 0.45),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  cursor: pointer;
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s ease;
}

.play:hover { filter: brightness(1.06); }

.play:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #5b3117,
    0 4px 12px rgba(0, 0, 0, 0.4),
    inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.play:focus-visible,
.hud-buttons button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.best {
  margin: 4px 0 0;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.best b { color: var(--gold); }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--copper-hi);
}

.over-line {
  margin: -6px 0 0;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.tiny {
  margin: 2px 0 0;
  font-size: 11px;
  color: #7f8792;
}

#overScreen h2 { font-size: clamp(46px, 9vw, 82px); color: var(--gold); }

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: #7f8792;
}

/* ---------------------------------------------------------- Fullscreen */

.frame:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
}

.frame:fullscreen canvas { height: 100%; width: 100%; object-fit: contain; background: var(--ink); }

/* Inside the site's iframe: fill the frame, keep the 16:10 canvas letterboxed. */
html.embedded,
html.embedded body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

html.embedded body {
  padding: 0;
  display: block;
  background: #0d0f12;
}

html.embedded .shell {
  width: 100vw;
  height: 100vh;
  gap: 0;
}

html.embedded .frame {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.embedded canvas {
  width: 100%;
  height: 100%;
  display: block;
}

html.embedded .hint { display: none; }

@media (max-width: 620px) {
  html.embedded .hud { padding: 6px 8px; }
}

@media (max-width: 620px) {
  body { padding: 8px; }
  .frame { border-width: 3px; }
  .hud { padding: 8px 9px; gap: 8px; }
  .heart { width: 18px; height: 17px; }
  .hud-buttons button { width: 34px; height: 34px; font-size: 12px; }
  .screen { gap: 9px; padding: 16px; }
  .controls { gap: 6px 12px; }
  .toast { top: 18%; }
  .combo { top: 56px; right: 10px; }
}

@media (max-height: 460px) and (orientation: landscape) {
  .screen h1 { font-size: 30px; }
  .tagline, .controls, .best { display: none; }
  .mark { width: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .mark { animation: none; }
  .toast.show { animation-duration: 0.01s; }
}
