:root {
  --mango: #FFB020;
  --orange: #FF7A1A;
  --deep: #E8590C;
  --ink: #2B1600;
  --cream: #FFF6EC;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #FFE7A8 0%, #FFC861 55%, #FF9E3D 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#stage, #stage canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* sunny backdrop (pure CSS, behind the 3D canvas) */
#sky { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
#sun {
  position: absolute; top: 9%; right: 12%;
  width: min(34vw, 220px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, #FFF7D1 0%, #FFE27A 55%, rgba(255, 226, 122, 0) 72%);
  animation: glow 4s ease-in-out infinite alternate;
}
@keyframes glow { to { transform: scale(1.08); } }
.cloud {
  position: absolute; height: 38px; width: 130px; border-radius: 40px;
  background: rgba(255, 255, 255, 0.75);
  animation: drift 40s linear infinite;
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: inherit; border-radius: 50%;
}
.cloud::before { width: 60px; height: 60px; top: -28px; left: 18px; }
.cloud::after { width: 46px; height: 46px; top: -20px; left: 64px; }
.c1 { top: 16%; left: -160px; }
.c2 { top: 30%; left: -160px; transform: scale(0.7); animation-duration: 58s; animation-delay: -25s; opacity: 0.8; }
@keyframes drift { to { left: 110%; } }
#hills {
  position: fixed; left: 0; right: 0; bottom: 0; height: 30vh; pointer-events: none;
  background:
    radial-gradient(120% 90% at 20% 100%, #FFB25C 0 58%, transparent 59%),
    radial-gradient(110% 80% at 85% 100%, #FF9E3D 0 55%, transparent 56%);
}

.mute {
  position: fixed; right: 12px; bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 5;
  font: 700 12px "Outfit", sans-serif; letter-spacing: 0.12em;
  color: var(--ink); background: var(--cream);
  border: 2px solid var(--ink); box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 10px; cursor: pointer;
}

#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) 14px 0;
  pointer-events: none;
}
#hud[hidden] { display: none; }
.hud-box {
  background: var(--cream);
  border: 3px solid var(--ink);
  padding: 6px 14px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 84px;
  box-shadow: 4px 4px 0 var(--ink);
}
.hud-label { font-size: 12px; font-weight: 700; letter-spacing: 0.18em; }
#score, #time { font-size: 30px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
#time.low { color: #D62828; }
#combo-box { background: var(--deep); color: #fff; align-self: center; margin-top: 10px; }
#combo-box[hidden] { display: none; }
#combo { font-size: 18px; font-weight: 800; letter-spacing: 0.06em; }

.overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(43, 22, 0, 0.28);
  padding: 16px;
}
.overlay[hidden] { display: none; }
.panel {
  background: var(--cream);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 28px 28px 24px;
  text-align: center;
  width: min(360px, 100%);
}
.panel h1 { font-size: 56px; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.panel h1 span { color: var(--deep); }
.panel p { margin-top: 10px; font-size: 18px; font-weight: 500; }
.panel .hint { font-size: 14px; opacity: 0.7; }
.big { font-size: 72px !important; font-weight: 800 !important; line-height: 1; margin-top: 4px !important; }

.btn {
  margin-top: 20px;
  width: 100%;
  font: 800 24px "Outfit", sans-serif;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--deep);
  border: 3px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 14px 0;
  cursor: pointer;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }

