* { box-sizing: border-box; margin: 0; padding: 0; }
/* Everything (text, padding, buttons, panels) is sized in rem, so shrinking the
   root font shrinks the whole UI uniformly - "a little bit smaller". */
html { font-size: 85%; }
html, body { height: 100%; overflow: hidden; font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
body { background: #0b0e14; color: #f4f6fb; }

#game-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

/* Speed "wind" streaks - horizontal lines that rush OUT from the centre toward
   you, like flying forward through the wind. Opacity is driven by JS by speed. */
#wind { position: fixed; inset: 0; z-index: 4; overflow: hidden; pointer-events: none;
  opacity: 0; transition: opacity 0.25s ease; }
#wind .streak {
  position: absolute; left: 50%; top: 50%; height: 2px; width: 24vmax;
  transform-origin: 0 50%;            /* rotate/extend out from screen centre */
  background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 100%);
  border-radius: 2px; will-change: transform, opacity;
  animation: warp linear infinite;
}
@keyframes warp {
  0%   { transform: rotate(var(--a)) translateX(1.5vmax) scaleX(0.12); opacity: 0; }
  15%  { opacity: 0.9; }
  100% { transform: rotate(var(--a)) translateX(72vmax) scaleX(1); opacity: 0; }
}

/* Floating "+1" pop-ups when a collectible is grabbed. White, bold, rise a
   little and fade out (like the score pops in most arcade runners). */
#floaters { position: fixed; inset: 0; z-index: 6; overflow: hidden; pointer-events: none; }
.floater {
  position: absolute; transform: translate(-50%, -50%);
  color: #fff; font-weight: 900; white-space: nowrap;
  /* Big and punchy for young players; clamped so it can't overflow a phone. */
  font-size: clamp(2.4rem, 6vw, 3.6rem); line-height: 1.05;
  letter-spacing: 0.5px;
  -webkit-text-stroke: 2px rgba(20,26,40,0.55);
  paint-order: stroke fill;
  text-shadow: 0 4px 14px rgba(0,0,0,0.7), 0 0 18px rgba(255,255,255,0.35);
  animation: floatUp 0.9s ease-out forwards; will-change: transform, opacity;
}
/* Trash-pickup praise: a warm-coloured line that lingers longer (the text is
   longer, so it needs more time to read) and fades up more gently. Sits on a
   soft dark pill so the words stay readable over any bright environment. */
.floater.message {
  color: #ffe066;
  font-size: clamp(1.9rem, 4.6vw, 2.8rem);
  max-width: 88vw; white-space: normal; text-align: center;
  padding: 0.45rem 1.1rem; border-radius: 18px;
  background: rgba(30,24,10,0.42);
  border: 2px solid rgba(255,224,102,0.45);
  -webkit-text-stroke: 1.5px rgba(40,30,5,0.5);
  text-shadow: 0 4px 14px rgba(0,0,0,0.75), 0 0 22px rgba(255,209,102,0.45);
  animation: floatUpMessage 2.2s ease-out forwards;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20%  { opacity: 1; transform: translate(-50%, -85%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
@keyframes floatUpMessage {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12%  { opacity: 1; transform: translate(-50%, -80%) scale(1.1); }
  80%  { opacity: 1; transform: translate(-50%, -150%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(1); }
}

/* Global sound on/off button - sits above every screen in the top-right. */
#sound-toggle {
  position: fixed; top: 0.9rem; right: 0.9rem; z-index: 20;
  width: 3.4rem; height: 3.4rem; padding: 0; margin: 0; border-radius: 50%;
  font-size: 1.6rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  background: rgba(20,26,40,0.72); color: #fff; border: 1px solid rgba(255,255,255,0.25);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35); backdrop-filter: blur(6px);
}
#sound-toggle:hover { filter: brightness(1.12); }
#sound-toggle.muted { opacity: 0.7; }

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,14,22,0.75), rgba(8,10,18,0.95));
  z-index: 10; padding: 1rem;
}
.overlay.hidden, .hidden { display: none !important; }

.panel {
  width: min(560px, 94vw); background: rgba(20,26,40,0.92); border: 1px solid rgba(120,150,220,0.2);
  border-radius: 18px; padding: 2.25rem; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}
