/* Atom Academy — rainforest theme, modern glass UI, periodic-table collection.
   Everything is CSS/SVG/emoji: no image assets, fully offline. */

:root {
  --ink: #0f2417;
  --paper: rgba(255,255,255,0.92);
  --glass: rgba(11, 38, 24, 0.42);
  --glass-edge: rgba(180, 255, 210, 0.28);
  --muted: #6b7b70;
  --accent: #ffd166;        /* warm sunlight gold */
  --leaf: #2fbf71;
  --leaf-deep: #0c6b3f;
  --good: #34d399;
  --bad: #ef6f6f;
  --sky-top: #0b3d2e;
  --radius: 20px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: #eafff2;
  background: #06160f;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ======================================================================
   RAINFOREST SCENE  (fixed, behind everything)
   ====================================================================== */
.scene {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  --sky-top: #103f2e; --sky-mid: #0c5a37; --sky-bot: #06160f;
  --silhouette: #08311f; --spark: #fff3a6; --floor: rgba(4,18,11,.92);
}
.scene .sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(255,246,207,.5) 0%, rgba(255,246,207,0) 42%),
    linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 45%, var(--sky-bot) 100%);
  transition: background .6s ease;
}
/* god-rays slanting through the canopy */
.scene .rays {
  position: absolute; inset: -10% -10% 30% -10%;
  background: repeating-linear-gradient(101deg,
      rgba(255,247,200,0.10) 0px, rgba(255,247,200,0.10) 22px,
      transparent 22px, transparent 90px);
  mix-blend-mode: screen;
  filter: blur(3px);
  animation: sway 14s ease-in-out infinite alternate;
}
@keyframes sway { from { transform: translateX(-14px); } to { transform: translateX(14px); } }

.scene .canopy { position: absolute; top: 0; left: 0; width: 100%; height: 230px; }
.scene .canopy path { fill: var(--silhouette); opacity: 0.95; transition: fill .6s ease; }
.scene.no-canopy .canopy { display: none; }

/* drifting bits (leaves / snow / bubbles / stars, set per expedition) */
.scene .drifters span {
  position: absolute; top: -6%; left: var(--x);
  font-size: calc(26px * var(--s)); opacity: 0.8;
  animation: drift 16s linear infinite; animation-delay: var(--t);
  filter: drop-shadow(0 4px 6px rgba(0,0,0,.3));
}
@keyframes drift {
  0%   { transform: translateY(-10vh) translateX(0) rotate(0deg); opacity: 0; }
  10%  { opacity: .85; }
  100% { transform: translateY(112vh) translateX(40px) rotate(220deg); opacity: .2; }
}

/* hanging vines from the canopy (jungle/dino only) */
.scene .vines { display: none; }
.scene.has-vines .vines { display: block; }
.scene .vines span {
  position: absolute; top: 0; left: var(--x); width: 4px; height: var(--h);
  background: linear-gradient(#0a4f31, #0c6b3f);
  border-radius: 0 0 6px 6px; transform-origin: top center;
  animation: vinesway 9s ease-in-out infinite alternate;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15);
}
.scene .vines span::after {
  content: "🍃"; position: absolute; bottom: -10px; left: -10px; font-size: 22px;
}
@keyframes vinesway { from { transform: rotate(-3deg); } to { transform: rotate(3deg); } }

.scene .critters .critter {
  position: absolute; left: var(--x); top: var(--y); font-size: 30px; opacity: .9;
  animation: flit 12s ease-in-out infinite; animation-delay: var(--d);
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
}
@keyframes flit {
  0%,100% { transform: translate(0,0) rotate(-4deg); }
  25% { transform: translate(30px,-18px) rotate(6deg); }
  50% { transform: translate(8px,12px) rotate(-3deg); }
  75% { transform: translate(-24px,-8px) rotate(5deg); }
}

