:root {
  --bg: #05070d;
  --ink: #e9f3e4;
  --muted: #9aa6c4;
  --gold: #e6c46a;
  --leaf: #7ddc84;
  --water: #5fc9f3;
  --moon: #b9a0ff;
  --panel: rgba(9, 13, 26, 0.84);
  --line: rgba(170, 195, 255, 0.2);
  --serif: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr minmax(110px, 320px) 1fr;
  gap: 14px;
  align-items: center;
  pointer-events: none;
  background: linear-gradient(rgba(3, 5, 12, 0.8), rgba(3, 5, 12, 0));
}
#grove { font-size: 17px; letter-spacing: 0.08em; }
#pips { margin-top: 3px; font-size: 13px; color: var(--gold); font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }

.light-label {
  font-size: 11px; letter-spacing: 0.25em; text-transform: uppercase;
  color: var(--muted); text-align: center; margin-bottom: 4px;
}
.light-track {
  height: 10px; border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  overflow: hidden;
}
#light {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #f08a4b, var(--gold) 45%, #fff3c4);
  border-radius: 6px;
  transition: width 0.15s linear;
}
#light.low { animation: throb 0.6s infinite alternate; }
@keyframes throb { to { filter: brightness(1.7); } }

.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
#score { font-size: 22px; font-variant-numeric: tabular-nums; }
.hud-buttons { display: flex; gap: 6px; pointer-events: auto; }
.hud-buttons button {
  width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 24, 18, 0.7);
  color: var(--ink); font-size: 15px; cursor: pointer;
  font-family: inherit;
}
.hud-buttons button.off { opacity: 0.4; text-decoration: line-through; }

#hint {
  position: fixed; left: 50%; bottom: max(22px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(90vw, 460px);
  padding: 8px 16px; border-radius: 18px;
  background: rgba(6, 16, 11, 0.72);
  border: 1px solid var(--line);
  color: var(--ink); font-size: 15px; text-align: center;
  pointer-events: none;
}

#banner {
  position: fixed; left: 0; right: 0; top: 38%;
  text-align: center; pointer-events: none;
  font-size: clamp(26px, 6vw, 46px);
  letter-spacing: 0.12em;
  color: #fff3c4;
  text-shadow: 0 0 24px rgba(255, 200, 87, 0.8);
  animation: rise 2.2s ease-out both;
}
#banner small { display: block; font-size: 0.42em; color: var(--ink); letter-spacing: 0.06em; margin-top: 8px; padding: 0 24px; text-wrap: balance; }
@keyframes rise {
  0% { opacity: 0; transform: translateY(18px); }
  20%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; }
}

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(5, 7, 13, 0.35), rgba(2, 3, 8, 0.88));
  overflow-y: auto;
}
.panel {
  width: min(100%, 520px);
  padding: 30px 28px 24px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 0 60px rgba(120, 160, 255, 0.06);
  text-align: center;
  backdrop-filter: blur(6px);
}
.panel.small { width: min(100%, 360px); }

h1 {
  margin: 0; font-weight: 400;
  font-size: clamp(40px, 11vw, 68px);
  letter-spacing: 0.3em; margin-right: -0.3em;
  color: #fff3c4;
  text-shadow: 0 0 30px rgba(255, 200, 87, 0.55);
}
h2 { margin: 0 0 16px; font-weight: 400; font-size: 28px; letter-spacing: 0.1em; color: #fff3c4; }
.tagline { margin: 8px 0 18px; color: var(--gold); letter-spacing: 0.34em; margin-right: -0.34em; font-size: 15px; text-transform: uppercase; }
.premise { margin: 0 auto 24px; max-width: 34ch; font-size: 16.5px; line-height: 1.5; text-wrap: balance; }

.how { list-style: none; margin: 0 0 22px; padding: 0; text-align: left; font-size: 15.5px; line-height: 1.45; }
.how li { position: relative; padding: 7px 0 7px 26px; border-top: 1px solid var(--line); }
.how li:first-child { border-top: 0; }
.dot { position: absolute; left: 2px; top: 13px; width: 11px; height: 11px; border-radius: 50%; }
.dot.leaf { background: var(--leaf); box-shadow: 0 0 10px var(--leaf); }
.dot.sun { background: var(--gold); box-shadow: 0 0 10px var(--gold); }
.dot.water { background: var(--water); box-shadow: 0 0 10px var(--water); }
.dot.moon { background: var(--moon); box-shadow: 0 0 10px var(--moon); }
.dot.shade { background: #0b0612; border: 1.5px solid #a06ee6; box-shadow: 0 0 10px #6a3aa8; }
.how b { font-weight: 400; color: #fff3c4; letter-spacing: 0.05em; }

button.primary {
  padding: 13px 30px; border-radius: 30px;
  border: 1px solid rgba(255, 200, 87, 0.7);
  background: linear-gradient(#2c3c6a, #162040);
  color: #fff3c4; font-family: inherit; font-size: 18px; letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(255, 200, 87, 0.25);
}
button.primary:hover { filter: brightness(1.2); }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.controls { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.best { margin: 8px 0 0; color: var(--gold); font-size: 14px; min-height: 1em; }
.final { font-size: 20px; margin: 0; }
.final strong { font-size: 34px; color: #fff3c4; font-weight: 400; margin-left: 8px; }
#screen-over .best { margin-bottom: 18px; }

@media (max-width: 480px) {
  #hud { grid-template-columns: auto 1fr auto; gap: 10px; }
  #grove { font-size: 15px; }
  #score { font-size: 18px; }
  .panel { padding: 22px 18px 18px; }
  .how { font-size: 14.5px; }
}

#btn-skip {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: max(22px, env(safe-area-inset-bottom));
  padding: 8px 16px; border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(9, 13, 26, 0.7);
  color: var(--ink); font-family: inherit; font-size: 14px; letter-spacing: 0.08em;
  cursor: pointer;
}
h1, h2, #grove, #banner { font-weight: 300; }

#clock { color: var(--gold); letter-spacing: 0.08em; margin-left: 6px; font-variant-numeric: tabular-nums; }
#banner { font-weight: 700; text-transform: uppercase; color: var(--gold); letter-spacing: 0.06em; font-size: clamp(22px, 5.4vw, 40px); padding: 0 16px; text-shadow: 0 0 22px rgba(0, 0, 0, 0.9); }
#banner small { font-weight: 600; color: #fff; text-transform: none; }
h1 { font-weight: 700; color: var(--gold); text-shadow: none; letter-spacing: 0.22em; margin-right: -0.22em; }
h2 { font-weight: 700; text-transform: uppercase; color: var(--gold); font-size: 22px; }
.tagline { font-weight: 700; color: #fff; }
.premise { font-weight: 600; text-transform: uppercase; font-size: 13.5px; letter-spacing: 0.06em; line-height: 1.7; }

#final-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 8px; margin: 16px 0 6px; }
#final-stats div { padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; }
#final-stats dt { font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
#final-stats dd { margin: 3px 0 0; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.final strong { font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 700; }
@media (max-width: 480px) { .hud-buttons button { width: 30px; height: 30px; font-size: 13px; } .hud-buttons { gap: 4px; } .hud-right { gap: 8px; } }
