:root {
  color-scheme: dark;
  --ink: #fff9ed;
  --muted: #c9c8c2;
  --panel: rgba(25, 33, 47, .86);
  --line: rgba(255, 245, 218, .16);
  --gold: #e8bd72;
  --shadow: 0 20px 52px rgba(3, 8, 17, .38);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: radial-gradient(circle at 80% 0%, rgba(77, 117, 118, .42) 0, transparent 30%), radial-gradient(circle at 8% 92%, rgba(125, 72, 45, .28) 0, transparent 27%), linear-gradient(145deg, #0e1724, #182638 55%, #101b2b);
  font-family: ui-rounded, "Avenir Next", "Nunito", system-ui, sans-serif;
}

button { font: inherit; }

.stars { position: fixed; inset: 0; pointer-events: none; opacity: .22; background-image: radial-gradient(#fff 1px, transparent 1px); background-size: 44px 44px; mask-image: linear-gradient(to bottom, #000, transparent 75%); }

.topbar, main { width: min(1180px, calc(100% - 48px)); margin: 0 auto; }
.topbar { height: 80px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: 11px; align-items: center; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { color: var(--gold); font-size: 30px; }
.status-pill { padding: 9px 14px; border: 1px solid var(--line); background: rgba(10,8,42,.35); border-radius: 999px; color: var(--muted); font-size: 13px; }

.hero { padding: 42px 0 30px; display: flex; align-items: end; justify-content: space-between; gap: 36px; }
.eyebrow { margin: 0 0 9px; color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(40px, 5vw, 68px); line-height: .98; letter-spacing: -.055em; }
.lede { max-width: 650px; margin: 18px 0 0; color: var(--muted); font-size: 18px; }
.profile-switch { flex: 0 0 auto; display: flex; gap: 10px; }
.profile { border: 1px solid var(--line); color: var(--ink); background: rgba(255,255,255,.06); border-radius: 18px; padding: 12px 17px; cursor: pointer; text-align: left; transition: transform .18s ease, background .18s ease; }
.profile:hover, .profile:focus-visible { transform: translateY(-2px); }
.profile.active { background: #fff9ed; color: #172335; }
.profile span { font-size: 19px; margin-right: 5px; }
.profile small { display: block; margin: 4px 0 0 29px; opacity: .65; }

.games { display: grid; grid-template-columns: repeat(6, 1fr); gap: 13px; }
.library { margin: 24px 0; padding: 26px; border: 1px solid var(--line); border-radius: 28px; background: rgba(20,18,48,.62); }
.library-heading { display: flex; justify-content: space-between; gap: 20px; align-items: end; }.library-tools { display: flex; gap: 8px; align-items: center; }
.library h2 { margin: 0; font-size: 30px; }.library-heading input { width: 220px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.08); color: var(--ink); }
.lesson-library { display: grid; gap: 10px; margin-top: 18px; }.saved-lesson { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 17px; border-radius: 20px; background: rgba(255,255,255,.06); }
.saved-lesson h3 { margin: 3px 0; font-size: 19px; }.saved-lesson p { margin: 4px 0; color: var(--muted); }.saved-lesson small { color: var(--gold); }.saved-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: end; }.saved-actions button { border: 0; border-radius: 12px; padding: 9px 12px; color: var(--ink); cursor: pointer; background: rgba(255,255,255,.1); }.saved-actions span { color: var(--muted); font-size: 12px; }.library-empty { color: var(--muted); }
.library-progress { color: var(--muted); }.next-step { display: none; margin-top: 6px; }.parent-mode .next-step { display: block; }
.game-card { min-height: 154px; padding: 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; color: #fff9ed; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; text-align: left; cursor: pointer; box-shadow: var(--shadow); transition: transform .18s ease, filter .18s ease, border-color .18s ease; }
.game-card:hover, .game-card:focus-visible { transform: translateY(-5px) scale(1.015); filter: saturate(1.1); }
.game-card.has-preview { background-image: linear-gradient(145deg, rgba(9,16,28,.12), rgba(9,16,28,.82)), var(--preview-image); background-size: cover; background-position: center; }
.game-card.active { outline: 3px solid var(--gold); outline-offset: 3px; }
.game-card strong { margin-top: 12px; font-size: 17px; }
.game-card small { margin-top: 3px; color: rgba(255,249,237,.72); line-height: 1.25; }
.game-icon { min-width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: rgba(255,249,237,.16); color: #fff9ed; font-weight: 900; font-size: 20px; }
.coral { background: linear-gradient(145deg, #a9584e, #713c45); }.yellow { background: linear-gradient(145deg, #b6843f, #76552f); }.mint { background: linear-gradient(145deg, #3e8276, #285b5c); }.blue { background: linear-gradient(145deg, #477a9d, #2c4f78); }.violet { background: linear-gradient(145deg, #766391, #4a466f); }.pink { background: linear-gradient(145deg, #a7637a, #70495f); }

.stage { position: relative; min-height: 240px; margin: 24px 0 18px; padding: 30px 34px; border-radius: 30px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; overflow: hidden; }
.stage::before { content: ""; position: absolute; inset: 0; opacity: .34; pointer-events: none; background-image: radial-gradient(circle at 18% 25%, rgba(255,255,255,.18) 0 2px, transparent 3px), radial-gradient(circle at 78% 70%, rgba(255,255,255,.12) 0 1px, transparent 2px); background-size: 84px 84px, 58px 58px; }
body[data-theme="language"] .stage { background: linear-gradient(135deg, #442e4f, #1a2941); }
body[data-theme="mathematics"] .stage { background: linear-gradient(135deg, #4e3a22, #183e42); }
body[data-theme="computer science"] .stage { background: linear-gradient(135deg, #1d3b43, #252447); }
body[data-theme="biology"] .stage { background: linear-gradient(135deg, #173d3a, #273f30); }
body[data-theme="physics"] .stage { background: linear-gradient(135deg, #28335b, #452b54); }
body[data-theme="creativity"] .stage { background: linear-gradient(135deg, #512d48, #26385a); }
.stage-copy { position: relative; z-index: 2; max-width: 720px; }
.stage h2 { margin: 0 0 8px; font-size: 34px; letter-spacing: -.035em; }
.stage p { color: var(--muted); font-size: 17px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.actions button { border: 0; border-radius: 14px; padding: 12px 16px; color: var(--ink); cursor: pointer; }
.primary { background: #b96d56; font-weight: 800; box-shadow: 0 8px 24px rgba(185,109,86,.28); }
.secondary { background: rgba(255,255,255,.09); }
.activity-orb { width: 150px; height: 150px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 28%, #fff0bd, #d6a85e 30%, #a85e50 68%, #43566c); box-shadow: 0 0 0 20px rgba(255,255,255,.035), 0 0 70px rgba(216,164,99,.25); animation: float 3.4s ease-in-out infinite; }
.activity-orb span { font-size: 58px; text-shadow: 0 6px 18px rgba(70,20,90,.35); }
.lesson-art { width: 190px; height: 190px; flex: 0 0 auto; object-fit: cover; border-radius: 28px; box-shadow: 0 0 0 8px rgba(255,255,255,.08), 0 0 50px rgba(255,115,175,.24); animation: float 3.4s ease-in-out infinite; }
#camera-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .24; transform: scaleX(-1); }

.voice-dock { min-height: 72px; margin-bottom: 28px; padding: 14px 22px; border-radius: 22px; display: flex; align-items: center; gap: 15px; border: 1px solid var(--line); background: rgba(11,8,35,.5); }
.voice-dock.recording { background: rgba(126,54,58,.72); }
.voice-dock strong, .voice-dock small { display: block; }
.voice-dock small { color: var(--muted); margin-top: 3px; }
.mic-dot { width: 17px; height: 17px; border-radius: 50%; background: #d98a68; box-shadow: 0 0 0 7px rgba(217,138,104,.13); }
.wave { margin-left: auto; display: flex; align-items: center; gap: 5px; height: 30px; }
.wave i { display: block; width: 4px; height: 9px; border-radius: 4px; background: var(--gold); }
.recording .wave i { animation: wave .65s ease-in-out infinite alternate; }
.recording .wave i:nth-child(2), .recording .wave i:nth-child(4) { animation-delay: -.3s; }

[hidden] { display: none !important; }
.preview-screen, .immersive-screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: #0b1320; }
.preview-backdrop { position: absolute; inset: 0; background: radial-gradient(circle at 75% 20%, rgba(232,189,114,.16), transparent 32%); }
.preview-card { position: relative; width: min(1020px, calc(100% - 48px)); min-height: min(650px, calc(100% - 48px)); display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border: 1px solid var(--line); border-radius: 32px; background: rgba(25,33,47,.96); box-shadow: var(--shadow); }
.preview-art-wrap { min-height: 360px; display: grid; place-items: center; background: #172638; overflow: hidden; }
.preview-art-wrap img { width: 100%; height: 100%; object-fit: cover; }
.art-loading { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 700; }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,249,237,.25); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
.preview-copy { align-self: center; padding: 46px; }
.preview-copy h2 { margin: 0 0 14px; font-size: clamp(32px, 4vw, 54px); line-height: 1; }
.preview-copy > p:not(.eyebrow) { color: var(--muted); font-size: 19px; line-height: 1.5; }
.play-button { margin-top: 18px; font-size: 17px; }
.icon-button { position: absolute; z-index: 2; top: 18px; right: 18px; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: rgba(12,21,34,.72); font-size: 28px; cursor: pointer; }
.immersive-screen { align-items: end; justify-items: start; }
.immersive-screen > img, .immersive-shade { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.immersive-shade { background: linear-gradient(90deg, rgba(7,13,23,.9), rgba(7,13,23,.12) 75%), linear-gradient(0deg, rgba(7,13,23,.72), transparent 55%); }
.immersive-copy { position: relative; max-width: 760px; padding: clamp(28px, 7vw, 92px); }
.immersive-copy h2 { margin: 0 0 14px; font-size: clamp(42px, 7vw, 88px); line-height: .96; }
.immersive-copy p:not(.eyebrow) { max-width: 700px; color: var(--ink); font-size: clamp(18px, 2vw, 25px); line-height: 1.45; }
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes float { 50% { transform: translateY(-9px) rotate(4deg); } }
@keyframes wave { to { height: 29px; } }

@media (max-width: 980px) { .games { grid-template-columns: repeat(3, 1fr); }.hero { align-items: flex-start; flex-direction: column; }.game-card { min-height: 135px; } }
@media (max-width: 620px) { .topbar, main { width: min(100% - 24px, 1180px); }.games { grid-template-columns: repeat(2, 1fr); }.profile-switch { width: 100%; }.profile { flex: 1; }.stage { padding: 24px; }.activity-orb { width: 90px; height: 90px; }.activity-orb span { font-size: 36px; }.actions { flex-direction: column; }.actions button { width: 100%; }.library { padding: 20px 16px; }.library-heading { display: block; }.library-heading h2 { max-width: 100%; }.library-tools { margin-top: 14px; display: grid; grid-template-columns: 1fr auto; }.library-tools input { width: auto; min-width: 0; }.saved-lesson { display: block; }.saved-actions { margin-top: 14px; justify-content: flex-start; }.saved-actions button { font-size: 14px; } }
@media (max-width: 760px) { .preview-card { grid-template-columns: 1fr; }.preview-art-wrap { min-height: 260px; max-height: 44vh; }.preview-copy { padding: 28px; } }
@media (min-width: 981px) and (max-height: 800px) {
  .topbar { height: 58px; }
  .hero { padding: 22px 0 18px; }
  h1 { font-size: 48px; }
  .lede { margin-top: 10px; font-size: 16px; }
  .game-card { min-height: 116px; padding: 12px 14px; border-radius: 20px; }
  .game-card strong { margin-top: 8px; }
  .game-icon { min-width: 40px; height: 40px; border-radius: 12px; }
  .stage { min-height: 178px; margin: 16px 0 12px; padding: 20px 28px; }
  .stage h2 { font-size: 29px; }
  .stage p { margin: 7px 0; font-size: 15px; }
  .actions { margin-top: 13px; }
  .actions button { padding: 10px 14px; }
  .library { margin: 10px 0; padding: 12px 18px; }
  .library-heading { align-items: center; }
  .library h2 { font-size: 22px; }
  .library-heading input { padding: 8px 11px; }
  .lesson-library { margin-top: 8px; }
  .library-empty { margin: 0; }
  .activity-orb { width: 116px; height: 116px; }
  .activity-orb span { font-size: 44px; }
  .voice-dock { min-height: 58px; margin-bottom: 12px; padding: 10px 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
