:root {
  --sky: #4aa7e8;
  --navy: #12355b;
  --ink: #1b2433;
  --gold: #ffd24a;
  --gold-deep: #e09a12;
  --ollie: #ffe14a;
  --grass: #3aa35a;
  --panel: rgba(18, 36, 64, 0.82);
  --line: rgba(255, 226, 120, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html, body, #app {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #0d2438;
  color: #fff8dc;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
}

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

#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(8, 18, 32, 0.45) 100%);
  z-index: 1;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
}

#screen-splash { justify-content: center; align-items: flex-end; text-align: center; }
#screen-splash .splash-copy { margin-bottom: 8vh; }
.splash-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.1);
}
.splash-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 30, 55, 0.15) 0%, rgba(10, 30, 55, 0.72) 100%);
}
.splash-copy { position: relative; z-index: 1; }
.splash-copy h1 {
  font-size: clamp(2.1rem, 6vw, 4rem);
  line-height: 0.95;
  color: var(--gold);
  text-shadow: 0 4px 0 #9a6a00, 0 10px 24px rgba(0,0,0,0.45);
  margin: 8px 0 28px;
}

.kicker {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #c9e7ff;
}

.menu-panel {
  width: min(420px, 100%);
  max-height: calc(100dvh - 36px - var(--safe-top) - var(--safe-bottom));
  overflow: auto;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 28px;
  padding: 28px 26px 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}
.menu-panel.wide { width: min(720px, 100%); }
.menu-panel.compact { width: min(360px, 100%); }
.menu-panel h1, .menu-panel h2 {
  color: var(--gold);
  text-shadow: 0 3px 0 #8a5a00;
  margin: 6px 0 10px;
  font-size: clamp(1.45rem, 4.2vw, 2.1rem);
  line-height: 1.08;
}
.subtitle {
  color: #ffe7a0;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.82rem;
  margin: 0 0 12px;
}
.tagline { color: #e7f3ff; opacity: 0.9; margin-bottom: 18px; line-height: 1.35; }
.credits-body { color: #e7f3ff; line-height: 1.45; margin-bottom: 12px; }

.menu-nav { display: grid; gap: 10px; }

.btn {
  appearance: none;
  border: 2px solid #fff3b0;
  background: linear-gradient(#3d7cc2, #245a96);
  color: #fff8dc;
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 12px 18px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 #16375c;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #16375c; }
.btn.primary {
  background: linear-gradient(#ffe25a, #f0b21a);
  color: #3a2500;
  border-color: #fff6c2;
  box-shadow: 0 4px 0 #b07a00;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.level-card {
  text-align: left;
  padding: 12px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: rgba(9, 28, 52, 0.7);
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.level-card[disabled] { opacity: 0.45; cursor: not-allowed; }
.level-card .num { color: var(--gold); font-weight: 800; }
.level-card .best { font-size: 0.78rem; opacity: 0.8; margin-top: 4px; }

.help-list { list-style: none; display: grid; gap: 10px; margin: 8px 0 18px; }
.help-list li {
  background: rgba(9, 28, 52, 0.55);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.35;
}

.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.setting input, .setting select {
  width: 140px;
  accent-color: var(--gold);
  background: #0e2744;
  color: #fff8dc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
}

#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) 0 calc(12px + var(--safe-left));
  pointer-events: none;
}
.hud-left, .hud-right { display: flex; gap: 8px; align-items: center; }
.pill {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}
.hud-left { flex-wrap: wrap; }
.coin-pill { display: flex; align-items: center; gap: 8px; }
.pill.skill.super { border-color: #ffd27a; color: #ffe7a0; }
.pill.skill.slow { border-color: #8cefff; color: #c5f6ff; }
.coin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3a8, #f0b21a 55%, #c47a00);
  box-shadow: inset 0 -2px 0 #a66a00;
}
.icon-btn {
  pointer-events: auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--gold);
  font-weight: 900;
  cursor: pointer;
}

.toast {
  position: absolute;
  left: 50%;
  top: calc(78px + var(--safe-top));
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(90, 22, 22, 0.9);
  border: 2px solid #ffb4a8;
  color: #fff4ea;
  padding: 10px 16px;
  border-radius: 12px;
  width: min(520px, calc(100% - 24px));
  text-align: center;
}
.toast.ok {
  background: rgba(18, 64, 42, 0.92);
  border-color: #b6f0c8;
  color: #eafff1;
}
.cheat-row {
  display: grid;
  gap: 6px;
  margin: 0 0 14px;
}
.cheat-row input {
  appearance: none;
  border: 2px solid var(--line);
  background: rgba(9, 28, 52, 0.7);
  color: #fff8dc;
  font: inherit;
  border-radius: 12px;
  padding: 10px 12px;
}

#touch {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}
#stick {
  pointer-events: auto;
  position: absolute;
  left: calc(28px + var(--safe-left));
  bottom: calc(28px + var(--safe-bottom));
  width: 128px; height: 128px;
}
.stick-ring {
  position: absolute; inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 226, 120, 0.45);
  background: rgba(12, 28, 48, 0.35);
}
.stick-knob {
  position: absolute;
  width: 58px; height: 58px;
  left: 35px; top: 35px;
  border-radius: 50%;
  background: linear-gradient(#ffe25a, #e09a12);
  box-shadow: 0 4px 0 #9a6a00;
}
#btn-jump {
  pointer-events: auto;
  position: absolute;
  right: calc(28px + var(--safe-right));
  bottom: calc(36px + var(--safe-bottom));
  width: 92px; height: 92px;
  border-radius: 50%;
  border: 3px solid #fff3b0;
  background: linear-gradient(#ffe25a, #f0b21a);
  color: #3a2500;
  font-weight: 900;
  letter-spacing: 0.06em;
  box-shadow: 0 6px 0 #b07a00;
}

@media (min-width: 900px) {
  .screen { padding-left: 7vw; }
}