/* Foundation of Goodness branding shown atop the start + game-over panels. The
   logo sits on a white pad so it reads on both the light and the dark panels. */
.brand { text-align: center; margin: 0 auto 1.3rem; }
.brand-logo {
  display: block; width: min(240px, 72%); height: auto; margin: 0 auto 0.55rem;
  background: #fff; border-radius: 12px; padding: 0.5rem 0.7rem;
}
.brand-caption { font-size: 1.15rem; font-weight: 600; line-height: 1.35; color: #cdd6ee; margin: 0; }
.panel-wide .brand-caption { color: #5a6b8c; }

.panel h1 { font-size: 3.6rem; margin-bottom: 0.7rem; letter-spacing: -0.5px; line-height: 1.12; }
.subtitle { color: #aab4cc; font-size: 1.7rem; line-height: 1.4; margin-bottom: 1.5rem; }
.hint { color: #7e8aa6; font-size: 1.35rem; line-height: 1.45; margin-top: 1.2rem; }
.admin-link { margin-top: 1rem; font-size: 1.15rem; }
.admin-link a, a { color: #6fa8ff; text-decoration: none; }

textarea, input, select {
  width: 100%; padding: 1.1rem 1.3rem; border-radius: 14px; border: 1px solid rgba(120,150,220,0.3);
  background: #0e1422; color: #f4f6fb; font-size: 1.6rem; font-family: inherit; resize: vertical;
}
textarea { margin-bottom: 1rem; }

button {
  width: 100%; padding: 1.2rem 1.4rem; margin-top: 0.7rem; border: none; border-radius: 14px;
  background: linear-gradient(135deg, #4f8cff, #6f5cff); color: white; font-size: 1.7rem; font-weight: 700;
  cursor: pointer; transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.secondary { background: rgba(120,150,220,0.18); }

#loading-text { font-size: 1.6rem; line-height: 1.45; }

.spinner {
  width: 44px; height: 44px; margin: 0 auto 1rem; border-radius: 50%;
  border: 4px solid rgba(120,150,220,0.25); border-top-color: #6fa8ff; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.final-score { font-size: 2.2rem; margin: 0.6rem 0 1.1rem; color: #ffd166; }

/* End-game stats: what the player did this run (collected / dodged / steps) */
.stats { display: flex; justify-content: center; gap: 0.8rem; margin: 0.5rem 0 1.4rem; }
.stat { flex: 1; max-width: 9rem; background: rgba(120,150,220,0.14);
  border: 1px solid rgba(120,150,220,0.22); border-radius: 16px; padding: 1rem 0.6rem; }
.stat-num { display: block; font-size: 2.6rem; font-weight: 800; color: #ffd166; line-height: 1; }
.stat-label { display: block; font-size: 1.1rem; color: #cdd6ee; margin-top: 0.4rem; }

/* End-game recap: the decisions the player made at each gate this run. */
.deeds-section { margin: 0.2rem 0 1.1rem; text-align: left; }
.deeds-title { font-size: 1.3rem; font-weight: 800; color: #cdd6ee; margin: 0 0 0.2rem; text-align: center; }
.deeds-summary { font-size: 1.05rem; color: #ffd166; margin: 0 0 0.7rem; text-align: center; }
.deeds-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem;
  max-height: 12rem; overflow-y: auto;
}
.deed {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.8rem; border-radius: 12px;
  background: rgba(120,150,220,0.14); border: 1px solid rgba(120,150,220,0.22);
}
.deed-skip { opacity: 0.6; }
.deed-dist { font-size: 0.95rem; font-weight: 700; color: #9fb0d8; min-width: 3.6rem; }
.deed-emoji { font-size: 1.5rem; line-height: 1; }
.deed-text { flex: 1; font-size: 1.15rem; font-weight: 600; color: #eef2ff; }
.deed-mult { font-size: 1.05rem; font-weight: 800; color: #7ee08a; }

/* End-game: the kindness codes the player unlocked this run. */
.codes-section { margin: 0.2rem 0 1.1rem; text-align: left; }
.codes-title { font-size: 1.3rem; font-weight: 800; color: #cdd6ee; margin: 0 0 0.2rem; text-align: center; }
.codes-summary { font-size: 1.05rem; color: #ffd166; margin: 0 0 0.7rem; text-align: center; }
.codes-list {
  list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem;
  max-height: 14rem; overflow-y: auto;
}
.code-item {
  padding: 0.55rem 0.85rem; border-radius: 12px; font-size: 1.1rem; font-weight: 600; color: #eef2ff;
  background: rgba(255,209,102,0.12); border: 1px solid rgba(255,209,102,0.3);
}
.code-item::before { content: '🎁 '; }

/* End-game eco summary: celebrates the trash the player cleaned up. */
.eco-banner {
  display: flex; align-items: center; gap: 0.7rem; text-align: left;
  margin: 0.2rem 0 1.3rem; padding: 0.9rem 1.1rem; border-radius: 14px;
  background: rgba(80,200,140,0.15); border: 1px solid rgba(80,200,140,0.35);
}
.eco-banner .eco-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.eco-banner p { font-size: 1.35rem; line-height: 1.4; color: #b6f0cf; margin: 0; }

#hud {
  position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 0.75rem; align-items: center; font-variant-numeric: tabular-nums;
}
#score { font-size: 3.8rem; font-weight: 800; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
/* Live distance-in-meters readout - the number the "🏁 500m" gates count up to. */
#distance-hud { font-size: 1.6rem; font-weight: 700; color: #cdd6ee;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6); align-self: center; }
#collected-hud { font-size: 2.2rem; font-weight: 800; color: #ffd166;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6); align-self: center; }
#trash-hud { font-size: 2.2rem; font-weight: 800; color: #7ee08a;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6); align-self: center; }
/* Persistent badge for the currently-active distance-event bonus (e.g. "🐟 x3"). */
#event-hud { font-size: 2.2rem; font-weight: 800; color: #ffd166;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6); align-self: center; }

/* Center banner for distance-event prompts ("Pick a path!", locked-in praise). */
#event-prompt {
  position: fixed; top: 6.4rem; left: 50%; transform: translateX(-50%); z-index: 6;
  font-size: 1.5rem; font-weight: 800; color: #fff; white-space: nowrap;
  background: rgba(20,45,28,0.62); padding: 0.5rem 1.15rem; border-radius: 999px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6); pointer-events: none;
}
#event-prompt.hidden { display: none; }

/* Milestone "🏁 500m reached!" banner - bigger + higher, a bigger moment. */
#distance-flag {
  position: fixed; top: 3.6rem; left: 50%; transform: translateX(-50%); z-index: 7;
  font-size: 1.9rem; font-weight: 800; color: #fff; white-space: nowrap;
  background: rgba(30,30,60,0.68); padding: 0.55rem 1.4rem; border-radius: 999px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.7); pointer-events: none;
  border: 2px solid rgba(255,255,255,0.35);
}
#distance-flag.hidden { display: none; }

/* Litterer note: celebrates cleaning up someone else's mess (sits lower-centre). */
#litter-note {
  position: fixed; bottom: 4.5rem; left: 50%; transform: translateX(-50%); z-index: 6;
  max-width: 90vw; text-align: center;
  font-size: 1.35rem; font-weight: 800; color: #fff;
  background: rgba(60,45,20,0.72); padding: 0.6rem 1.3rem; border-radius: 16px;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6); pointer-events: none;
  border: 2px solid rgba(255,209,102,0.5);
}
#litter-note.hidden { display: none; }
/* Red bounce (kept generic for reuse; no longer used for a carry-cap warning). */
.floater.warn {
  color: #ff6b6b;
  text-shadow: 0 4px 14px rgba(0,0,0,0.7), 0 0 18px rgba(255,107,107,0.45);
}

#source-badge {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 0.25rem 0.6rem;
  border-radius: 6px; background: rgba(120,150,220,0.2); color: #cdd6ee; align-self: center;
}

/* ---- Greeting / start menu (transparent backdrop so the character shows) ----
   On PC the card is pinned to the LEFT and vertically centred so the idling
   character (centre of the scene) is never covered. On mobile it's centred and
   may cover the character - that's acceptable there. */
#explore-screen {
  position: fixed; inset: 0; z-index: 8; display: flex;
  align-items: center; justify-content: flex-start;
  padding: 2rem clamp(1rem, 5vw, 4rem); pointer-events: none;
}
#explore-screen.hidden { display: none; }

.start-menu {
  pointer-events: auto; width: min(400px, 92vw);
  background: rgba(18,24,38,0.9); border: 1px solid rgba(120,150,220,0.3);
  border-radius: 22px; padding: 1.6rem 1.6rem 1.5rem;
  box-shadow: 0 20px 60px rgba(15,30,70,0.55); color: #eaf1ff;
  text-align: left; backdrop-filter: blur(7px);
}
.menu-title { margin: 0 0 0.5rem; font-size: 1.6rem; color: #fff; }
.menu-purpose { margin: 0 0 0.8rem; font-size: 1rem; line-height: 1.5; color: #cfe0ff; }
.menu-codes {
  margin: 0 0 1.1rem; padding: 0.7rem 0.85rem; font-size: 0.95rem; line-height: 1.45; color: #ffe9b0;
  background: rgba(255,209,102,0.12); border: 1px solid rgba(255,209,102,0.3); border-radius: 12px;
}
.menu-codes b { color: #fff; }
.menu-controls { list-style: none; margin: 0 0 0.9rem; padding: 0; display: grid; gap: 0.55rem; }
.menu-controls li { display: flex; align-items: center; gap: 0.7rem; font-size: 1rem; color: #e8f0ff; }
.menu-controls .keys { display: inline-flex; gap: 0.3rem; flex: 0 0 auto; min-width: 92px; }
.menu-controls .key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.9rem; height: 1.9rem; padding: 0 0.5rem;
  background: rgba(120,150,220,0.22); border: 1px solid rgba(150,180,240,0.4);
  border-radius: 8px; font-size: 0.9rem; font-weight: 700; color: #fff;
}
.menu-mobile-hint { margin: 0 0 1.1rem; font-size: 0.85rem; color: #9fb3d8; }

#explore-btn {
  pointer-events: auto; width: 100%; padding: 1rem 1.4rem; font-size: 1.15rem;
  border-radius: 14px; box-shadow: 0 12px 40px rgba(40,70,140,0.5);
  animation: bob 1.8s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* On phones: centre the menu (covering the character is fine) and hide the
   desktop-only mobile hint's redundancy stays, keep it. */
@media (max-width: 640px) {
  #explore-screen { justify-content: center; padding: 1rem; }
  .start-menu { width: min(460px, 94vw); }
}

/* ---- Hold-to-sprint button (touch devices only) ---- */
#sprint-btn {
  display: none; position: fixed; right: 5vw; bottom: 13vh; z-index: 9;
  width: 88px; height: 88px; border-radius: 50%; padding: 0;
  font-size: 2.6rem; line-height: 1; touch-action: none; user-select: none;
  background: radial-gradient(circle at 35% 30%, #ffe08a, #f2a53c);
  color: #6a3d00; border: 3px solid rgba(255,255,255,0.85);
  box-shadow: 0 10px 28px rgba(120,70,0,0.45);
}
#sprint-btn:active { transform: scale(0.92); filter: brightness(1.1); }
/* Only surface it on touch devices, and only once the run has started
   (the .hidden class, which is display:none !important, gates that). */
@media (hover: none) and (pointer: coarse) {
  #sprint-btn { display: flex; align-items: center; justify-content: center; }
}

/* ============================================================================
   Kid-friendly start screen (tabs, idea buttons, chat, preview)
   ========================================================================== */
.overlay { background: radial-gradient(ellipse at center, rgba(120,180,255,0.35), rgba(60,90,160,0.55)); }
.panel-wide { width: min(680px, 95vw); background: rgba(255,255,255,0.96); color: #25324a;
  border: 1px solid rgba(120,150,220,0.25); box-shadow: 0 24px 70px rgba(40,70,140,0.35); }
.panel-wide h1 { color: #2a3a5c; }
.panel-wide .subtitle { color: #5a6b8c; }
.panel-wide .hint { color: #8a96b0; }
.panel-wide textarea, .panel-wide input[type="text"] { background: #f3f7ff; color: #25324a; border-color: rgba(120,150,220,0.4); }

/* Tab bar */
.tabs { display: flex; gap: 0.4rem; margin: 0.25rem 0 1rem; }
.tabs .tab { flex: 1; margin-top: 0; padding: 1rem 0.4rem; font-size: 1.35rem;
  background: rgba(120,150,220,0.14); color: #45557a; }
.tabs .tab.is-active { background: linear-gradient(135deg, #4f8cff, #6f5cff); color: #fff; }

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.tab-help { color: #5a6b8c; font-size: 1.5rem; line-height: 1.4; margin-bottom: 0.95rem; }

/* Tab 1 - idea buttons */
.idea-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin-bottom: 0.9rem; }
.idea { margin-top: 0; padding: 1.2rem 0.3rem; font-size: 1.45rem; font-weight: 700;
  background: #eef3ff; color: #3a4a6e; border: 2px solid transparent; }
.idea:hover { filter: none; background: #e3ecff; }
.idea.chosen { background: linear-gradient(135deg, #ffd166, #ff9f5a); color: #5a3a10; border-color: #ff8a3c; }

/* Tab 3 - chat */
.chat-log { text-align: left; max-height: 280px; overflow-y: auto; padding: 0.6rem;
  background: #f3f7ff; border-radius: 12px; margin-bottom: 0.6rem; min-height: 110px; }
.bubble { display: inline-block; clear: both; max-width: 85%; padding: 0.8rem 1.1rem;
  border-radius: 14px; margin: 0.35rem 0; font-size: 1.45rem; line-height: 1.4; }
.bubble.assistant { float: left; background: #e6eeff; color: #2a3a5c; border-bottom-left-radius: 4px; }
.bubble.user { float: right; background: linear-gradient(135deg, #4f8cff, #6f5cff); color: #fff; border-bottom-right-radius: 4px; }
.chat-input-row { display: flex; gap: 0.4rem; align-items: stretch; }
.chat-input-row input { flex: 1; }
.chat-send { width: auto; margin-top: 0; padding: 0.6rem 1.1rem; }

/* Think More toggle */
.think-more { display: flex; align-items: center; gap: 0.6rem; justify-content: center;
  margin-top: 1.1rem; font-size: 1.3rem; color: #5a6b8c; cursor: pointer; }
.think-more input { width: auto; transform: scale(1.6); }
.think-more em { color: #8a96b0; font-style: normal; font-size: 1.15rem; }

/* Preview + redirect panels stay on the default dark panel; brighten text */
.preview-text { font-size: 1.85rem; line-height: 1.55; margin: 0.95rem 0 1.45rem; color: #ffe9b0; }
.panel-wide .admin-link a { color: #4f8cff; }

/* ---- Attributions / credits page ---- */
.attributions-panel h1 { color: #2a3a5c; }
.attributions-body { text-align: left; max-height: 62vh; overflow-y: auto; margin: 1rem 0 1.2rem; }
.attributions-body h2 { font-size: 1.55rem; margin: 1.3rem 0 0.5rem; color: #2a3a5c; }
.attr-music { font-size: 1.4rem; line-height: 1.5; color: #25324a; }
.attr-music a { color: #2f6df0; text-decoration: underline; }
.credits-list { list-style: none; padding: 0; margin: 0; }
.credits-list li { font-size: 1.25rem; line-height: 1.7; color: #45557a; }
.music-license-link { display: inline-block; margin-top: 0.4rem; font-size: 1.35rem;
  color: #2f6df0; text-decoration: underline; cursor: pointer; }

/* Music license certificate popup (dark panel, monospace, scrolls) */
.license-panel { text-align: left; width: min(620px, 94vw); }
.license-text {
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.05rem; line-height: 1.5; max-height: 62vh; overflow-y: auto;
  background: #0e1422; border: 1px solid rgba(120,150,220,0.25); border-radius: 12px;
  padding: 1rem 1.1rem; color: #d7def0; margin-bottom: 1rem;
}
