/* Full-screen cards: title, planet info, pause, game over, Space Passport and certificate. */

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10; padding: 16px;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at center, rgba(14, 9, 40, .2), rgba(8, 6, 26, .62));
  transition: opacity .35s, visibility 0s;
}
/* Hidden screens stop drawing once they have faded out, so their blur and animations
   don't keep the browser busy while you play. */
.overlay.hidden { opacity: 0; pointer-events: none; visibility: hidden; transition: opacity .35s, visibility 0s .35s; }
.overlay.hidden * { animation-play-state: paused; }
.card {
  width: min(440px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
  padding: 32px 26px 26px; border-radius: 28px; text-align: center;
  background: linear-gradient(160deg, rgba(62, 42, 138, .58), rgba(24, 18, 64, .74));
  border: 1px solid rgba(255, 255, 255, .15);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .12);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: transform .4s cubic-bezier(.2, 1.3, .4, 1);
}
.overlay.hidden .card { transform: translateY(16px) scale(.97); }

/* ---------- Shared card pieces ---------- */
/* Green "Montessori" over orange "Galaxy", like the Montessori Garden school logo */
.logo { font-weight: 800; line-height: .95; letter-spacing: -.01em; filter: drop-shadow(0 4px 18px rgba(0, 0, 0, .35)); }
.logo-top { display: block; font-size: clamp(26px, 5.5vw, 40px); letter-spacing: .01em; color: #86e05e; }
.logo-main {
  display: block; font-size: clamp(52px, 12vw, 84px);
  padding-bottom: .14em; margin-bottom: -.1em;  /* room for the "y" tail: gradient text is clipped to the box */
  background: linear-gradient(90deg, #ffd35a, #ffa53d); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tag { margin-top: 8px; color: var(--ink-dim); font-size: 16px; }
.mission {
  display: inline-block; margin-top: 12px; padding: 6px 14px; border-radius: 99px; font-size: 14px; font-weight: 700;
  color: #2a1446; background: linear-gradient(90deg, var(--gold), #ffb3d1);
}
.mission:empty { display: none; }
h2 { font-size: clamp(30px, 7vw, 40px); font-weight: 800; color: #fff; }
.small { margin-top: 14px; font-size: 13px; color: var(--ink-dim); letter-spacing: .04em; }
.actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.big-btn {
  font: 800 20px/1 var(--font); letter-spacing: .02em; color: #2a1446;
  padding: 16px 44px; border: 0; border-radius: 999px; cursor: pointer;
  background: linear-gradient(135deg, #ffe07a, #ff9ac4);
  box-shadow: 0 8px 26px rgba(255, 154, 196, .45), inset 0 -3px 0 rgba(0, 0, 0, .12);
  transition: transform .15s;
  animation: breathe 2.4s ease-in-out infinite;
}
.big-btn:hover { transform: translateY(-2px) scale(1.04); }
.big-btn:active { transform: scale(.97); }
@keyframes breathe { 50% { box-shadow: 0 8px 34px rgba(255, 154, 196, .7), inset 0 -3px 0 rgba(0, 0, 0, .12); } }
.big-btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.ghost-btn {
  font: 700 15px/1 var(--font); color: var(--ink); cursor: pointer;
  padding: 14px 18px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08);
  transition: background .2s, transform .15s;
}
.ghost-btn:hover { background: rgba(255, 255, 255, .15); transform: translateY(-1px); }
.ghost-btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.facts { list-style: none; margin: 16px 0 20px; display: grid; gap: 8px; text-align: left; }
.facts li { position: relative; padding: 9px 12px 9px 34px; border-radius: 12px; background: rgba(255, 255, 255, .06); font-size: 15px; line-height: 1.4; }
.facts li::before { content: '★'; position: absolute; left: 12px; top: 9px; color: var(--gold); }
.kicker { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--mint); line-height: 1.5; }

/* ---------- Title screen ---------- */
.title-card { width: min(880px, calc(100vw - 32px)); position: relative; }
/* The space picture behind the title card (drawn by js/ui/homescene.js). */
.home-scene { background: #09091a; }
#homeSky { position: absolute; left: 0; top: 0; }
.title-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px 28px; align-items: start;
  grid-template-areas: "head setup" "howto setup";
}
.howto { list-style: none; margin: 22px 0 24px; display: grid; gap: 9px; text-align: left; }
.howto li {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 14px; border-radius: 14px; background: rgba(255, 255, 255, .06);
  font-size: 15px; line-height: 1.35;
}
.t-head { grid-area: head; }
.t-howto { grid-area: howto; margin: 0; }
.howto .ico { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; font-weight: 800; }
.ico.steer { background: rgba(143, 247, 207, .16); color: var(--mint); }
.ico.star { background: rgba(255, 211, 90, .16); color: var(--gold); }
.ico.love { background: rgba(255, 122, 168, .16); color: var(--pink); }
.ico.lvl { background: rgba(199, 168, 255, .16); color: var(--lilac); }
#loadError { margin: 18px 0 0; color: #ffb3c8; line-height: 1.45; }
.thanks {
  margin-top: 18px; padding: 12px 14px; border-radius: 14px;
  font-size: 14px; line-height: 1.45; color: #fff;
  background: linear-gradient(135deg, rgba(255, 154, 196, .18), rgba(143, 247, 207, .14));
  border: 1px solid rgba(255, 255, 255, .18);
}
.thanks::before { content: '✦ '; color: var(--gold); }
.thanks::after { content: ' ✦'; color: var(--gold); }
.thanks b { color: var(--gold); }

/* Pilot name, rocket colors and difficulty */
.t-setup {
  grid-area: setup; display: grid; gap: 12px; text-align: left;
  padding: 16px; border-radius: 20px; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .1);
}
.pilot { display: flex; gap: 14px; align-items: center; }
.rocket-preview { flex: none; width: 60px; height: 90px; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, .35)); }
.rp-body { fill: var(--rb); }
.rp-accent { fill: var(--ra); }
.rp-glass { fill: #9ae6ff; }
.rp-flame { fill: #ffc94d; transform-origin: 40px 94px; animation: flicker .18s ease-in-out infinite alternate; }
@keyframes flicker { to { transform: scaleY(.72); } }
.field { display: grid; gap: 6px; flex: 1; }
.field-label { font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-dim); }
#pilotName {
  width: 100%; font: 700 17px var(--font); color: #fff; padding: 11px 14px; border-radius: 12px; outline: none;
  border: 1px solid rgba(255, 255, 255, .2); background: rgba(10, 6, 30, .45);
  user-select: text; -webkit-user-select: text;
}
#pilotName:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(143, 247, 207, .25); }
.swatches { display: grid; grid-template-columns: repeat(6, auto); justify-content: space-between; gap: 8px 6px; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  border: 4px solid var(--rb); background: var(--ra); transition: transform .15s, box-shadow .15s;
}
.swatch[aria-checked="true"] { box-shadow: 0 0 0 3px #fff; transform: scale(1.1); }
.ages { display: flex; gap: 8px; flex-wrap: wrap; }
.age-btn {
  font: 800 15px var(--font); color: var(--ink); cursor: pointer; min-width: 58px; padding: 9px 12px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06); transition: background .15s, border-color .15s;
}
.age-btn[aria-checked="true"] { background: rgba(143, 247, 207, .16); border-color: var(--mint); }
.age-btn:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.diffs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.diff-btn {
  font: inherit; color: var(--ink); cursor: pointer; padding: 10px 6px; border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .06);
  display: grid; gap: 3px; justify-items: center; text-align: center; transition: background .15s, border-color .15s, transform .15s;
}
.diff-btn .d-icon { font-size: 22px; line-height: 1; }
.diff-btn .d-name { font-size: 13px; font-weight: 800; }
.diff-btn .d-desc { font-size: 11px; color: var(--ink-dim); line-height: 1.3; }
.diff-btn[aria-checked="true"] { background: rgba(143, 247, 207, .16); border-color: var(--mint); transform: translateY(-1px); }
.test-level { display: block; text-align: center; font-size: 12px; color: var(--gold); }
.test-level select { font: 700 12px var(--font); color: #fff; background: rgba(10, 6, 30, .6); border: 1px dashed var(--gold); border-radius: 8px; padding: 4px 6px; }
.launch-row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.swatch:focus-visible, .diff-btn:focus-visible, .sticker:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }

/* ---------- Planet info (shown before each level) ---------- */
.info-card { width: min(460px, calc(100vw - 32px)); padding-top: 24px; }
#infoArt { display: block; width: 150px; height: 150px; margin: 8px auto 2px; }

/* ---------- Game over ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 22px; }
.stat { padding: 12px 4px; border-radius: 16px; background: rgba(255, 255, 255, .07); }
.stat b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
.stat.gold b { color: var(--gold); }
#newBest {
  display: inline-block; margin-top: 10px; padding: 5px 12px; border-radius: 99px;
  font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: #2a1446; background: linear-gradient(90deg, var(--mint), var(--gold));
}

/* ---------- Space Passport & certificate ---------- */
#passportScreen, #certScreen { z-index: 12; }
.passport-card { width: min(640px, calc(100vw - 32px)); }
.stickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; margin: 18px 0; }
.sticker {
  font: 700 12px var(--font); color: var(--ink); cursor: pointer;
  display: grid; justify-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .06);
}
.sticker canvas { width: 64px; height: 64px; }
.sticker.locked { cursor: default; color: var(--ink-dim); }
.sticker.locked canvas { filter: brightness(0) opacity(.35); }
.sticker.selected { border-color: var(--gold); background: rgba(255, 211, 90, .12); }
.sticker-detail { text-align: left; padding: 14px 16px; border-radius: 16px; background: rgba(255, 255, 255, .06); margin-bottom: 16px; }
.sticker-detail h3 { font-size: 20px; }
.sticker-detail .facts { margin: 10px 0 12px; }
/* Passport tabs: Stickers | Did you know? (the Space Book) */
.tabs { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.tab {
  font: 700 14px var(--font); color: var(--ink-dim); cursor: pointer; padding: 9px 14px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .04);
}
.tab[aria-selected="true"] { color: #2a1446; background: linear-gradient(90deg, var(--gold), #ffb3d1); border-color: transparent; }
.tab:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
.book { display: grid; gap: 12px; margin: 16px 0; text-align: left; max-height: 52vh; overflow: auto; }
.book-topic { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .05); }
.book-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.book-head h3 { font-size: 18px; }
.book-read { padding: 8px 12px; font-size: 14px; }
.book .facts { margin: 8px 0 0; }
.cert-card { width: min(780px, calc(100vw - 32px)); padding: 18px; }
#certCanvas { display: block; width: 100%; height: auto; border-radius: 14px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); }
#printCert { display: none; }
@media print {
  html, body { height: auto; overflow: visible; background: #fff !important; }
  body > *:not(#printCert) { display: none !important; }
  #printCert { display: block !important; width: 100%; height: auto; }
  @page { size: landscape; margin: 10mm; }
}

@media (max-width: 760px) {
  .title-grid { grid-template-columns: 1fr; grid-template-areas: "head" "setup" "howto"; }
}
@media (max-width: 520px) {
  .howto li { font-size: 14px; }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .diff-btn .d-desc { display: none; }
}

/* Phones (narrow, or short in landscape): a simpler, compact title screen that fits without scrolling.
   Only the name, age, rocket color, difficulty and one big Launch button. The tips are hidden,
   because touch players get a short "drag to fly" line instead and Bani explains the rest. */
@media (max-width: 600px), (max-height: 500px) {
  .title-card { padding: 14px 14px 12px; }
  .title-card .tag, .t-howto { display: none; }
  .title-grid { gap: 8px; }
  /* "Montessori Galaxy" on one line */
  .title-card .logo { white-space: nowrap; }
  .logo-top, .logo-main { display: inline; }
  .logo-top { font-size: 24px; margin-right: .25em; }
  .logo-main { font-size: 34px; padding-bottom: 0; margin-bottom: 0; }
  .title-card .mission { margin-top: 6px; padding: 4px 10px; font-size: 12px; }
  /* Name and age share one row; the rocket preview sits beside the color dots;
     everything else spans the full width. */
  .t-setup {
    padding: 0; gap: 9px 10px; background: none; border: 0;
    grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "name name age" "rocket paint paint";
  }
  .t-setup > * { grid-column: 1 / -1; }
  .t-setup > .pilot { display: contents; }
  .t-setup .pilot .field { grid-area: name; }
  .t-setup > .age-field { grid-area: age; }
  .t-setup > .paint-field { grid-area: paint; }
  .rocket-preview { grid-area: rocket; align-self: end; width: 42px; height: 63px; margin-bottom: 2px; }
  .ages { gap: 4px; flex-wrap: nowrap; }
  .field { gap: 4px; }
  .field-label { font-size: 11px; }
  .pilot { gap: 10px; }
  #pilotName { padding: 8px 12px; font-size: 16px; }
  .age-btn { min-width: 0; padding: 8px 7px; font-size: 13px; }
  .swatches { gap: 7px; }
  .swatch { width: 30px; height: 30px; border-width: 3px; }
  .diff-btn { padding: 6px 4px; gap: 1px; border-radius: 12px; }
  .diff-btn .d-icon { font-size: 18px; }
  .diff-btn .d-name { font-size: 12px; }
  .diff-btn .d-desc { display: none; }
  .launch-row { gap: 6px; margin-top: 2px; }
  .launch-row #btnStart { order: -1; flex-basis: 100%; padding: 12px 20px; font-size: 19px; }
  .launch-row .ghost-btn { flex: 1; padding: 9px 8px; font-size: 14px; }
  #titleSmall { margin-top: 0; font-size: 12px; }
  .title-card .thanks { margin-top: 8px; padding: 0; font-size: 11px; background: none; border: 0; color: var(--ink-dim); }
}
}

/* Countdown: giant numbers that pop in, then "Blast off!" */
#countdownScreen { z-index: 11; background: radial-gradient(ellipse at center, rgba(14, 9, 40, .1), rgba(8, 6, 26, .5)); cursor: pointer; align-content: center; }
.cd-num {
  font-weight: 800; line-height: 1; font-size: clamp(140px, 30vw, 280px); font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #fff3b0, var(--gold) 45%, #ff9ac4); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 8px 30px rgba(255, 180, 90, .5));
}
.cd-num.go { font-size: clamp(56px, 12vw, 130px); }
.cd-num.pop { animation: cdPop .6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes cdPop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.cd-tip { margin-top: 18px; color: var(--ink-dim); font-weight: 700; text-align: center; }
