/* ─────────────────────────────────────────────────────────────────────────────
   ARTIFICER FOUNDRIES — base styles (site 2: the Toy Box)
   Tokens, type, chrome (header, footer, jar, toasts, cabinet), shared components.
   Page styles live in css/pages/<page>.css, floor styles in css/floors/<floor>.css.
   ───────────────────────────────────────────────────────────────────────────── */

@font-face { font-family: 'Fredoka'; font-weight: 400; font-display: swap; src: url('../fonts/fredoka-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 500; font-display: swap; src: url('../fonts/fredoka-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 600; font-display: swap; src: url('../fonts/fredoka-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Fredoka'; font-weight: 700; font-display: swap; src: url('../fonts/fredoka-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url('../fonts/nunito-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 400; font-style: italic; font-display: swap; src: url('../fonts/nunito-latin-400-italic.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url('../fonts/nunito-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url('../fonts/nunito-latin-800-normal.woff2') format('woff2'); }
@font-face { font-family: 'Press Start 2P'; font-weight: 400; font-display: swap; src: url('../fonts/press-start-2p-latin-400-normal.woff2') format('woff2'); }

:root {
  /* Brand palette (fixed, used by art) */
  --night: #151B2E;
  --night-2: #1B2238;
  --soot: #232A40;
  --soot-2: #2C3450;
  --soot-3: #39425F;
  --ember: #FF6B1A;
  --ember-2: #FF8A3D;
  --molten: #FFC23D;
  --brass: #C8A15A;
  --steam: #4FD1C5;
  --cream: #FFF3DF;
  --outline: #0D1120;          /* the thick cartoon outline on all art */
  --pink: #FF5ACD;
  --green: #3BD16F;
  --violet: #7C5CFF;

  /* Semantic tokens (UI chrome; flip for light mode) */
  --bg: var(--night);
  --bg-2: var(--night-2);
  --panel: var(--soot);
  --panel-2: var(--soot-2);
  --line: var(--soot-3);
  --fg: var(--cream);
  --fg-muted: #B7B9CC;
  --link: var(--steam);
  --accent: var(--ember);
  --on-accent: #1A1208;
  --ok: #3BD16F;
  --bad: #FF5A5A;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --glow: 0 0 24px rgba(255, 107, 26, .45);

  /* Type */
  --font-display: 'Fredoka', 'Nunito', ui-rounded, system-ui, sans-serif;
  --font-body: 'Nunito', ui-rounded, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-pixel: 'Press Start 2P', ui-monospace, monospace;
  --step--1: clamp(.84rem, .8rem + .15vw, .92rem);
  --step-0: clamp(1rem, .96rem + .2vw, 1.1rem);
  --step-1: clamp(1.2rem, 1.1rem + .5vw, 1.45rem);
  --step-2: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --step-3: clamp(2rem, 1.6rem + 2vw, 3rem);
  --step-4: clamp(2.6rem, 1.9rem + 3.6vw, 4.6rem);
  --step-5: clamp(3.2rem, 2.2rem + 5.4vw, 6.4rem);

  /* Shape & motion */
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --stroke: 3px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --bounce: cubic-bezier(.68, -0.55, .27, 1.55);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --head-h: 68px;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1200px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) body:not(.is-home) {
    --bg: #FFF6E8;
    --bg-2: #FFEFD6;
    --panel: #FFFFFF;
    --panel-2: #FFF3E0;
    --line: #EBDDC4;
    --fg: #1D2238;
    --fg-muted: #5A5F75;
    --link: #0B7F77;
    --shadow: 0 10px 30px rgba(60, 40, 10, .12);
    --kicker: #A34E00;
    color-scheme: light;
  }
}

/* ── reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--head-h) + 12px); }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--fg);
  font: 400 var(--step-0)/1.6 var(--font-body);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 2px; }
a:hover { color: var(--molten); }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0 0 .5em; letter-spacing: .005em; text-wrap: balance; }
h1 { font-size: var(--step-4); font-weight: 700; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }
p { margin: 0 0 1em; text-wrap: pretty; }
small, .small { font-size: var(--step--1); }
code, kbd { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .92em; background: var(--panel-2); padding: .1em .35em; border-radius: 6px; }
kbd { border: 1px solid var(--line); border-bottom-width: 3px; }
hr { border: 0; border-top: 2px dashed var(--line); margin: 2rem 0; }
[hidden] { display: none !important; }
::selection { background: var(--ember); color: #fff; }

:focus-visible { outline: 3px solid var(--molten); outline-offset: 3px; border-radius: 6px; box-shadow: 0 0 0 6px rgba(255, 107, 26, .35); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 1000; background: var(--molten); color: var(--outline); padding: .6em 1em; border-radius: var(--r-sm); font-weight: 800; text-decoration: none; transition: top .2s; }
.skip:focus { top: 12px; }
.sprite { position: absolute; }
.noscript { margin: 0; padding: .8em; background: var(--panel); text-align: center; }

/* ── layout helpers ──────────────────────────────────────────────────────── */
.wrap { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }
.wrap-narrow { width: min(100% - 2 * var(--gutter), 760px); margin-inline: auto; }
.section { padding-block: clamp(48px, 8vw, 110px); }
.stack > * + * { margin-top: 1rem; }
.lede { font-size: var(--step-1); color: var(--fg-muted); max-width: 42ch; }
.kicker { font-family: var(--font-display); font-weight: 600; font-size: var(--step--1); text-transform: uppercase; letter-spacing: .14em; color: var(--kicker, var(--molten)); margin: 0 0 .6em; }
.muted { color: var(--fg-muted); }
.center { text-align: center; }
.grid { display: grid; gap: clamp(16px, 2.4vw, 28px); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.page-head { padding-top: clamp(40px, 7vw, 96px); padding-bottom: clamp(16px, 3vw, 40px); }
.page-head h1 { margin-bottom: .25em; }
.draft-tag { display: inline-block; font: 700 .7rem/1 var(--font-body); text-transform: uppercase; letter-spacing: .12em; padding: .35em .6em; border-radius: 99px; background: rgba(255, 194, 61, .16); color: var(--kicker, var(--molten)); border: 1.5px dashed color-mix(in srgb, var(--kicker, var(--molten)) 60%, transparent); vertical-align: middle; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--ember); --btn-fg: var(--on-accent); --btn-edge: #B7440B;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .7em 1.35em;
  font: 600 var(--step-0)/1 var(--font-display); letter-spacing: .01em;
  color: var(--btn-fg); background: var(--btn-bg);
  border: var(--stroke) solid var(--outline); border-radius: 999px;
  box-shadow: 0 5px 0 var(--btn-edge), 0 8px 18px rgba(0, 0, 0, .25);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: transform .18s var(--spring), box-shadow .18s var(--spring), background-color .2s;
  will-change: transform;
}
.btn:hover { color: var(--btn-fg); transform: translateY(-2px) scale(1.03); box-shadow: 0 7px 0 var(--btn-edge), 0 12px 24px rgba(0, 0, 0, .3); }
.btn:active { transform: translateY(4px) scale(.97, .94); box-shadow: 0 1px 0 var(--btn-edge), 0 3px 8px rgba(0, 0, 0, .25); transition-duration: .06s; }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }
.btn-steam { --btn-bg: var(--steam); --btn-edge: #238C84; }
.btn-molten { --btn-bg: var(--molten); --btn-edge: #B9851A; }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--fg); --btn-edge: transparent; border-color: var(--line); box-shadow: none; }
.btn-ghost:hover { border-color: var(--fg-muted); box-shadow: none; }
.btn-small { min-height: 36px; padding: .45em .95em; font-size: var(--step--1); box-shadow: 0 3px 0 var(--btn-edge); }
.btn-big { min-height: 60px; padding: .8em 1.8em; font-size: var(--step-1); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

/* chunky cartoon panel */
.panel {
  background: var(--panel); border: var(--stroke) solid var(--outline); border-radius: var(--r-lg);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35); padding: clamp(18px, 3vw, 32px);
}
body:not(.is-home) .panel { border-color: var(--line); }

/* ── forms ───────────────────────────────────────────────────────────────── */
.field { display: grid; gap: .35em; margin-bottom: 1rem; }
.field label { font-weight: 700; }
.field .err { color: var(--bad); font-weight: 700; font-size: var(--step--1); }
input[type="text"], input[type="email"], input[type="search"], input[type="password"], textarea, select {
  width: 100%; padding: .75em .9em; border-radius: var(--r-sm);
  background: var(--bg-2); border: 2px solid var(--line); color: var(--fg);
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--molten); box-shadow: 0 0 0 4px rgba(255, 194, 61, .25); }
textarea { resize: vertical; min-height: 8em; }
.hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
.switch { display: flex; align-items: center; gap: .6em; padding: .45em 0; cursor: pointer; }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 99px; background: var(--soot-3); border: 2px solid var(--outline); position: relative; flex: none; cursor: pointer; transition: background .2s; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--cream); transition: transform .25s var(--spring); }
.switch input:checked { background: var(--ember); }
.switch input:checked::after { transform: translateX(20px); }

/* ── header ──────────────────────────────────────────────────────────────── */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 95%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--line) 70%, transparent);
  transition: background .3s;
}
.head-inner { width: min(100% - 2 * var(--gutter), 1360px); margin-inline: auto; height: var(--head-h); display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); flex: none; }
.brand:hover { color: var(--fg); }
.brand-mark { width: 40px; height: 40px; color: var(--brass); transition: transform .5s var(--spring); }
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.08); }
.wordmark { display: flex; align-items: baseline; font: 700 1.35rem/1 var(--font-display); letter-spacing: .06em; white-space: nowrap; }
.wm-a { display: inline-block; width: .82em; height: 1em; position: relative; margin-right: .02em; color: var(--brass); transform-origin: 50% 100%; }
.wm-a-glyph { width: 100%; height: 100%; overflow: visible; transition: opacity .15s; }
.wm-a.is-out .wm-a-glyph { opacity: 0; }
.wm-a.is-out::after { content: ''; position: absolute; inset: 8% 6% 0; border: 2px dashed color-mix(in srgb, var(--brass) 70%, transparent); border-radius: 40% 40% 4px 4px; opacity: .8; }
.wm-rest { margin-right: .35em; }
.wm-b { font-weight: 500; color: var(--brass); letter-spacing: .12em; font-size: .78em; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: .5em .9em; border-radius: 99px; text-decoration: none;
  font: 600 1rem/1 var(--font-display); color: var(--fg); letter-spacing: .02em;
  transition: background .2s, transform .25s var(--spring), color .2s;
}
.site-nav a:hover { background: var(--panel); color: var(--molten); transform: translateY(-2px) rotate(-2deg); }
.site-nav a[aria-current="page"] { background: var(--ember); color: var(--on-accent); }
.head-tools { display: flex; gap: 6px; align-items: center; }
.tool {
  display: inline-flex; align-items: center; gap: .4em; height: 40px; min-width: 40px; padding: 0 10px;
  border-radius: 99px; border: 2px solid var(--line); background: transparent; color: var(--fg);
  font: 600 .85rem/1 var(--font-display); transition: transform .25s var(--spring), border-color .2s, background .2s;
}
.tool:hover { transform: scale(1.08) rotate(-3deg); border-color: var(--molten); }
.tool svg { width: 20px; height: 20px; }
.tool[aria-pressed="true"] { background: var(--steam); color: var(--outline); border-color: var(--outline); }
.tool-menu { display: none; }

