@font-face {
  font-family: Audiowide;
  src: url("assets/fonts/Audiowide-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Chakra Petch";
  src: url("assets/fonts/ChakraPetch-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #100e14;
  --paper: #f4efe6;
  --mute: #b7afc2;
  --faint: #8d869a;
  --pink: #ff4fa3;
  --pink-soft: #f0a8c8;
  --teal: #3ef0e0;
  --orange: #ff7a1a;
  --gold: #ffd56a;
  --lavender: #c3b4f0;
  --line: #322c3c;
  --display: Audiowide, "Century Gothic", "Trebuchet MS", sans-serif;
  --body: "Chakra Petch", "Segoe UI", Verdana, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
  font-weight: 400;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}

@media (pointer: coarse), (max-width: 819px) {
  html, body {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
  }

  #stage {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
  }
}

#stage:fullscreen,
#stage:-webkit-full-screen {
  width: 100vw;
  height: 100dvh;
  background: #070414;
}

button, input { font: inherit; color: inherit; }

button { cursor: pointer; }

#stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #070414;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

canvas:focus { outline: none; }

canvas:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -6px;
}

.grain, .vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grain {
  opacity: 0.2;
  mix-blend-mode: overlay;
  background-image: url("assets/grain.png");
  background-size: 160px 160px;
}

.vignette {
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.58) 100%);
}

html.reduce .grain { opacity: 0.1; }