#popups { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop {
  position: absolute;
  font-weight: 800; font-size: 26px;
  transform: translate(-50%, -50%);
  animation: rise 0.8s ease-out forwards;
  text-shadow: 2px 2px 0 var(--cream);
  white-space: nowrap;
}
.pop.good { color: var(--ink); }
.pop.gold { color: #B07A00; font-size: 34px; }
.pop.bad { color: #D62828; }
@keyframes rise {
  from { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
  20% { transform: translate(-50%, -60%) scale(1.15); }
  to { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ---------- Screens (step 3) ---------- */
.panel { max-height: calc(100dvh - 32px); overflow-y: auto; }
.logo { display: block; width: 100%; border: 3px solid var(--ink); }
.game-name {
  margin-top: -14px; position: relative;
  display: inline-block; background: var(--ink); color: var(--mango);
  font-size: 34px !important; letter-spacing: 0.32em !important; padding: 4px 6px 4px 16px;
  transform: rotate(-3deg);
}
.prize-line {
  display: inline-block; margin-top: 12px !important;
  background: var(--mango); border: 2px solid var(--ink);
  padding: 4px 10px; font-size: 15px !important; font-weight: 700 !important;
}

#countdown {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-size: min(42vw, 220px); font-weight: 800; color: var(--cream);
  -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill;
  text-shadow: 8px 8px 0 var(--ink);
}
#countdown[hidden] { display: none; }
#countdown.beat { animation: beat 0.7s ease-out; }
@keyframes beat { from { transform: scale(1.6); opacity: 0; } 25% { transform: scale(1); opacity: 1; } }

.prize { margin-top: 16px; border: 3px dashed var(--ink); padding: 12px; background: #FFF1D6; }
.prize-title { margin-top: 0 !important; font-size: 20px !important; font-weight: 800 !important; }
.code {
  margin-top: 8px !important; font: 800 26px ui-monospace, "Cascadia Mono", Consolas, monospace !important;
  letter-spacing: 0.06em; background: var(--ink); color: var(--mango); padding: 8px 4px;
  user-select: all; -webkit-user-select: all;
}
.golden-badge {
  display: inline-block; margin-top: 10px !important; padding: 3px 10px;
  background: #FFD44D; border: 2px solid var(--ink); font-size: 14px !important; font-weight: 800 !important;
}
.small { font-size: 14px !important; margin-top: 8px !important; }

.form-score { font-size: 16px !important; }
.field { display: block; text-align: left; margin-top: 14px; font-weight: 700; font-size: 14px; }
.field .opt { font-weight: 500; opacity: 0.7; }
.field input {
  display: block; width: 100%; margin-top: 4px;
  font: 500 18px "Outfit", sans-serif; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); padding: 10px;
  user-select: text; -webkit-user-select: text;
}
.field input:focus { outline: 3px solid var(--orange); outline-offset: 1px; }
.tick { display: flex; gap: 10px; align-items: flex-start; text-align: left; margin-top: 14px; font-size: 13px; line-height: 1.35; }
.tick input { width: 22px; height: 22px; flex: none; accent-color: var(--deep); margin-top: 1px; }
.form-error { min-height: 1.2em; color: #C21E1E; font-size: 14px !important; font-weight: 700 !important; }
.form-error:empty { margin-top: 0 !important; }
.link {
  margin-top: 12px; background: none; border: 0; cursor: pointer;
  font: 700 15px "Outfit", sans-serif; color: var(--ink); text-decoration: underline; padding: 6px 12px;
}

.board { list-style: none; margin-top: 12px; text-align: left; }
.board li {
  display: flex; gap: 10px; align-items: center;
  padding: 7px 10px; border-bottom: 2px solid rgba(43, 22, 0, 0.15); font-size: 17px;
}
.board li:nth-child(-n+3) .rank { background: var(--mango); }
.board li.me { background: var(--ink); color: var(--cream); }
.board .rank {
  width: 28px; height: 28px; flex: none; display: grid; place-items: center;
  border: 2px solid var(--ink); background: var(--cream); color: var(--ink); font-weight: 800; font-size: 14px;
}
.board .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Attract mode (step 4) ---------- */
#attract {
  position: fixed; inset: 0; z-index: 4; cursor: pointer;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: max(20px, env(safe-area-inset-top)) 16px max(56px, env(safe-area-inset-bottom));
}
.attract-top { width: min(300px, 70vw); text-align: center; }
.attract-top .logo { box-shadow: 6px 6px 0 var(--ink); }
.attract-bottom { text-align: center; }
.tap {
  display: inline-block; font-size: clamp(30px, 7vw, 54px); font-weight: 800; letter-spacing: 0.08em;
  color: #fff; background: var(--deep); border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink);
  padding: 8px 24px; animation: nudge 1.2s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: scale(1.06); } }
.attract-bottom .prize-line { display: table; margin: 16px auto 0 !important; }
.attract-best { margin-top: 10px; font-weight: 700; font-size: 16px; }
.qr-box {
  position: absolute; left: 20px; bottom: 64px; width: 150px; text-align: center;
  background: var(--cream); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 10px;
}
.qr-box svg { display: block; width: 100%; height: auto; }
.qr-box p { margin-top: 6px; font-size: 13px; font-weight: 700; line-height: 1.2; }
/* on a phone the player is already on their phone: no QR */
@media (max-width: 700px) { .qr-box { display: none; } }
