:root {
  --bg: #05051a;
  --bg-panel: #0a0e1a;
  --panel: rgba(0, 51, 102, 0.38);
  --panel2: rgba(10, 14, 26, 0.92);
  --cyan: #00d2ff;
  --cyan-bright: #00e5ff;
  --purple: #8a2be2;
  --purple-bright: #bf00ff;
  --text: #ffffff;
  --muted: #9aa8b8;
  --ok: #2ecc71;
  --bad: #e74c3c;
  --radius: 14px;
  --font: "Montserrat", "Segoe UI", system-ui, sans-serif;
  --font-display: "Orbitron", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% 0%, rgba(0, 210, 255, 0.1), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 30%, rgba(191, 0, 255, 0.12), transparent 50%);
}

.hcm { color: var(--cyan); }
.verse { color: var(--purple-bright); }

.screen {
  display: none;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Chrome */
.site-chrome {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: rgba(5, 5, 26, 0.55);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 210, 255, 0.15);
}

.site-chrome__home {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-chrome__logo {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cyan), var(--purple-bright));
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.35);
}

.site-chrome__wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-chrome__xp {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cyan);
}

.xp-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: 0.6rem 1.2rem;
  background: rgba(0, 210, 255, 0.15);
  border: 1px solid rgba(0, 210, 255, 0.45);
  border-radius: 999px;
  color: var(--cyan-bright);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.xp-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Welcome */
.welcome {
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem 2rem;
  text-align: center;
}

.logo {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.tagline {
  margin-top: 0.75rem;
  max-width: 560px;
  color: var(--muted);
  line-height: 1.65;
}

.welcome-sub {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.curriculum-badge {
  display: inline-block;
  margin-bottom: 1rem;
  padding: 0.4rem 1rem;
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--cyan);
  letter-spacing: 0.04em;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  max-width: 680px;
  margin: 1.75rem auto 1.25rem;
  width: 100%;
}

.avatar-card {
  background: var(--panel);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  color: inherit;
  font: inherit;
  text-align: center;
}

.avatar-card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 210, 255, 0.35);
}

.avatar-card.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 24px rgba(0, 210, 255, 0.25);
}

.avatar-card .icon {
  font-size: 2.5rem;
}

.avatar-card h3 {
  margin-top: 0.5rem;
  font-size: 1rem;
}

.avatar-card p {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.35rem;
}

.welcome-links,
.lobby-external {
  margin-top: 1.5rem;
  font-size: 0.82rem;
}

.ext-link {
  color: var(--cyan);
  text-decoration: none;
  margin: 0 0.35rem;
}

.ext-link:hover {
  color: var(--cyan-bright);
}

.ext-label {
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  border: none;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(90deg, var(--cyan), var(--purple-bright));
  color: #fff;
  box-shadow: 0 0 20px rgba(0, 210, 255, 0.3);
}

.btn-primary:not(:disabled):hover {
  transform: scale(1.03);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(0, 210, 255, 0.25);
}

.btn-ghost:hover {
  color: var(--cyan);
  border-color: var(--cyan);
}

/* Lobby */
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(0, 210, 255, 0.12);
}

.lobby-brand {
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
}