.settings {
  position: absolute; right: var(--gutter); top: calc(var(--head-h) - 4px); width: min(360px, calc(100vw - 2 * var(--gutter)));
  background: var(--panel); border: var(--stroke) solid var(--outline); border-radius: var(--r-lg); padding: 18px 20px;
  box-shadow: var(--shadow); z-index: 60; transform-origin: top right; animation: pop-in .3s var(--spring);
}
.settings-title { font-size: var(--step-1); margin-bottom: .4em; }
.settings textarea { font: .78rem/1.3 ui-monospace, monospace; min-height: 0; }
.settings summary { cursor: pointer; font-weight: 700; margin-top: .6em; }
.settings .row { display: flex; gap: 8px; margin: .5em 0; flex-wrap: wrap; }
.settings { max-height: calc(100dvh - var(--head-h) - 16px); overflow-y: auto; overscroll-behavior: contain; }
.acct-box { margin: 0 0 .8em; padding: 12px 14px; border-radius: var(--r-sm); background: var(--bg-2); border: 2px solid var(--line); }
.acct-box.is-in { border-color: color-mix(in srgb, var(--steam) 55%, transparent); }
.acct-line { margin: 0 0 .2em; line-height: 1.3; }
.acct-box .small { margin: 0 0 .4em; color: var(--fg-muted); }
.acct-dot { display: inline-block; width: 9px; height: 9px; margin-right: .45em; border-radius: 50%; background: var(--steam); box-shadow: 0 0 0 3px color-mix(in srgb, var(--steam) 25%, transparent); vertical-align: 1px; }
.acct-google { min-height: 44px; margin: .5em 0 .1em; color-scheme: light; }
.reset-zone { margin-top: .9em; padding-top: .7em; border-top: 2px dashed var(--line); }
.reset-open { appearance: none; background: none; border: 0; padding: .2em 0; font: 700 var(--step--1)/1.3 var(--font-body); color: var(--fg-muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.reset-open:hover, .reset-open[aria-expanded="true"] { color: var(--bad); }
.reset-warn { margin-top: .5em; padding: 12px 14px; border-radius: var(--r-sm); border: 2px solid var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); animation: pop-in .25s var(--spring); }
.reset-warn p { margin: 0 0 .35em; }
.btn-danger { --btn-bg: var(--bad); --btn-fg: #fff; --btn-edge: #A52A2A; }

@media (max-width: 900px) {
  .wm-b { display: none; }
}
@media (max-width: 760px) {
  :root { --head-h: 60px; }
  .tool-menu { display: inline-flex; }
  .tool-sound .tool-label { display: none; }
  .site-nav { position: absolute; left: 0; right: 0; top: var(--head-h); margin: 0; background: var(--bg); border-bottom: 2px solid var(--line); padding: 8px var(--gutter) 16px; display: none; }
  .site-nav.is-open { display: block; animation: drop-in .35s var(--spring); }
  .site-nav ul { flex-direction: column; }
  .site-nav a { font-size: 1.25rem; padding: .7em .9em; }
  .head-tools { margin-left: auto; }
  .wordmark { font-size: 1.15rem; }
}
@media (max-width: 380px) {
  .brand-mark { display: none; }
}

/* ── footer ──────────────────────────────────────────────────────────────── */
.site-foot { border-top: 2px solid var(--line); background: var(--bg-2); padding: 40px 0 110px; margin-top: 0; }
.foot-inner { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; display: grid; gap: 20px; }
.foot-brand { display: flex; gap: 14px; align-items: center; color: var(--fg-muted); }
.foot-brand img { width: 48px; height: 48px; flex: none; }
.foot-brand p { margin: 0; }
.foot-nav, .foot-social { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot-nav a, .foot-social a { color: var(--fg); text-decoration: none; font-weight: 700; display: inline-block; transition: transform .25s var(--spring), color .2s; }
.foot-nav a:hover, .foot-social a:hover { color: var(--molten); transform: translateY(-3px) rotate(-3deg); }
.coffee { font-variant-numeric: tabular-nums; color: var(--molten); font-weight: 800; }

/* ── the Spark Jar ───────────────────────────────────────────────────────── */
.jar {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 70;
  width: 64px; height: 80px; padding: 0; border: 0; background: none; color: var(--fg);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
  transition: transform .3s var(--spring); touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  --glow-a: 0;
}
.jar:hover { transform: scale(1.08) rotate(-4deg); }
.jar:active { transform: scale(.94); }
.jar.is-bump { animation: jar-bump .6s var(--spring); }
.jar::before { /* the glow inside */
  content: ''; position: absolute; left: 10px; right: 10px; bottom: 6px; top: 22px; border-radius: 12px 12px 18px 18px;
  background: radial-gradient(ellipse at 50% 80%, rgba(255, 194, 61, calc(.25 + var(--glow-a) * .6)), rgba(255, 107, 26, calc(var(--glow-a) * .5)) 55%, transparent 80%);
  filter: blur(2px);
}
.jar-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.jar-sparks { position: absolute; left: 12px; right: 12px; bottom: 8px; top: 24px; overflow: hidden; border-radius: 10px 10px 16px 16px; }
.jar-sparks i { position: absolute; width: 7px; height: 9px; border-radius: 50% 50% 45% 45%; background: radial-gradient(circle at 50% 65%, #FFF3DF, #FFC23D 45%, #FF6B1A 80%); box-shadow: 0 0 6px #FFC23D; animation: jar-bob 2.4s ease-in-out infinite; }
.jar-count { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); background: var(--outline); color: var(--cream); border-radius: 99px; padding: 3px 8px; font: 700 .78rem/1 var(--font-display); white-space: nowrap; border: 2px solid var(--molten); }
.jar-count span { opacity: .7; }

@keyframes jar-bob { 0%, 100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.1); } }
@keyframes jar-bump { 0% { transform: scale(1); } 30% { transform: scale(1.25, .85); } 55% { transform: scale(.9, 1.15) translateY(-6px); } 100% { transform: scale(1); } }

/* ── toasts (achievements + notes) ───────────────────────────────────────── */
.toasts { position: fixed; z-index: 200; right: max(12px, env(safe-area-inset-right)); bottom: 108px; display: flex; flex-direction: column-reverse; gap: 10px; align-items: flex-end; pointer-events: none; width: min(380px, calc(100vw - 24px)); }
.toast {
  pointer-events: auto; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  width: 100%; padding: 12px 16px 12px 12px; border-radius: var(--r);
  background: var(--soot); color: var(--cream); border: var(--stroke) solid var(--outline);
  box-shadow: 0 6px 0 rgba(0, 0, 0, .4), var(--shadow);
  animation: toast-in .55s var(--spring) both; cursor: pointer;
}
.toast.out { animation: toast-out .4s var(--ease-out) both; }
.toast.plain { grid-template-columns: 1fr; }
.toast-icon { width: 52px; height: 60px; animation: spark-dance 1.2s ease-in-out infinite; }
.toast-k { font: 700 .72rem/1 var(--font-display); text-transform: uppercase; letter-spacing: .16em; color: var(--molten); }
.toast-t { font: 600 1.2rem/1.15 var(--font-display); margin: .15em 0; }
.toast-q { font-size: .92rem; color: #D9D6E6; line-height: 1.35; }
.toast-n { font: 700 .75rem/1 var(--font-display); color: var(--steam); margin-top: .35em; }
.toast .btn { margin-top: .5em; }
.toast.ach { background: linear-gradient(135deg, #2D2340, #232A40 60%); border-color: var(--molten); box-shadow: 0 6px 0 #6B4A0B, 0 0 30px rgba(255, 194, 61, .35); }
@keyframes toast-in { 0% { transform: translateX(120%) rotate(8deg); opacity: 0; } 60% { transform: translateX(-6%) rotate(-2deg); opacity: 1; } 100% { transform: none; } }
@keyframes toast-out { to { transform: translateX(120%) rotate(6deg); opacity: 0; } }
@keyframes spark-dance { 0%, 100% { transform: rotate(-6deg) scale(1); } 50% { transform: rotate(6deg) scale(1.08, .95); } }
@keyframes pop-in { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes drop-in { 0% { transform: translateY(-16px); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* ── stage + fx layers ───────────────────────────────────────────────────── */
.stage { position: fixed; inset: 0; z-index: 65; pointer-events: none; overflow: hidden; }
.stage > * { pointer-events: auto; }
.stage > .no-hit, .stage .no-hit { pointer-events: none; }
canvas.fx-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 90; pointer-events: none; }
.shake { animation: shake .45s cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake { 10%, 90% { transform: translate(-1px, 1px); } 20%, 80% { transform: translate(3px, -2px); } 30%, 50%, 70% { transform: translate(-5px, 2px); } 40%, 60% { transform: translate(5px, -1px); } }

/* ── the cabinet (modal for games and the jar) ───────────────────────────── */
dialog.cabinet {
  --cab: #FF6B1A; --cab-2: #FFC23D;
  --bg: var(--night); --bg-2: var(--night-2); --panel: var(--soot); --panel-2: var(--soot-2); --line: var(--soot-3); --fg: var(--cream); --fg-muted: #B7B9CC; --link: var(--steam); --kicker: var(--molten);
  width: min(980px, 100vw - 24px); max-height: calc(100dvh - 24px); padding: 0; border: 0; background: transparent; color: var(--cream); overflow: visible;
}
dialog.cabinet::backdrop { background: rgba(8, 10, 20, .84); }
dialog.cabinet[open] { animation: cab-in .5s var(--spring); }
.cab-body {
  position: relative; display: flex; flex-direction: column; max-height: calc(100dvh - 24px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--cab) 85%, #000) 0%, color-mix(in srgb, var(--cab) 55%, #000) 100%);
  border: 4px solid var(--outline); border-radius: 28px 28px 20px 20px; box-shadow: 0 14px 0 rgba(0, 0, 0, .45), 0 30px 80px rgba(0, 0, 0, .6);
  padding: 12px 14px 14px;
}
.cab-marquee {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px; margin-bottom: 12px;
  background: linear-gradient(180deg, #1B1030, #10091F); border: 3px solid var(--outline); border-radius: 16px;
  box-shadow: inset 0 0 22px color-mix(in srgb, var(--cab-2) 45%, transparent);
}
.cab-title { font: 700 var(--step-2)/1 var(--font-display); color: var(--cab-2); text-shadow: 0 0 12px color-mix(in srgb, var(--cab-2) 70%, transparent), 0 3px 0 #000; margin: 0; letter-spacing: .03em; }
.cab-kicker { font: 700 .72rem/1 var(--font-display); text-transform: uppercase; letter-spacing: .16em; color: var(--cream); opacity: .8; display: block; margin-bottom: 4px; }
.cab-close { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--outline); background: var(--cream); color: var(--outline); display: grid; place-items: center; transition: transform .25s var(--spring); }
.cab-close:hover { transform: rotate(90deg) scale(1.1); }
.cab-close svg { width: 20px; height: 20px; }
.cab-screen {
  position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  background: #0B0E1A; border: 4px solid var(--outline); border-radius: 18px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .06), inset 0 0 40px rgba(0, 0, 0, .8);
}
.cab-screen > .game-root { min-height: min(560px, calc(100dvh - 160px)); }
@keyframes cab-in { 0% { transform: translateY(40px) scale(.8); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* game results overlay (core/games.js) */
.game-root { position: relative; color: var(--cream); }
.gover {
  position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 10, 22, .88); animation: pop-in .35s var(--spring);
}
.gover-card { --fg: var(--cream); --fg-muted: #B7B9CC; --line: var(--soot-3); --panel: var(--soot); --bg-2: var(--night-2); --kicker: var(--molten); color: var(--cream); width: min(440px, 100%); background: var(--soot); border: var(--stroke) solid var(--outline); border-radius: var(--r-lg); padding: 22px; text-align: center; box-shadow: 0 8px 0 rgba(0, 0, 0, .4); max-height: 100%; overflow: auto; }
.gover-score { font: 700 var(--step-4)/1 var(--font-display); color: var(--molten); text-shadow: 0 4px 0 #6B3A0B; margin: .1em 0; }
.gover-best { color: var(--fg-muted); margin: 0 0 .6em; }
.gover-best.is-new { color: var(--steam); font-weight: 800; animation: pop-in .5s var(--spring); }
.gover-tickets { display: inline-flex; align-items: center; gap: .4em; font: 600 1.1rem/1 var(--font-display); color: var(--molten); margin-bottom: .8em; }
.gover-tickets svg { width: 34px; height: 22px; }
.gover-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.initials { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.initials input { width: 56px; height: 64px; text-align: center; font: 700 2rem/1 var(--font-display); text-transform: uppercase; background: var(--outline); border: 3px solid var(--molten); border-radius: 12px; color: var(--molten); padding: 0; }
.board { list-style: none; margin: 10px 0 0; padding: 0; text-align: left; font-variant-numeric: tabular-nums; }
.board li { display: grid; grid-template-columns: 2.2em 3.5em 1fr; gap: 8px; padding: 4px 8px; border-radius: 8px; font: 600 1rem/1.4 var(--font-display); }
.board li:nth-child(odd) { background: rgba(255, 255, 255, .04); }
.board li.me { background: rgba(79, 209, 197, .2); color: var(--steam); }
.board .s { text-align: right; }
.board-tabs { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.board-tabs button { border: 2px solid var(--line); background: transparent; color: var(--fg); border-radius: 99px; padding: .3em .9em; font: 600 .85rem/1 var(--font-display); }
.board-tabs button[aria-pressed="true"] { background: var(--steam); color: var(--outline); border-color: var(--outline); }

/* jar panel (inside the cabinet) */
.jarlist { padding: 18px; }
.jarlist h3 { font-size: var(--step-1); color: var(--molten); margin: 1em 0 .5em; }
.jarlist h3:first-child { margin-top: 0; }
.jarlist ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 10px; }
.jarlist li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); border: 2px solid rgba(255, 255, 255, .06); }
.jarlist li.got { background: rgba(255, 194, 61, .1); border-color: rgba(255, 194, 61, .35); }
.jarlist li svg { width: 36px; height: 44px; color: var(--fg-muted); }
.jarlist .nm { font: 600 1rem/1.15 var(--font-display); }
.jarlist .ds { font-size: .82rem; color: var(--fg-muted); line-height: 1.3; }
.jarlist .wh { display: inline-block; margin-top: 4px; font: 700 .78rem/1.2 var(--font-display); color: var(--steam); text-decoration: none; }
.jarlist .wh:hover { color: var(--molten); text-decoration: underline; }
.jarlist .tw-tip { margin: -.2em 0 .7em; font-size: .88rem; color: var(--fg-muted); line-height: 1.4; }
.tw-tip-btn { appearance: none; border: 0; background: none; padding: 0; font-family: var(--font-display); font-weight: 700; font-size: 1em; line-height: inherit; color: var(--steam); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.tw-tip-btn:hover { color: var(--molten); }
.tw-tip-touch { display: none; }
@media (hover: none) and (pointer: coarse) { .tw-tip-kb { display: none; } .tw-tip-touch { display: inline; } }
.jarlist .top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.jarlist .meter { height: 14px; border-radius: 99px; background: var(--outline); border: 2px solid var(--outline); overflow: hidden; flex: 1 1 200px; }
.jarlist .meter i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember), var(--molten)); border-radius: 99px; }

/* ── the elevator dial (home) ────────────────────────────────────────────── */
.dial {
  position: fixed; left: max(12px, env(safe-area-inset-left)); top: calc(var(--head-h) + 16px); z-index: 40;
  display: flex; flex-direction: column; gap: 6px; padding: 8px 6px; border-radius: 18px;
  background: rgba(13, 17, 32, .88); border: 2px solid var(--outline);
}
.dial a { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font: 700 .8rem/1 var(--font-display); color: var(--fg-muted); text-decoration: none; border: 2px solid transparent; transition: all .3s var(--spring); }
.dial a:hover { color: var(--cream); border-color: var(--line); }
.dial a.is-here { background: var(--molten); color: var(--outline); border-color: var(--outline); transform: scale(1.15); box-shadow: 0 0 14px rgba(255, 194, 61, .6); }
@media (max-width: 760px) { .dial { display: none; } }

/* ── home floors: shared frame (each floor styles itself in css/floors/) ─── */
.floors { position: relative; }
.floor { position: relative; min-height: 100vh; min-height: 100svh; overflow: clip; isolation: isolate; }
.floor-inner { position: relative; z-index: 2; width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; padding-block: clamp(56px, 9vh, 110px); }
.floor-slab { position: relative; z-index: 5; height: 34px; background: repeating-linear-gradient(90deg, #2A2F45 0 60px, #242940 60px 62px); border-top: 4px solid var(--outline); border-bottom: 4px solid var(--outline); box-shadow: 0 10px 20px rgba(0, 0, 0, .4); }
.floor-label { font: 700 .78rem/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; color: var(--molten); display: inline-flex; align-items: center; gap: .6em; margin-bottom: .8em; }
.floor-label b { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--molten); color: var(--outline); letter-spacing: 0; }
[data-depth] { will-change: transform; }

/* ── toy affordances ─────────────────────────────────────────────────────── */
.pokeable { cursor: pointer; transition: transform .3s var(--spring); }
.pokeable:hover { transform: scale(1.04) rotate(-1deg); }
.wobble { animation: wobble .6s var(--spring); }
@keyframes wobble { 0% { transform: rotate(0); } 25% { transform: rotate(-6deg) scale(1.05); } 50% { transform: rotate(5deg); } 75% { transform: rotate(-2deg); } 100% { transform: rotate(0); } }
.squash { animation: squash .45s var(--spring); }
@keyframes squash { 0% { transform: scale(1); } 30% { transform: scale(1.18, .82); } 60% { transform: scale(.92, 1.08); } 100% { transform: scale(1); } }

/* ── calm mode (reduced motion, by system or by switch) ──────────────────── */
html.calm *, html.calm *::before, html.calm *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important;
  transition-duration: .01ms !important; scroll-behavior: auto !important;
}
html.calm .jar-sparks i, html.calm .toast-icon { animation: none !important; }
html.calm [data-depth] { transform: none !important; }

/* ── 8-bit mode (the Konami code; tricks.css adds the rest) ──────────────── */
html.pixel { --font-display: var(--font-pixel); --font-body: var(--font-pixel); }
html.pixel body { font-size: .78rem; line-height: 1.9; }
html.pixel h1 { font-size: clamp(1.4rem, 1rem + 2vw, 2.4rem); }
html.pixel h2 { font-size: clamp(1.1rem, .9rem + 1vw, 1.6rem); }
html.pixel img, html.pixel svg, html.pixel canvas { image-rendering: pixelated; }

@media print {
  .site-head, .jar, .stage, .toasts, .dial, canvas.fx-canvas, .site-foot nav { display: none !important; }
  body { background: #fff; color: #000; }
}