/* twinkling fireflies */
.scene .fireflies { position: absolute; inset: 0; }
.scene .fireflies::before, .scene .fireflies::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    radial-gradient(2px 2px at 12% 70%, var(--spark), transparent),
    radial-gradient(2px 2px at 28% 52%, var(--spark), transparent),
    radial-gradient(3px 3px at 47% 80%, var(--spark), transparent),
    radial-gradient(2px 2px at 63% 60%, var(--spark), transparent),
    radial-gradient(2px 2px at 81% 74%, var(--spark), transparent),
    radial-gradient(2px 2px at 92% 55%, var(--spark), transparent);
  animation: twinkle 4s ease-in-out infinite;
}
.scene .fireflies::after { animation-delay: 2s; transform: translateY(20px); }
@keyframes twinkle { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

.scene .floor {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26vh;
  background: linear-gradient(180deg, transparent, var(--floor));
  transition: background .6s ease;
}

/* ======================================================================
   LAYOUT + GLASS
   ====================================================================== */
#app { min-height: 100vh; display: flex; justify-content: center; }
.screen { width: 100%; max-width: 860px; margin: 0 auto; padding: 18px; }
.hidden { display: none !important; }
.muted { color: #bfe9cf; opacity: .8; }
.center { text-align: center; }

.glass, .card, .topbar, .modal-card {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.card {
  border-radius: 26px; padding: 30px; margin: 6vh auto; max-width: 560px;
  box-shadow: 0 24px 70px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.12);
}
.card.center { text-align: center; }

.logo {
  font-size: 40px; margin: 0; font-weight: 800; letter-spacing: -0.5px;
  background: linear-gradient(90deg, #d6ffe6, #ffe98a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 2px 30px rgba(255,233,138,.25);
}
.tagline { color: #bfe9cf; margin: 6px 0 22px; }
h1, h2 { color: #f2fff8; }

/* Buttons */
.btn {
  font: inherit; font-weight: 700; cursor: pointer; color: #08251a;
  background: linear-gradient(180deg, #b9ffd6, #38d98a);
  border: none; padding: 13px 20px; border-radius: 16px;
  box-shadow: 0 8px 22px rgba(20,200,120,.30), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .07s ease, filter .15s ease, box-shadow .15s ease;
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 10px 26px rgba(20,200,120,.42); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.btn.big { font-size: 19px; padding: 15px 30px; }
.btn.ghost {
  background: rgba(255,255,255,.10); color: #eafff2;
  border: 1px solid var(--glass-edge); box-shadow: none;
}
.btn.ghost:hover { background: rgba(255,255,255,.18); }
.btn-row { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* Tier chooser (clear Easy → Medium → Hard for ★★★) */
.tier-card { max-width: 440px; }
.tier-options { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 22px; }
.tier-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  font: inherit; text-align: left; cursor: pointer; color: #eafff2;
  background: rgba(255,255,255,.10); border: 1px solid var(--glass-edge);
  border-radius: 16px; padding: 14px 18px; transition: transform .07s ease, background .15s ease, box-shadow .15s ease;
}
.tier-opt:hover:not(:disabled) { background: rgba(255,255,255,.18); transform: translateY(-1px); }
.tier-opt:active:not(:disabled) { transform: translateY(1px); }
.tier-opt .tier-name { font-size: 20px; font-weight: 800; }
.tier-opt .tier-state { font-size: 13px; opacity: .85; }
.tier-opt.tier-easy   { border-left: 6px solid #7ee08a; }
.tier-opt.tier-medium { border-left: 6px solid #ffd166; }
.tier-opt.tier-hard   { border-left: 6px solid #ff8a6a; }
.tier-opt.cleared { background: rgba(126,224,138,.16); box-shadow: inset 0 0 0 1px rgba(126,224,138,.4); }
.tier-opt.cleared .tier-name { color: #b6f5c0; }
.tier-opt.locked { opacity: .45; cursor: default; }

.icon-btn {
  font: inherit; font-size: 19px; cursor: pointer; border: 1px solid var(--glass-edge);
  background: rgba(255,255,255,.10); color: #eafff2; width: 44px; height: 44px;
  border-radius: 13px; transition: background .15s ease;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }

/* Inputs */
.text-input, .num-input {
  font: inherit; padding: 13px 15px; border: 1px solid var(--glass-edge); border-radius: 14px;
  width: 100%; background: rgba(255,255,255,.92); color: #08251a; font-weight: 600;
}
.num-input { max-width: 220px; text-align: center; font-size: 26px; font-weight: 800; }
.add-row { display: flex; gap: 10px; margin-top: 18px; }
.add-row .text-input { flex: 1; }

/* Profiles */
.profile-list { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.profile-row { display: flex; gap: 8px; }
.profile-pick {
  flex: 1; display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,.12); color: #f2fff8; border: 1px solid var(--glass-edge);
  box-shadow: none; font-size: 18px;
}
.profile-pick:hover { background: rgba(255,255,255,.2); }
.profile-meta { font-weight: 600; color: #bfe9cf; font-size: 13px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px; border-radius: 18px; margin-top: 6px;
}
.topbar-actions { display: flex; gap: 6px; }
.theme-chip, .progress-chip, .skill-chip {
  font-weight: 700; color: #eafff2; background: rgba(0,0,0,.22);
  padding: 7px 13px; border-radius: 12px; font-size: 14px; border: 1px solid rgba(255,255,255,.10);
}
.map-body, .game-body, .collection-body { padding: 20px 4px; }
.map-body h2 { margin-bottom: 2px; }

/* Level grid — leafy stepping-stones */
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 16px; margin-top: 18px; }
.level-node {
  position: relative;
  aspect-ratio: 1 / 1; border: 1px solid rgba(255,255,255,.18); border-radius: 22px; cursor: pointer;
  background: linear-gradient(160deg, #46e08f, #0c8a4f); color: #062b1b;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.4); font-weight: 800;
  transition: transform .08s ease, filter .15s ease;
}
.level-node:hover { filter: brightness(1.06); transform: translateY(-2px); }
.level-node.locked {
  background: linear-gradient(160deg, #2a4034, #1b2b22); color: #8fae9d; cursor: default;
  box-shadow: 0 8px 18px rgba(0,0,0,.4);
}
.level-node.done { background: linear-gradient(160deg, #ffe07a, #f2b73a); color: #5b3d05; }
/* the next level to play pulses a gold ring so it's obvious where to tap */
.level-node.next { border: 2px solid var(--accent); animation: nextpulse 1.5s ease-in-out infinite; }
.level-node.next::after {
  content: "▶"; position: absolute; top: 6px; right: 8px; font-size: 12px; color: #5b3d05;
}
@keyframes nextpulse {
  0%, 100% { box-shadow: 0 10px 24px rgba(0,0,0,.35), 0 0 0 0 rgba(255,209,102,.65); }
  50%      { box-shadow: 0 10px 24px rgba(0,0,0,.35), 0 0 0 12px rgba(255,209,102,0); }
}
.level-emoji { font-size: 20px; line-height: 1; }
.level-num { font-size: 24px; }
.level-stars { font-size: 13px; letter-spacing: 1px; }

/* Destinations strip — the journey across expeditions */
.destinations { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 4px; }
.dest {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: rgba(255,255,255,.1); border: 1px solid var(--glass-edge); transition: transform .15s ease;
}
.dest.locked { opacity: .4; filter: grayscale(.6); }
.dest.current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 16px -2px var(--accent); transform: translateY(-2px) scale(1.08); }

/* Winding chapter trail */
.level-path { display: flex; flex-direction: column; gap: 26px; margin-top: 14px; }
.chapter {
  background: rgba(0,0,0,.18); border: 1px solid var(--glass-edge); border-radius: 22px;
  padding: 12px 8px 24px; overflow: hidden;
}
.chapter-head { text-align: center; font-weight: 800; color: #f2fff8; font-size: 18px; padding: 8px 0 4px; }
.chapter-emoji { font-size: 22px; }
.trail { position: relative; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 14px 0 4px; }
.trail::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.45) 0 8px, transparent 8px 18px); border-radius: 4px;
}
.trail .level-node { position: relative; z-index: 1; width: 84px; height: 84px; aspect-ratio: auto; }
.trail .level-node:nth-child(odd)  { transform: translateX(-62px); }
.trail .level-node:nth-child(even) { transform: translateX(62px); }
.trail .level-node:hover { filter: brightness(1.06); }
.trail .level-node.next { z-index: 2; }

/* Arrival screen */
.arrival-card { max-width: 460px; }
.arrival-emoji { font-size: 78px; animation: pop .5s ease; }
.arrival-kicker { letter-spacing: 3px; text-transform: uppercase; font-size: 12px; color: var(--accent); font-weight: 800; margin: 8px 0 0; }
.arrival-card h1 { font-size: 30px; margin: 6px 0 10px; }

/* How-to-play intro */
.intro-card { max-width: 460px; }
.intro-emoji { font-size: 70px; line-height: 1; animation: pop .4s ease; }
.intro-card h1 { font-size: 26px; margin: 10px 0 6px; }
.intro-text { color: #d6ffe6; font-size: 17px; margin: 0 0 16px; min-height: 50px; }
.intro-dots { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; }
.intro-dots .dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.25); transition: all .2s ease; }
.intro-dots .dot.on { background: var(--accent); transform: scale(1.25); }
@media (max-width: 480px) {
  .trail .level-node:nth-child(odd)  { transform: translateX(-40px); }
  .trail .level-node:nth-child(even) { transform: translateX(40px); }
}

/* Game */
.skill-chip { display: inline-block; margin-bottom: 16px; }
.question {
  background: var(--paper); color: var(--ink); border-radius: 22px; padding: 30px;
  font-size: 27px; line-height: 1.5; text-align: center; min-height: 96px; font-weight: 600;
  box-shadow: 0 18px 50px rgba(0,0,0,.4);
}
.prompt { font-weight: 700; }
.banner { font-size: 15px; color: #0c8a4f; font-weight: 800; margin-bottom: 10px; }
.word { cursor: pointer; border-radius: 7px; padding: 0 3px; transition: background .12s ease; }
.word:hover { background: #ffe07a; }
.answer-area { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; align-items: center; margin: 22px 0; }
.choice {
  background: var(--paper); color: var(--ink); min-width: 88px; font-size: 23px;
  border: 1px solid rgba(255,255,255,.4);
}
.choice:hover { filter: brightness(1.02); }
.choice.tf { min-width: 130px; }

/* Question visuals (clock, graphs, arrays, fractions, coins, bars) */
.visual { display: flex; justify-content: center; margin: 2px 0 16px; }
.shape-vis { font-size: 74px; line-height: 1; }
.clock { display: block; }
.coins { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 320px; }
.coin {
  display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 46px; padding: 0 8px;
  border-radius: 50%; font-weight: 800; color: #4a3a10; border: 2px solid #b88a2a;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #d4af37); box-shadow: 0 3px 6px rgba(0,0,0,.3);
}
.coin-nickel { min-width: 52px; height: 52px; }
.coin-quarter { min-width: 56px; height: 56px; }
.coin-dime { background: radial-gradient(circle at 35% 30%, #f1f5f9, #cbd5e1); border-color: #94a3b8; color: #334155; }
.bars { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label { font-weight: 800; color: var(--ink); width: 18px; }
.bar { display: inline-block; height: 22px; border-radius: 6px; background: linear-gradient(90deg, #34d399, #059669); box-shadow: inset 0 1px 0 rgba(255,255,255,.4); }
.ruler { display: flex; }
.ruler span { width: 18px; text-align: center; font-size: 10px; color: var(--muted); border-left: 1px solid #cbd5e1; }
.graph { display: flex; flex-direction: column; gap: 8px; }
.graph-row { display: flex; align-items: center; gap: 10px; }
.graph-name { min-width: 86px; text-align: right; font-weight: 700; color: var(--ink); border-right: 3px solid #94a3b8; padding-right: 10px; }
.graph-bar { font-size: 22px; letter-spacing: 3px; word-break: break-all; }
.array { display: inline-flex; flex-direction: column; gap: 6px; }
.arr-row { font-size: 22px; letter-spacing: 4px; line-height: 1; }
.fracbar { display: flex; width: 220px; height: 64px; border: 3px solid var(--ink); border-radius: 8px; overflow: hidden; }
.frac-part { flex: 1; border-right: 2px solid var(--ink); }
.frac-part:last-child { border-right: none; }
.frac-part.on { background: repeating-linear-gradient(45deg, #34d399, #34d399 6px, #10b981 6px, #10b981 12px); }
/* Area grid (count unit squares) */
.area-grid { display: inline-flex; flex-direction: column; border: 2px solid var(--ink); }
.area-row { display: flex; }
.area-cell { width: 22px; height: 22px; border: 1px solid #6aa588; background: #d1fae5; }
/* Rectangle figure (perimeter) */
.rect-fig { position: relative; display: inline-block; padding: 20px 26px; }
.rect-box { width: 132px; height: 82px; border: 3px solid var(--ink); border-radius: 4px; background: #eef7f1; }
.rect-fig .rl-top { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font-weight: 800; color: var(--ink); }
.rect-fig .rl-side { position: absolute; top: 50%; left: 2px; transform: translateY(-50%); font-weight: 800; color: var(--ink); }
/* Multiplication area / box model */
.mult-area { display: inline-block; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.ma-row { display: flex; }
.ma-corner, .ma-col, .ma-rowlabel, .ma-cell { min-width: 58px; height: 46px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; color: var(--ink); }
.ma-corner { background: #b8e6cc; }
.ma-col { background: #d1fae5; border-left: 1px solid #6aa588; }
.ma-rowlabel { background: #d1fae5; border-top: 1px solid #6aa588; }
.ma-cell { background: #eef7f1; border-left: 1px solid #6aa588; border-top: 1px solid #6aa588; }

/* Place value: big number with ONE digit highlighted (unambiguous "value of this digit") */
.pv-num { font-size: 38px; font-weight: 800; letter-spacing: 3px; color: var(--ink); text-align: center; }
.pv-num .pv-target { color: #fff; background: var(--accent, #fb923c); border-radius: 8px; padding: 0 8px; text-decoration: none; box-shadow: 0 2px 0 rgba(0,0,0,.18); }

/* Feedback */
.feedback { min-height: 30px; text-align: center; font-size: 18px; font-weight: 700; padding: 8px 12px; border-radius: 14px; }
.feedback.good { color: #d6ffe6; }
.feedback.hint { color: #5b3d05; background: #ffe9a8; }
.feedback.worked { color: #08251a; background: #d6f3ff; }
.feedback.soft { color: #eafff2; background: rgba(255,255,255,.12); }

/* Complete */
.stars-row { margin: 12px 0; }
.big-star { font-size: 60px; color: #3a5246; display: inline-block; transition: transform .35s ease, color .35s ease, text-shadow .35s ease; }
.big-star.on { color: var(--accent); transform: scale(1.14) rotate(-7deg); text-shadow: 0 6px 22px rgba(255,209,102,.6); }
.greet { color: #d6ffe6; }

/* ======================================================================
   PERIODIC TABLE
   ====================================================================== */
.collection-body h2 { margin: 0 0 4px; }
.ptable-wrap {
  overflow-x: auto; padding: 14px; border-radius: 18px;
  background: rgba(3, 16, 10, 0.62); border: 1px solid var(--glass-edge);
}
.ptable {
  display: grid;
  grid-template-columns: repeat(18, minmax(30px, 1fr));
  grid-template-rows: repeat(7, auto) 10px auto auto;
  gap: 5px; min-width: 660px;
}
.cell {
  position: relative; aspect-ratio: 1 / 1; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; line-height: 1; user-select: none;
  border: 1px solid rgba(255,255,255,.12); background: rgba(13, 40, 27, 0.92);
  color: #aacebd; transition: transform .1s ease, box-shadow .15s ease;
}
.cell .z { position: absolute; top: 3px; left: 4px; font-size: 8px; font-weight: 600; opacity: .8; }
.cell .sym { font-size: clamp(11px, 1.6vw, 18px); }
.cell .nm { font-size: 7px; font-weight: 600; opacity: .85; margin-top: 1px; display: none; }

/* state: not in any installed disk yet → dim, but still legible */
.cell.soon { opacity: .62; }
.cell.soon .sym { opacity: .8; }

/* state: collectible now but not earned → silhouette with category hint */
.cell.earnable {
  border-style: dashed; border-color: var(--c, #ffd166);
  background: rgba(22, 52, 37, 0.95); color: #e6fff1;
  box-shadow: inset 0 0 12px -4px var(--c, #ffd166);
}
.cell.earnable .sym { opacity: .85; }

/* state: owned → lit by category colour */
.cell.owned {
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 92%, white 8%), var(--c));
  color: #10261c; border-color: rgba(255,255,255,.45); cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.4), 0 0 18px -2px var(--c), inset 0 1px 0 rgba(255,255,255,.5);
}
.cell.owned:hover { transform: translateY(-3px) scale(1.04); }
.cell.owned .nm { display: block; }
.cell.owned.tier2 { outline: 2px solid #fff; }
.cell.owned.tier3 { outline: 2px solid #b9f3ff; box-shadow: 0 6px 16px rgba(0,0,0,.4), 0 0 26px 0 #b9f3ff; }

/* the La-Lu / Ac-Lr placeholder markers in the main grid */
.cell.marker { background: transparent; border-style: dotted; color: #7fa291; font-size: 9px; cursor: default; }

.ptable-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #cdeedd; }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; }

/* Family badges */
.badges { margin-top: 18px; }
.badges-title { font-weight: 800; color: #f2fff8; font-size: 17px; margin-bottom: 10px; }
.badge-card { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(255,255,255,.07); border: 1px solid var(--glass-edge); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; }
.badge-card.earned { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 24%, transparent), rgba(255,255,255,.06)); border-color: var(--c); }
.badge-emoji { font-size: 24px; }
.badge-name { font-weight: 700; color: #eafff2; flex: 1; min-width: 130px; }
.badge-prog { font-weight: 800; color: #bfe9cf; }
.badge-mem { display: flex; gap: 4px; flex-wrap: wrap; }
.badge-el { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.08); color: #7fa291; }
.badge-el.on { background: var(--c, var(--accent)); color: #10261c; }
.badge-big { font-size: 64px; line-height: 1; animation: pop .4s ease; }
.badge-row { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.badge-row .badge-el { font-size: 14px; padding: 4px 9px; }

.soon-banner { margin: 4px 0 14px; padding: 14px; border-radius: 16px; text-align: center; color: #d6ffe6; background: rgba(255,255,255,.08); border: 1px solid var(--glass-edge); font-weight: 700; }
.soon-banner.unlocked { color: #062b1b; background: linear-gradient(90deg, #b9ffd6, #7fe9b0); }

/* Settings */
.overview { background: rgba(255,255,255,.08); border: 1px solid var(--glass-edge); border-radius: 14px; padding: 16px; line-height: 1.8; margin: 14px 0; }
.toggle-row { display: flex; gap: 10px; align-items: center; font-weight: 700; margin: 14px 0; }
.settings-saves { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.file-label { display: inline-flex; align-items: center; cursor: pointer; }
.tools { margin-top: 18px; border-top: 1px solid var(--glass-edge); padding-top: 16px; }
.tools h2 { font-size: 18px; margin: 0 0 4px; }
.tools .muted { margin: 0 0 12px; font-size: 13px; }
.tool-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tool-row label { font-weight: 700; }
.num-input.small { max-width: 110px; font-size: 18px; padding: 8px 10px; }
.btn.danger { background: rgba(239,111,111,.18); color: #ffd9d9; border-color: rgba(239,111,111,.5); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px);
  background: rgba(8,30,20,.92); color: #eafff2; padding: 13px 22px; border-radius: 16px;
  opacity: 0; transition: opacity .2s ease, transform .2s ease; z-index: 60; font-weight: 700;
  border: 1px solid var(--glass-edge); backdrop-filter: blur(10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(2,12,7,.6); display: flex; align-items: center; justify-content: center; z-index: 70; padding: 20px; backdrop-filter: blur(3px); }
.modal-card { border-radius: 26px; padding: 30px; text-align: center; max-width: 400px; width: 100%; box-shadow: 0 30px 90px rgba(0,0,0,.6); }
.modal-card h1 { color: #ffe98a; }
.modal-card .btn { margin-top: 20px; }
.element-tile {
  width: 116px; height: 116px; margin: 0 auto 14px; border-radius: 20px; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c, #ffd166) 90%, white), var(--c, #ffd166));
  box-shadow: 0 0 30px -4px var(--c, #ffd166);
}
.element-tile .el-sym { font-size: 50px; font-weight: 800; color: #10261c; }
.element-tile .el-z { position: absolute; top: 9px; left: 12px; font-size: 14px; color: #2a4a39; font-weight: 800; }
.element-tile .el-cat { position: absolute; bottom: 8px; right: 0; left: 0; font-size: 10px; color: #1c3a2b; font-weight: 700; }
.element-tile.tier2 { outline: 3px solid #ffffff; outline-offset: 2px; }
.element-tile.tier3 { outline: 3px solid #b9f3ff; outline-offset: 2px; box-shadow: 0 0 36px 0 #b9f3ff; }
.tier-chain { display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tier-step { font-size: 12px; padding: 4px 9px; border-radius: 9px; background: rgba(255,255,255,.08); color: #9fbcae; }
.tier-step.on { background: rgba(255,209,102,.22); color: #ffe9a8; }
.tier-step.cur { outline: 2px solid var(--accent); color: #fff; font-weight: 800; }
.tier-arrow { color: #7fa291; font-weight: 700; }
.tier-hint { font-size: 12px; margin: 10px 0 0; }
.disk-burst { font-size: 44px; animation: pop .5s ease; }
.element-pop, .disk-pop { animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* Floppy-disk swap (disk-unlock moment) */
.disk-swap {
  position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px; padding: 20px;
  background: rgba(2, 10, 7, 0.94); backdrop-filter: blur(5px);
}
.drive-stage { position: relative; width: 260px; height: 280px; }
.drive {
  position: absolute; bottom: 0; left: 50%; margin-left: -130px; width: 260px; height: 74px;
  background: linear-gradient(#3a4654, #1e2630); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.12); z-index: 3;
}
.drive-slot {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); width: 188px; height: 12px;
  background: #0a0f15; border-radius: 6px; box-shadow: inset 0 2px 5px rgba(0,0,0,.9);
}
.drive-light { position: absolute; bottom: 14px; right: 20px; width: 12px; height: 12px; border-radius: 50%; background: #14532d; transition: all .3s ease; }
.drive-light.on { background: #22c55e; box-shadow: 0 0 14px #22c55e; }
.floppy {
  position: absolute; left: 50%; margin-left: -76px; bottom: 46px; width: 152px; height: 152px;
  border-radius: 9px 9px 12px 12px; background: linear-gradient(150deg, #2b3442, #161b22);
  box-shadow: 0 18px 40px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12); z-index: 2;
}
.floppy::before {   /* metal shutter */
  content: ""; position: absolute; top: 12px; left: 34px; width: 74px; height: 44px;
  background: linear-gradient(#d3dae3, #9aa6b3); border-radius: 3px; box-shadow: inset 0 0 0 2px #64748b;
}
.floppy::after {    /* shutter window */
  content: ""; position: absolute; top: 12px; left: 76px; width: 18px; height: 44px; background: #161b22; border-radius: 2px;
}
.floppy-label {
  position: absolute; left: 14px; right: 14px; bottom: 14px; height: 64px; background: #f8fafc; border-radius: 4px;
  display: flex; align-items: center; justify-content: center; text-align: center; color: #0f172a;
  font-weight: 800; font-size: 18px; letter-spacing: .5px; box-shadow: inset 0 0 0 1px #cbd5e1;
}
.floppy.new { opacity: 0; }
.floppy.old.ejecting { animation: floppy-eject 1.1s cubic-bezier(.5,-0.2,.7,1) forwards; }
.floppy.new.inserting { animation: floppy-insert 1.2s cubic-bezier(.3,.2,.3,1.2) .9s forwards; }
@keyframes floppy-eject {
  0% { transform: translateY(0); opacity: 1; }
  18% { transform: translateY(12px); }
  100% { transform: translateY(-340px) rotate(-5deg); opacity: 0; }
}
@keyframes floppy-insert {
  0% { transform: translateY(-340px); opacity: 0; }
  35% { opacity: 1; }
  82% { transform: translateY(7px); }
  100% { transform: translateY(0); opacity: 1; }
}
.disk-swap-caption { text-align: center; color: #eafff2; min-height: 80px; }
.disk-swap-caption h1 { color: #ffe98a; margin: 0 0 6px; }
.swap-status { color: #bfe9cf; font-weight: 700; letter-spacing: 1px; }

/* Victory / graduation */
.victory-card {
  max-width: 520px; margin: 5vh auto; text-align: center; padding: 32px; color: #1a2e22;
  background: linear-gradient(160deg, #fffdf5, #fdeecf); border: 6px double #d4af37;
  border-radius: 24px; box-shadow: 0 26px 80px rgba(0,0,0,.55);
}
.trophy { font-size: 92px; line-height: 1; animation: trophy 1.1s ease-in-out infinite alternate; filter: drop-shadow(0 10px 18px rgba(212,175,55,.5)); }
@keyframes trophy { from { transform: translateY(0) rotate(-3deg); } to { transform: translateY(-12px) rotate(3deg); } }
.victory-kicker { letter-spacing: 2px; font-weight: 800; color: #b8860b; margin: 6px 0 0; }
.victory-name { font-size: 42px; margin: 4px 0 6px; background: linear-gradient(90deg, #b8860b, #e0792b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.victory-sub { color: #4a5a4f; margin: 0 0 14px; font-weight: 600; }
.victory-stats { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 14px 0 20px; }
.vstat { display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff7e6; border: 1px solid #e7cf9a; border-radius: 16px; padding: 12px 18px; min-width: 92px; }
.vnum { font-size: 22px; font-weight: 800; color: #1a2e22; }
.vstat span:last-child { font-size: 12px; color: #6b7b70; }

/* Fireworks */
.fireworks { position: fixed; inset: 0; pointer-events: none; z-index: 78; overflow: hidden; }
.fw-burst { position: absolute; }
.fw-spark { position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 10px currentColor; animation: fw .95s ease-out forwards; }
@keyframes fw { 0% { transform: translate(0,0); opacity: 1; } 100% { transform: translate(var(--dx), var(--dy)); opacity: 0; } }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.confetti-bit { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; animation: fall 2s linear forwards; }
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0); opacity: 1; }
  100% { transform: translateY(105vh) rotate(540deg); opacity: .9; }
}

@media (max-width: 520px) {
  .card { padding: 22px; margin: 4vh auto; }
  .logo { font-size: 32px; }
  .question { font-size: 23px; padding: 22px; }
}
