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

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #07050a;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Phone-shaped column; fills the screen on mobile, centred on desktop */
#stage {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #1a0f0a;
}

@media (min-width: 481px) {
  #stage { box-shadow: 0 0 80px rgba(255, 140, 20, 0.12); }
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden { display: none !important; }

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

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 0;
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chip {
  display: flex;
  flex-direction: column;
  min-height: 46px;
  padding: 6px 12px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(20, 12, 8, 0.65);
  line-height: 1;
}

.chip.right {
  margin-left: auto;
  align-items: flex-end;
}

.label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffd98a;
}

.value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.pill {
  padding: 4px 11px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #e3141b;
  font-size: 15px;
  font-weight: 900;
  font-style: italic;
  white-space: nowrap;
}

.segments {
  display: flex;
  gap: 3px;
  margin-top: 7px;
}

.segments i {
  width: 11px;
  height: 13px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
}

.segments i.on { background: #5fe08a; }
.segments.low i.on { background: #ff5a4f; animation: blink 0.9s steps(2) infinite; }

@keyframes blink {
  50% { opacity: 0.35; }
}

.icon-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(20, 12, 8, 0.65);
  cursor: pointer;
}

.icon-btn span {
  width: 4px;
  height: 15px;
  border-radius: 2px;
  background: #fff;
}

.boss-bar {
  width: min(260px, 72%);
  margin: 10px auto 0;
  text-align: center;
  line-height: 1;
}

.boss-bar span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e8d27a;
}

.boss-bar i {
  display: block;
  height: 9px;
  margin-top: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.5);
}

.boss-bar b {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6b5a24, #c9a83a);
  transform-origin: left center;
}

/* Active power-ups, each with a bar that drains */
.powers {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.power {
  position: relative;
  overflow: hidden;
  padding: 4px 9px 6px;
  border: 1.5px solid var(--c);
  border-radius: 999px;
  background: rgba(20, 12, 8, 0.75);
  color: var(--c);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.power i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--c);
  transform-origin: left center;
}

.power.rapid { --c: #ffb020; }
.power.spread { --c: #59c3ff; }
.power.guard { --c: #5fe08a; }

/* Full Service button; the ring fills as contaminants are destroyed */
.service {
  position: absolute;
  right: 12px;
  bottom: max(8px, env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: conic-gradient(#ffd54a calc(var(--p, 0) * 360deg), rgba(255, 255, 255, 0.16) 0);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  color: #fff;
  font: inherit;
  cursor: pointer;
  touch-action: none;
}

.service span {
  position: absolute;
  inset: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #1d140f;
  line-height: 1;
}

.service b {
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.service small {
  margin-top: 3px;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffd98a;
}

.service.ready { animation: pulse 0.9s ease-in-out infinite; }
.service.ready span { background: #e3141b; }
.service.ready small { color: #fff; }

@keyframes pulse {
  50% { transform: scale(1.1); }
}

/* ---------- Wave banner ---------- */

.banner {
  position: absolute;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
}

.banner small {
  display: block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #ffd98a;
}

.banner span {
  display: block;
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
  white-space: nowrap;
  text-shadow: 0 3px 0 #9b1b1e, 0 6px 18px rgba(0, 0, 0, 0.6);
}

.banner.show { animation: banner 2.2s ease-out forwards; }

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -80%); }
}

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

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 26px) 22px calc(env(safe-area-inset-bottom) + 26px);
  text-align: center;
}

.screen.dim { background: rgba(8, 4, 2, 0.65); }

.spacer {
  flex: 1;
  min-height: 12px;
}

.title-screen {
  background: linear-gradient(rgba(5, 3, 8, 0.6), rgba(5, 3, 8, 0) 40%, rgba(5, 3, 8, 0) 58%, rgba(5, 3, 8, 0.7));
}

/* Stand-in wordmark until we get the real logo files */
.osk {
  font-size: 32px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #e3141b;
  text-shadow:
    -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 2px 2px 0 #fff,
    0 -2px 0 #fff, 0 2px 0 #fff, -2px 0 0 #fff, 2px 0 0 #fff,
    3px 4px 0 #1a1a1a;
}

.osk.small {
  font-size: 18px;
  text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff, 2px 2px 0 #1a1a1a;
}

h1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 14px;
  line-height: 1;
}

.title-small {
  margin-right: -0.32em;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: #ffd54a;
  text-shadow: 0 3px 0 #8a2c00;
}

.title-big {
  font-size: 86px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.04em;
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 6px 0 #9b1b1e, 0 12px 24px rgba(0, 0, 0, 0.5);
}

.tagline {
  max-width: 290px;
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff1dc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.howto {
  list-style: none;
  display: grid;
  gap: 9px;
  width: 100%;
  max-width: 330px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(20, 12, 8, 0.75);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.howto li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ico {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 22px;
  font-size: 20px;
  font-style: normal;
  font-weight: 900;
  color: #ffd54a;
}

.ico-dirt::before,
.ico-filter::before,
.ico-service::before {
  content: "";
  display: block;
}

.ico-dirt::before {
  width: 16px;
  height: 16px;
  border: 2px dotted #e4d6bd;
  border-radius: 50%;
  background: #9b8a74;
}

.ico-filter::before {
  width: 12px;
  height: 19px;
  border: 1.5px solid #fff;
  border-radius: 3px;
  background: linear-gradient(#d9dee3 0 34%, #e3141b 34% 68%, #d9dee3 68%);
}

.ico-service::before {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background:
    radial-gradient(#1d140f 0 52%, transparent 53%),
    conic-gradient(#ffd54a 0 70%, rgba(255, 255, 255, 0.25) 0);
}

.btn {
  appearance: none;
  padding: 14px 44px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: #e3141b;
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: 0 5px 0 #8a1014, 0 10px 24px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8a1014, 0 6px 14px rgba(0, 0, 0, 0.4);
}

.best {
  min-height: 16px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffe4ad;
}

/* ---------- Game over ---------- */

.card {
  width: 100%;
  max-width: 320px;
  margin-bottom: 22px;
  padding: 22px 20px 18px;
  border-top: 8px solid #e3141b;
  border-radius: 22px;
  background: #fff8ec;
  color: #2b1406;
  box-shadow: 0 6px 0 #c9781b, 0 18px 40px rgba(0, 0, 0, 0.45);
}

.caught {
  font-size: 40px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  text-transform: uppercase;
  color: #e3141b;
}

.quip {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: #6b4a33;
}

.final-label,
.final-row span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #a0714a;
}

.final-label { margin-top: 16px; }

.final-score {
  font-size: 54px;
  font-weight: 900;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.new-best {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ffd54a;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.final-row {
  display: flex;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0dcc0;
}

.final-row div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.final-row b {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.brand-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 12px;
  font-weight: 700;
  color: #6b4a33;
}

.paused-title {
  margin-bottom: 22px;
  font-size: 44px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  text-shadow: 0 4px 0 #9b1b1e;
}

/* Shorter phones */
@media (max-height: 700px) {
  .title-big { font-size: 68px; }
  .tagline { font-size: 14px; }
  .howto { gap: 7px; margin-bottom: 14px; padding: 11px 14px; font-size: 13px; }
  .card { padding: 18px 18px 14px; }
  .final-score { font-size: 44px; }
}
