/* ---- The Little Spark's Big Journey — HUD & overlay styling ---- */
:root {
  --ink: #1d2333;
  --paper: rgba(255, 253, 247, 0.94);
  --paper-border: rgba(29, 35, 51, 0.12);
  --accent: #ff7a3d;
  --accent-2: #3ec6ff;
  --shadow: 0 10px 30px rgba(10, 14, 30, 0.35);
  --radius: 18px;
  font-size: 16px;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0e1a; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Avenir Next", "Trebuchet MS", Verdana, sans-serif; color: var(--ink); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene.dragging { cursor: grabbing; }
#scene.hoverable { cursor: pointer; }

.hud { position: fixed; z-index: 10; user-select: none; }
.hidden { display: none !important; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(24, 30, 58, 0.88), rgba(6, 8, 18, 0.96));
  backdrop-filter: blur(6px);
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.intro-card, .help-card {
  max-width: min(560px, 90vw); text-align: center; color: #f4f1e8;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px; padding: 42px 38px; box-shadow: var(--shadow);
}
.intro-spark { font-size: 64px; animation: bob 2.4s ease-in-out infinite; filter: drop-shadow(0 0 22px #ffd76e); }
@keyframes bob { 0%,100% { transform: translateY(0) scale(1);} 50% { transform: translateY(-12px) scale(1.08);} }
.intro-card h1 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); margin: 12px 0 10px; letter-spacing: 0.5px; }
.intro-sub { color: #c8cbe0; line-height: 1.55; margin-bottom: 26px; font-size: clamp(0.9rem, 2.4vw, 1.05rem); }
.intro-hint { margin-top: 18px; color: #8f94b3; font-size: 0.85rem; }
.big-btn {
  font: inherit; font-weight: 700; font-size: 1.15rem; color: #241505;
  background: linear-gradient(180deg, #ffd76e, #ff9a3d);
  border: none; border-radius: 999px; padding: 14px 34px; cursor: pointer;
  box-shadow: 0 6px 0 #c96a1d, 0 12px 26px rgba(255, 150, 50, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.big-btn:hover { transform: translateY(-2px) scale(1.03); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #c96a1d; }
.help-card { text-align: left; }
.help-card h2 { text-align: center; margin-bottom: 16px; }
.help-card ul { list-style: none; margin-bottom: 22px; }
.help-card li { margin: 12px 0; line-height: 1.5; color: #dfe2f2; }
.help-card .big-btn { display: block; margin: 0 auto; }

/* ---------- Top bar ---------- */
#topbar {
  top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#phaseTitle {
  display: flex; align-items: center; gap: 10px;
  background: var(--paper); border: 1px solid var(--paper-border);
  border-radius: 999px; padding: 8px 18px 8px 8px; box-shadow: var(--shadow);
  max-width: 44vw; overflow: hidden; white-space: nowrap;
}
#phaseNum {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: #fff; font-weight: 800; flex: none;
  transition: background 0.4s ease;
}
#phaseName { font-weight: 800; font-size: 0.98rem; text-overflow: ellipsis; overflow: hidden; }
#phaseDots { display: flex; gap: 7px; background: var(--paper); border: 1px solid var(--paper-border); border-radius: 999px; padding: 9px 12px; box-shadow: var(--shadow); }
#phaseDots .dot {
  width: 15px; height: 15px; border-radius: 50%; border: none; cursor: pointer;
  background: #d7d3c4; transition: transform 0.18s ease, background 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
#phaseDots .dot:hover { transform: scale(1.35); }
#phaseDots .dot.done { background: #b9b29c; }
#phaseDots .dot.current { transform: scale(1.45); box-shadow: 0 0 0 3px rgba(255,255,255,0.85), 0 0 14px currentColor; }
.top-right { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--paper-border);
  background: var(--paper); font-size: 1.1rem; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow); transition: transform 0.15s ease;
}
.icon-btn:hover { transform: scale(1.12) rotate(-4deg); }

/* ---------- Passport ---------- */
#passport {
  top: 66px; left: 16px; display: flex; flex-direction: column; gap: 5px;
  background: var(--paper); border: 1px solid var(--paper-border);
  border-radius: var(--radius); padding: 9px 10px; box-shadow: var(--shadow);
}
#passport .stamp {
  width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: #ece7d8; filter: grayscale(1); opacity: 0.45;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#passport .stamp.earned { filter: none; opacity: 1; transform: scale(1.12); box-shadow: inset 0 0 0 2px rgba(29,35,51,0.25); }
#passport .stamp.now { animation: stampPop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1); box-shadow: 0 0 0 3px #ffd76e, inset 0 0 0 2px rgba(29,35,51,0.25); }
@keyframes stampPop { 0% { transform: scale(0.2) rotate(-30deg);} 60% { transform: scale(1.5) rotate(8deg);} 100% { transform: scale(1.12) rotate(0);} }

/* ---------- Caption ---------- */
#caption {
  left: 50%; transform: translateX(-50%);
  bottom: 86px; width: min(640px, calc(100vw - 32px));
  background: var(--paper); border: 1px solid var(--paper-border);
  border-radius: var(--radius); padding: 14px 20px 10px; box-shadow: var(--shadow);
  text-align: center; transition: opacity 0.3s ease;
}
#captionKid { font-size: clamp(1rem, 2.6vw, 1.22rem); font-weight: 700; line-height: 1.4; }
#captionKid .em { color: var(--accent); }
#captionTech {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed rgba(29,35,51,0.25);
  font-size: 0.86rem; line-height: 1.55; color: #454c63; text-align: left;
}
.link-btn {
  margin-top: 6px; background: none; border: none; color: #6b7290; font: inherit;
  font-size: 0.8rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--ink); }

