:root {
  --sky: #d5e4f8;
  --ink: #10203b;
  --muted: #3e5678;
  --card: #f6f9ff;
  --line: #c9d8ee;
  --blue: #1c4fad;
  --blue-dark: #163e88;
  --green: #1e8a4c;
  --gold: #e3a008;
  --sun: #d9480f;
  --worlds: #1c7ed6;
  --motion: #5f3dc4;
  --night: #070b16;
  --shadow: 0 12px 30px rgba(16, 32, 59, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
      radial-gradient(circle at 15% 0%, #f4f8ff 0, transparent 40%),
    radial-gradient(circle at 90% 10%, #d5e4ff 0, transparent 35%),
    linear-gradient(180deg, #eef4ff, var(--sky));
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, p { margin: 0; }

.screen {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}
.screen:has(.is-wide) { width: min(100%, 980px); }

.card {
  background: var(--card);
  border: 3px solid #fff;
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1rem 1.4rem;
}
.card.is-wide { padding: 1.1rem clamp(0.75rem, 2.5vw, 1.6rem) 1.4rem; }

.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
}
.title-row h1 { text-align: left; }
.title-row .kicker { text-align: left; }
.brand { width: 64px; height: 64px; border-radius: 16px; display: block; }

.kicker {
  margin: 0 0 0.35rem;
  text-align: center;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
.kicker.k-sun { color: var(--sun); }
.kicker.k-worlds { color: var(--worlds); }
.kicker.k-motion { color: var(--motion); }
h1 {
  text-align: center;
  font-size: clamp(2.2rem, 8vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.lede {
  margin: 0.7rem auto 0.9rem;
  max-width: 36rem;
  text-align: center;
  font-size: 1.25rem;
  line-height: 1.4;
  color: var(--muted);
}
b.k-conduction { color: var(--conduction); }
b.k-convection { color: var(--convection); }
b.k-radiation { color: var(--radiation); }

/* 3D stage */
.stage {
  position: relative;
  margin: 0.4rem 0 0.6rem;
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #1c2b46, var(--night));
  box-shadow: 0 10px 30px rgba(11, 20, 36, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.stage-slot {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 220px;
  max-height: 62vh;
  touch-action: none;
}
.stage-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  opacity: 0;
  transition: opacity 0.45s ease;
  outline: none;
  cursor: grab;
}
.stage-canvas:active { cursor: grabbing; }
.stage-slot.is-live .stage-canvas { opacity: 1; }
.stage-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  text-align: center;
  color: #c9d6ea;
  font-size: 1.05rem;
  font-weight: 700;
  pointer-events: none;
}
.stage-slot.is-live .stage-note { display: none; }
.stage-slot.is-off .stage-note { color: #ffd2b8; }
.stage-caption {
  position: absolute;
  left: 0.75rem;
  top: 0.7rem;
  max-width: calc(100% - 1.5rem);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(9, 16, 30, 0.72);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.stage-tip {
  position: absolute;
  right: 0.75rem;
  bottom: 0.55rem;
  color: rgba(214, 226, 245, 0.7);
  font-size: 0.8rem;
  font-weight: 650;
  pointer-events: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0.2rem 0 0.8rem;
}
.tool {
  min-height: 2.6rem;
  padding: 0.3rem 1rem;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: #fff;
  font-size: 1rem;
  font-weight: 800;
}
.tool.is-on { border-color: var(--blue); color: var(--blue-dark); }
.follow:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}
.follow select {
  min-height: 2rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  background: #fff;
  color: inherit;
  font: inherit;
  font-weight: 700;
}
.follow-note {
  flex-basis: 100%;
  margin: 0.1rem 0 0;
  text-align: center;
  font-weight: 600;
  line-height: 1.4;
}
.stage-clock {
  position: absolute;
  left: 0.75rem;
  bottom: 0.55rem;
  margin: 0;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: rgba(9, 16, 30, 0.72);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  pointer-events: none;
}
.tool:hover { border-color: var(--blue); }
.heat-dial {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.6rem;
  padding: 0.2rem 1rem;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: #fff;
  font-weight: 800;
}
.heat-dial input {
  width: min(42vw, 180px);
  accent-color: var(--blue);
}

.legend {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}
.swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  margin-left: 0.4rem;
}
.swatch.is-cool { background: #2f5bff; box-shadow: 0 0 8px #2f5bff; }
.swatch.is-warm { background: #f2542d; box-shadow: 0 0 8px #f2542d; }
.swatch.is-hot { background: #ffd23f; box-shadow: 0 0 8px #ffb703; }

/* explore */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.3rem 0 0.6rem;
}
.tab {
  min-height: 3.6rem;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.15;
}
.tab small {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}
.tab.k-sun.is-on { border-color: var(--sun); background: #fff1e8; }
.tab.k-worlds.is-on { border-color: var(--worlds); background: #e9f3ff; }
.tab.k-motion.is-on { border-color: var(--motion); background: #f3edff; }
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.chip {
  min-height: 2.4rem;
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 0.95rem;
  font-weight: 750;
}
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip:hover { border-color: var(--ink); }
.visual-title {
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  margin: 0.2rem 0 0.2rem;
}
.explain {
  max-width: 44rem;
  margin: 0 auto;
  text-align: center;
  font-size: 1.2rem;
  line-height: 1.45;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  max-width: 34rem;
  margin: 0.9rem auto 0;
}
.choices .go, .choices .ghost { margin-top: 0; min-height: 3.6rem; }
.choices .go { font-size: 1.3rem; }

/* quiz */
.trail {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  margin: 0.2rem 0 0.7rem;
}
.stone {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: #d5e0f0;
  box-shadow: inset 0 0 0 2px #b7c8de;
}
.stone.is-done { background: var(--gold); box-shadow: none; }
.stone.is-now { box-shadow: inset 0 0 0 3px var(--blue); background: #fff; }

.prompt {
  text-align: center;
  font-size: clamp(1.7rem, 8vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0.2rem auto 0.4rem;
  max-width: 46rem;
}
.prompt.is-long {
  font-size: clamp(1.25rem, 4.2vw, 1.85rem);
  line-height: 1.25;
  letter-spacing: 0;
}
.hint {
  min-height: 2rem;
  margin: 0.2rem 0 0.6rem;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 800;
  color: #9a3412;
}
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  max-width: 46rem;
  margin: 0 auto;
}
.answers button, .go {
  min-height: 4.4rem;
  border-radius: 18px;
  border: 3px solid var(--line);
  background: #fff;
  font-size: 2.2rem;
  font-weight: 800;
}
.answers.is-text button {
  font-size: 1.2rem;
  line-height: 1.25;
  padding: 0.5rem;
}
.answers button:hover, .go:hover { border-color: var(--blue); }
.answers button:focus-visible, .go:focus-visible, .tool:focus-visible, .tab:focus-visible, .chip:focus-visible, .ghost:focus-visible, .next:focus-visible {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}
.answers button:disabled { opacity: 0.45; cursor: default; }
.answers button.is-right {
  opacity: 1;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.ghost {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  min-height: 3.2rem;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
}
.ghost:hover { border-color: var(--blue); }
.go, .next {
  display: block;
  width: 100%;
  margin-top: 1rem;
  min-height: 4.2rem;
  border: 0;
  border-radius: 18px;
  background: var(--blue);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}
.next { max-width: 46rem; margin-left: auto; margin-right: auto; }
.go:hover, .next:hover { background: var(--blue-dark); }

.home {
  display: block;
  width: fit-content;
  margin: 1rem auto 0;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  text-decoration: none;
}
.home:hover, .home:focus-visible { border-color: var(--blue); }
.home:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }

.stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.8rem 0 0.2rem;
  font-size: 2.2rem;
  line-height: 1;
}
.stars span { color: #d5deea; }
.stars span.is-earned { color: var(--gold); }
.score {
  text-align: center;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  margin-top: 0.4rem;
}

@media (max-width: 620px) {
  .answers { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .tab small { display: none; }
  .stage-slot { aspect-ratio: 4 / 3; }
  .stage-caption { font-size: 0.9rem; }
  .stage-tip { display: none; }
  .title-row { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-canvas { transition: none; }
}
