:root {
  --blue: #1846b8;
  --blue-deep: #0b2a6b;
  --teal: #3ff0c8;
  --teal-deep: #0e9f86;
  --red: #e0141f;
  --sand: #e9d3a6;
  --ink: #fff7ea;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --display: "Arial Black", "Helvetica Neue", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #12060a;
  color: var(--ink);
  font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: fixed;
  inset: 0;
  margin: 0 auto;
  max-width: calc(100dvh * 0.62);
  overflow: hidden;
  background: var(--sand);
}

canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }

.hud-top {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55), 0 0 10px rgba(0, 0, 0, .35);
}

.hud-left { display: flex; flex-direction: column; gap: 4px; }
.hud-center { text-align: center; }
.hud-right { display: flex; justify-content: flex-end; }

.score { font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1; letter-spacing: 1px; }
.meters { font-size: 13px; font-weight: 700; opacity: .9; }

.hearts { display: flex; gap: 3px; font-size: 18px; line-height: 1; }
.hearts .heart { color: #ff3b4a; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .5)); }
.hearts .heart.empty { opacity: .25; filter: grayscale(1); }

.followers { display: flex; align-items: center; gap: 5px; font-weight: 800; font-size: 15px; }
.follower-icon {
  width: 12px; height: 14px; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(#f0dfbf 0 40%, #b98d5a 40%);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .5);
}
.mult {
  font-family: var(--display);
  font-size: 12px;
  color: var(--teal);
  background: rgba(11, 42, 107, .75);
  border-radius: 8px;
  padding: 1px 6px;
  text-shadow: none;
}
.mult:empty { display: none; }

.icon-btn {
  pointer-events: auto;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(11, 42, 107, .7);
  border: 2px solid rgba(255, 255, 255, .25);
  font-size: 14px;
  font-weight: 900;
}

.dew {
  position: absolute;
  top: calc(var(--safe-top) + 64px);
  left: 50%;
  transform: translateX(-50%);
  width: 58%;
  display: flex;
  align-items: center;
  gap: 6px;
}
.dew-label { font-family: var(--display); font-size: 11px; color: var(--teal); text-shadow: 0 1px 0 #000; }
.dew-bar {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .45);
  border: 1.5px solid rgba(255, 255, 255, .35);
  overflow: hidden;
}
.dew-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #0e9f86, #3ff0c8 70%, #c9fff1);
  box-shadow: 0 0 10px var(--teal);
  transform-origin: left center;
  transition: transform .15s linear;
}
.dew-fill.low { animation: low 0.5s steps(2) infinite; }
@keyframes low { 50% { opacity: .35; } }

.blast-btn {
  pointer-events: auto;
  position: absolute;
  right: 14px;
  bottom: calc(var(--safe-bottom) + 18px);
  width: 82px; height: 82px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c9fff1, #3ff0c8 35%, #0e9f86 75%, #075c4e);
  box-shadow: 0 6px 0 #04382f, 0 10px 24px rgba(0, 0, 0, .45);
  color: #04382f;
  display: grid;
  place-items: center;
  transition: transform .08s, filter .2s;
}
.blast-btn:active { transform: translateY(3px) scale(.97); }
.blast-btn.empty { filter: grayscale(.85) brightness(.75); }
.blast-btn.ready { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 #04382f, 0 0 0 8px rgba(63, 240, 200, .35), 0 10px 24px rgba(0, 0, 0, .45); } }
.blast-word { font-family: var(--display); font-size: 13px; line-height: 1.05; text-align: center; }
.blast-count {
  position: absolute; top: -4px; left: -4px;
  min-width: 26px; height: 26px; border-radius: 13px;
  background: var(--red); color: #fff;
  font-family: var(--display); font-size: 14px;
  display: grid; place-items: center;
  border: 2px solid #fff;
}
.blast-ring { position: absolute; inset: -6px; width: calc(100% + 12px); height: calc(100% + 12px); transform: rotate(-90deg); }
.blast-ring circle { fill: none; stroke: rgba(0, 0, 0, .25); stroke-width: 5; }
.blast-ring .progress { stroke: #fff; stroke-linecap: round; stroke-dasharray: 289; stroke-dashoffset: 289; transition: stroke-dashoffset .2s; }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; }

.title-screen { display: flex; flex-direction: column; justify-content: flex-end; }
.hero {
  position: absolute; inset: 0;
  background: #3b0a0d url("assets/hero.webp") center 20% / cover no-repeat;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: scale(1.04); } to { transform: scale(1.12) translateY(-1.5%); } }
.title-shade {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 42, 107, .55) 0%, rgba(11, 42, 107, 0) 22%),
    linear-gradient(0deg, rgba(8, 18, 48, .97) 0%, rgba(8, 18, 48, .88) 34%, rgba(8, 18, 48, 0) 62%);
}
.title-content {
  position: relative;
  padding: 0 22px calc(var(--safe-bottom) + 22px);
  text-align: center;
}
.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  line-height: .9;
  display: flex; flex-direction: column;
  transform: rotate(-3deg);
}
.logo span {
  display: block;
  color: var(--teal);
  -webkit-text-stroke: 2px #04382f;
  text-shadow: 0 4px 0 #04382f, 0 8px 0 var(--blue-deep), 0 0 30px rgba(63, 240, 200, .55);
}
.logo span:first-child { font-size: clamp(54px, 18vw, 86px); letter-spacing: 4px; }
.logo span:last-child { font-size: clamp(40px, 13.5vw, 64px); color: #fff; -webkit-text-stroke-color: var(--blue-deep); }
.tagline {
  display: inline-block;
  margin: 18px 0 16px;
  padding: 6px 14px;
  font-family: var(--display);
  font-size: clamp(16px, 5.4vw, 22px);
  letter-spacing: 2px;
  background: var(--red);
  color: #fff;
  transform: rotate(-2deg);
  box-shadow: 0 4px 0 #6b0008;
}
.play-btn {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  padding: 16px 0;
  border-radius: 16px;
  font-family: var(--display);
  font-size: 26px;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(180deg, #2f6bff, var(--blue) 55%, #12348a);
  box-shadow: 0 6px 0 #081d52, 0 10px 26px rgba(0, 0, 0, .5), inset 0 2px 0 rgba(255, 255, 255, .35);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .4);
}
.play-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #081d52; }
.ghost-btn {
  display: block;
  margin: 12px auto 0;
  padding: 10px 18px;
  background: transparent;
  font-weight: 800;
  letter-spacing: 1px;
  opacity: .8;
}
.best { margin: 12px 0 6px; font-weight: 700; color: var(--teal); min-height: 1em; }
.how {
  text-align: left;
  font-size: 14px;
  line-height: 1.4;
  background: rgba(255, 255, 255, .07);
  border-radius: 12px;
  padding: 8px 12px;
  max-width: 360px;
  margin: 0 auto;
}
.how summary { font-weight: 800; cursor: pointer; text-align: center; }
.how ul { margin: 8px 0 4px; padding-left: 18px; }
.how li { margin-bottom: 5px; }
.red { color: #ff5a5f; }
.teal { color: var(--teal); }
.mute { position: absolute; top: calc(var(--safe-top) + 10px); right: 10px; font-size: 18px; }
.switch-game {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 10px 0 8px;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 10.5px;
  line-height: 1.05;
  letter-spacing: .5px;
  color: #fff;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .4);
  background: linear-gradient(180deg, #ff4a50, var(--red) 60%, #8a0a10);
  border: 2px solid rgba(255, 255, 255, .3);
  box-shadow: 0 4px 0 #4a0006, 0 6px 14px rgba(0, 0, 0, .4);
}
.switch-icon { font-size: 16px; }
.switch-game:active { transform: translateY(3px); box-shadow: 0 1px 0 #4a0006; }

.panel-screen {
  display: grid;
  place-items: center;
  background: rgba(8, 10, 30, .72);
  backdrop-filter: blur(3px);
  padding: 20px;
}
.over-hero {
  position: absolute; inset: 0;
  background: url("assets/hero.webp") center 30% / cover no-repeat;
  opacity: .35;
  filter: saturate(1.3);
}
.panel {
  position: relative;
  width: 100%;
  max-width: 360px;
  text-align: center;
  background: linear-gradient(180deg, rgba(24, 70, 184, .95), rgba(11, 42, 107, .97));
  border: 3px solid rgba(255, 255, 255, .2);
  border-radius: 22px;
  padding: 22px 18px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
}
.panel h2 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: 28px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 3px 0 var(--red);
}
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stats div { background: rgba(0, 0, 0, .25); border-radius: 10px; padding: 7px 4px; }
.stats span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .75; }
.stats b { font-family: var(--display); font-size: 20px; }
.stats div:first-child b { color: var(--teal); }
.quote { font-style: italic; opacity: .85; margin: 4px 0 14px; font-size: 14px; }
.quote b { color: var(--teal); font-style: normal; }
.new-best { display: block; color: var(--teal); font-size: 14px; letter-spacing: 2px; margin-top: 6px; text-shadow: none; }

.rotate {
  display: none;
  position: fixed; inset: 0;
  background: var(--blue-deep);
  place-items: center;
  text-align: center;
  font-family: var(--display);
  font-size: 22px;
  z-index: 10;
}
@media (orientation: landscape) and (max-height: 520px) {
  .rotate { display: grid; }
}
