/* =========================================================================
   Reroll · A Life Simulator — styles
   Mobile-first. Single centered column that behaves like a native app.
   ========================================================================= */

:root {
  --bg-0: #0a0e24;
  --bg-1: #121838;
  --bg-2: #1b2350;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-solid: #161d40;
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-strong: rgba(255, 255, 255, 0.18);
  --ink: #f4f6ff;
  --ink-dim: #aab3d6;
  --ink-faint: #6f78a0;
  --accent: #7c8cff;
  --accent-2: #ff8fb1;
  --gold: #ffce5c;
  --good: #58e0a6;
  --bad: #ff7a8a;

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --maxw: 460px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

body { overflow: hidden; }

h1, h2, h3, .serif { font-family: "Fraunces", Georgia, serif; }

.app {
  position: relative;
  width: 100%;
  max-width: var(--maxw);
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow: hidden;
}

#share-canvas { position: fixed; left: -9999px; top: -9999px; }

/* ---- Generic screen wrapper -------------------------------------------- */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: rise 0.45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop  { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  appearance: none;
  border: 1px solid var(--stroke-strong);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  border-radius: var(--r-md);
  padding: 16px 18px;
  width: 100%;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
  text-align: left;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  text-align: center;
  border: none;
  color: #1a1030;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), #ffb14e);
  box-shadow: 0 10px 30px rgba(255, 180, 78, 0.35);
}
.btn-ghost {
  text-align: center;
  background: transparent;
  border-color: var(--stroke);
  color: var(--ink-dim);
}

/* ===== TITLE SCREEN ===================================================== */
.title {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.title .logo {
  font-size: clamp(42px, 13vw, 62px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}
.title .logo span { font-size: 0.42em; display: block; letter-spacing: .35em; color: var(--ink-faint); -webkit-text-fill-color: var(--ink-faint); margin-top: 10px; }
.title .tagline { color: var(--ink-dim); max-width: 330px; margin: 6px auto 22px; line-height: 1.55; font-size: 16px; }
.title .tagline b { display: block; color: var(--ink); font-size: 20px; font-family: "Fraunces"; margin-bottom: 4px; }
.title .tagline .tag-cta { display: inline-block; margin-top: 8px; color: var(--gold); font-weight: 700; }
.title .actions { width: 100%; max-width: 320px; display: grid; gap: 12px; }
.title .planet { font-size: 88px; filter: drop-shadow(0 14px 30px rgba(124,140,255,.5)); animation: float 5s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.title .meta { color: var(--ink-faint); font-size: 13px; margin-top: 18px; }

/* ===== CARD (birth / event / result share within flow) ================= */
.flow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 10px;
}
.age-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: var(--panel);
  border: 1px solid var(--stroke-strong);
  padding: 8px 18px 9px;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.age-pill b {
  color: var(--gold);
  font-family: "Fraunces", Georgia, serif;
  font-weight: 900;
  font-size: 34px;
  line-height: .9;
  letter-spacing: -0.01em;
}
.progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  overflow: hidden;
}
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }

.card {
  background: var(--panel-solid);
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  animation: pop .4s cubic-bezier(.2,.8,.2,1) both;
}
.card .scene { width: 100%; height: 38vh; max-height: 280px; min-height: 170px; display: block; }
.card .scene-wrap { position: relative; }
.card .stage-tag {
  position: absolute; left: 14px; bottom: 12px;
  background: rgba(0,0,0,.4); backdrop-filter: blur(6px);
  border: 1px solid var(--stroke);
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #fff;
}
.card .body {
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.card h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.card .text { color: var(--ink-dim); line-height: 1.55; font-size: 16px; margin: 0; }

.choices { display: grid; gap: 10px; margin-top: auto; padding-top: 4px; }
.choice { display: flex; align-items: center; gap: 12px; }
.choice .ico { font-size: 22px; flex: none; width: 26px; text-align: center; }
.choice .lbl { line-height: 1.3; }

/* Outcome flash after a choice */
.outcome { animation: rise .35s both; }
.outcome .result-text { color: var(--ink); line-height: 1.55; font-size: 16px; }
.deltas { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.delta { font-weight: 700; font-size: 13px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--stroke); }
.delta.up { color: var(--good); background: rgba(88,224,166,.10); }
.delta.down { color: var(--bad); background: rgba(255,122,138,.10); }

/* ===== STAT BARS (birth + HUD) ========================================= */
.stats { display: grid; gap: 9px; }
.stat { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; }
.stat .s-ico { font-size: 18px; text-align: center; }
.stat .s-bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.stat .s-bar > i { display: block; height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.2,.8,.2,1); }
.stat .s-val { font-weight: 700; font-size: 13px; color: var(--ink-dim); min-width: 26px; text-align: right; font-variant-numeric: tabular-nums; }
.s-looks  > i { background: linear-gradient(90deg,#ff9ad1,#ff6fae); }
.s-smarts > i { background: linear-gradient(90deg,#8ab4ff,#5d7cff); }
.s-health > i { background: linear-gradient(90deg,#6fe6c2,#36c98f); }
.s-wealth > i { background: linear-gradient(90deg,#ffe07a,#ffb347); }
.s-happy  > i { background: linear-gradient(90deg,#ffd36e,#ff9f5b); }
.s-social > i { background: linear-gradient(90deg,#c79bff,#9a6bff); }

/* ===== BIRTH SCREEN extras ============================================= */
.origin-lines { display: grid; gap: 10px; }
.origin-line { display: flex; gap: 12px; align-items: flex-start; background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--r-sm); padding: 12px 14px; }
.origin-line .o-ico { font-size: 22px; }
.origin-line .o-k { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }
.origin-line .o-v { font-weight: 700; font-size: 15px; }

/* ===== RESULT SCREEN =================================================== */
/* Compact by design so the whole payoff fits one screen (overflow-y stays as a
   safety valve for very short viewports / tall ad units). */
.result { gap: 9px; overflow-y: auto; }
.grade-badge {
  align-self: center; position: relative;
  width: 104px; height: 104px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(from 210deg, var(--gold), var(--accent-2), var(--accent), var(--gold));
  box-shadow: 0 14px 40px rgba(255,206,92,.35);
  animation: pop .6s both;
}
.grade-badge::after { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--panel-solid); z-index: 1; }
.grade-badge .g { position: relative; z-index: 2; font-family: "Fraunces"; font-weight: 900; font-size: 48px; line-height: 1;
  background: linear-gradient(120deg, var(--gold), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result .title-line { text-align: center; }
.result .title-line h2 { margin: 0; font-size: 24px; font-family: "Fraunces"; letter-spacing: -0.5px; line-height: 1.1; }
.result .title-line .sub { color: var(--ink-dim); margin-top: 2px; font-size: 13.5px; }
.title-rarity {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .14em;
  padding: 3px 11px; border-radius: 999px; margin-bottom: 6px;
  color: var(--rc, #aab3d6); border: 1px solid currentColor; background: color-mix(in srgb, currentColor 14%, transparent);
}
.title-rarity.rt-legendary { --rc: #ffce5c; animation: rarePulse 2s ease-in-out infinite; }
.title-rarity.rt-epic { --rc: #c98bff; }
.title-rarity.rt-rare { --rc: #7c8cff; }
@keyframes rarePulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.4); } }
.score-big { text-align: center; font-variant-numeric: tabular-nums; margin-top: 2px; }
.score-big .lbl { color: var(--ink-dim); font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; }
.score-big b { font-size: 42px; font-family: "Fraunces"; color: var(--gold); }
.score-big .of { color: var(--ink-faint); font-size: 17px; }
.verdict { display: flex; gap: 8px; margin: 4px 0 2px; }
.verdict .vstat {
  flex: 1; text-align: center; background: var(--panel); border: 1px solid var(--stroke);
  border-radius: var(--r-md); padding: 9px 5px;
}
.verdict .vstat b { display: block; font-size: 17px; color: var(--gold); font-family: "Fraunces"; line-height: 1.1; }
.verdict .vstat span { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.epitaph {
  font-family: "Fraunces"; font-style: italic; font-size: 15.5px; line-height: 1.4;
  text-align: center; color: var(--ink); padding: 2px 6px; margin: 0;
}
/* Two-column stat bars on the result so all six fit in three rows. */
.result .stats { grid-template-columns: 1fr 1fr; column-gap: 16px; row-gap: 7px; }
.recap { background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: 8px 11px; }
.recap h3 { margin: 0 0 5px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }
.recap .moment { display: flex; gap: 9px; padding: 3px 0; border-top: 1px solid var(--stroke); font-size: 13px; line-height: 1.3; color: var(--ink-dim); }
.recap .moment:first-of-type { border-top: none; }
.recap .moment .m-age { color: var(--gold); font-weight: 700; flex: none; width: 48px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(255,206,92,.12); border: 1px solid rgba(255,206,92,.3); color: var(--gold); }
.badge-more { cursor: pointer; background: var(--panel); border-color: var(--stroke-strong); color: var(--ink-dim); font: inherit; font-size: 12px; font-weight: 700; width: auto; }
/* Action buttons in a 2×2 grid to halve their footprint. */
.result .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 2px; }
.result .actions .btn { padding: 11px 12px; font-size: 15px; }

/* ===== Misc ============================================================ */
.center-note { color: var(--ink-faint); text-align: center; font-size: 13px; }
.kbd-hint { color: var(--ink-faint); font-size: 12px; text-align: center; margin-top: 6px; }

@media (min-height: 760px) {
  .card .scene { height: 30vh; }
}

/* =========================================================================
   v2 — creation flow, daily, leaderboard, talents + motion
   ========================================================================= */

/* ---- buttons added ---- */
.btn-accent {
  text-align: center; border: none; color: #fff; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 30px rgba(124,140,255,.32);
}
.btn.sm { padding: 11px 14px; font-size: 14px; width: auto; }
.title .actions .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---- animated aurora backdrop ---- */
.app::before {
  content: ""; position: fixed; inset: -20% -20% auto -20%; height: 70%;
  background:
    radial-gradient(40% 50% at 25% 30%, rgba(124,140,255,.22), transparent 70%),
    radial-gradient(38% 45% at 78% 20%, rgba(255,143,177,.18), transparent 70%),
    radial-gradient(35% 40% at 55% 60%, rgba(88,224,166,.12), transparent 70%);
  filter: blur(20px); z-index: -1; pointer-events: none;
  animation: aurora 22s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate3d(-4%, -2%, 0) scale(1.05); }
  100% { transform: translate3d(5%, 4%, 0) scale(1.18); }
}

/* ---- living scenes ---- */
.scene .tw   { animation: tw 3s ease-in-out infinite; }
.scene .halo { animation: halo 4s ease-in-out infinite; }
.scene .halo2{ animation-duration: 5.2s; }
@keyframes tw   { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes halo { 0%,100% { opacity: .12; } 50% { opacity: .30; } }
.card .scene { animation: kenburns 20s ease-in-out infinite alternate; transform-origin: center; }
@keyframes kenburns { from { transform: scale(1.03); } to { transform: scale(1.12) translate(-2%, -2%); } }

/* ---- card + choice entrances ---- */
.card.deal { animation: deal .5s cubic-bezier(.2,.85,.2,1) both; }
@keyframes deal { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
.choice { animation: rise .42s both; }
.delta  { animation: pop .4s both; }

/* ---- CREATION FLOW ---- */
.screen.create { gap: 14px; }
.create-head { text-align: center; padding-top: 6px; }
.create-head .steps { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.create-head .steps i { width: 30px; height: 5px; border-radius: 999px; background: rgba(255,255,255,.12); transition: background .3s; }
.create-head .steps i.on { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.create-head .ask { font-size: 24px; margin: 0; line-height: 1.2; }
.daily-tag { font-size: 13px; vertical-align: middle; color: var(--gold); -webkit-text-fill-color: var(--gold); }

.pick-grid { display: grid; gap: 12px; flex: 1; align-content: center; min-height: 0; overflow-y: auto; padding: 4px 0; }
.pickcard {
  appearance: none; cursor: pointer; text-align: center; color: var(--ink);
  background: var(--panel-solid); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-md); padding: 16px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  box-shadow: var(--shadow); transition: transform .12s, border-color .2s, background .2s;
  animation: deal .5s cubic-bezier(.2,.85,.2,1) both;
}
.pick-grid .pickcard:nth-child(1) { animation-delay: .04s; }
.pick-grid .pickcard:nth-child(2) { animation-delay: .12s; }
.pick-grid .pickcard:nth-child(3) { animation-delay: .20s; }
.pickcard:active { transform: scale(.97); }
.pickcard:hover { border-color: var(--accent); }
.pickcard .pc-emoji { font-size: 40px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0,0,0,.4)); }
.pickcard .pc-hint { font-family: "Fraunces", serif; font-style: italic; color: var(--ink-dim); font-size: 15px; }
.pickcard .pc-name { font-weight: 800; font-size: 18px; }
.pickcard .pc-sub  { color: var(--ink-faint); font-size: 13px; line-height: 1.4; }
.pickcard.talent { border-color: rgba(255,206,92,.3); }
.create-foot { display: flex; gap: 10px; justify-content: center; }

/* ---- origin sublines + talent/fate chips ---- */
.o-sub { color: var(--ink-faint); font-size: 13px; margin-top: 2px; }
.fate-chip { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-2);
  background: rgba(255,143,177,.12); border: 1px solid rgba(255,143,177,.3); padding: 2px 7px; border-radius: 999px; margin-left: 6px; }
.origin-line.gift { border-color: rgba(255,206,92,.3); background: rgba(255,206,92,.06); }
.born-with { margin-top: 3px; font-weight: 700; color: var(--gold); font-size: 13.5px; }

/* Extra squeeze for short viewports so the result still fits without scrolling. */
@media (max-height: 780px) {
  .result { gap: 7px; }
  .grade-badge { width: 88px; height: 88px; }
  .grade-badge .g { font-size: 40px; }
  .score-big b { font-size: 36px; }
  .result .title-line h2 { font-size: 23px; }
  .epitaph { font-size: 14.5px; }
  .recap .moment { padding: 4px 0; font-size: 13px; }
  .legal-row { margin-top: 6px; }
}
@media (max-height: 750px) {
  .card .scene { height: 26vh; min-height: 140px; }
}

/* ---- daily banner ---- */
.daily-banner { text-align: center; font-size: 14px; color: var(--ink); background: rgba(124,140,255,.12);
  border: 1px solid rgba(124,140,255,.3); border-radius: 999px; padding: 9px 14px; }
.daily-banner b { color: var(--accent); }

/* ---- grade reveal shine + confetti ---- */
.grade-badge.shine { overflow: hidden; }
.grade-badge.shine::before {
  content: ""; position: absolute; inset: -40%; z-index: 3;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.55) 50%, transparent 60%);
  animation: sweep 1.6s ease-in-out .4s 2;
}
@keyframes sweep { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
.badge.new { box-shadow: 0 0 0 1px rgba(255,206,92,.5), 0 0 18px rgba(255,206,92,.35); }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 60; }
.confetti i { position: absolute; top: -12%; width: 9px; height: 14px; border-radius: 2px; opacity: .95;
  animation-name: fall; animation-timing-function: cubic-bezier(.3,.6,.5,1); animation-fill-mode: forwards; }
@keyframes fall { to { transform: translateY(118vh) rotate(680deg); opacity: .85; } }

/* ---- leaderboard ---- */
.lb { display: grid; gap: 8px; }
.lb-row { display: grid; grid-template-columns: 26px 30px 1fr auto; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--stroke); border-radius: var(--r-sm); padding: 10px 12px; }
.lb-rank { color: var(--ink-faint); font-weight: 800; text-align: center; }
.lb-grade { font-family: "Fraunces", serif; font-weight: 900; font-size: 22px; color: var(--gold); text-align: center; }
.lb-main { min-width: 0; }
.lb-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { color: var(--ink-faint); font-size: 12px; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--ink); }

/* ---- legal / support / ads ---- */
.legal-row { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 12px; }
.legal, .support { font-size: 13px; text-decoration: none; color: var(--ink-faint); }
.legal:hover { color: var(--ink-dim); }
.support { color: var(--gold); font-weight: 600; }
.ad-slot { margin: 6px 0; }
.ad-slot:empty { display: none; margin: 0; }

.consent {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between;
  background: var(--panel-solid); border-top: 1px solid var(--stroke-strong);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  font-size: 13px; color: var(--ink-dim); box-shadow: 0 -12px 30px rgba(0,0,0,.45);
  animation: rise .35s both;
}
.consent a { color: var(--accent); }
.consent-btns { display: flex; gap: 8px; margin-left: auto; }
.consent .btn.sm { width: auto; padding: 9px 16px; }

/* ---- slot machine birth ---- */
.create-head .ask-sub { color: var(--ink-dim); margin-top: 4px; font-size: 14px; }
.slots { display: grid; gap: 12px; margin: 14px 0; }
.slot {
  display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 12px;
  background: var(--panel-solid); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-md); padding: 14px 16px; box-shadow: var(--shadow);
}
.slot-label { color: var(--ink-faint); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.reel { display: flex; align-items: center; gap: 12px; min-height: 44px; overflow: hidden; }
.reel-emoji { font-size: 30px; line-height: 1; }
.reel-name { font-weight: 800; font-size: 18px; line-height: 1.15; }
.reel.blur { filter: blur(1.5px); opacity: .8; }
.reel.locked { animation: lockpop .3s cubic-bezier(.2,.8,.2,1); }
@keyframes lockpop { from { transform: scale(1.14); } to { transform: scale(1); } }
.slot.idle .reel { opacity: .35; }
.create-foot.col { flex-direction: column; gap: 10px; }
.btn.big { font-size: 18px; padding: 18px; }

/* ---- born page (compact, CTA above the fold) ---- */
.screen.born { justify-content: flex-start; gap: 10px; }
.born-scene { border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); position: relative; flex: none; }
.born-scene .scene { width: 100%; height: 26vh; max-height: 210px; min-height: 150px; display: block; }
.born-scene .stage-tag {
  position: absolute; left: 14px; bottom: 12px;
  background: rgba(0,0,0,.42); backdrop-filter: blur(6px);
  border: 1px solid var(--stroke);
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #fff;
}
.born-title { font-family: "Fraunces", serif; font-size: 23px; line-height: 1.15; text-align: center; margin: 2px 0 0; }
.born-sum { text-align: center; color: var(--ink-dim); font-size: 15px; }
.born-sum b { color: var(--gold); }
.screen.born .btn-primary { margin: 2px 0; }
.screen.born .stats { margin-top: 2px; }

/* ---- leaderboard name entry ---- */
.lb-entry { background: var(--panel); border: 1px solid var(--stroke-strong); border-radius: var(--r-md); padding: 10px 12px; text-align: center; }
.lb-entry h3 { margin: 0 0 7px; font-size: 14px; }
.lb-entry-row { display: flex; gap: 8px; }
.lb-entry-row input {
  flex: 1; min-width: 0; background: rgba(0,0,0,.28); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm); color: var(--ink); padding: 12px 14px; font: inherit;
}
.lb-entry-row input::placeholder { color: var(--ink-faint); }
.lb-entry-row .btn.sm { width: auto; white-space: nowrap; }
.lb-entry .center-note { margin-top: 8px; }
input.shake { animation: shake .4s; border-color: var(--bad) !important; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.lb-row.top .lb-grade { text-shadow: 0 0 12px rgba(255,206,92,.5); }
.lb-dim { color: var(--ink-faint); font-weight: 400; }
.lb-row.mine {
  background: linear-gradient(90deg, rgba(124,140,255,.22), rgba(124,140,255,.08));
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(124,140,255,.25), 0 6px 18px rgba(124,140,255,.18);
  animation: minepulse 1.4s ease-in-out 2;
}
@keyframes minepulse { 0%,100% { box-shadow: 0 0 0 1px rgba(124,140,255,.25), 0 6px 18px rgba(124,140,255,.18); } 50% { box-shadow: 0 0 0 2px rgba(124,140,255,.6), 0 8px 26px rgba(124,140,255,.4); } }
.you-tag {
  display: inline-block; background: var(--accent); color: #0a0e24;
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  padding: 1px 6px; border-radius: 999px; vertical-align: middle; margin-left: 2px;
}

/* ---- how to play ---- */
.screen.how { overflow-y: auto; gap: 8px; -webkit-overflow-scrolling: touch; }
.how-top {
  position: sticky; top: 0; z-index: 5; margin: -4px 0 2px;
  padding: 6px 0; background: linear-gradient(var(--bg-0) 70%, rgba(10,14,36,0));
}
.how-top .btn { width: auto; padding: 8px 16px; }
.how-body { display: flex; flex-direction: column; gap: 9px; text-align: left; margin: 4px 0 2px; }
.how-step { display: grid; grid-template-columns: 26px 1fr; gap: 11px; align-items: start; line-height: 1.35; color: var(--ink-dim); font-size: 14px; }
.how-step b { color: var(--ink); }
.how-step i { color: var(--gold); font-style: normal; }
.how-n { width: 26px; height: 26px; border-radius: 50%; background: var(--gold); color: #141a3c; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.how-stats { display: flex; flex-wrap: wrap; gap: 7px; margin-left: 37px; }
.how-stat { background: var(--panel); border: 1px solid var(--stroke); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; }
.how-tip { background: rgba(124,140,255,.12); border: 1px solid var(--stroke); border-radius: var(--r-md); padding: 10px 13px; font-size: 13.5px; color: var(--ink-dim); line-height: 1.4; }
.how-tip b { color: var(--ink); }

/* ---- game modes ---- */
.mode-btn { display: flex; align-items: center; gap: 14px; text-align: left; padding: 14px 18px; }
.mode-btn .mode-ico { font-size: 30px; line-height: 1; flex: none; }
.mode-btn .mode-txt { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.mode-btn .mode-txt b { font-size: 17px; }
.mode-btn .mode-txt small { font-weight: 600; opacity: .82; font-size: 12.5px; }
.mode-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; vertical-align: middle; white-space: nowrap; }
.mode-tag.choc { background: rgba(255,143,177,.18); color: #ffb3c8; }
.mode-tag.classic { background: rgba(124,140,255,.20); color: #aab8ff; }

/* ---- leaderboard mode tabs ---- */
.lb-tabs { display: flex; gap: 8px; margin: 2px 0 12px; }
.lb-tab { flex: 1; appearance: none; background: var(--panel); border: 1px solid var(--stroke); color: var(--ink-dim); border-radius: 999px; padding: 9px 10px; font: inherit; font-weight: 700; font-size: 13px; cursor: pointer; transition: background .15s, color .15s; }
.lb-tab.on { background: var(--accent); color: #0a0e24; border-color: var(--accent); }

/* ---- contact form ---- */
.linkbtn { background: none; border: none; padding: 0; font: inherit; cursor: pointer; }
.contact-form { display: flex; flex-direction: column; gap: 10px; text-align: left; margin: 4px 0 2px; }
.contact-form input, .contact-form textarea {
  width: 100%; background: rgba(0,0,0,.28); border: 1px solid var(--stroke-strong);
  border-radius: var(--r-sm); color: var(--ink); padding: 12px 14px; font: inherit; resize: vertical;
}
.contact-form input::placeholder, .contact-form textarea::placeholder { color: var(--ink-faint); }
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent); }
.contact-form .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.contact-status { font-size: 14px; min-height: 0; color: var(--ink-dim); }
.contact-status.err { color: #ff9aa8; }
.contact-done { text-align: center; display: flex; flex-direction: column; gap: 12px; padding: 12px 0; }
.contact-done b { font-size: 18px; }

/* ===== LANDING SKY — drifting clouds, themed by local day/night ==========
   A fixed backdrop shown only on the title screen (body.scene-title). The
   palette swaps via body.theme-day / body.theme-night, set once at boot from
   the visitor's local clock. Pure CSS, no image files. */
.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  display: none;            /* only painted on the landing screen */
  background: transparent;  /* night lets the body gradient show through */
}
body.scene-title .sky { display: block; }
.app { position: relative; z-index: 1; }

/* day/night toggle + menu — only on the landing, themed to the live palette */
.theme-toggle, .app-menu-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 40;
  width: 42px; height: 42px; border-radius: 50%;
  display: none; place-items: center;
  font-size: 20px; line-height: 1; cursor: pointer;
  border: 1px solid var(--stroke-strong);
  background: var(--panel); color: var(--ink);
  backdrop-filter: blur(8px); box-shadow: var(--shadow);
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
}
.theme-toggle { right: 14px; }
.app-menu-btn { left: 14px; font-size: 22px; }
body.scene-title .theme-toggle, body.scene-title .app-menu-btn { display: grid; }
.theme-toggle:hover, .app-menu-btn:hover { border-color: var(--accent); }
.theme-toggle:active, .app-menu-btn:active { transform: scale(.9); }
body.theme-day .theme-toggle, body.theme-day .app-menu-btn {
  background: rgba(255,255,255,.66); color: #15305f; border-color: rgba(255,255,255,.8);
}

/* ---- DAY: a full light palette for the WHOLE app -----------------------
   The app is almost entirely variable-driven, so re-pointing these tokens
   themes every screen. Hardcoded exceptions are patched just below. */
body.theme-day {
  /* light sky-blue background gradient (gameplay screens) */
  --bg-0: #c7e0f7; --bg-1: #dcecfb; --bg-2: #eef6ff;
  --panel: rgba(255,255,255,0.72);
  --panel-solid: #ffffff;
  --stroke: rgba(28,55,106,0.12);
  --stroke-strong: rgba(28,55,106,0.20);
  --ink: #13294f;
  --ink-dim: #3a4d72;
  --ink-faint: #61719a;
  --accent: #4a5fe0;
  --accent-2: #e85a8c;
  --gold: #c8861b;        /* deepened so gold text reads on white panels */
  --good: #1f9d6b;
  --bad: #d83a4a;
  --shadow: 0 16px 40px rgba(40,80,150,0.18);
  /* cloud colours (white, sunlit) */
  --cl-edge: rgba(255,255,255,.95);
  --cl-core: #ffffff;
  --cl-base: rgba(210,226,245,.95);
  --cl-shadow: rgba(120,150,190,.40);
}
body.theme-day { background:
  radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg-1) 45%, var(--bg-0) 100%); }

/* night uses the default (:root) dark palette — only cloud tokens differ */
body.theme-night {
  --cl-edge: rgba(190,205,255,.66);
  --cl-core: rgba(226,232,255,.82);
  --cl-base: rgba(70,84,140,.72);
  --cl-shadow: rgba(5,8,22,.6);
}

/* ---- DAY: patch the few hardcoded colours that assume a dark page ---- */
body.theme-day .progress,
body.theme-day .stat .s-bar,
body.theme-day .create-head .steps i { background: rgba(28,55,106,.12); }
body.theme-day .lb-entry-row input,
body.theme-day .contact-form input,
body.theme-day .contact-form textarea { background: rgba(255,255,255,.78); }
body.theme-day .mode-tag.choc { color: #c43d6b; }
body.theme-day .mode-tag.classic { color: #4a5fe0; }
body.theme-day .contact-status.err { color: #c62f3d; }
body.theme-day .app::before { opacity: .5; }
/* default to night tokens if no theme class is present */
.sky { --cl-edge: rgba(190,205,255,.66); --cl-core: rgba(226,232,255,.82);
       --cl-base: rgba(70,84,140,.72); --cl-shadow: rgba(5,8,22,.6); }

/* daytime: paint a blue sky over the dark body */
body.theme-day .sky {
  background: linear-gradient(180deg,#3f9bf0 0%,#6fb6f6 38%,#a6d6fb 72%,#d6eeff 100%);
}

/* sun (day) / moon + aurora (night) glow */
.glow { position: absolute; inset: 0; animation: skyBreathe 14s ease-in-out infinite; }
body.theme-day .glow {
  background:
    radial-gradient(40% 34% at 78% 12%, rgba(255,252,225,.95), rgba(255,247,200,0) 62%),
    radial-gradient(70% 45% at 50% 108%, rgba(255,255,255,.45), transparent 70%);
}
body.theme-night .glow {
  background:
    radial-gradient(34% 30% at 78% 12%, rgba(214,224,255,.45), transparent 64%),
    radial-gradient(45% 38% at 22% 22%, rgba(124,140,255,.18), transparent 70%),
    radial-gradient(42% 36% at 82% 30%, rgba(255,143,177,.10), transparent 72%),
    radial-gradient(60% 40% at 50% 110%, rgba(88,224,166,.08), transparent 70%);
}
@keyframes skyBreathe { 0%,100%{opacity:.9} 50%{opacity:1} }

/* twinkling starfield — night only */
.stars { position: absolute; inset: -10% 0; background-repeat: repeat; display: none; }
body.theme-night .stars { display: block; }
.stars.s1 {
  background-image:
    radial-gradient(1.4px 1.4px at 20px 30px, #fff, transparent),
    radial-gradient(1.2px 1.2px at 120px 80px, #cdd6ff, transparent),
    radial-gradient(1.6px 1.6px at 200px 160px, #fff, transparent),
    radial-gradient(1.1px 1.1px at 300px 50px, #b8c4ff, transparent),
    radial-gradient(1.3px 1.3px at 360px 220px, #fff, transparent);
  background-size: 400px 300px;
  animation: twinkle 4.5s ease-in-out infinite, driftStars 140s linear infinite;
}
.stars.s2 {
  background-image:
    radial-gradient(1px 1px at 70px 120px, #fff, transparent),
    radial-gradient(1px 1px at 250px 40px, #e7ecff, transparent),
    radial-gradient(1px 1px at 330px 180px, #fff, transparent),
    radial-gradient(1px 1px at 40px 240px, #c7d0ff, transparent);
  background-size: 380px 280px; opacity: .6;
  animation: twinkle 6s ease-in-out infinite .8s, driftStars 220s linear infinite reverse;
}
@keyframes twinkle { 0%,100%{opacity:.85} 50%{opacity:.45} }
@keyframes driftStars { from{background-position:0 0} to{background-position:400px 0} }

/* puffy clouds — same shapes, themed colours */
.cloud {
  position: absolute;
  background:
    radial-gradient(closest-side at 18% 58%, var(--cl-edge), transparent 100%),
    radial-gradient(closest-side at 34% 40%, var(--cl-core), transparent 100%),
    radial-gradient(closest-side at 50% 30%, var(--cl-core), transparent 100%),
    radial-gradient(closest-side at 64% 42%, var(--cl-core), transparent 100%),
    radial-gradient(closest-side at 82% 56%, var(--cl-edge), transparent 100%),
    radial-gradient(closest-side at 50% 70%, var(--cl-base), transparent 100%);
  filter: blur(5px);
  will-change: transform;
}
.cloud::before {
  content: ""; position: absolute; inset: 50% 10% -12% 10%; border-radius: 50%;
  background: radial-gradient(closest-side at 50% 50%, var(--cl-shadow), transparent 72%);
  filter: blur(11px); z-index: -1;
}
.c1 { width: 360px; height: 160px; top: 13%;    left: -380px; opacity: .95; animation: drift1 52s linear infinite -8s; }
.c2 { width: 260px; height: 120px; top: 31%;    left: -280px; opacity: .85; filter: blur(7px);  animation: drift2 70s linear infinite -40s; }
.c3 { width: 460px; height: 200px; top: 4%;     left: -490px; opacity: .70; filter: blur(10px); animation: drift3 92s linear infinite -64s; }
.c4 { width: 220px; height: 104px; top: 47%;    left: -240px; opacity: .92; animation: drift4 58s linear infinite -30s; }
.c5 { width: 330px; height: 148px; bottom: 9%;  left: -350px; opacity: .78; filter: blur(8px);  animation: drift5 80s linear infinite -22s; }
@keyframes drift1 { from{transform:translateX(0)} to{transform:translateX(125vw)} }
@keyframes drift2 { from{transform:translateX(0)} to{transform:translateX(135vw)} }
@keyframes drift3 { from{transform:translateX(0)} to{transform:translateX(145vw)} }
@keyframes drift4 { from{transform:translateX(0)} to{transform:translateX(140vw)} }
@keyframes drift5 { from{transform:translateX(0)} to{transform:translateX(150vw)} }

/* daytime legibility: darken the title text/chrome over the bright sky */
body.theme-day.scene-title .title .logo {
  background: linear-gradient(120deg,#0e2b5c,#2f6fd6 55%,#16407e);
  -webkit-background-clip: text; background-clip: text;
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
body.theme-day.scene-title .title .logo span { color: #2c4a7e; -webkit-text-fill-color: #2c4a7e; }
body.theme-day.scene-title .title .tagline { color: #1c376a; font-weight: 600; }
body.theme-day.scene-title .title .meta { color: #1d3a6e; font-weight: 600; text-shadow: 0 1px 0 rgba(255,255,255,.4); }
body.theme-day.scene-title .title .planet { filter: drop-shadow(0 12px 26px rgba(20,60,120,.35)); }
body.theme-day.scene-title .title .btn-ghost {
  background: rgba(255,255,255,.62); color: #15305f;
  border-color: rgba(255,255,255,.8); box-shadow: 0 4px 14px rgba(40,80,150,.18);
}
body.theme-day.scene-title .title .legal { color: #1d3a6e; }
body.theme-day.scene-title .title .legal:hover { color: #0e2b5c; }

/* ---- respect reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .app::before, .card .scene, .scene .tw, .scene .halo,
  .grade-badge.shine::before { animation: none !important; }
  .card.deal, .choice, .delta, .pickcard { animation: none !important; }
  .cloud, .stars, .glow { animation: none !important; }
}

/* =========================================================================
   Menu (hamburger) + Title Encyclopedia
   ========================================================================= */
.menu-screen .menu-actions { max-width: 420px; width: 100%; margin: 0 auto; }
.menu-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-item .m-count {
  font-size: 12px; font-weight: 800; color: var(--ink-faint);
  background: var(--panel); border: 1px solid var(--stroke); border-radius: 999px; padding: 3px 10px;
}

.enc-screen .enc-list { display: grid; gap: 8px; }
.enc-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--stroke);
  border-left: 3px solid var(--rc, var(--ink-faint));
  border-radius: var(--r-sm); padding: 10px 12px;
}
.enc-row:not(.got) { opacity: .5; }
.enc-mark { font-size: 18px; width: 22px; text-align: center; color: var(--rc, var(--ink-faint)); flex: none; }
.enc-main { flex: 1; min-width: 0; }
.enc-title { font-weight: 800; font-size: 15px; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.enc-tier { font-size: 10px; font-weight: 800; letter-spacing: .12em; color: var(--rc, var(--ink-faint)); }
.enc-line { font-family: "Fraunces"; font-style: italic; font-size: 13.5px; color: var(--ink-dim); margin-top: 1px; }
.enc-pct { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.enc-pct b { color: var(--ink-dim); }
.enc-got { color: var(--good); font-weight: 900; font-size: 18px; flex: none; }

/* Rarity accent colours — shared by the result tag and the encyclopedia. */
.rt-legendary { --rc: #ffce5c; }
.rt-epic      { --rc: #c98bff; }
.rt-rare      { --rc: #7c8cff; }
.rt-common    { --rc: var(--ink-faint); }
/* DAY: deepen rarity colours so they read on the light background. */
body.theme-day .rt-legendary { --rc: #b07d12; }
body.theme-day .rt-epic      { --rc: #8b3fd6; }
body.theme-day .rt-rare      { --rc: #3f54d6; }

/* Landing tagline: keep it legible over the clouds in BOTH themes. */
body.scene-title .title .tagline { text-shadow: 0 1px 10px rgba(10,14,36,.45); }
body.theme-day.scene-title .title .tagline { text-shadow: 0 1px 2px rgba(255,255,255,.65); }
body.theme-day.scene-title .title .tagline b { color: #102a55; }
body.theme-day.scene-title .title .tagline .tag-cta { color: #b06a00; }

/* New-title discovery celebration on the result screen */
.title-rarity.is-new {
  color: var(--rc, var(--gold)); border-color: var(--rc, var(--gold));
  background: color-mix(in srgb, var(--rc, var(--gold)) 22%, transparent);
  animation: newTitlePop .5s cubic-bezier(.2,1.3,.4,1) both, rarePulse 1.6s ease-in-out .5s infinite;
}
@keyframes newTitlePop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.collect-note {
  display: block; background: none; border: none; cursor: pointer; padding: 0;
  color: var(--gold); font-weight: 700; font-size: 12.5px; margin: 4px auto 0; font-family: inherit;
}
.collect-note b { color: var(--ink); }
.collect-note:hover { text-decoration: underline; }

/* Quick-share buttons on the result screen */
.result .actions .act-wide { grid-column: 1 / -1; }
.share-targets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.share-targets .btn.sm { width: 100%; padding: 10px 4px; font-size: 13px; }
.share-hint { font-size: 11px; color: var(--ink-faint); text-align: center; line-height: 1.3; margin: 0; }
