:root {
  --accent: #e07840;
  --ink: #2a2438;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; overflow: hidden; height: 100%;
  font-family: "Trebuchet MS", "Comic Sans MS", Verdana, sans-serif;
  background: #f7d9b0;
  touch-action: none;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- top HUD ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  pointer-events: none;
  z-index: 10;
}
#brand {
  background: rgba(28, 24, 44, 0.82); color: #ffe9b8;
  padding: 8px 14px; border-radius: 999px; font-size: 15px;
}
#phase-name {
  background: var(--accent); color: #fff;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: bold;
  transition: background 0.5s;
}
#mute-btn {
  margin-left: auto; pointer-events: auto;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(28,24,44,0.82); color: #fff;
  font-size: 17px; cursor: pointer;
}
#mute-btn:hover { transform: scale(1.08); }

/* ---------- phase rail ---------- */
#rail {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 7px; z-index: 10;
}
.dot {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  background: rgba(28,24,44,0.75); color: #ffe9b8;
  font-weight: bold; font-size: 14px; cursor: pointer;
  transition: transform 0.15s, background 0.3s;
}
.dot:hover { transform: scale(1.15); }
.dot.now { background: var(--accent); color: #fff; transform: scale(1.22); border-color: #fff; }

/* ---------- phase card ---------- */
#phase-card {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 14px; width: min(560px, calc(100vw - 24px));
  background: rgba(28, 24, 44, 0.88); color: #fff;
  border-radius: 20px; padding: 14px 18px 12px;
  z-index: 10; backdrop-filter: blur(6px);
  border: 2px solid rgba(255,255,255,0.12);
}
#phase-title {
  font-size: 20px; font-weight: bold; color: #ffe9b8;
  margin-bottom: 4px;
}
#phase-title::before { content: '✦ '; color: var(--accent); }
#kid-line { font-size: 15px; line-height: 1.35; color: #fff; }
#more-btn {
  margin-top: 6px; background: none; border: none; color: var(--accent);
  font-size: 13px; font-weight: bold; cursor: pointer; padding: 2px 0;
  font-family: inherit;
}
#detail {
  max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height 0.35s, opacity 0.35s;
  font-size: 13px; line-height: 1.45; color: #cfc8e8;
}
#detail.open { max-height: 160px; opacity: 1; margin-top: 4px; }
#hint {
  margin-top: 8px; font-size: 12.5px; color: #ffe9b8; opacity: 0.9;
  border-top: 1px dashed rgba(255,255,255,0.2); padding-top: 7px;
}
#card-btns { display: flex; gap: 8px; margin-top: 10px; }
.nav {
  flex: 1; padding: 9px 6px; border-radius: 12px; border: none;
  background: rgba(255,255,255,0.14); color: #fff;
  font-family: inherit; font-size: 14px; font-weight: bold; cursor: pointer;
}
.nav:hover { background: var(--accent); }
#replay-btn { flex: 0.8; }

/* ---------- toast ---------- */
#toast {
  position: fixed; top: 108px; left: 50%; transform: translateX(-50%) translateY(-8px);
  background: #fff8e8; color: var(--ink);
  padding: 10px 20px; border-radius: 999px; font-size: 15px; font-weight: bold;
  opacity: 0; transition: opacity 0.3s, transform 0.3s; z-index: 12;
  pointer-events: none; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- start overlay ---------- */
#start {
  position: fixed; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at center, rgba(40,30,70,0.55), rgba(20,16,40,0.85));
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s;
}
#start.gone { opacity: 0; pointer-events: none; }
#start-inner {
  background: rgba(30, 26, 52, 0.95); border-radius: 26px;
  padding: 34px 40px; max-width: 520px; width: calc(100vw - 40px);
  text-align: center; color: #fff;
  border: 3px solid rgba(255,255,255,0.15);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
#start h1 { margin: 0 0 10px; font-size: 30px; color: #ffe9b8; }
#start .tag { font-size: 15px; line-height: 1.5; color: #d8d0f0; margin: 0 0 16px; }
.controls-legend {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px;
  font-size: 13px; color: #bfb8dd; text-align: left;
  margin-bottom: 18px;
}
.controls-legend b { color: #ffe9b8; }
#start-btn {
  background: var(--accent); border: none; color: #fff;
  font-size: 19px; font-weight: bold; font-family: inherit;
  padding: 13px 34px; border-radius: 999px; cursor: pointer;
  transition: transform 0.15s;
}
#start-btn:hover { transform: scale(1.06); }
#start .meet { font-size: 13px; color: #bfb8dd; margin: 14px 0 0; }

/* ---------- controls hint (bottom-left) ---------- */
#controls-hint {
  position: fixed; left: 14px; bottom: 14px; z-index: 9;
  font-size: 11.5px; color: rgba(40,30,20,0.75);
  background: rgba(255,248,232,0.65); padding: 6px 10px; border-radius: 10px;
}

/* ---------- virtual joystick ---------- */
.joy-base {
  position: fixed; width: 100px; height: 100px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: 2px solid rgba(255,255,255,0.4);
  display: none; z-index: 20; pointer-events: none;
}
.joy-knob {
  position: absolute; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,0.75);
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  #rail { top: 56px; }
  .dot { width: 30px; height: 30px; font-size: 12px; }
  #phase-card { padding: 10px 14px 10px; bottom: 10px; }
  #phase-title { font-size: 17px; }
  #kid-line { font-size: 13.5px; }
  #detail { font-size: 12px; }
  #hint { font-size: 11.5px; }
  #controls-hint { display: none; }
  #brand { font-size: 13px; padding: 6px 10px; }
  #phase-name { font-size: 12px; padding: 6px 10px; }
  #start-inner { padding: 24px 22px; }
  #start h1 { font-size: 24px; }
  .controls-legend { grid-template-columns: 1fr; }
}