.lobby-sub-label {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.user-chip,
.lobby-xp {
  background: var(--panel);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.lobby-xp {
  color: var(--cyan);
  font-weight: 700;
}

.lobby-main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.lobby-title {
  font-size: 1.45rem;
}

.lobby-sub {
  color: var(--muted);
  margin: 0.35rem 0 1.25rem;
  line-height: 1.55;
}

.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.zone-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  border: 1px solid rgba(0, 210, 255, 0.12);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  text-align: left;
  color: inherit;
  font: inherit;
  position: relative;
}

.zone-card:hover {
  border-color: rgba(0, 210, 255, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.zone-card.visited::after {
  content: "✓";
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  color: var(--cyan);
  font-weight: 700;
}

.zone-num {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--purple-bright);
}

.zone-card .z-icon {
  font-size: 2rem;
  margin-top: 0.35rem;
}

.zone-card h3 {
  margin-top: 0.5rem;
  font-size: 1.05rem;
  color: var(--cyan-bright);
}

.zone-card p {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.progress-bar {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid rgba(0, 210, 255, 0.1);
}

.progress-bar label {
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-track {
  height: 8px;
  background: var(--panel2);
  border-radius: 4px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple-bright));
  width: 0%;
  transition: width 0.4s;
}

.leaderboard {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid rgba(191, 0, 255, 0.15);
}

.leaderboard h3 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
}

.leaderboard ol {
  list-style: none;
}

.leaderboard li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-rank {
  width: 1.5rem;
  color: var(--purple-bright);
  font-weight: 700;
}

.lb-name { flex: 1; }
.lb-xp { color: var(--cyan); font-weight: 600; }
.lb-empty { color: var(--muted); font-size: 0.85rem; }

.lobby-external {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Zone */
.zone-screen {
  padding-bottom: 2rem;
}

.zone-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 3.5rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(0, 210, 255, 0.1);
}

.zone-nav h2 {
  font-size: 1.1rem;
  flex: 1;
}

.zone-intro {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 1.5rem 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
  border-left: 3px solid var(--cyan);
}

.zone-body {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  width: 100%;
}

.zone-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  line-height: 1.55;
}

.zone-hint--3d strong {
  color: var(--cyan-bright);
}

.webgl-mount {
  width: 100%;
  height: min(52vh, 480px);
  min-height: 300px;
  margin-bottom: 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(0, 210, 255, 0.25);
  box-shadow: 0 0 32px rgba(0, 210, 255, 0.12);
  position: relative;
  background: #020210;
}

.webgl-mount--artifacts {
  height: min(42vh, 380px);
}

.webgl-mount--thought {
  height: min(38vh, 340px);
}

.webgl-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  cursor: grab;
}

.webgl-canvas:active {
  cursor: grabbing;
}

.zone-body--timeline {
  max-width: 100%;
}

/* Time tunnel — Khu 1 */
.zone-body--timeline {
  max-width: 100%;
}

.time-tunnel-wrap {
  width: 100%;
}

.time-tunnel {
  position: relative;
  height: min(420px, 55vh);
  margin: 0 -0.5rem 1.5rem;
  perspective: 900px;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #020210 0%, #0a1530 50%, #05051a 100%);
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.tunnel-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 40% 80% at 50% 50%, rgba(0, 210, 255, 0.2), transparent 70%),
    radial-gradient(ellipse 30% 50% at 50% 100%, rgba(191, 0, 255, 0.15), transparent);
  animation: tunnel-pulse 4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes tunnel-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.tunnel-track {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.5rem, 3vw, 1.5rem);
  padding: 2rem 1rem;
  transform-style: preserve-3d;
  animation: tunnel-drift 24s linear infinite;
}

@keyframes tunnel-drift {
  0% { transform: translateZ(0) rotateX(8deg); }
  50% { transform: translateZ(20px) rotateX(6deg); }
  100% { transform: translateZ(0) rotateX(8deg); }
}

.milestone-node {
  flex: 0 0 auto;
  min-width: 120px;
  max-width: 160px;
  padding: 1rem 0.75rem;
  border: 2px solid rgba(0, 210, 255, 0.35);
  border-radius: 12px;
  background: rgba(5, 5, 26, 0.85);
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: center;
  transform: translateZ(calc(var(--i) * 12px)) scale(calc(1 - var(--i) * 0.02));
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  animation: node-float 3s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.4s);
}

@keyframes node-float {
  0%, 100% { transform: translateY(0) translateZ(calc(var(--i) * 12px)); }
  50% { transform: translateY(-6px) translateZ(calc(var(--i) * 12px + 8px)); }
}

.milestone-node:hover,
.milestone-node.visited {
  border-color: var(--cyan-bright);
  box-shadow: 0 0 24px rgba(0, 210, 255, 0.35);
}

.milestone-year {
  display: block;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--cyan);
}

