/* Earthling: space above, the real Earth below. Kids sits on the sunlit side, 16+ on the night side. */

@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/assets/fonts/bricolage.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}
@font-face { font-family: 'Atkinson Next'; src: url('/assets/fonts/atkinson-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('/assets/fonts/atkinson-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Atkinson Next'; src: url('/assets/fonts/atkinson-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --sky: #071430;          /* space above the sunlit side; matches the top of the Earth pictures */
  --sky-ink: #eef4ff;
  --sky-soft: #b3c8e8;
  --ocean: #174a86;
  --ocean-deep: #0e3363;
  --land: #2fa45e;
  --land-ink: #0d3a20;
  --sun: #ffc93a;
  --sun-ink: #3a2a00;
  --cloud: #ffffff;
  --mist: #bdd6f6;
  --ink: #0f2a4a;
  --alert: #ffb4a8;
  --night: #071629;
  --earth: url('/assets/space/earth-day.webp');

  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Atkinson Next', ui-sans-serif, system-ui, sans-serif;
  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 32px);
  --card-radius: 18px;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ocean: #0f335f;
    --ocean-deep: #091f3d;
    --land: #2b9a57;
    --mist: #a4bfe3;
  }
}

/* The night side of the planet: the 16+ section. */
body[data-side='night'], .door-night {
  --sky: #05061a;          /* matches the top of the night picture */
  --sky-ink: #f2eeff;
  --sky-soft: #bdb5e6;
  --ocean: #1b1850;
  --ocean-deep: #110f38;
  --mist: #bab3e4;
}
.earth-night { --earth: url('/assets/space/earth-night.webp'); }
.earth-day { --earth: url('/assets/space/earth-day.webp'); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--cloud);
  background: var(--ocean);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 6px; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--sun); color: var(--sun-ink); padding: 8px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { left: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Top bar (in space) ---------- */
.topbar { background: var(--sky); color: var(--sky-ink); position: relative; z-index: 4; }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; }
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; letter-spacing: -0.04em; line-height: 1; }
.mark img { width: 34px; height: 34px; flex: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav button {
  text-decoration: none; background: none; border: 0; cursor: pointer;
  padding: 8px 12px; border-radius: 999px; font-weight: 600; font-size: 0.98rem; color: var(--sky-ink);
}
.nav a:hover, .nav button:hover { background: color-mix(in srgb, var(--sky-ink) 12%, transparent); }
.nav a[aria-current='page'] { background: var(--sky-ink); color: var(--sky); }
.nav a[aria-current='true'] { box-shadow: inset 0 0 0 2px var(--sky-ink); }

/* ---------- Hero: space, with the real Earth along the bottom ---------- */
.hero { background: var(--sky); color: var(--sky-ink); position: relative; }
.hero.earth {
  background: var(--sky) var(--earth) center bottom / max(100%, 980px) auto no-repeat;
  padding-bottom: clamp(150px, 19vw, 300px);
}
/* The planet fades into the page below, as if you'd landed. */
.hero.earth::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: clamp(60px, 8vw, 130px); background: linear-gradient(to bottom, transparent, var(--ocean)); pointer-events: none; z-index: 1; }
.hero-inner { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: clamp(24px, 4vw, 56px); align-items: start; padding-top: clamp(16px, 4vw, 48px); position: relative; z-index: 3; }
.hero h1 {
  font-family: var(--font-display); font-weight: 800; font-size: clamp(2.7rem, 7.4vw, 6.1rem);
  line-height: 0.93; letter-spacing: -0.045em; margin: 0 0 20px; text-wrap: balance;
}
.hero-copy p { font-size: clamp(1.05rem, 1.6vw, 1.22rem); max-width: 34ch; margin: 0 0 26px; color: var(--sky-soft); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-feature { margin-top: clamp(0px, 3vw, 40px); }
.stars { position: absolute; inset: 0; width: 100%; height: 100%; fill: #fff; z-index: 0; pointer-events: none; opacity: 0.7; }

/* ---------- Things flying past ---------- */
.flyby { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 2; --band: clamp(150px, 19vw, 300px); }
.home .flyby { --band: clamp(200px, 24vw, 330px); }
.fly {
  position: absolute; left: 0; bottom: calc(var(--band) * var(--lane)); width: var(--w); height: auto; max-width: none;
  animation-duration: var(--dur); animation-delay: var(--delay); animation-timing-function: linear; animation-iteration-count: infinite;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
  will-change: transform;
}
@keyframes drift-r { from { transform: translateX(-30vw) rotate(var(--r0)); } to { transform: translateX(110vw) rotate(var(--r1)); } }
@keyframes drift-l { from { transform: translateX(110vw) rotate(var(--r0)); } to { transform: translateX(-30vw) rotate(var(--r1)); } }
@keyframes dash-l { 0% { transform: translateX(115vw) rotate(var(--r0)); } 22% { transform: translateX(-35vw) rotate(var(--r1)); } 100% { transform: translateX(-35vw) rotate(var(--r1)); } }
@media (max-width: 720px) {
  .fly { width: calc(var(--w) * 0.6); }
  .fly-station, .fly-capsule { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .fly { animation: none !important; transform: translateX(var(--rest)) rotate(var(--r0)); }
}

/* ---------- Home: the two doors ---------- */
.home { padding-bottom: clamp(36px, 6vw, 72px); overflow: hidden; }
.home-copy { position: relative; z-index: 3; padding-top: clamp(16px, 4vw, 44px); margin-bottom: clamp(24px, 4vw, 40px); display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 40px; }
.hero .home-copy h1 { flex: 1 1 auto; font-size: clamp(2.5rem, 5vw, 4.5rem); margin-bottom: 0; }
.home-copy p { flex: 0 1 34ch; margin: 0 0 6px; font-size: clamp(1.05rem, 1.6vw, 1.22rem); color: var(--sky-soft); }
.doors { display: grid; grid-template-columns: 1fr 1fr; border: 6px solid var(--cloud); border-radius: 32px; overflow: hidden; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25), 0 30px 80px rgba(0, 0, 0, 0.45); }
/* One picture across both doors: the sunlit half behind Kids, the night half behind 16+. */
.door { position: relative; display: flex; flex-direction: column; min-height: clamp(380px, 40vw, 520px); color: var(--sky-ink); text-decoration: none; }
.door-day {
  background:
    radial-gradient(circle at 0% 0%, rgba(255, 238, 196, 0.32), rgba(255, 238, 196, 0) 48%),
    #071430 url('/assets/space/earth-split.webp') left bottom / 200% auto no-repeat;
}
.door-night { background: #05061a url('/assets/space/earth-split.webp') right bottom / 200% auto no-repeat; }
.door-body { position: relative; z-index: 3; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: clamp(24px, 3.5vw, 44px); text-shadow: 0 2px 18px rgba(0, 0, 0, 0.5); }
.door-name { font-family: var(--font-display); font-weight: 800; font-size: clamp(3.8rem, 10vw, 8.2rem); line-height: 0.8; letter-spacing: -0.055em; margin-bottom: 6px; }
.door-line { max-width: 27ch; color: var(--sky-soft); font-size: clamp(1rem, 1.4vw, 1.15rem); }
.door-go { margin-top: 6px; display: inline-flex; align-items: center; min-height: 46px; padding: 0 22px; border-radius: 999px; background: var(--sky-ink); color: var(--sky); font-weight: 700; text-shadow: none; transition: transform 120ms ease; }
.door-day .door-go { background: var(--sun); color: var(--sun-ink); }
.door:hover .door-go { transform: translateY(-2px); }
.door:focus-visible { outline: none; }
.door:focus-visible::after { content: ''; position: absolute; inset: 0; z-index: 5; border: 4px solid var(--sun); pointer-events: none; }

/* ---------- 16+ age check ---------- */
.gate { text-align: center; }
.hero.gate.earth { padding-bottom: clamp(170px, 24vw, 340px); }
.gate-inner { position: relative; z-index: 3; max-width: 680px; padding-top: clamp(48px, 8vw, 110px); }
.gate h1 { font-size: clamp(2.6rem, 7vw, 5rem); }
.gate p { color: var(--sky-soft); font-size: clamp(1.05rem, 1.6vw, 1.22rem); max-width: 40ch; margin: 0 auto 26px; }
.gate .hero-actions { justify-content: center; }
.gate .gate-note { font-size: 0.95rem; margin: 18px auto 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 0; cursor: pointer; text-decoration: none; font-weight: 700; font-size: 1.02rem;
  transition: transform 90ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-play { background: var(--land); color: #fff; }
.btn-play:hover { background: #28934f; }
.btn-buy { background: var(--cloud); color: var(--ink); }
.btn-pass { background: var(--sun); color: var(--sun-ink); }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.btn-ink { background: var(--sky-ink); color: var(--sky); }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.btn svg { width: 20px; height: 20px; }

/* ---------- Main (on the planet) ---------- */
main { flex: 1; }
.surface { background: var(--ocean); padding-top: clamp(28px, 5vw, 56px); padding-bottom: 72px; }
.section { margin-bottom: clamp(48px, 7vw, 80px); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 18px; }
.section h2 { font-family: var(--font-display); font-weight: 750; font-size: clamp(1.65rem, 3.2vw, 2.4rem); letter-spacing: -0.03em; line-height: 1.05; margin: 0; }
.section-head p { margin: 0; color: var(--mist); max-width: 52ch; }

/* ---------- Game "stickers" ---------- */
.row { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 26px 22px; }
@media (max-width: 640px) {
  .row.scroll { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); gap: 16px; margin-inline: calc(var(--gutter) * -1); padding: 4px var(--gutter) 10px; scrollbar-width: none; }
  .row.scroll::-webkit-scrollbar { display: none; }
  .row.scroll > * { flex: 0 0 78%; scroll-snap-align: start; }
}
.card { display: block; text-decoration: none; color: inherit; position: relative; }
.card-art {
  display: block; position: relative; aspect-ratio: 16 / 10; border-radius: var(--card-radius); overflow: hidden;
  border: 4px solid var(--cloud); background: var(--ocean-deep);
  transition: transform 140ms ease;
}
.card:hover .card-art, .card:focus-visible .card-art { transform: translateY(-3px) rotate(-0.8deg); }
.card-art img { width: 100%; height: 100%; object-fit: cover; }
.card-art .fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; line-height: 1; letter-spacing: -0.03em; }
.badge { position: absolute; top: 10px; left: 10px; font-size: 0.82rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--cloud); color: var(--ink); }
.badge.free, .badge.owned { background: var(--land); color: #fff; }
.badge.pass { background: var(--sun); color: var(--sun-ink); }
.badge.peek { background: var(--ink); color: var(--cloud); }
.card-title { display: block; font-family: var(--font-display); font-weight: 750; font-size: 1.22rem; letter-spacing: -0.02em; line-height: 1.15; margin: 12px 2px 2px; }
.card-line { display: block; color: var(--mist); font-size: 0.95rem; margin: 0 2px; }

/* Hero featured sticker: bigger, title on the art. */
.feature { display: block; text-decoration: none; color: #fff; }
.feature .card-art { border-width: 6px; border-radius: 24px; box-shadow: 0 0 0 2px var(--sky-ink); aspect-ratio: 16 / 10; }
.feature-cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 18px 14px; background: linear-gradient(to top, rgba(4, 16, 33, 0.82), transparent); }
.feature-cap strong { display: block; font-family: var(--font-display); font-size: clamp(1.4rem, 2.4vw, 2rem); letter-spacing: -0.03em; line-height: 1.05; }
.feature-cap span { font-size: 0.95rem; opacity: 0.9; }

/* ---------- Filter chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip { border: 2px solid var(--mist); background: transparent; color: var(--cloud); padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.95rem; }
.chip[aria-pressed='true'] { background: var(--cloud); border-color: var(--cloud); color: var(--ink); }

/* ---------- Pass band ---------- */
.passband { background: var(--sun); color: var(--sun-ink); border-radius: 28px; padding: clamp(24px, 4vw, 44px); display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center; }
.passband h2 { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.8rem, 3.6vw, 2.8rem); letter-spacing: -0.035em; line-height: 1; margin: 0 0 10px; }
.passband p { margin: 0; max-width: 44ch; }
.passband .btn-ink { background: var(--sun-ink); color: var(--sun); }

/* ---------- Game page ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: clamp(24px, 5vw, 56px); align-items: start; }
.game h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -0.04em; line-height: 0.98; margin: 0 0 10px; }
.game .tagline { font-size: 1.15rem; color: var(--mist); margin: 0 0 22px; }
.game .actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.game .note { color: var(--mist); font-size: 0.95rem; margin: 0 0 24px; }
.game .desc { max-width: 60ch; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 24px 0 0; font-size: 0.97rem; }
.facts dt { color: var(--mist); }
.facts dd { margin: 0; }
.peek-note { background: var(--ocean-deep); border-radius: 16px; padding: 14px 16px; margin: 0 0 22px; }
.back { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--mist); font-weight: 600; margin-bottom: 18px; }
.back:hover { color: var(--cloud); }

/* ---------- Plain pages (pass, account, owner, legal) ---------- */
.page h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: -0.04em; line-height: 1; margin: 0 0 14px; }
.page .lead { font-size: 1.15rem; color: var(--mist); max-width: 50ch; margin: 0 0 28px; }
.prose { max-width: 66ch; }
.prose h2 { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: -0.02em; margin: 32px 0 8px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; max-width: 760px; margin-bottom: 28px; }
.plan { background: var(--cloud); color: var(--ink); border-radius: 22px; padding: 24px; }
.plan h2 { font-family: var(--font-display); margin: 0; font-size: 1.3rem; }
.plan .price { font-family: var(--font-display); font-weight: 800; font-size: 2.4rem; letter-spacing: -0.04em; margin: 6px 0 2px; }
.plan .per { color: #4b6382; margin: 0 0 18px; }
.plan .btn { width: 100%; }
.ticks { list-style: none; padding: 0; margin: 0 0 28px; display: grid; gap: 8px; }
.ticks li { padding-left: 30px; position: relative; }
.ticks li::before { content: ''; position: absolute; left: 0; top: 0.35em; width: 18px; height: 10px; border-left: 3px solid var(--sun); border-bottom: 3px solid var(--sun); transform: rotate(-45deg); }
.panel { background: var(--ocean-deep); border-radius: 20px; padding: 20px 22px; margin-bottom: 20px; }
.panel h2 { font-family: var(--font-display); font-size: 1.3rem; margin: 0 0 8px; }
.msg { padding: 12px 16px; border-radius: 14px; background: var(--ocean-deep); margin: 0 0 18px; }
.msg.err { background: #5a1e1e; color: #ffe2dc; }

/* Owner table */
.table-wrap { overflow-x: auto; }
table.owner { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 0.95rem; }
table.owner th, table.owner td { text-align: left; padding: 10px 6px; border-bottom: 1px solid color-mix(in srgb, var(--mist) 35%, transparent); vertical-align: middle; }
table.owner th { color: var(--mist); font-weight: 600; }
table.owner select, table.owner input[type='number'], .field input { background: var(--ocean-deep); border: 2px solid color-mix(in srgb, var(--mist) 50%, transparent); border-radius: 10px; padding: 6px 8px; }
table.owner input[type='number'] { width: 76px; }
table.owner td:first-child { min-width: 130px; }
table.owner select[name='version'] { max-width: 170px; }
table.owner .row-actions { min-width: 150px; }
table.owner .row-actions .btn { margin: 2px 0; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 0.9rem; }
.field { display: grid; gap: 4px; margin-bottom: 12px; max-width: 260px; }
.field span { color: var(--mist); font-size: 0.92rem; }
.saved { color: #9ff0bf; font-size: 0.9rem; }

/* ---------- Player ---------- */
body.playing { background: var(--night); overflow: hidden; }
body.playing .topbar, body.playing footer { display: none; }
.player { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--night); }
.player-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top)); background: #0c1f38; color: #fff; min-height: 48px; }
.player-bar .title { flex: 1; min-width: 0; font-family: var(--font-display); font-weight: 750; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, 0.1); border: 0; color: #fff; border-radius: 999px; padding: 8px 12px; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.icon-btn svg { width: 18px; height: 18px; }
.player-stage { position: relative; flex: 1; min-height: 0; }
.player-stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player.immersive .player-bar { display: none; }
.exit-immersive { position: absolute; top: max(8px, env(safe-area-inset-top)); right: 8px; z-index: 3; display: none; }
.player.immersive .exit-immersive { display: inline-flex; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--night); color: #fff; z-index: 4; }
.overlay h2 { font-family: var(--font-display); font-size: 1.6rem; margin: 0 0 8px; }
.overlay p { color: var(--mist); margin: 0 0 18px; max-width: 34ch; }
.rotate-icon { width: 64px; height: 64px; margin: 0 auto 14px; }
@media (prefers-reduced-motion: no-preference) {
  .rotate-icon { animation: tilt 1.8s ease-in-out infinite; }
  @keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
}
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.2); border-top-color: var(--sun); margin: 0 auto 14px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Footer ---------- */
footer.foot { background: var(--ocean-deep); color: var(--mist); font-size: 0.93rem; }
footer.foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-block: 26px; }
footer.foot nav { display: flex; gap: 18px; }
footer.foot a { text-decoration: none; }
footer.foot a:hover { color: var(--cloud); }

/* ---------- Sign-in sheet (test mode) ---------- */
dialog.sheet { border: 0; border-radius: 22px; padding: 24px; max-width: 380px; width: calc(100% - 32px); background: var(--cloud); color: var(--ink); }
dialog.sheet::backdrop { background: rgba(4, 16, 33, 0.6); }
dialog.sheet h2 { font-family: var(--font-display); margin: 0 0 6px; }
dialog.sheet p { margin: 0 0 14px; color: #4b6382; }
dialog.sheet input { width: 100%; border: 2px solid #9fb6d3; border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; }
dialog.sheet .row-btns { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Small screens ---------- */
@media (max-width: 720px) {
  .doors { grid-template-columns: 1fr; }
  .door { min-height: 330px; }
}
@media (max-width: 820px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-feature { margin-top: 0; }
  .game { grid-template-columns: 1fr; }
  .passband { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .nav a, .nav button { padding: 8px 9px; font-size: 0.92rem; }
  .mark { font-size: 1.35rem; }
  .mark img { width: 28px; height: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
