/* Frogs TD · Package E · "pond-craft" UI (SPEC §8). Self-hosted OFL fonts; no network. */
@font-face { font-family: 'Baloo 2'; src: url('../assets/fonts/Baloo2/Baloo2-Variable-latin.woff2') format('woff2'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Nunito'; src: url('../assets/fonts/Nunito/Nunito-Variable-latin.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }

.fg-root {
  --ui-scale: 1;
  --cream: #f6efd9; --muted: #cfe0d2; --ink: #0b1f1c; --glass: rgba(12, 36, 33, 0.74); --glass-2: rgba(20, 54, 48, 0.86); --solid: #10302b;
  --line: rgba(246, 239, 217, 0.16); --gold: #ffd25a; --gold-2: #ffb21c; --danger: #ff7b6b; --ok: #8be89a; --accent: #9ee6b8;
  --spring: cubic-bezier(.34, 1.56, .64, 1); --t-in: 220ms; --r-pad: 26px; --r-stone: 16px;
  --hp-hi: #6fe07f; --hp-mid: #ffd24a; --hp-lo: #ff5a4a;
  --font-display: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
  --font-ui: 'Nunito', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  position: fixed; inset: 0; z-index: 20; pointer-events: none; color: var(--cream); font-family: var(--font-ui);
  font-size: 16px; line-height: 1.3; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent; overflow: hidden; overflow: clip;
}
/* `hidden` must win over component display rules; clip (not hidden) so focus() can never scroll the overlay layers */
.fg-root [hidden] { display: none !important; }
.fg-hud, .fg-world, .fg-toasts { overflow: clip; }
.fg-root[data-colorblind]:not([data-colorblind="off"]) { --hp-hi: #56b4e9; --hp-mid: #f0e442; --hp-lo: #d55e00; --ok: #56b4e9; --danger: #ff9a3c; }
.fg-root * { box-sizing: border-box; }
.fg-root button, .fg-root input, .fg-root select { font: inherit; color: inherit; }
.fg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.fg-ic { width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.25em; flex: none; }

/* scaled layers (UI scale 75–150 %) */
.fg-hud, .fg-screens, .fg-toasts { position: absolute; inset: 0; zoom: var(--ui-scale); pointer-events: none; }
.fg-world { position: absolute; inset: 0; pointer-events: none; }

/* focus ring: visible for keyboard on every interactive element */
.fg-root :focus { outline: none; }
.fg-root :focus-visible { outline: 3px solid #ffe27a; outline-offset: 3px; box-shadow: 0 0 0 6px rgba(11, 31, 28, .85); border-radius: 14px; }

/* ---------- primitives ---------- */
.fg-panel { background: var(--glass); border: 1px solid var(--line); border-radius: var(--r-pad); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .08); pointer-events: auto; }
.fg-root.fg-q-low .fg-panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--glass-2); }
.fg-btn { min-width: 44px; min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(246, 239, 217, .22); cursor: pointer;
  background: linear-gradient(180deg, #2f7a5c, #1d5443); color: var(--cream); font-weight: 800; letter-spacing: .02em; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; box-shadow: 0 3px 0 #0f3328, 0 6px 14px rgba(0, 0, 0, .25); transition: transform 140ms var(--spring), filter 120ms; pointer-events: auto; position: relative; }
.fg-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.fg-btn:active { transform: translateY(1px) scale(.98); }
.fg-btn[disabled], .fg-btn[aria-disabled="true"] { filter: grayscale(.7) brightness(.8); cursor: not-allowed; }
.fg-btn.is-primary { background: linear-gradient(180deg, #ffd860, #f0a81c); color: #2a1a00; box-shadow: 0 3px 0 #a86a00, 0 6px 14px rgba(0, 0, 0, .25); }
.fg-btn.is-danger { background: linear-gradient(180deg, #d9604f, #a63b30); box-shadow: 0 3px 0 #6b211a, 0 6px 14px rgba(0, 0, 0, .25); }
.fg-btn.is-ghost { background: rgba(255, 255, 255, .06); box-shadow: none; }
.fg-btn.is-round { width: 48px; height: 48px; padding: 0; }
.fg-btn.is-holding::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: rgba(255, 255, 255, .28); transform-origin: left; transform: scaleX(var(--hold, 0)); }
.fg-h1 { font-family: var(--font-display); font-weight: 800; font-size: 44px; line-height: 1; margin: 0 0 12px; letter-spacing: .01em; text-shadow: 0 3px 0 rgba(0, 0, 0, .35); }
.fg-h2 { font-family: var(--font-display); font-weight: 700; font-size: 26px; margin: 0 0 8px; }
.fg-muted { color: var(--muted); }
.fg-num { font-family: var(--font-ui); font-weight: 900; font-variant-numeric: tabular-nums; }
.fg-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); font-size: 13px; font-weight: 700; }
@keyframes fg-pop { from { opacity: 0; transform: scale(.86) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fg-fade { from { opacity: 0; } to { opacity: 1; } }
.fg-in { animation: fg-pop var(--t-in) var(--spring) both; }
.fg-tp.fg-in { animation: fg-fade 160ms both; } /* no scale: a scaled pop shrinks 44px tap targets mid-animation */

/* ---------- HUD ---------- */
.fg-hud > * { pointer-events: auto; }
.fg-hud-tl { position: absolute; left: 16px; top: 14px; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; min-width: 200px; }
.fg-flies { display: flex; align-items: center; gap: 10px; font-size: 28px; }
.fg-flyicon { position: relative; width: 34px; height: 34px; color: var(--gold); }
.fg-flyicon .fg-ic { position: absolute; inset: 0; width: 100%; height: 100%; }
.fg-flyicon .w { color: rgba(255, 255, 255, .8); transform-origin: 50% 45%; animation: fg-flap .09s linear infinite alternate; }
@keyframes fg-flap { from { transform: scaleY(1); } to { transform: scaleY(.55); } }
.fg-flies.is-bump .fg-num { animation: fg-bump 260ms var(--spring); }
@keyframes fg-bump { 40% { transform: scale(1.18); color: #fff3b0; } }
.fg-wave { font-weight: 800; font-size: 16px; }
.fg-bar { height: 8px; border-radius: 99px; background: rgba(0, 0, 0, .35); overflow: hidden; }
.fg-bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(90deg, var(--accent), #e8ffb0); border-radius: inherit; transition: width 300ms; }
.fg-hud-tr { position: absolute; right: 16px; top: 14px; display: flex; gap: 8px; padding: 8px; }
.fg-speed { min-width: 64px; }
.fg-hud-bc { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 18px; padding: 10px 18px 10px 14px; }
.fg-heart { position: relative; width: 64px; height: 58px; color: var(--hp-hi); }
.fg-heart .fg-ic { width: 100%; height: 100%; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .4)); }
.fg-heart .fill { position: absolute; inset: 0; clip-path: inset(calc((1 - var(--hp, 1)) * 100%) 0 0 0); }
.fg-heart .bg { position: absolute; inset: 0; color: rgba(0, 0, 0, .45); }
.fg-heart.is-mid { color: var(--hp-mid); } .fg-heart.is-low { color: var(--hp-lo); animation: fg-throb 1.5s ease-in-out infinite; }
@keyframes fg-throb { 50% { transform: scale(1.08); } }
.fg-heart.is-hit { animation: fg-shake 320ms; }
@keyframes fg-shake { 20% { transform: translateX(-4px); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.fg-hpnum { font-size: 26px; min-width: 76px; }
.fg-hpnum small { font-size: 14px; color: var(--muted); }
.fg-hplabel { font-family: var(--font-display); font-size: 14px; color: var(--muted); }
.fg-mega { --cd: 0; position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer; padding: 0; color: var(--cream);
  background: radial-gradient(circle at 50% 40%, #6c4bd6, #321e7a 70%); box-shadow: 0 4px 0 #1c0f4a, 0 8px 18px rgba(0, 0, 0, .35); display: grid; place-items: center; }
.fg-mega::before { content: ''; position: absolute; inset: -5px; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--gold) calc((1 - var(--cd)) * 360deg), rgba(0, 0, 0, .55) 0); -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%); mask: radial-gradient(circle, transparent 60%, #000 61%); }
.fg-mega .fg-ic { width: 40px; height: 40px; }
.fg-mega .lbl { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-weight: 900; font-size: 13px; white-space: nowrap; text-shadow: 0 1px 2px #000; }
.fg-mega.is-ready { animation: fg-ready 1.2s ease-in-out infinite; }
.fg-mega.is-ready .lbl { color: var(--gold); }
@keyframes fg-ready { 50% { box-shadow: 0 4px 0 #1c0f4a, 0 0 0 8px rgba(255, 210, 90, .35), 0 0 28px rgba(255, 210, 90, .7); } }
.fg-mega[aria-disabled="true"] { filter: saturate(.5) brightness(.85); cursor: default; }
.fg-mega .cdnum { position: absolute; font-weight: 900; font-size: 20px; text-shadow: 0 2px 2px #000; }
.fg-hud-br { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fg-next { min-height: 56px; font-size: 18px; padding: 8px 22px; }
.fg-next .bonus { color: #2a1a00; background: rgba(255, 255, 255, .5); border-radius: 99px; padding: 0 8px; font-size: 15px; }
.fg-next small { font-weight: 700; opacity: .8; font-size: 13px; }
.fg-wp { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; max-width: 420px; }
.fg-wp-title { font-family: var(--font-display); font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; }
.fg-wp-lane { display: flex; align-items: center; gap: 6px; }
.fg-wp-lane > span { font-size: 12px; font-weight: 800; color: var(--muted); min-width: 46px; }
.fg-eicon { position: relative; width: 44px; height: 44px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); display: grid; place-items: center; cursor: help; padding: 0; }
.fg-eicon svg.portrait { width: 34px; height: 34px; }
.fg-eicon .n { position: absolute; right: -4px; bottom: -6px; font-size: 12px; font-weight: 900; background: var(--solid); border-radius: 99px; padding: 0 5px; border: 1px solid var(--line); }
.fg-eicon.is-boss { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(255, 90, 74, .35); }
.fg-codexbar { position: absolute; left: 0; top: 50%; transform: translateY(-50%); display: flex; align-items: stretch; pointer-events: none; }
.fg-codexbar > * { pointer-events: auto; }
.fg-codexbar .tab { writing-mode: vertical-rl; border-radius: 0 16px 16px 0; min-height: 110px; min-width: 44px; padding: 12px 8px; }
.fg-codexbar .list { display: none; flex-direction: column; gap: 6px; padding: 10px; max-height: 60vh; overflow: auto; border-radius: 0 var(--r-pad) var(--r-pad) 0; }
.fg-codexbar.is-open .list { display: flex; }
.fg-codexbar .list button { justify-content: flex-start; min-width: 200px; }

/* off-screen threat arrows */
.fg-arrow { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; color: var(--danger); display: none; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }
.fg-arrow .fg-ic { width: 100%; height: 100%; }
.fg-arrow .b { position: absolute; inset: 9px; display: grid; place-items: center; color: #fff; }
.fg-arrow .b .fg-ic { width: 18px; height: 18px; }

/* pad hotspots: keyboard focus targets that follow the pads (pointer clicks go to A's raycast picking) */
.fg-pads { position: absolute; inset: 0; }
.fg-pad { position: absolute; left: 0; top: 0; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; border: 0; background: transparent; pointer-events: none; padding: 0; }
.fg-pad:focus-visible { outline: 3px dashed #ffe27a; outline-offset: 2px; background: rgba(255, 226, 122, .12); }

/* ---------- radial build menu ---------- */
.fg-radial { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.fg-radial-in { position: absolute; left: 0; top: 0; transform: scale(var(--ui-scale)); }
.fg-radial .ring { position: absolute; left: 0; top: 0; border-radius: 50%; border: 2px dashed rgba(246, 239, 217, .25); transform: translate(-50%, -50%); }
.fg-radial .ico { position: absolute; left: 0; top: 0; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; pointer-events: auto; cursor: pointer;
  border: 2px solid rgba(246, 239, 217, .35); background: radial-gradient(circle at 50% 35%, #3b8f6a, #1a4a3c 75%); display: grid; place-items: center; padding: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .4); animation: fg-bloom 240ms var(--spring) both; animation-delay: calc(var(--i) * 14ms); }
@keyframes fg-bloom { from { transform: translate(var(--fx), var(--fy)) scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.fg-radial .ico svg.portrait { width: 40px; height: 40px; }
.fg-radial .ico .cost { position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); font-size: 12px; font-weight: 900; background: var(--solid); padding: 0 6px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; color: var(--gold); }
.fg-radial .ico .key { position: absolute; top: -6px; left: -6px; font-size: 11px; font-weight: 900; background: #f6efd9; color: var(--ink); border-radius: 6px; min-width: 18px; padding: 0 3px; text-align: center; }
.fg-radial .ico .dt { position: absolute; top: -4px; right: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--solid); display: grid; place-items: center; }
.fg-radial .ico .dt .fg-ic { width: 14px; height: 14px; }
.fg-radial .ico.is-poor { filter: grayscale(.85) brightness(.7); }
.fg-radial .ico.is-poor .cost { color: #ff8b7b; text-decoration: line-through; text-decoration-thickness: 2px; }
.fg-radial .ico.is-new::after { content: attr(data-new); position: absolute; top: -12px; left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; font-size: 10px; font-weight: 900; padding: 0 5px; border-radius: 6px; }
.fg-radial .hint { position: absolute; left: 0; top: 0; transform: translate(-50%, 0); white-space: nowrap; font-size: 13px; font-weight: 800; padding: 4px 10px; border-radius: 99px; background: rgba(0, 0, 0, .55); }
.fg-radial .x { position: absolute; left: 0; top: 0; width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: auto; }

/* tooltip card */
.fg-tip { position: absolute; left: 0; top: 0; width: 290px; padding: 12px 14px; pointer-events: none; z-index: 5; font-size: 14px; animation: fg-fade 140ms both; }
.fg-tip h4 { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 1.1; }
.fg-tip .role { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.fg-tip .stats { display: grid; grid-template-columns: repeat(4, auto); gap: 2px 12px; margin: 6px 0; }
.fg-tip .stats b { display: block; font-size: 11px; color: var(--muted); font-weight: 800; text-transform: uppercase; }
.fg-tip .desc { margin: 6px 0; }
.fg-tip .vs { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 12px; margin-top: 4px; }
.fg-tip .vs b { font-size: 11px; color: var(--muted); text-transform: uppercase; margin-right: 2px; }
.fg-tip .good { color: var(--ok); } .fg-tip .bad { color: var(--danger); }

/* tower panel */
.fg-tp { position: absolute; right: 16px; top: 0; bottom: 0; margin: auto 0; height: fit-content; width: 340px; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px;
  /* Vertically centred WITHOUT transform (the fg-pop entrance animation owns `transform` and used to cancel translateY(-50%), pushing the panel's lower half off-screen).
     Always fits the viewport (zoom-aware); compacts on short screens and scrolls inside only as a last resort. */
  max-height: calc(100vh / var(--ui-scale, 1) - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
/* short screens (JS-set, zoom-aware): compact panel; tiny (501–620 css px): two columns; phone (<=500): compact dock, never the 600px two-column. */
.fg-short .fg-tp { gap: 6px; padding: 10px 14px 12px; }
.fg-short .fg-tp .fg-branch svg.art { display: none; } .fg-short .fg-tp .fg-branch { padding: 8px; } .fg-short .fg-tp-head svg.portrait { width: 44px; height: 44px; }
.fg-tiny .fg-tp { display: block; column-count: 2; column-gap: 14px; width: min(600px, calc(100vw / var(--ui-scale, 1) - 24px)); }
.fg-tiny .fg-tp > * { break-inside: avoid; margin-bottom: 6px; }
/* Landscape-phone dock: short right-bottom panel, branch cards in a snapping horizontal row, play area stays visible. */
.fg-phone .fg-tp {
  display: flex; flex-direction: column; column-count: auto; width: min(360px, calc(100vw / var(--ui-scale, 1) - 16px));
  max-width: calc(100vw / var(--ui-scale, 1) - 16px); max-height: min(200px, calc(100vh / var(--ui-scale, 1) - 88px));
  right: 8px; left: auto; top: 72px; bottom: auto; margin: 0; height: auto; padding: 8px 10px; gap: 6px;
  overflow-x: hidden; overflow-y: auto;
}
.fg-phone .fg-tp button { min-width: 44px; min-height: 44px; flex-shrink: 0; box-sizing: border-box; }
.fg-phone .fg-tp > * { flex-shrink: 0; }
.fg-phone .fg-tp-stats, .fg-phone .fg-tp > .fg-h2, .fg-phone .fg-tp > .fg-muted { display: none; }
.fg-phone .fg-tp-head h3 { font-size: 16px; line-height: 1.1; }
.fg-phone .fg-pips { margin-top: 2px; }
.fg-phone .fg-branches { display: flex; flex-flow: row nowrap; gap: 8px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.fg-phone .fg-branch { flex: 0 0 auto; width: 160px; min-width: 160px; min-height: 44px; scroll-snap-align: start; scroll-margin-inline: 8px; padding: 6px 10px; }
.fg-phone .fg-branch svg.art, .fg-phone .fg-branch p { display: none; }
.fg-phone .fg-tp-row > .fg-btn { min-height: 44px; }
.fg-tp-head { display: flex; gap: 10px; align-items: center; }
.fg-tp-head svg.portrait { width: 54px; height: 54px; flex: none; }
.fg-tp-head h3 { margin: 0; font-family: var(--font-display); font-size: 22px; line-height: 1.05; }
.fg-pips { display: flex; gap: 4px; margin-top: 4px; }
.fg-pips i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--gold); }
.fg-pips i.on { background: var(--gold); }
.fg-pips i.br { border-radius: 4px; }
.fg-tp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 14px; }
.fg-tp-stats > div { background: rgba(0, 0, 0, .22); border-radius: 12px; padding: 6px 8px; }
.fg-tp-stats b { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; }
.fg-delta { color: var(--ok); font-weight: 900; font-size: 12px; margin-left: 3px; }
.fg-tp-row { display: flex; gap: 8px; align-items: stretch; }
.fg-tp-row > .fg-btn { flex: 1; }
.fg-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fg-branch { text-align: left; padding: 10px; border-radius: 16px; border: 2px solid var(--line); background: rgba(0, 0, 0, .25); cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 44px; color: var(--cream); }
.fg-branch svg.art { width: 100%; height: 54px; }
.fg-branch h5 { margin: 0; font-family: var(--font-display); font-size: 17px; line-height: 1.05; }
.fg-branch p { margin: 0; font-size: 12px; color: var(--muted); }
.fg-branch .s { font-size: 12px; font-weight: 800; }
.fg-branch[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 210, 90, .3); }
.fg-tp .full { color: var(--gold); font-weight: 900; }

/* boss bar */
.fg-boss { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); width: min(560px, 46vw); padding: 8px 14px 12px; display: none; }
.fg-boss.is-on { display: block; animation: fg-pop 260ms var(--spring) both; }
.fg-boss .name { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-display); font-size: 20px; }
.fg-boss .bar { position: relative; height: 16px; border-radius: 99px; background: rgba(0, 0, 0, .5); overflow: hidden; margin-top: 4px; }
.fg-boss .bar i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; }
.fg-boss .trail { background: #ffefc2; width: calc(var(--trail, 1) * 100%); }
.fg-boss .hp { background: linear-gradient(90deg, #ff5a4a, #ff9a3c); width: calc(var(--hp, 1) * 100%); }
.fg-boss .pip { position: absolute; top: -2px; bottom: -2px; width: 3px; background: var(--cream); border-radius: 2px; }
.fg-boss .phases { display: flex; gap: 4px; }
.fg-boss .phases i { width: 12px; height: 12px; transform: rotate(45deg); border: 2px solid var(--danger); }
.fg-boss .phases i.on { background: var(--danger); }

/* banners + letterbox */
.fg-banner { position: absolute; left: 0; right: 0; top: 28%; text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 64px; letter-spacing: .04em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, .45), 0 0 30px rgba(0, 0, 0, .4); pointer-events: none; animation: fg-banner 2.2s var(--spring) both; }
.fg-banner.is-boss { color: #ffd0c8; font-size: 52px; }
@keyframes fg-banner { 0% { opacity: 0; transform: scale(1.6); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
.fg-letterbox::before, .fg-letterbox::after { content: ''; position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 400ms ease; z-index: 1; }
.fg-letterbox::before { top: 0; } .fg-letterbox::after { bottom: 0; }
.fg-letterbox.is-on::before, .fg-letterbox.is-on::after { height: 9vh; }
.fg-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 120px 30px rgba(255, 40, 30, .65); transition: opacity 120ms; }
.fg-vignette.is-low { animation: fg-vig 1.5s ease-in-out infinite; }
@keyframes fg-vig { 0%, 100% { opacity: .15; } 50% { opacity: .55; } }
.fg-flash { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, rgba(255, 255, 240, .9), rgba(255, 255, 255, .25)); opacity: 0; }
.fg-flash-reduced .fg-flash { display: none; }
.fg-flash-reduced .fg-vignette { box-shadow: inset 0 0 90px 10px rgba(255, 40, 30, .35); }
.fg-float { position: absolute; left: 0; top: 0; font-weight: 1000; font-size: 26px; color: #ff6b5a; text-shadow: 0 2px 0 #3a0a06, 0 0 8px rgba(0, 0, 0, .6); pointer-events: none; white-space: nowrap; }

/* captions + toasts */
.fg-captions { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; z-index: 8; }
.fg-caption { background: rgba(0, 0, 0, .78); color: #fff; padding: 4px 12px; border-radius: 8px; font-size: calc(18px * var(--ui-scale)); font-weight: 700; transition: opacity 400ms; }
.fg-caption.is-out { opacity: 0; }
.fg-toasts { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 90px; }
.fg-toast { padding: 10px 16px; font-weight: 800; animation: fg-pop 220ms var(--spring) both; }
.fg-toast.is-boss { border-color: var(--danger); } .fg-toast.is-achievement { border-color: var(--gold); }

/* ---------- full screens ---------- */
.fg-screen { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: auto; animation: fg-fade 200ms both; }
.fg-screen.is-dim { background: radial-gradient(ellipse at center, rgba(8, 24, 22, .45), rgba(8, 24, 22, .85)); }
/* Victory hold (A's 7 s victoryOrbit): panel + dim stay hidden and click-through until revealed, then fade in */
.fg-screen.is-cine { pointer-events: none; background: none; }
.fg-screen.is-cine .fg-card { visibility: hidden; }
.fg-screen[data-screen=victory]:not(.is-cine) { animation: fg-fade 700ms both; }
.fg-screen.is-solid { background: radial-gradient(ellipse at 50% 30%, #1d5546, #0b1f1c 75%); }
.fg-card { padding: 26px 30px; min-width: 340px; max-width: min(92vw, 760px); max-height: 92vh; overflow: auto; animation: fg-pop var(--t-in) var(--spring) both; }
.fg-col { display: flex; flex-direction: column; gap: 10px; }
.fg-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fg-menu .fg-btn { min-width: 240px; font-size: 20px; min-height: 52px; }

/* boot */
.fg-boot { text-align: center; }
.fg-boot .studio { font-family: var(--font-display); font-size: 22px; letter-spacing: .3em; text-transform: uppercase; opacity: 0; animation: fg-sting 1.6s ease both; }
@keyframes fg-sting { 0% { opacity: 0; letter-spacing: .6em; } 30%, 70% { opacity: 1; letter-spacing: .3em; } 100% { opacity: .75; } }
.fg-logo { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 96px; line-height: 1; margin: 18px 0 26px; color: #c8f06a; text-shadow: 0 6px 0 #1f4a1a, 0 12px 24px rgba(0, 0, 0, .4); }
.fg-logo .o { position: relative; display: inline-block; }
.fg-logo .o::before { content: ''; position: absolute; left: 50%; top: 58%; width: 1.1em; height: .36em; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(ellipse at 40% 40%, #58b85a, #2b6b2e); z-index: -1; }
.fg-logo .hopper { position: absolute; left: 50%; top: -.55em; width: .5em; height: .5em; margin-left: -.25em; color: #7ee070; animation: fg-hop 1.4s .8s var(--spring) both; }
.fg-logo .hopper .fg-ic { width: 100%; height: 100%; }
@keyframes fg-hop { 0% { transform: translate(-2.2em, .6em) scale(.6); opacity: 0; } 50% { transform: translate(-1em, -.8em); opacity: 1; } 100% { transform: translate(0, .05em); opacity: 1; } }
.fg-prog { position: relative; width: min(460px, 80vw); height: 26px; border-radius: 99px; background: rgba(0, 0, 0, .35); margin: 0 auto; }
.fg-prog .water { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(90deg, #1c6a74, #3fb6a8); clip-path: inset(0 calc((1 - var(--p, 0)) * 100%) 0 0); }
.fg-prog .tad { position: absolute; top: 50%; left: calc(var(--p, 0) * 100%); width: 44px; height: 44px; transform: translate(-50%, -50%); }
.fg-prog-label { margin-top: 12px; color: var(--muted); font-weight: 700; }

/* title */
.fg-title { text-align: center; align-self: end; margin-bottom: 8vh; }
.fg-title .fg-logo { font-size: 110px; margin-bottom: 6px; }
.fg-title .tag { font-family: var(--font-display); font-size: 24px; margin-bottom: 18px; color: var(--cream); text-shadow: 0 2px 4px #000; }

/* world map */
.fg-map { width: min(1180px, 96vw); height: min(720px, 90vh); position: relative; padding: 0; overflow: hidden; display: grid; grid-template-columns: 1fr 340px; }
.fg-map-art { position: relative; background: radial-gradient(ellipse at 40% 40%, #f3e2b8, #d9bd83 70%, #b8935a); border-radius: var(--r-pad) 0 0 var(--r-pad); }
.fg-map-art svg.paper { position: absolute; inset: 0; width: 100%; height: 100%; }
.fg-map-head { position: absolute; left: 18px; top: 14px; right: 18px; display: flex; justify-content: space-between; align-items: center; color: #3a2a10; z-index: 2; }
.fg-map-head .fg-h2 { margin: 0; color: #3a2a10; text-shadow: none; }
.fg-map-head .fg-chip { background: rgba(58, 42, 16, .14); color: #3a2a10; font-size: 15px; }
.fg-node { position: absolute; width: 92px; margin-left: -46px; margin-top: -46px; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 0; cursor: pointer; color: #2a1c08; }
.fg-node .thumb { width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff7dc; box-shadow: 0 4px 0 rgba(58, 42, 16, .45), 0 8px 14px rgba(0, 0, 0, .25); overflow: hidden; position: relative; transition: transform 160ms var(--spring); }
.fg-node:hover .thumb, .fg-node[aria-pressed="true"] .thumb { transform: scale(1.1); }
.fg-node[aria-pressed="true"] .thumb { border-color: var(--gold); }
.fg-node .thumb svg { width: 100%; height: 100%; display: block; }
.fg-root .fg-node { color: #2a1c08; } /* beat `.fg-root button {color:inherit}` so labels are dark on the cream pills */
.fg-node .nm { font-family: var(--font-display); font-weight: 800; font-size: 13px; background: rgba(255, 247, 220, .92); border-radius: 99px; padding: 0 8px; white-space: nowrap; }
.fg-node .st { display: flex; gap: 1px; color: #b98a10; } .fg-node .st .fg-ic { width: 16px; height: 16px; } .fg-node .st .off { color: rgba(58, 42, 16, .35); }
.fg-node .lk { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: 40px; height: 40px; border-radius: 50%; background: rgba(30, 22, 10, .78); color: #fff; display: grid; place-items: center; }
.fg-node .req { font-size: 11px; font-weight: 900; color: #5a1a0a; background: rgba(255, 247, 220, .92); border-radius: 6px; padding: 0 4px; }
.fg-node .endless { position: absolute; top: -4px; right: 0; font-size: 10px; font-weight: 900; background: #6c4bd6; color: #fff; border-radius: 6px; padding: 1px 5px; }
.fg-node.is-locked .thumb { filter: grayscale(.85) brightness(.75); }
.fg-levelcard { padding: 18px; display: flex; flex-direction: column; gap: 10px; border-radius: 0 var(--r-pad) var(--r-pad) 0; background: var(--glass-2); overflow: auto; }
.fg-levelcard .loc { color: var(--muted); font-size: 14px; margin-top: -6px; }
.fg-seg { display: flex; gap: 4px; background: rgba(0, 0, 0, .25); padding: 4px; border-radius: 999px; }
.fg-seg button { flex: 1; min-height: 44px; border-radius: 999px; border: 0; background: transparent; cursor: pointer; font-weight: 800; font-size: 14px; }
.fg-seg button[aria-pressed="true"] { background: var(--cream); color: var(--ink); }
.fg-icons { display: flex; flex-wrap: wrap; gap: 6px; }

/* victory / defeat */
.fg-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.fg-stars .s { width: 76px; height: 76px; color: rgba(0, 0, 0, .35); }
.fg-stars .s .fg-ic { width: 100%; height: 100%; }
.fg-stars .s.on { color: var(--gold); animation: fg-starin 520ms var(--spring) both; animation-delay: calc(var(--i) * 450ms + 200ms); filter: drop-shadow(0 0 12px rgba(255, 210, 90, .6)); }
@keyframes fg-starin { from { transform: scale(2.6) rotate(-40deg); opacity: 0; } to { transform: none; opacity: 1; } }
.fg-statgrid { display: grid; grid-template-columns: repeat(2, minmax(140px, 1fr)); gap: 8px; margin: 8px 0 16px; }
.fg-statgrid > div { background: rgba(0, 0, 0, .22); border-radius: 14px; padding: 8px 12px; }
.fg-statgrid b { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.fg-statgrid .v { font-size: 24px; font-weight: 900; }
.fg-mvp { display: flex; gap: 10px; align-items: center; } .fg-mvp svg.portrait { width: 48px; height: 48px; }
.fg-tip-box { background: rgba(255, 210, 90, .12); border: 1px solid rgba(255, 210, 90, .35); border-radius: 14px; padding: 10px 12px; margin: 8px 0 14px; max-width: 520px; }

/* settings */
.fg-settings { width: min(760px, 94vw); }
.fg-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.fg-tabs [role="tab"] { min-height: 44px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; cursor: pointer; font-weight: 800; }
.fg-tabs [role="tab"][aria-selected="true"] { background: var(--cream); color: var(--ink); }
.fg-field { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); min-height: 52px; }
.fg-field label, .fg-field .lab { font-weight: 700; }
.fg-field input[type="range"] { width: 220px; height: 44px; accent-color: var(--gold); cursor: pointer; }
.fg-field select { min-height: 44px; min-width: 180px; border-radius: 12px; background: var(--solid); border: 1px solid var(--line); padding: 0 10px; }
.fg-toggle { position: relative; width: 64px; height: 44px; border: 0; background: none; cursor: pointer; padding: 0; }
.fg-toggle::before { content: ''; position: absolute; left: 4px; top: 8px; width: 56px; height: 28px; border-radius: 99px; background: rgba(0, 0, 0, .4); border: 1px solid var(--line); }
.fg-toggle::after { content: ''; position: absolute; left: 8px; top: 12px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 160ms var(--spring); }
.fg-toggle[aria-checked="true"]::before { background: #2f7a5c; } .fg-toggle[aria-checked="true"]::after { transform: translateX(28px); background: var(--cream); }
.fg-toggle span { position: absolute; right: -2px; top: 13px; font-size: 0; }
.fg-kbd { display: inline-block; min-width: 44px; text-align: center; padding: 4px 8px; border-radius: 8px; background: var(--cream); color: var(--ink); font-weight: 900; font-size: 14px; }

/* codex */
.fg-card.fg-codex { max-width: 96vw; }
.fg-codex { width: min(1000px, 96vw); height: min(680px, 90vh); display: grid; grid-template-columns: 280px 1fr; grid-template-rows: auto 1fr; gap: 12px; }
.fg-codex .hd { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.fg-codex .lst { overflow: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.fg-codex .lst button { display: flex; align-items: center; gap: 8px; min-height: 48px; border-radius: 14px; border: 1px solid transparent; background: rgba(0, 0, 0, .2); cursor: pointer; text-align: left; padding: 4px 10px; color: var(--cream); }
.fg-codex .lst button[aria-selected="true"] { border-color: var(--gold); background: rgba(255, 210, 90, .1); }
.fg-codex .lst svg.portrait { width: 36px; height: 36px; }
.fg-codex .det { display: grid; grid-template-columns: 300px 1fr; gap: 14px; overflow: auto; align-content: start; }
.fg-codex .turntable { width: 300px; height: 300px; border-radius: 22px; background: radial-gradient(circle at 50% 40%, #2c6c5a, #0e2a24); overflow: hidden; }
.fg-codex .turntable canvas { width: 100% !important; height: 100% !important; display: block; }

/* reduced motion: no springs/loops (functionally identical) */
.fg-reduced-motion *, .fg-reduced-motion *::before, .fg-reduced-motion *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
.fg-reduced-motion .fg-mega.is-ready { box-shadow: 0 4px 0 #1c0f4a, 0 0 0 6px rgba(255, 210, 90, .55); }

/* portrait / small / touch layouts */
@media (max-aspect-ratio: 1/1), (max-width: 760px) {
  .fg-hud-bc { bottom: 10px; gap: 10px; padding: 8px 12px; }
  .fg-hud-br { bottom: 120px; }
  .fg-wp { max-width: 70vw; }
  .fg-tp { right: 8px; left: 8px; top: auto; bottom: 120px; margin: 0; height: auto; width: auto; max-height: calc(100vh / var(--ui-scale, 1) - 190px); }
  /* Landscape-phone class wins over the portrait full-width sheet (e.g. 667x375 is both narrow and short). */
  .fg-phone .fg-tp { display: flex; flex-direction: column; column-count: auto; right: 8px; left: auto; top: 72px; bottom: auto; margin: 0; height: auto;
    width: min(360px, calc(100vw / var(--ui-scale, 1) - 16px)); max-width: calc(100vw / var(--ui-scale, 1) - 16px);
    max-height: min(200px, calc(100vh / var(--ui-scale, 1) - 88px)); }
  .fg-map { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .fg-levelcard { border-radius: 0 0 var(--r-pad) var(--r-pad); max-height: 45vh; }
  .fg-codex { grid-template-columns: 1fr; }
  .fg-codex .det { grid-template-columns: 1fr; }
  .fg-boss { width: 70vw; top: 74px; }
}
@media (pointer: coarse) { .fg-radial .ico { width: 60px; height: 60px; margin: -30px 0 0 -30px; } }

/* level intro: Skip button (when A exposes actions.skipIntro) or a non-interactive hint */
.fg-intro-hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); padding: 6px 16px; border-radius: 99px; background: rgba(0, 0, 0, .55); color: #fff; font-weight: 800; font-size: 14px; pointer-events: none; animation: fg-fade 300ms both; }
.fg-skip-intro { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 6; min-width: 44px; min-height: 44px; }