.milestone-title {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.milestone-stage {
  background: var(--panel2);
  border: 1px solid rgba(0, 210, 255, 0.2);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 0.5rem;
  animation: stage-in 0.35s ease;
}

@keyframes stage-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.milestone-close {
  margin-bottom: 0.75rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.milestone-head-year {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--purple-bright);
}

.milestone-head h3 {
  margin-top: 0.25rem;
}

.milestone-tagline {
  color: var(--cyan);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

.milestone-desc {
  margin: 1rem 0;
  line-height: 1.65;
  color: var(--muted);
}

.milestone-actions {
  margin-top: 1rem;
}

/* Artifacts — Khu 2 */
.artifact-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 800px) {
  .artifact-layout {
    grid-template-columns: minmax(200px, 280px) 1fr;
  }
}

.artifact-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.artifact-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid rgba(0, 210, 255, 0.12);
  border-radius: 10px;
  padding: 0.65rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}

.artifact-card.active,
.artifact-card:hover {
  border-color: var(--cyan);
}

.artifact-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.artifact-thumb-ph {
  width: 48px;
  text-align: center;
  font-size: 1.5rem;
}

.artifact-card strong {
  display: block;
  font-size: 0.9rem;
}

.artifact-card p {
  font-size: 0.75rem;
  color: var(--muted);
}

.artifact-viewer {
  background: var(--panel2);
  border: 1px solid rgba(0, 210, 255, 0.15);
  border-radius: var(--radius);
  padding: 1.25rem;
  min-height: 200px;
}

.artifact-viewer:not(.active) {
  display: none;
}

.viewer-stage {
  width: min(280px, 100%);
  height: 220px;
  margin: 1rem auto;
  perspective: 900px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-obj {
  width: 180px;
  height: 180px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--accent, #1a3a5c), #05051a);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), inset 0 0 40px rgba(0, 210, 255, 0.08);
  transition: transform 0.08s;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.viewer-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.viewer-emoji {
  font-size: 4rem;
}

.viewer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.narration-box {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0, 210, 255, 0.06);
  border-radius: 8px;
  border-left: 3px solid var(--cyan);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Thought — Khu 3 */
.topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.topic-tab {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 210, 255, 0.2);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
}

.topic-tab.active {
  border-color: var(--cyan);
  color: var(--cyan-bright);
  background: rgba(0, 210, 255, 0.1);
}

.topic-panel {
  background: var(--panel2);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid rgba(191, 0, 255, 0.12);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.info-card {
  padding: 0.75rem;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
  background: rgba(0, 210, 255, 0.08);
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.info-card--youth {
  background: rgba(191, 0, 255, 0.1);
  border-color: rgba(191, 0, 255, 0.25);
}

.thought-points {
  margin: 0.75rem 0 0 1.2rem;
  line-height: 1.75;
  color: var(--muted);
}

.story-box {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 8px;
  font-style: italic;
  line-height: 1.6;
}

/* Quiz — Khu 4 */
.quiz-xp-bar {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.quiz-xp-bar strong {
  color: var(--cyan);
}

.quiz-card {
  background: var(--panel2);
  border-radius: var(--radius);
  padding: 1.5rem;
  border: 1px solid rgba(191, 0, 255, 0.15);
}

.quiz-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.quiz-q {
  font-size: 1.1rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.quiz-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-choice {
  text-align: left;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.quiz-choice:hover {
  border-color: rgba(0, 210, 255, 0.3);
}

.quiz-choice.correct {
  border-color: var(--ok);
  background: rgba(46, 204, 113, 0.12);
}

.quiz-choice.wrong {
  border-color: var(--bad);
  background: rgba(231, 76, 60, 0.12);
}

.quiz-explain {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-result {
  text-align: center;
  padding: 1.5rem 0;
}

.badge-display {
  font-size: 4rem;
  margin: 1rem 0;
}

.score-text {
  font-size: 1.35rem;
  color: var(--cyan-bright);
  font-weight: 700;
}

.quiz-result-sub {
  color: var(--muted);
  margin-top: 0.75rem;
}

/* Media */
.media-figure {
  margin-top: 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.media-figure img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.media-figure figcaption {
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.media-credit {
  padding: 0 1rem 0.75rem;
  font-size: 0.75rem;
  color: var(--purple-bright);
}

.video-wrap {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  background: #000;
}

.video-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

@media (max-width: 600px) {
  .zone-nav {
    padding-top: 3.25rem;
    flex-wrap: wrap;
  }

  .tunnel-track {
    flex-wrap: wrap;
    animation: none;
    overflow-y: auto;
    align-content: center;
  }

  .time-tunnel {
    height: auto;
    min-height: 320px;
  }
}