/* ---------- Hint bubble ---------- */
#hintBubble {
  left: 50%; transform: translateX(-50%);
  bottom: 196px; background: #1d2333; color: #ffe9a8;
  padding: 9px 18px; border-radius: 999px; font-size: 0.9rem; font-weight: 700;
  box-shadow: var(--shadow); animation: hintPulse 1.8s ease-in-out infinite;
  pointer-events: none; white-space: nowrap;
}
@keyframes hintPulse { 0%,100% { transform: translateX(-50%) translateY(0);} 50% { transform: translateX(-50%) translateY(-7px);} }

/* ---------- Bottom nav ---------- */
#nav {
  bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center;
}
.nav-btn {
  font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
  border: 1px solid var(--paper-border); border-radius: 999px;
  background: var(--paper); color: var(--ink);
  padding: 13px 24px; box-shadow: var(--shadow), 0 4px 0 rgba(29,35,51,0.18);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.3s;
}
.nav-btn:hover { transform: translateY(-2px) scale(1.04); }
.nav-btn:active { transform: translateY(2px); box-shadow: var(--shadow); }
.nav-btn.next { background: linear-gradient(180deg, #8ef0c3, #34c98a); color: #06351f; }
.nav-btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.nav-btn.replay { padding: 13px 18px; }

/* ---------- Joystick (touch) ---------- */
#joystick {
  position: fixed; z-index: 20; left: 26px; bottom: 96px;
  width: 116px; height: 116px; border-radius: 50%;
  background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.28);
  touch-action: none;
}
#joystickKnob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px;
  border-radius: 50%; background: rgba(255,255,255,0.75);
  transform: translate(-50%, -50%); box-shadow: 0 4px 12px rgba(0,0,0,0.35);
}

/* ---------- Toast ---------- */
#toast {
  position: fixed; z-index: 40; top: 76px; left: 50%; transform: translateX(-50%);
  background: #1d2333; color: #fff; font-weight: 700; font-size: 0.95rem;
  padding: 11px 22px; border-radius: 999px; box-shadow: var(--shadow);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); pointer-events: none;
  max-width: 86vw; text-align: center;
}
@keyframes toastIn { from { transform: translateX(-50%) translateY(-18px) scale(0.7); opacity: 0; } to { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } }

/* ---------- Small screens ---------- */
@media (max-width: 760px) {
  #phaseName { font-size: 0.82rem; }
  #phaseTitle { padding: 6px 12px 6px 6px; max-width: 52vw; }
  #phaseNum { width: 26px; height: 26px; font-size: 0.8rem; }
  #phaseDots { gap: 5px; padding: 7px 9px; }
  #phaseDots .dot { width: 11px; height: 11px; }
  #passport { top: 118px; left: 8px; padding: 6px 7px; gap: 4px; }
  #passport .stamp { width: 24px; height: 24px; font-size: 13px; border-radius: 8px; }
  #caption { bottom: 78px; padding: 10px 14px 8px; }
  #captionKid { font-size: 0.95rem; }
  #captionTech { font-size: 0.78rem; }
  .nav-btn { padding: 11px 16px; font-size: 0.9rem; }
  #hintBubble { bottom: 178px; font-size: 0.8rem; }
  #joystick { bottom: 224px; left: 18px; width: 96px; height: 96px; }
}
@media (max-height: 500px) {
  #caption { bottom: 70px; }
  #passport { display: none; }
}
