/* Hopway Heroes — bright, chunky, kid-friendly UI */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --green: #4cbb5e; --green-d: #37984a;
  --blue: #3aa0e8; --blue-d: #2b7fc0;
  --purple: #9b6ae0; --purple-d: #7d4fc4;
  --orange: #ff9f3b; --orange-d: #e8842a;
  --gray: #8d99ae; --gray-d: #6f7a8d;
  --ink: #23324d;
  --card: #ffffff;
  --sky1: #7ed6ff; --sky2: #cdf3ff;
}
html, body {
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky1), var(--sky2) 60%, #b9f0c0);
}
#app { position: fixed; inset: 0; }
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
  text-align: center;
}
.screen.scrolly { justify-content: flex-start; overflow-y: auto; touch-action: pan-y; }
.hidden { display: none !important; }

/* Title */
.sky-deco { font-size: 40px; letter-spacing: 24px; opacity: .9; animation: floaty 5s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-8px);} }
.logo { font-size: clamp(40px, 8vw, 72px); line-height: 1.05; text-shadow: 0 4px 0 rgba(0,0,0,.12); }
.logo-hop { color: #ff7043; }
.logo-heroes { color: #2e7d32; }
.tagline { font-size: clamp(16px, 2.5vw, 22px); font-weight: 600; color: #35507a; }
.title-buttons { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; width: min(360px, 86vw); }
.title-foot { color: #4a6285; font-weight: 600; }

/* Buttons */
.big-btn {
  min-height: 64px; padding: 12px 26px;
  font-size: 22px; font-weight: 800; font-family: inherit;
  color: #fff; border: none; border-radius: 18px;
  cursor: pointer; touch-action: manipulation;
  box-shadow: 0 5px 0 rgba(0,0,0,.18);
  transition: transform .08s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.big-btn:disabled { opacity: .45; }
.btn-green { background: var(--green); box-shadow: 0 5px 0 var(--green-d); }
.btn-blue { background: var(--blue); box-shadow: 0 5px 0 var(--blue-d); }
.btn-purple { background: var(--purple); box-shadow: 0 5px 0 var(--purple-d); }
.btn-gray { background: var(--gray); box-shadow: 0 5px 0 var(--gray-d); }
.chip-btn {
  min-width: 64px; min-height: 64px; padding: 10px 18px;
  font-size: 20px; font-weight: 800; font-family: inherit;
  border: none; border-radius: 16px; background: #fff; color: var(--ink);
  box-shadow: 0 3px 0 rgba(0,0,0,.15); cursor: pointer; touch-action: manipulation;
}
.row-btns { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* Picker */
#screen-picker h2 { font-size: clamp(26px, 4vw, 38px); }
.picker-grid {
  display: grid; grid-template-columns: repeat(4, minmax(70px, 96px));
  gap: 12px; justify-content: center;
}
@media (max-width: 820px) { .picker-grid { grid-template-columns: repeat(4, minmax(64px, 84px)); } }
.picker-card {
  aspect-ratio: 1; border-radius: 20px; border: 4px solid transparent;
  font-size: clamp(30px, 5vw, 44px); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.15);
  min-width: 60px; min-height: 60px;
}
.picker-card.selected { border-color: #23324d; transform: scale(1.08); }
.picker-card.taken { opacity: .3; pointer-events: none; }
.picker-name-row { display: flex; gap: 12px; align-items: center; }
.picker-name {
  background: #fff; border-radius: 16px; padding: 12px 22px;
  font-size: clamp(20px, 3vw, 28px); font-weight: 800; min-width: 200px;
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}

/* Map */
.map-header {
  position: sticky; top: 0; z-index: 5; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 4px; backdrop-filter: blur(6px);
  background: rgba(205,243,255,.8); border-radius: 14px;
}
.map-header h2 { font-size: clamp(20px, 3vw, 30px); }
#map-worlds { width: min(900px, 96vw); display: flex; flex-direction: column; gap: 18px; padding-bottom: 30px; }
.world-card {
  border-radius: 22px; padding: 16px; color: #fff; text-align: left;
  box-shadow: 0 6px 14px rgba(0,0,0,.15);
}
.world-card h3 { font-size: clamp(20px, 3vw, 26px); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.world-card .world-sub { font-weight: 600; opacity: .95; margin: 2px 0 10px; }
.world-locked-note { font-weight: 800; font-size: 18px; }
.level-row { display: flex; gap: 12px; flex-wrap: wrap; }
.level-btn {
  min-width: 108px; min-height: 84px; border-radius: 16px; border: none;
  font-family: inherit; font-weight: 800; font-size: 17px; cursor: pointer;
  background: rgba(255,255,255,.92); color: var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.2);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 8px;
}
.level-btn .lvl-stars { font-size: 15px; letter-spacing: 2px; }
.level-btn .lvl-best { font-size: 12px; font-weight: 700; color: #5c6c8a; }
.level-btn.locked { background: rgba(255,255,255,.35); color: rgba(30,40,60,.55); pointer-events: none; }
.player-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px; padding: 8px 16px;
  font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 rgba(0,0,0,.15);
  white-space: nowrap;
}
.player-chip .avatar { font-size: 22px; }

/* High scores */
.hs-table { width: min(680px, 94vw); display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; }
.hs-row {
  display: grid; grid-template-columns: 44px 52px 1fr auto auto; gap: 10px; align-items: center;
  background: #fff; border-radius: 14px; padding: 10px 14px; font-weight: 800;
  box-shadow: 0 2px 0 rgba(0,0,0,.1); font-size: 17px; text-align: left;
}
.hs-row .hs-rank { color: var(--orange-d); font-size: 20px; }
.hs-row .hs-stars { color: #e8a90a; }
.hs-empty { font-weight: 700; color: #4a6285; padding: 30px 0; }

/* Game */
#screen-game { padding: 0; }
#game-canvas-wrap, #game-canvas-wrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  touch-action: none; display: block;
}
#hud {
  position: absolute; top: max(8px, env(safe-area-inset-top)); left: 10px; right: 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  pointer-events: none;
}
#hud .chip-btn, #hud button { pointer-events: auto; }
.hud-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.hud-pill {
  background: rgba(255,255,255,.92); border-radius: 999px; padding: 8px 14px;
  font-weight: 800; font-size: 16px; box-shadow: 0 2px 0 rgba(0,0,0,.12);
}
#touch-controls { position: absolute; inset: 0; pointer-events: none; }
.move-zone {
  position: absolute; bottom: 0; top: 34%; width: 27%;
  pointer-events: auto; touch-action: none;
  display: flex; align-items: flex-end; justify-content: center;
  color: rgba(255,255,255,.7); font-size: 40px;
}
.move-zone span {
  margin-bottom: max(26px, env(safe-area-inset-bottom));
  background: rgba(30,50,80,.25); border-radius: 50%;
  width: 76px; height: 76px; display: flex; align-items: center; justify-content: center;
}
.move-zone.active span { background: rgba(30,50,80,.5); }
#zone-left { left: 0; }
#zone-right { left: 27%; }
#btn-jump {
  position: absolute; right: 22px; bottom: max(24px, env(safe-area-inset-bottom));
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffc46b, var(--orange));
  box-shadow: 0 6px 0 var(--orange-d);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; color: #fff; pointer-events: auto; touch-action: none;
}
#btn-jump.active { transform: translateY(4px); box-shadow: 0 2px 0 var(--orange-d); }
#toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  background: rgba(255,255,255,.95); color: var(--ink);
  font-weight: 800; font-size: clamp(18px, 3vw, 26px);
  padding: 14px 26px; border-radius: 18px; box-shadow: 0 4px 12px rgba(0,0,0,.2);
  animation: toastpop .35s; pointer-events: none; z-index: 30; text-align: center;
}
@keyframes toastpop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }

/* Overlays */
.overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(30, 45, 80, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.card {
  background: var(--card); border-radius: 26px; padding: 26px 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  max-width: min(520px, 92vw); max-height: 88vh; overflow-y: auto;
}
.card h2 { font-size: clamp(24px, 4vw, 34px); }
.card p { font-size: 18px; font-weight: 600; color: #3d5170; }
.stars-row { font-size: 44px; letter-spacing: 6px; }
.score-line { font-size: 22px !important; font-weight: 800 !important; color: var(--ink) !important; }
.encourage { color: #2e7d32 !important; font-weight: 800 !important; }
#complete-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* Handoff */
#screen-handoff { background: linear-gradient(180deg, #b388ff44, transparent); }
.handoff-card { border: 5px solid var(--purple); }
.handoff-arrow { font-size: 54px; animation: floaty 1.6s ease-in-out infinite; }
#handoff-text { font-size: 22px; }

/* Results */
#screen-results h2 { font-size: clamp(28px, 5vw, 42px); }
.results-cards { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.result-card {
  background: #fff; border-radius: 22px; padding: 20px 26px; min-width: 220px;
  box-shadow: 0 6px 0 rgba(0,0,0,.12); display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.result-card .avatar { font-size: 52px; }
.result-card .r-name { font-weight: 800; font-size: 22px; }
.result-card .r-score { font-size: 28px; font-weight: 800; color: var(--blue-d); }
.result-card .r-stars { font-size: 22px; color: #e8a90a; }
.result-card.winner { outline: 5px solid #ffd54f; }
.result-card .r-badge { font-weight: 800; color: var(--orange-d); }
.results-totals { font-weight: 800; font-size: 19px; color: #35507a; }

/* Onboarding */
.onboard-card { align-items: stretch; text-align: left; }
.onboard-card h2 { text-align: center; }
.onboard-row { display: flex; align-items: center; gap: 14px; font-size: 18px; font-weight: 600; color: #3d5170; }
.onboard-icon { font-size: 30px; min-width: 64px; text-align: center; }
#onboarding { z-index: 60; }