.topbar, .hud, .banner, .hint {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.topbar {
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  padding: calc(0.45rem + env(safe-area-inset-top)) 0.7rem 0.2rem;
}

.brand {
  pointer-events: auto;
  color: var(--pink-soft);
  text-decoration: none;
  font-family: var(--display);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(255, 79, 163, 0.45);
}

.actions { display: flex; gap: 0.35rem; pointer-events: auto; }

.hud {
  top: calc(2.35rem + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.15rem 0.6rem;
  padding: 0.15rem 0.75rem 0.8rem;
  background: linear-gradient(180deg, rgba(7, 4, 16, 0.78), rgba(7, 4, 16, 0));
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.74rem, 2.5vw, 0.98rem);
}

.hud p { margin: 0; }

.hud-score { justify-self: start; }
.hud-wave { justify-self: center; text-align: center; color: var(--teal); }
.hud-side { justify-self: end; text-align: right; }

.k {
  display: block;
  color: var(--faint);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hud strong { font-weight: 500; color: var(--paper); }

.combo-hot { color: var(--pink-soft); text-shadow: 0 0 10px rgba(255, 79, 163, 0.7); }

.candles { display: inline-flex; gap: 0.2rem; vertical-align: middle; }

.candle { width: 16px; height: 28px; display: inline-block; }

.candle .flame { fill: #ffd56a; }
.candle .wax { fill: #f4efe6; }
.candle.out .flame { display: none; }
.candle.out .wax { fill: #5c5568; }

.lanes { display: inline-flex; gap: 0.25rem; margin-top: 0.2rem; }

.lanes span {
  min-width: 1.4rem;
  text-align: center;
  border: 1px solid rgba(195, 180, 240, 0.4);
  border-radius: 999px;
  color: var(--faint);
  font-size: 0.72rem;
  padding: 0.05rem 0.3rem;
}

.lanes span.on {
  color: #140812;
  background: var(--pink);
  border-color: var(--pink);
}

.banner {
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 0 0 18px rgba(255, 79, 163, 0.55);
}

.banner .eyebrow, .card .eyebrow {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.banner-title {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-size: clamp(2rem, 7vw, 4rem);
  font-weight: 400;
  letter-spacing: -0.03em;
}

.hint {
  left: 50%;
  bottom: calc(54px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(10, 6, 16, 0.72);
  color: var(--paper);
  font-size: 0.85rem;
  white-space: nowrap;
  max-width: calc(100% - 1.2rem);
  overflow: hidden;
  text-overflow: ellipsis;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: calc(3.2rem + env(safe-area-inset-top)) 0.8rem calc(78px + env(safe-area-inset-bottom));
  overflow: auto;
  touch-action: pan-y;
  pointer-events: auto;
}

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

.card {
  width: min(460px, 100%);
  margin-top: 2vh;
  padding: 1rem 1.05rem 1.05rem;
  border-radius: 18px;
  border: 3px solid var(--paper);
  background:
    radial-gradient(circle at 0 0, rgba(255, 79, 163, 0.18), transparent 36%),
    radial-gradient(circle at 100% 0, rgba(62, 240, 224, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(22, 14, 32, 0.94), rgba(10, 6, 16, 0.96));
  box-shadow:
    0 0 0 5px rgba(16, 8, 18, 0.55),
    0 0 0 8px rgba(255, 79, 163, 0.85),
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 40px rgba(255, 79, 163, 0.05);
  user-select: text;
  -webkit-user-select: text;
}

.card h1, .card h2, .word {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.presents {
  margin: 0.35rem 0 0.2rem;
  text-align: center;
  color: var(--lavender);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.word {
  margin: 0.15rem 0 0.35rem;
  text-align: center;
  font-size: clamp(2.3rem, 10vw, 3.5rem);
  color: var(--paper);
  text-shadow:
    0 0 18px rgba(255, 79, 163, 0.65),
    3px 3px 0 #140812;
}

.word span {
  display: inline-block;
  animation: hop 1.15s ease-in-out infinite;
}

.word span:nth-child(2) { animation-delay: 0.12s; color: var(--pink-soft); }
.word span:nth-child(3) { animation-delay: 0.22s; }

html.reduce .word span { animation: none; }

@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  40% { transform: translateY(-7px) rotate(-1.5deg); }
  60% { transform: translateY(-2px) rotate(1deg); }
}

.deck, .how {
  margin: 0.35rem 0;
  color: var(--mute);
  font-size: 0.98rem;
  line-height: 1.45;
}

.legend {
  list-style: none;
  margin: 0.55rem 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 0.6rem;
  color: var(--paper);
  font-size: 0.88rem;
}

.legend li { display: flex; align-items: center; gap: 0.4rem; }

.pip {
  width: 0.85rem;
  height: 0.55rem;
  border-radius: 40% 40% 45% 45%;
  background: #3a2158;
  box-shadow: 0 0 0 2px #140812;
  position: relative;
  flex: none;
}

.pip::before, .pip::after {
  content: "";
  position: absolute;
  top: -0.28rem;
  width: 0.48rem;
  height: 0.38rem;
  border-radius: 50% 50% 0 0;
  background: inherit;
}

.pip::before { left: -0.18rem; transform: rotate(-28deg); }
.pip::after { right: -0.18rem; transform: rotate(28deg); }

.pip.fast { background: #148a96; transform: scale(0.82); }
.pip.gold { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.pip.bad { background: #8d1230; box-shadow: 0 0 8px var(--orange); }

.keys {
  margin: 0.2rem 0 0.7rem;
  color: var(--faint);
  font-size: 0.82rem;
}

.cluster { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.btn {
  border-radius: 999px;
  border: 1px solid transparent;
  min-height: 2.75rem;
  padding: 0.55rem 1rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-primary {
  background: var(--orange);
  color: #140812;
  box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.55), 0 0 18px rgba(255, 122, 26, 0.35);
}

.btn-primary:hover { background: #e85d04; }

.btn-ghost {
  background: transparent;
  color: var(--paper);
  border-color: rgba(195, 180, 240, 0.55);
}

.btn-ghost[aria-pressed="true"] {
  border-color: var(--pink);
  color: var(--pink-soft);
}

.btn-exit {
  min-height: 2rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
}

#btn-start, #btn-retry, #btn-resume, #btn-coach {
  scroll-margin-bottom: 88px;
}

.for-touch { display: none; }

html.touch .for-keys { display: none; }
html.touch .for-touch { display: block; }
html.touch p.for-touch { display: block; }

.hud-vital {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  margin-top: 0.15rem;
}

.hp-wrap { display: flex; flex-direction: column; gap: 0.12rem; }

.hp-bar {
  display: flex;
  gap: 3px;
  min-height: 10px;
}

.hp-bar i {
  display: block;
  width: 16px;
  height: 10px;
  border-radius: 2px;
  background: #3a2430;
  box-shadow: inset 0 0 0 1px rgba(255, 79, 163, 0.4);
}

.hp-bar i.on {
  background: linear-gradient(180deg, #ff4fa3, #ff7a1a);
  box-shadow: 0 0 8px rgba(255, 79, 163, 0.75);
}

html.reduce .hp-bar i.on { box-shadow: none; }

.bats-count { margin: 0; }
.bats-count strong {
  color: var(--teal);
  font-weight: 500;
  letter-spacing: 0.03em;
}

.pip.bomb { background: #ff7a1a; box-shadow: 0 0 8px #ff4fa3; }

.result-line {
  margin: 0.15rem 0;
  color: var(--paper);
  font-size: 1.05rem;
}

#over-title.win-title {
  color: #3ef0e0;
  font-size: clamp(1.55rem, 6.4vw, 2.15rem);
  text-shadow:
    0 0 16px rgba(62, 240, 224, 0.9),
    0 0 28px rgba(255, 79, 163, 0.55),
    3px 3px 0 #140812;
}

#over-title.loss-title {
  color: #ffb088;
  font-size: clamp(1.7rem, 7vw, 2.35rem);
  text-shadow: 0 0 16px rgba(255, 122, 26, 0.75), 3px 3px 0 #140812;
}

.smash {
  display: block;
  width: 92px;
  height: 74px;
  margin: 0.15rem auto 0;
}

.smash[hidden] { display: none !important; }

.coach, .count-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.8rem calc(64px + env(safe-area-inset-bottom));
  background: rgba(8, 4, 14, 0.62);
}

.coach[hidden], .count-overlay[hidden] { display: none !important; }

.coach-card {
  width: min(420px, 100%);
  padding: 1rem 1.05rem 1.1rem;
  border-radius: 18px;
  border: 3px solid var(--paper);
  background: linear-gradient(180deg, rgba(22, 14, 32, 0.96), rgba(10, 6, 16, 0.98));
  box-shadow: 0 0 0 5px rgba(255, 79, 163, 0.75);
}

.count-overlay { z-index: 14; flex-direction: column; text-align: center; cursor: pointer; }

.count-kicker {
  margin: 0;
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

#count-num {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: clamp(4.5rem, 22vw, 7rem);
  line-height: 0.9;
  color: var(--paper);
  text-shadow: 0 0 18px rgba(255, 79, 163, 0.7);
}

.btn:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.best-line { margin: 0.55rem 0 0; color: var(--gold); }

.score-xl {
  margin: 0.15rem 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  line-height: 1;
}

.form {
  display: grid;
  gap: 0.7rem;
  margin-top: 0.7rem;
}

.form label span, .field-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--paper);
}

.form input[type="email"],
.form input[type="tel"] {
  width: 100%;
  padding: 0.7rem 0.75rem;
  border-radius: 0.8rem;
  border: 1px solid var(--line);
  background: #100e14;
  color: var(--paper);
  font-size: 16px;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.65rem;
  align-items: start;
  color: var(--mute);
  font-size: 0.92rem;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  accent-color: var(--pink);
}

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#reward-thanks h2 {
  font-family: var(--display);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 400;
  line-height: 1.15;
  margin: 0.4rem 0;
}

@media (max-width: 420px) {
  .legend { grid-template-columns: 1fr; }
  .hint { white-space: normal; text-align: center; }
  .hud { font-size: 0.75rem; }
}

@media (max-height: 520px) {
  .card { margin-top: 0; }
  .word { font-size: 2rem; }
  .how { font-size: 0.88rem; }
}
