/* =========================================================
   The Workday Wizard — styles.css
   Dark mode, purple/blue accents, animated, mobile-tuned.
   ========================================================= */

/* ---------- Tokens ---------- */
:root {
  --bg: #0b0a17;
  --bg-2: #110f22;
  --surface: #181530;
  --surface-2: #1f1c3d;
  --surface-3: #272348;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);

  --text: #ECEAF7;
  --text-dim: #A8A4C7;
  /* v1.9.3 — bumped from #6f6a91 → #8b87b0 so body-mute copy clears
     WCAG AA 4.5:1 on the dark background (was ~4.0:1). Affects hints,
     empty-state line, footer, output-label, aux links. */
  --text-mute: #8b87b0;

  /* v1.9.3 — user-adjustable text scale. Bound to the A button in the
     topbar via script.js. Multiplied into the key text-size rules
     below so the page responds to user preference without breaking
     layout. Default 1.0, persisted to localStorage as wwTextScale. */
  --text-scale: 1;

  /* v1.9.4 — viewport-derived scale that grows with screen width so
     the canvas truly fills bigger monitors instead of staying small
     and centered. Floors at 1 on narrow screens (so mobile/laptop
     stay at the current sizes), grows linearly past 1600px wide.
       - 1280px viewport: scale = 1.0
       - 1600px viewport: scale = 1.0
       - 1920px viewport: scale = 1.2
       - 2560px viewport: scale = 1.6
       - 3840px viewport: scale = 2.4 (4K)
       - 5120px viewport: scale = 3.2 (5K / wide ultrawides)
     No upper cap per user preference — "grow to fill ultrawides too".

     Every size rule that should scale with the canvas multiplies by
     var(--vp-scale, 1) alongside var(--text-scale, 1). Topbar chrome
     deliberately stays fixed-size for predictability.

     IMPLEMENTATION NOTE: dividing 100vw by `1600px` (both lengths)
     yields a unitless number, which is what we need so it can be
     multiplied into other length values without unit clashes. Don't
     change `1600px` to `1600` — CSS will silently reject the rule. */
  --vp-scale: max(1, calc(100vw / 1600px));

  --accent: #8B5CF6;
  --accent-2: #3B82F6;
  --accent-3: #EC4899;
  --accent-soft: rgba(139, 92, 246, 0.18);
  --accent-glow: rgba(139, 92, 246, 0.35);
  --gold: #FFD166;

  /* --grad references the accent variables so body.level-N overrides
     automatically retint everywhere --grad is used (buttons, output
     border, badges, status bar fill, etc.) */
  --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  --grad-3: linear-gradient(135deg, var(--accent-3) 0%, var(--accent) 50%, var(--accent-2) 100%);
  --grad-soft: linear-gradient(135deg, rgba(139,92,246,0.15) 0%, rgba(59,130,246,0.10) 100%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 4px 14px rgba(0,0,0,0.25);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
          Roboto, Helvetica, Arial, sans-serif;
  --font-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;

  /* iOS safe-area handling */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------- Progression themes ----------
   Each level subtly retints the accent palette so the page evolves
   as the user casts more. L1-L3 are gentle shifts. L4 (After-Hours
   Wizard) goes magenta/red — clearly different, slightly cursed. */
body.level-1 {
  --accent:   #8B5CF6;  /* violet — default */
  --accent-2: #3B82F6;  /* blue */
}
body.level-2 {
  --accent:   #25b8ff;  /* brighter cyan-blue */
  --accent-2: #7c5cff;
  --accent-soft: rgba(37, 184, 255, 0.18);
}
body.level-3 {
  --accent:   #b77cff;  /* deeper violet */
  --accent-2: #ffd166;  /* gold accent */
  --accent-soft: rgba(183, 124, 255, 0.18);
}
body.level-4 {
  --accent:   #ff3d81;  /* magenta */
  --accent-2: #ffb000;  /* amber */
  --accent-3: #ff8a3d;  /* warm orange */
  --accent-soft: rgba(255, 61, 129, 0.20);
  --accent-glow: rgba(255, 61, 129, 0.40);
}

/* After-Hours Wizard Mode — the wizard has snapped.
   Persistent red theme once Konami / share-click unlock fires.
   Goes AFTER level-N rules so it wins the cascade no matter
   which level class is also on the body. */
body.spicy-unlocked {
  --accent:   #ff1744;       /* hot red */
  --accent-2: #ff6b1a;       /* burning orange */
  --accent-3: #ff007a;       /* hot pink */
  --accent-soft: rgba(255, 23, 68, 0.22);
  --accent-glow: rgba(255, 23, 68, 0.50);
}
/* Title gets a menacing red drop-shadow */
body.spicy-unlocked .title {
  filter: drop-shadow(0 0 14px rgba(255, 23, 68, 0.35));
}
/* Wizard mascot now radiates red */
body.spicy-unlocked .mascot {
  filter: drop-shadow(0 0 22px rgba(255, 23, 68, 0.45))
          drop-shadow(0 0 40px rgba(255, 23, 68, 0.25));
}
/* Ambient bg sparkles get a hot tint */
body.spicy-unlocked .bg-sparkles .sp {
  color: rgba(255, 120, 80, 0.7);
  filter: drop-shadow(0 0 6px rgba(255, 23, 68, 0.65));
}
/* Page background gets a faint red wash */
body.spicy-unlocked {
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(255, 23, 68, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(255, 107, 26, 0.10), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(255, 0, 122, 0.08), transparent 60%),
    var(--bg);
}
/* Output card looks slightly haunted */
body.spicy-unlocked .output-card {
  box-shadow:
    0 10px 30px rgba(255, 23, 68, 0.22),
    0 0 50px rgba(255, 23, 68, 0.08);
}

/* ---------- Spicy-mode distant lightning bolts ----------
   v1.8.4 — replaced the previous full-screen flash with discrete
   SVG zigzag bolts positioned at random spots in the upper half of
   the viewport. Each bolt sits BEHIND .wrap content (z-index 0) so
   the page text remains comfortable to read; the bolts peek through
   the page background gaps and the page margins like distant storm
   activity outside a window.

   Accessibility wins from this swap: no more whole-screen brightness
   peak. Skipped under prefers-reduced-motion via the global rule +
   JS guard. JS scheduler in script.js fires bolts every 4-9 seconds
   with a 40% chance of a tight ~300ms forked follow-up.

   Heavy blur + screen blend = atmospheric depth (looks "far" instead
   of "drawn on the foreground"). */
.distant-bolt {
  position: fixed;
  pointer-events: none;
  z-index: 0; /* behind .wrap (z-index 1) and modals */
  opacity: 0;
  filter: blur(0.8px) drop-shadow(0 0 8px rgba(220, 235, 255, 0.65));
  mix-blend-mode: screen;
  animation: distantBoltFlash 0.45s ease-out forwards;
  will-change: opacity;
}
.distant-bolt svg {
  display: block;
  width: 100%;
  height: 100%;
}
@keyframes distantBoltFlash {
  0%   { opacity: 0;    }
  12%  { opacity: 0.85; } /* primary illumination */
  25%  { opacity: 0.25; } /* dip */
  38%  { opacity: 0.70; } /* afterflash */
  100% { opacity: 0;    }
}

/* ---------- After-Hours Wizard ambient — candlelight + smoke ----------
   Two layers gated on body.spicy-unlocked:
   - ::before is a warm radial glow that slowly flickers, like the room
     is lit by something unholy a few feet behind the screen.
   - ::after is a horizontally drifting fog band along the page bottom.
   Both sit at z-index 0 (above the body background, below .wrap content).
   The global prefers-reduced-motion rule at the bottom of this file
   neutralizes the animations; the override below additionally hides
   the static fog band so reduced-motion users get a clean static look. */
body.spicy-unlocked::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 100%, rgba(255,  90, 20, 0.18), transparent 70%),
    radial-gradient(ellipse 35% 25% at 15%  85%, rgba(255,  60, 20, 0.12), transparent 70%),
    radial-gradient(ellipse 35% 25% at 85%  85%, rgba(255, 110, 30, 0.12), transparent 70%);
  mix-blend-mode: screen;
  animation: candleFlicker 5.5s ease-in-out infinite alternate;
}
@keyframes candleFlicker {
  0%   { opacity: 0.65; }
  18%  { opacity: 1; }
  32%  { opacity: 0.75; }
  48%  { opacity: 0.95; }
  62%  { opacity: 0.70; }
  78%  { opacity: 1; }
  100% { opacity: 0.80; }
}
body.spicy-unlocked::after {
  content: '';
  position: fixed;
  bottom: -8vh;
  left: -50vw;
  width: 200vw;
  height: 38vh;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(ellipse 22vw 7vh at 12% 55%, rgba(200,180,180,0.07), transparent 70%),
    radial-gradient(ellipse 28vw 8vh at 32% 75%, rgba(180,160,170,0.06), transparent 70%),
    radial-gradient(ellipse 24vw 7vh at 55% 50%, rgba(190,170,180,0.06), transparent 70%),
    radial-gradient(ellipse 30vw 9vh at 78% 70%, rgba(200,180,190,0.07), transparent 70%),
    radial-gradient(ellipse 22vw 6vh at 92% 55%, rgba(180,160,170,0.06), transparent 70%);
  filter: blur(6px);
  animation: smokeDrift 28s linear infinite;
}
@keyframes smokeDrift {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Smooth gradient transitions on theme-tinted surfaces */
.btn-cast, .output-card, .output-actions .btn-ghost, .mode-card.selected,
.status-bar-fill, .spellbook-modal .modal-head, .toast {
  transition: background 0.6s ease, border-color 0.6s ease, color 0.4s ease;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }

/* The [hidden] attribute must beat any class-level display rules
   (e.g. .modal { display: flex } and .feedback-form { display: flex }) */
[hidden] { display: none !important; }

/* ---------- Accessibility: visible focus ring on every focusable
   element. Most elements use the accent-2 (blue) ring; the primary
   CTAs override to white below for contrast on the gradient bg. */
:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: inherit;
}
/* Screen-reader-only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* v1.9.3 — switched 100vh → 100svh so iOS browser chrome doesn't
     clip the canvas at the bottom. Added the flex column so the
     footer naturally pins below the play area (`.wrap`) instead of
     adding to its height. */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 600px at 80% -10%, rgba(59,130,246,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 30%, rgba(139,92,246,0.12), transparent 60%),
    radial-gradient(700px 500px at 50% 110%, rgba(236,72,153,0.06), transparent 60%),
    var(--bg);
  position: relative;
  overflow-x: hidden;
}

/* ---------- Ambient: glow + drifting sparkles ---------- */
.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 400px at 50% 110%, rgba(139,92,246,0.10), transparent 60%);
  z-index: 0;
}

.bg-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.bg-sparkles .sp {
  position: absolute;
  color: rgba(255,255,255,0.55);
  font-size: 14px;
  filter: drop-shadow(0 0 6px rgba(139,92,246,0.55));
  animation: drift 18s linear infinite, twinkle 4s ease-in-out infinite;
  user-select: none;
}
.bg-sparkles .sp1 { left:  6%; top:  82%; font-size: 12px; animation-duration: 22s, 3.4s; }
.bg-sparkles .sp2 { left: 20%; top: 110%; font-size: 16px; animation-delay: -4s, -1s; }
.bg-sparkles .sp3 { left: 36%; top:  95%; font-size: 10px; animation-duration: 26s, 5s; animation-delay: -10s, 0s; }
.bg-sparkles .sp4 { left: 52%; top: 105%; font-size: 14px; animation-delay: -8s, -2.5s; }
.bg-sparkles .sp5 { left: 66%; top:  88%; font-size: 18px; animation-duration: 30s, 4.2s; animation-delay: -14s, -0.5s; }
.bg-sparkles .sp6 { left: 78%; top: 115%; font-size: 11px; animation-delay: -6s, -3s; }
.bg-sparkles .sp7 { left: 88%; top:  98%; font-size: 13px; animation-duration: 20s, 3.8s; animation-delay: -2s, -1.5s; }
.bg-sparkles .sp8 { left: 14%; top: 100%; font-size: 15px; animation-delay: -16s, -2s; }

@keyframes drift {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(-130vh) rotate(360deg); }
}
@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50%      { opacity: 1; }
}

/* ---------- Topbar ----------
   v1.9.5 — three-zone grid layout. Center column is `auto` width and
   `justify-self: center` makes it land in the true middle of the
   topbar, independent of the left/right group widths. The 1fr columns
   on either side expand to fill so the left group hugs the left edge
   and the right group hugs the right edge. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: linear-gradient(180deg, rgba(11,10,23,0.85), rgba(11,10,23,0.55) 60%, transparent);
}

/* v1.9.10 — Invisible on desktop (grid children pass through). On mobile
   becomes the horizontal scroll row; see @media (max-width: 720px). */
.topbar-inner { display: contents; }

/* Shared group base — inline flex, consistent button spacing */
.topbar-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0; /* allow groups to shrink if needed */
}
.topbar-left   { justify-self: start;  }
.topbar-center { justify-self: center; }
.topbar-right  { justify-self: end;    }
.topbar-btn {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: calc(13px * var(--text-scale, 1));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  /* v1.9.3 — bumped 36 → 40 to land closer to the WCAG 2.5.5 target
     guidance (44px ideal) without making the topbar feel chunky. */
  min-height: 40px;
  text-decoration: none; /* needed since .topbar-btn is used on <a> elements too (e.g. Shop link) */
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.topbar-btn:hover { background: var(--surface-2); border-color: var(--accent); }
.topbar-btn:active { transform: translateY(1px); }

/* v1.9.8 — Settings overflow gear (mobile-only).
   On desktop the .settings-toggle button is hidden and the three
   preferences (audio / confetti / text size) render as direct
   children of .topbar-left exactly as before. The .settings-row
   wrappers are display: contents on desktop so they collapse into
   the flex layout without adding any visual delta. On mobile
   (≤720px) the wrappers become real flex rows inside a fixed-
   positioned popover; see the @media block at the bottom of the
   stylesheet. */
.settings-toggle { display: none; }
.settings-row { display: contents; }
.settings-row-label { display: none; }

/* Icon-only variant — round, equal padding.
   v1.9.6 — bumped the inner font-size so the emoji/glyph fills more of
   the 40×40 box and reads with the same visual weight as the labeled
   buttons next to it. Without this, 🔇 and 🎉 looked noticeably
   smaller than "Favorites 🏆" even though the buttons were the same
   height pixel-for-pixel. */
.topbar-btn-icon {
  padding: 0;
  width: 40px;
  height: 40px;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/* ---------- Text-size control — single button + popover (v1.9.4) ----------
   One topbar button shows an "A" glyph. Click opens a small popover
   anchored beneath the button with three actions: Smaller, Reset, Bigger.
   Replaces the two A−/A+ pills from the first cut of v1.9.3 so the
   topbar stays minimal and the reset is one click. */
.textsize-control {
  position: relative;
  display: inline-flex;
}
.textsize-toggle .textsize-toggle-glyph {
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  font-family: var(--font-display);
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.textsize-toggle[aria-expanded="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.textsize-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 12;
  display: inline-flex;
  gap: 6px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: textsizePopIn 0.18s ease-out;
  transform-origin: top left;
}
@keyframes textsizePopIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
/* Little arrow pointing up at the toggle button */
.textsize-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 18px;
  width: 10px;
  height: 10px;
  background: var(--surface-2);
  border-left: 1px solid var(--border-strong);
  border-top:  1px solid var(--border-strong);
  transform: rotate(45deg);
}
.textsize-step {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0 12px;
  min-width: 40px;
  min-height: 36px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.textsize-step:hover {
  background: var(--surface-3);
  border-color: var(--accent);
}
.textsize-step:active { transform: translateY(1px); }
.textsize-step:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
/* The reset step gets a slightly different identity so it reads as
   the "neutral" middle position. Slightly larger glyph, subtle gold. */
.textsize-reset {
  color: #ffd866;
  border-color: rgba(255, 216, 102, 0.30);
}
.textsize-reset:hover {
  background: rgba(255, 216, 102, 0.08);
  border-color: #ffd866;
}
.textsize-step.just-changed {
  animation: textsizeAck 0.55s ease-out;
}
@keyframes textsizeAck {
  0%   { box-shadow: 0 0 0 0   var(--accent-glow); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 8px transparent;        border-color: var(--border-strong); }
}
.topbar-btn-icon[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
/* Toggle-emoji buttons dim the icon when off so the state reads
   without needing two different emoji glyphs. */
.topbar-btn-icon[aria-pressed="false"] .toggle-emoji {
  filter: grayscale(1);
  opacity: 0.5;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--grad);
  color: white;
  font-size: 11px;
  font-weight: 700;
  transition: transform 0.2s ease;
}
.badge.pulse {
  animation: badgePulse 0.6s ease-out 2;
}
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.35); }
}

/* ---------- Status panel (replaces the old 'Spells cast' chip) ----------
   Compact pill in the right side of the topbar: level title, count,
   next-unlock goal, and a thin progress bar. */
.status-panel {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-height: 36px;
  font-size: 12px;
  color: var(--text-dim);
  transition: border-color 0.4s, background 0.4s;
}
.status-name {
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}
.status-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  white-space: nowrap;
}
.status-meta-sep { opacity: 0.5; }
#spellCounter {
  font-weight: 700;
  color: var(--text);
}
.status-bar {
  width: 60px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  flex-shrink: 0;
}
.status-bar-fill {
  height: 100%;
  width: 0;
  background: var(--grad);
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Brief pulse on the panel when the user levels up */
.status-panel.leveled-up {
  animation: statusLevelUp 1.2s ease-out;
}
@keyframes statusLevelUp {
  0%   { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.6); }
  60%  { box-shadow: 0 0 0 12px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* Narrow screens: drop the level name, keep count + bar */
@media (max-width: 540px) {
  .status-panel { gap: 8px; padding: 5px 10px; }
  .status-name { display: none; }
  .status-bar { width: 48px; }
}

/* ---------- Layout ---------- */
.wrap {
  position: relative;
  z-index: 1;
  /* v1.9.4 — relaxed from a fixed 1080px cap to 92vw so the canvas
     actually fills wide monitors. Combined with --vp-scale on the
     inner elements, this makes "use my big screen" feel real instead
     of leaving a tiny centered island. Narrow screens get a healthy
     bottom floor via the mobile media query below. */
  max-width: 92vw;
  margin: 0 auto;
  width: 100%;
  /* v1.9.6 — switched from `flex: 1 0 auto` (grow to fill body) to
     `flex: 0 0 auto` (natural content height). Paired with removing
     `margin-top: auto` from .foot below, this means the footer
     hugs the output card instead of being pushed to the bottom
     of the viewport — reclaiming the empty space the user flagged.
     Any leftover viewport height sits as quiet empty space below
     the footer (invisible / unobtrusive). */
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  /* v1.9.6 — bumped padding-top from 4 → 20 (scales with vp-scale)
     so there's actual breathing room between the topbar and the
     hero title. */
  padding: calc(20px * var(--vp-scale, 1)) calc(24px * var(--vp-scale, 1)) calc(16px * var(--vp-scale, 1));
}
/* v1.9.6 — footer now sits a fixed distance below the output card
   instead of being shoved to the bottom of the viewport via
   `margin-top: auto`. The previous behavior left a noticeable gap
   on tall viewports; the user asked for that space to be reclaimed
   and redistributed to top breathing room. */
.foot {
  flex: 0 0 auto;
  margin-top: calc(20px * var(--vp-scale, 1));
  padding: calc(8px * var(--vp-scale, 1)) 0 calc(8px + var(--safe-bottom));
}

/* ---------- Hero ----------
   Stacked + centered on mobile.
   Side-by-side (mascot left, text right) at ≥720px. */
.hero {
  text-align: center;
  /* v1.9.6 — bumped from 6 to give the intro paragraph more space
     before the "Pick your magic" section label below it. */
  margin-bottom: calc(20px * var(--vp-scale, 1));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
@media (min-width: 720px) {
  .hero {
    flex-direction: row;
    text-align: left;
    align-items: center;
    /* v1.9.4 — gap + max-width scale with vp-scale so the hero grows
       proportionally on big screens. */
    gap: calc(18px * var(--vp-scale, 1));
    max-width: calc(760px * var(--vp-scale, 1));
    /* v1.9.6 — bumped from 6 to 20 so the intro has visible breathing
       room before the section label below it. */
    margin: 0 auto calc(20px * var(--vp-scale, 1));
  }
  .hero-text { flex: 1; min-width: 0; }
  .hero .mascot-wrap { flex-shrink: 0; margin: 0; }
}

.mascot-wrap {
  position: relative;
  /* v1.9.4 — mascot grows with the canvas. Base 130×182 at vp-scale=1,
     up to 312×437 at 4K (vp-scale=2.4). Pixel-art rendering stays
     crisp at any scale because of image-rendering: pixelated below. */
  width:  calc(130px * var(--vp-scale, 1));
  height: calc(182px * var(--vp-scale, 1));
  margin: 0 auto calc(4px * var(--vp-scale, 1));
  /* Bob lives on the wrap so the inner img is free to "thump"
     independently — transforms then compose nicely. */
  animation: mascotBob 5s ease-in-out infinite;
}
@keyframes mascotBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

.mascot {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* Preserve pixel-art crispness when scaled */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  transition: filter 0.2s ease;
}
.mascot:hover {
  filter: drop-shadow(0 0 18px rgba(251, 191, 36, 0.35));
}

/* Staff-thump animation on click. Quick downward jolt then settle. */
.mascot.thumping {
  animation: thump 0.42s cubic-bezier(.36,.04,.27,1) 1;
}
@keyframes thump {
  0%   { transform: translateY(0)   scaleY(1); }
  25%  { transform: translateY(6px) scaleY(0.96); }
  50%  { transform: translateY(8px) scaleY(0.94); }
  70%  { transform: translateY(-2px) scaleY(1.02); }
  100% { transform: translateY(0)   scaleY(1); }
}

/* ---------- After-Hours Wizard unlock — the explosion ----------
   Full-screen red flash, dramatic shake, centered "UNLOCKED"
   banner. Triggered once when Konami / share-click unlocks the
   spicy pack. JS spawns the .spicy-flash and .unlock-banner
   elements and adds .spicy-shaking to the body. */
.spicy-flash {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%,
      rgba(255, 23, 68, 0.55) 0%,
      rgba(255, 107, 26, 0.30) 30%,
      rgba(255, 23, 68, 0) 70%);
  animation: spicyFlash 1.3s ease-out forwards;
}
@keyframes spicyFlash {
  0%   { opacity: 0; transform: scale(0.4); }
  18%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.3); }
}

.unlock-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 10000;
  padding: 28px 44px 32px;
  background: linear-gradient(135deg, #ff1744 0%, #ff007a 50%, #ff6b1a 100%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  box-shadow:
    0 0 80px rgba(255, 23, 68, 0.6),
    0 20px 60px rgba(0, 0, 0, 0.5);
  color: #fff;
  text-align: center;
  pointer-events: none;
  animation: unlockBanner 4.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes unlockBanner {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.5)  rotate(-3deg); }
  8%   { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(1deg); }
  13%  {              transform: translate(-50%, -50%) scale(0.98) rotate(0deg); }
  /* Subtle breathing during the hold so it feels alive, not frozen */
  40%  {              transform: translate(-50%, -50%) scale(1.02); }
  65%  {              transform: translate(-50%, -50%) scale(1); }
  90%  { opacity: 1; transform: translate(-50%, -50%) scale(1)    rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.06); }
}
.unlock-banner-eyebrow {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  opacity: 0.95;
  margin: 0 0 8px;
}
.unlock-banner-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 8vw, 64px);
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0;
  line-height: 1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
.unlock-banner-sub {
  font-family: var(--font-display);
  font-size: clamp(15px, 2.2vw, 18px);
  font-style: italic;
  margin: 12px 0 0;
  opacity: 0.95;
}

/* The body itself shakes during the unlock — more dramatic than
   the easter-egg shake. Includes a small rotation for "things
   are coming loose" feel. */
.spicy-shaking {
  animation: spicyShake 0.85s ease-in-out;
}
@keyframes spicyShake {
  0%, 100% { transform: translate(0, 0)        rotate(0); }
  8%       { transform: translate(-9px, -4px)  rotate(-0.5deg); }
  18%      { transform: translate(8px, 4px)    rotate(0.5deg); }
  28%      { transform: translate(-7px, 3px)   rotate(-0.4deg); }
  38%      { transform: translate(6px, -3px)   rotate(0.4deg); }
  48%      { transform: translate(-5px, 2px)   rotate(-0.3deg); }
  58%      { transform: translate(4px, -2px)   rotate(0.3deg); }
  68%      { transform: translate(-3px, 1px)   rotate(-0.2deg); }
  78%      { transform: translate(2px, -1px)   rotate(0.1deg); }
  88%      { transform: translate(-1px, 0); }
}

/* Brief screen-shake during the easter-egg burst — playful, not jarring. */
.shake {
  animation: shake 0.36s ease-in-out;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

/* Larger, longer-lived sparkles for the easter egg */
.burst.easter {
  animation: burst 1.4s ease-out forwards;
  font-size: 18px;
}

/* Sparkles orbiting the mascot */
.mascot-sp {
  position: absolute;
  color: var(--gold);
  filter: drop-shadow(0 0 6px rgba(255, 209, 102, 0.7));
  font-size: 14px;
  animation: msTwinkle 2.6s ease-in-out infinite;
}
.mascot-sp.ms1 { top:  8%; left: -2%;  font-size: 12px; animation-delay: 0s; }
.mascot-sp.ms2 { top: 22%; right: -4%; font-size: 16px; animation-delay: 0.6s; }
.mascot-sp.ms3 { top: 60%; left: -6%;  font-size: 10px; animation-delay: 1.2s; }
@keyframes msTwinkle {
  0%, 100% { opacity: 0.2; transform: translateY(0) scale(0.85); }
  50%      { opacity: 1;   transform: translateY(-4px) scale(1.1); }
}

/* ---------- Mascot ember drift (spicy only) ----------
   Four glowing red dots rising from beneath the wizard on staggered
   loops, so the wizard appears to be slowly smoldering. Always in
   the DOM, but display:none until body.spicy-unlocked.

   Reduced-motion: the global animation-none rule freezes the embers
   at their 0% keyframe state (opacity: 0), so they render invisible
   without needing a separate hide rule. */
.mascot-ember { display: none; }
body.spicy-unlocked .mascot-ember {
  display: block;
  position: absolute;
  bottom: -4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd86b 0%, #ff7a1a 50%, #d62828 100%);
  box-shadow:
    0 0 6px  rgba(255, 110, 30, 0.95),
    0 0 12px rgba(255,  50,  0, 0.55);
  pointer-events: none;
  opacity: 0;
  animation: mascotEmberRise 3.6s ease-out infinite;
  will-change: transform, opacity;
}
body.spicy-unlocked .mascot-ember.me1 { left: 28%; animation-delay: 0s;   }
body.spicy-unlocked .mascot-ember.me2 { left: 52%; animation-delay: 0.9s; width: 5px; height: 5px; }
body.spicy-unlocked .mascot-ember.me3 { left: 68%; animation-delay: 1.8s; width: 7px; height: 7px; }
body.spicy-unlocked .mascot-ember.me4 { left: 42%; animation-delay: 2.7s; width: 4px; height: 4px; }
@keyframes mascotEmberRise {
  0%   { transform: translateY(0)     scale(0.8); opacity: 0;   }
  10%  { opacity: 0.9; }
  60%  { opacity: 0.8; }
  100% { transform: translateY(-90px) scale(0.4); opacity: 0;   }
}

.title {
  font-family: var(--font-display);
  font-weight: 600;
  /* v1.9.3/4 — title size combines a baseline clamp (handles narrow
     viewports) with --vp-scale (handles wide viewports). So at 1280
     it's ~42px, at 1920 it's ~50px, at 4K it's ~100px. Plus the user's
     text-scale preference multiplies on top. */
  font-size: calc(clamp(26px, 4.2vw, 42px) * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.5px;
  margin: 0 0 2px;
  line-height: 1.05;
  white-space: nowrap; /* "The Workday Wizard" stays on one line */
  background: var(--grad-3);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: gradientShift 12s ease-in-out infinite;
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.subtitle {
  margin: 0 0 calc(6px * var(--vp-scale, 1));
  font-size: calc(clamp(11px, 1.3vw, 14px) * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  min-height: 1.4em;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.subtitle.swap-out { opacity: 0; transform: translateY(-4px); }

.intro {
  max-width: calc(640px * var(--vp-scale, 1));
  margin: 0 auto;
  color: var(--text-dim);
  /* v1.9.3 — tighter line-height saves a hair of vertical room while
     still being comfortably readable. */
  line-height: 1.45;
  font-size: calc(14px * var(--text-scale, 1) * var(--vp-scale, 1));
}
/* In side-by-side hero, the intro flows left-aligned with the title */
@media (min-width: 720px) {
  .intro { margin: 0; }
}

/* ---------- Section label ---------- */
.section-label {
  text-align: center;
  font-size: calc(12px * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.25em;
  text-transform: uppercase;
  /* v1.8.5 — switched from accent-purple to gold and made the pulse
     brighter / faster. Gold ties to the wizard's existing sparkle motif
     (the cast-button sparkles, the ember confetti, the mascot glow)
     and pops better against the page's purple gradient bg. */
  color: #ffd866;
  /* v1.9.5 — slightly more breathing room below "Pick your magic" so
     the label doesn't feel glued to the mode grid. Scales with vp-scale
     so the gap grows on big screens too. */
  margin: 0 0 calc(14px * var(--vp-scale, 1));
  font-weight: 600;
  text-shadow: 0 0 8px rgba(255, 216, 102, 0.35);
  animation: sectionLabelPulse 3.5s ease-in-out infinite alternate;
}
@keyframes sectionLabelPulse {
  0%   {
    text-shadow:
      0 0 6px  rgba(255, 216, 102, 0.30),
      0 0 14px rgba(255, 200, 80,  0.10);
    color: #ffd866;
  }
  100% {
    text-shadow:
      0 0 16px rgba(255, 216, 102, 0.80),
      0 0 32px rgba(255, 180, 50,  0.45);
    color: #fff0b3;
  }
}
@media (prefers-reduced-motion: reduce) {
  .section-label {
    animation: none;
    text-shadow: 0 0 10px rgba(255, 216, 102, 0.45);
    color: #ffd866;
  }
}

/* ---------- Mode grid ---------- */
/* v1.9.5 — added more breathing room: the grid sits further from the
   cast block below, and the cards are slightly more separated. */
.modes { margin-bottom: calc(16px * var(--vp-scale, 1)); }

.mode-grid {
  display: grid;
  /* 4 equal columns so cards fill the same width as the output card
     below. Mobile carousel rules in the media query override this. */
  grid-template-columns: repeat(4, 1fr);
  gap: calc(14px * var(--vp-scale, 1));
}

.mode-card {
  position: relative;
  /* v1.8.5 — added a slow accent-glow breathing animation that runs
     by default (staggered per :nth-child below). The breathing makes
     the cards read as active/clickable for new users who might not
     otherwise know to click. :hover and .selected both pause the
     animation so those states take over cleanly. */
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: calc(10px * var(--vp-scale, 1)) calc(12px * var(--vp-scale, 1));
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.2s ease,
    background 0.2s ease,
    box-shadow 0.2s ease;
  text-align: center;
  color: inherit;
  font: inherit;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(5px * var(--vp-scale, 1));
  /* v1.9.3/4 — base card height; grows with --vp-scale on big screens
     so the grid actually fills space proportionally instead of feeling
     like a small island in the middle of a 4K monitor. */
  min-height: calc(80px * var(--vp-scale, 1));
  width: 100%;
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.18),
    0 0 18px rgba(139, 92, 246, 0.08);
  animation: modeCardBreathing 4s ease-in-out infinite;
}
/* Stagger the breathing across the 8 cards so the effect reads as
   a slow wave instead of all-cards-pulsing-in-sync. Each card
   inherits the same 4s cycle but starts at a different offset. */
.mode-card:nth-child(1) { animation-delay: 0s;    }
.mode-card:nth-child(2) { animation-delay: 0.45s; }
.mode-card:nth-child(3) { animation-delay: 0.90s; }
.mode-card:nth-child(4) { animation-delay: 1.35s; }
.mode-card:nth-child(5) { animation-delay: 1.80s; }
.mode-card:nth-child(6) { animation-delay: 2.25s; }
.mode-card:nth-child(7) { animation-delay: 2.70s; }
.mode-card:nth-child(8) { animation-delay: 3.15s; }
@keyframes modeCardBreathing {
  0%, 100% {
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.18),
      0 0 18px rgba(139, 92, 246, 0.08);
    border-color: var(--border-strong);
  }
  50% {
    box-shadow:
      0 6px 18px rgba(0, 0, 0, 0.22),
      0 0 28px rgba(139, 92, 246, 0.32);
    border-color: rgba(139, 92, 246, 0.45);
  }
}
/* Pause the breathing during interaction states so hover/selected
   styles below can take over without competing with the animation. */
.mode-card:hover,
.mode-card.selected,
.mode-card.cycling {
  animation-play-state: paused;
}
@media (prefers-reduced-motion: reduce) {
  .mode-card { animation: none; }
}

.mode-card::after {
  /* shine-on-hover sweep */
  content: '';
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.06), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s ease;
  pointer-events: none;
}
.mode-card:hover::after { left: 125%; }

.mode-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--surface-3, var(--surface-2)) 0%, var(--surface-2) 100%);
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.30),
    0 0 30px rgba(139, 92, 246, 0.25);
}

.mode-card:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.mode-card.selected {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    var(--grad) border-box;
  border: 1.5px solid transparent;
  box-shadow:
    0 0 0 4px var(--accent-soft),
    0 10px 30px rgba(0,0,0,0.35);
}

.mode-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width:  calc(38px * var(--vp-scale, 1));
  height: calc(38px * var(--vp-scale, 1));
  border-radius: 10px;
  background: var(--grad-soft);
  border: 1px solid var(--border);
  font-size: calc(22px * var(--vp-scale, 1));
  line-height: 1;
  margin-bottom: 0;
  transition: transform 0.3s ease, background 0.3s ease;
}
.mode-card:hover .mode-icon { transform: rotate(-6deg) scale(1.08); }
.mode-card.selected .mode-icon {
  background: var(--grad);
  color: white;
  border-color: transparent;
}

.mode-title {
  font-weight: 600;
  font-size: calc(14px * var(--text-scale, 1) * var(--vp-scale, 1));
  margin: 0;
  letter-spacing: 0.1px;
  line-height: 1.2;
}

.mode-desc {
  margin: 0;
  color: var(--text-dim);
  font-size: calc(11.5px * var(--text-scale, 1) * var(--vp-scale, 1));
  line-height: 1.3;
}

/* Slot-machine-style "the wizard is choosing" highlight, used
   briefly on each card during the I'm Feeling Cursed cycle. */
.mode-card.cycling {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    var(--grad-3) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 0 18px rgba(236, 72, 153, 0.4);
  transform: translateY(-1px) scale(1.02);
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}
.mode-card.cycling .mode-icon {
  background: var(--grad-3);
  color: #fff;
  border-color: transparent;
  transform: rotate(-4deg) scale(1.08);
}

/* Featured / lucky card */
.mode-card.featured {
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) padding-box,
    var(--grad-3) border-box;
  border: 1.5px solid transparent;
  box-shadow: 0 10px 30px rgba(236, 72, 153, 0.18);
}
.mode-card.featured .mode-icon {
  background: var(--grad-3);
  color: #fff;
  border-color: transparent;
  animation: dieRoll 4s ease-in-out infinite;
}
@keyframes dieRoll {
  0%, 100% { transform: rotate(0); }
  25%      { transform: rotate(-10deg) scale(1.05); }
  50%      { transform: rotate(8deg) scale(0.95); }
  75%      { transform: rotate(-4deg); }
}

/* ---------- Featured (9th) mode container ----------
   Always centered below the main grid/carousel.
   The card itself is reshaped into a thinner horizontal pill —
   icon on the left, title + description stacked on the right. */
.featured-mode {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}
.featured-mode .mode-card {
  /* override the square base styles */
  aspect-ratio: auto;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  width: 100%;
  max-width: 380px;
  padding: 10px 16px;
  gap: 2px 14px;
  margin: 0 auto;
  border-radius: 999px;
  /* Reset the carousel flex-basis so width/max-width actually applies
     when this card lives inside .featured-mode (a flex container). */
  flex: 0 0 auto;
}
.featured-mode .mode-card .mode-icon {
  grid-row: 1 / 3;
  width: 44px;
  height: 44px;
  font-size: 26px;
  border-radius: 12px;
}
.featured-mode .mode-card .mode-title {
  grid-column: 2;
  font-size: 14.5px;
  margin: 0;
}
.featured-mode .mode-card .mode-desc {
  grid-column: 2;
  font-size: 12px;
  margin: 0;
  line-height: 1.3;
}
/* When selected, keep the pill shape (no square highlight ring) */
.featured-mode .mode-card.selected {
  border-radius: 999px;
}

/* ---------- Mobile carousel pagination dots ----------
   Hidden on desktop, revealed when the grid becomes a carousel. */
.mode-dots {
  display: none;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.mode-dots .dot {
  appearance: none;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s, transform 0.25s, width 0.25s;
}
.mode-dots .dot:hover { background: rgba(255, 255, 255, 0.35); }
.mode-dots .dot.active {
  background: var(--grad);
  width: 22px; /* pill shape on active */
}

/* The ≥1024 desktop grid is now handled by the base rule
   (repeat(4, 1fr)) — cards naturally fill the wrap width. */

/* ---------- Cast ---------- */
.cast {
  text-align: center;
  /* v1.9.5 — bumped margins so the cast block sits between the mode
     grid and the output card with more breathing room. */
  margin: calc(18px * var(--vp-scale, 1)) 0 calc(20px * var(--vp-scale, 1));
  position: relative;
}

/* Side-by-side: primary CTA + "roll the dice" shortcut */
.cast-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.btn-cast {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: calc(11px * var(--vp-scale, 1)) calc(22px * var(--vp-scale, 1));
  border-radius: 999px;
  background: var(--grad);
  background-size: 200% 200%;
  color: white;
  font-weight: 600;
  font-size: calc(15px * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.35);
  transition: transform 0.15s ease, box-shadow 0.2s, opacity 0.2s;
  animation: castShimmer 6s ease-in-out infinite;
  position: relative;
}

/* "I'm Feeling Lucky" — v1.8.5 restored some flair.
   v1.8.1 had demoted this to a flat ghost-style so the mode cards
   could pull primary attention. v1.8.5 brings back a subtle gradient
   hint by default (visible-but-quiet) and the full pre-v1.8.1
   pink→purple→blue gradient on hover. Hierarchy intact: mode cards
   are still the primary breathing affordance; the lucky button has
   character again without competing.
   When spicy unlocks, the spicy-unlocked styles override this to
   give the cursed identity its red glow back. */
.btn-cast-alt {
  /* Subtle gradient tinting layered on top of the surface base.
     Reads as "this button has a personality" without the full
     pre-v1.8.1 brightness. */
  background:
    linear-gradient(135deg,
      rgba(236, 72, 153, 0.20) 0%,
      rgba(139, 92, 246, 0.18) 50%,
      rgba(96, 165, 250, 0.18) 100%),
    var(--surface);
  border: 1px solid rgba(236, 72, 153, 0.35);
  color: var(--text);
  box-shadow:
    0 6px 14px rgba(236, 72, 153, 0.18),
    0 0 18px rgba(139, 92, 246, 0.10);
  animation: none;
  transition: background 0.25s, border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.btn-cast-alt:hover {
  /* Full restoration of the pre-v1.8.1 bright gradient on hover */
  background: var(--grad-3);
  background-size: 200% 200%;
  border-color: transparent;
  box-shadow:
    0 12px 28px rgba(236, 72, 153, 0.42),
    0 0 30px rgba(139, 92, 246, 0.25);
  transform: translateY(-1px);
}
@keyframes castShimmer {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

.btn-cast:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(139, 92, 246, 0.5);
}
.btn-cast:active { transform: translateY(0); }
.btn-cast:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.btn-cast:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn-cast-icon { display: inline-block; transition: transform 0.4s; }
.btn-cast.casting .btn-cast-icon { animation: spin 0.9s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- Flaming d20 icon (lucky button at spicy level) ----------
   Replaces the 🎲 emoji once After-Hours Wizard mode is unlocked.
   A stylized hex (reads as a d20 at button-icon scale) ringed by
   five flickering flame emojis on staggered timings. Flames extend
   above and to the sides of the icon — overflow:visible is required. */
.btn-cast-icon.flaming-d20 {
  position: relative;
  display: inline-block;
  width: 26px;
  height: 26px;
  vertical-align: middle;
  overflow: visible;
}
.btn-cast-icon.flaming-d20 .d20-svg {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  filter: drop-shadow(0 0 5px rgba(255, 110, 30, 0.70));
  animation: d20Tumble 3.2s ease-in-out infinite;
}
@keyframes d20Tumble {
  0%, 100% { transform: rotate(0); }
  20%      { transform: rotate(-15deg) scale(1.04); }
  50%      { transform: rotate( 10deg) scale(0.96); }
  80%      { transform: rotate( -5deg); }
}
/* During cast: the die appears to roll. We swap d20Tumble for the
   sibling .btn-cast.casting spin on just the SVG (not the container)
   so the flames stay put and keep flickering — otherwise the whole
   wreath of flame would spin which looks chaotic. */
.btn-cast.casting .btn-cast-icon.flaming-d20 { animation: none; }
.btn-cast.casting .btn-cast-icon.flaming-d20 .d20-svg {
  animation: spin 0.9s linear infinite;
}
.btn-cast-icon.flaming-d20 .flame {
  position: absolute;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 0 5px rgba(255, 90, 0, 0.85));
  animation: flameFlicker 0.95s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
.btn-cast-icon.flaming-d20 .flame.f1 { top: -10px; left:  -4px; font-size: 11px; animation-delay: 0s;    }
.btn-cast-icon.flaming-d20 .flame.f2 { top: -14px; left:   9px; font-size: 14px; animation-delay: 0.18s; }
.btn-cast-icon.flaming-d20 .flame.f3 { top: -10px; right: -4px; font-size: 11px; animation-delay: 0.36s; }
.btn-cast-icon.flaming-d20 .flame.f4 { top:   6px; left:  -8px; font-size:  9px; animation-delay: 0.52s; }
.btn-cast-icon.flaming-d20 .flame.f5 { top:   6px; right: -8px; font-size: 10px; animation-delay: 0.70s; }
@keyframes flameFlicker {
  0%   { transform: translateY(0)    scale(1)    rotate(-4deg); opacity: 0.85; }
  50%  { transform: translateY(-2px) scale(1.18) rotate( 2deg); opacity: 1;    }
  100% { transform: translateY(-4px) scale(1.05) rotate(-2deg); opacity: 0.9;  }
}

/* Lucky button glows red on hover when spicy is active (the default
   .btn-cast-alt uses pink — we want red to match the cursed identity). */
body.spicy-unlocked .btn-cast-alt {
  box-shadow: 0 10px 24px rgba(255, 23, 68, 0.35);
}
body.spicy-unlocked .btn-cast-alt:hover {
  box-shadow: 0 14px 30px rgba(255, 23, 68, 0.55);
}

.hint {
  margin: 6px 0 0;
  font-size: calc(12.5px * var(--text-scale, 1) * var(--vp-scale, 1));
  color: var(--text-mute);
}
.kbd-hint {
  display: inline-block;
  margin-left: 6px;
  opacity: 0.7;
}
.kbd-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--text);
}
@media (max-width: 720px) {
  .kbd-hint { display: none; } /* irrelevant on touch */
}

/* ---------- Emoji confetti rain (on cast) ----------
   Each .confetti span is dropped from the top of the viewport
   with randomized x-drift and rotation (set via CSS custom
   properties from JS). prefers-reduced-motion is honored at the
   bottom of this file. */
.confetti {
  position: fixed;
  top: -50px;
  pointer-events: none;
  user-select: none;
  z-index: 100;
  animation: confettiFall linear forwards;
  will-change: transform, opacity;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
@keyframes confettiFall {
  0%   { transform: translate(0, 0)             rotate(0deg);              opacity: 0; }
  10%  {                                                                   opacity: 1; }
  100% { transform: translate(var(--xdrift, 0), 110vh) rotate(var(--rot, 360deg)); opacity: 0; }
}

/* Glowing red ember confetti (spicy variant — no text content).
   Used by spawnConfetti() for ~35% of per-cast pieces when spicy is
   unlocked, and by spawnSpicyConfetti() at the one-time unlock moment.
   `.ember-large` is the bigger sibling used for the unlock spectacle. */
.confetti.ember {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd86b 0%, #ff7a1a 35%, #d62828 75%, transparent 100%);
  box-shadow:
    0 0 8px  rgba(255, 110, 30, 0.95),
    0 0 16px rgba(255,  50,  0, 0.55);
  filter: none; /* override the default text-confetti drop-shadow */
}
.confetti.ember.ember-large {
  width: 11px;
  height: 11px;
  box-shadow:
    0 0 12px rgba(255, 110, 30, 1),
    0 0 22px rgba(255,  50,  0, 0.65);
}

/* Sparkle burst (injected by JS on cast) */
.burst {
  position: absolute;
  pointer-events: none;
  color: var(--gold);
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.9));
  font-size: 16px;
  animation: burst 0.9s ease-out forwards;
}
@keyframes burst {
  0%   { opacity: 1; transform: translate(0,0) scale(0.5); }
  100% { opacity: 0; transform: translate(var(--bx, 0px), var(--by, -40px)) scale(1.2) rotate(160deg); }
}

/* ---------- Output ---------- */
/* v1.9.5 — added padding above the spell window so it doesn't feel
   pinned to the cast hint. Scales with vp-scale so the gap grows
   proportionally on bigger screens. */
.output-section { margin-top: calc(14px * var(--vp-scale, 1)); }

.output-card {
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad) border-box;
  border: 1.5px solid transparent;
  border-radius: calc(16px * var(--vp-scale, 1));
  padding: calc(14px * var(--vp-scale, 1)) calc(16px * var(--vp-scale, 1)) calc(12px * var(--vp-scale, 1));
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  /* v1.9.3 — tighter bottom margin so the footer can sit closer when
     the canvas naturally clears it. */
  margin-bottom: calc(12px * var(--vp-scale, 1));
}
.output-card::before {
  content: "";
  position: absolute;
  top: -40%;
  left: -10%;
  width: 120%;
  height: 80%;
  background: radial-gradient(closest-side, rgba(139,92,246,0.12), transparent 70%);
  pointer-events: none;
}

/* Shimmer line that sweeps top of the card after a cast */
.output-card-shimmer {
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
  pointer-events: none;
  transform: skewX(-25deg);
}
.output-card.fresh .output-card-shimmer {
  animation: shimmerSweep 0.9s ease-out;
}
@keyframes shimmerSweep {
  from { left: -30%; }
  to   { left: 130%; }
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
  position: relative;
}

.output-label {
  font-size: calc(11px * var(--text-scale, 1) * var(--vp-scale, 1));
  text-transform: uppercase;
  letter-spacing: 0.28em;
  color: var(--text-mute);
}
.output-mode {
  font-size: calc(12px * var(--text-scale, 1) * var(--vp-scale, 1));
  color: var(--accent);
  letter-spacing: 0.06em;
}

.output-text {
  font-family: var(--font-display);
  font-size: calc(clamp(18px, 2.2vw, 22px) * var(--text-scale, 1) * var(--vp-scale, 1));
  line-height: 1.35;
  color: var(--text);
  min-height: calc(56px * var(--vp-scale, 1));
  white-space: pre-wrap;
  padding: 2px 2px calc(10px * var(--vp-scale, 1));
  letter-spacing: 0.2px;
  position: relative;
  text-align: center; /* center the poem inside the output card */
}

/* v1.9.3 — empty state shrinks so the pre-cast card doesn't hog
   canvas height. After the first cast, the .empty class is removed
   and the card expands naturally to fit the spell. */
.output-text.empty {
  font-family: var(--font);
  font-size: calc(14px * var(--text-scale, 1) * var(--vp-scale, 1));
  color: var(--text-mute);
  font-style: italic;
  min-height: calc(32px * var(--vp-scale, 1));
  padding-bottom: 4px;
}

.output-text.fade-in { animation: fadeIn 0.5s ease both; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Loading state ----------
   Soft pulse on the message + 3 staggered dots after it, so the
   ~1.1s wait feels alive instead of frozen. */
.output-text.loading {
  font-family: var(--font);     /* loading message reads as UI, not poem */
  font-size: 15px;
  font-style: italic;
  color: var(--text-mute);
  letter-spacing: 0.02em;
}
.output-text.loading .loading-text {
  animation: loadingPulse 1.6s ease-in-out infinite;
}
@keyframes loadingPulse {
  0%, 100% { opacity: 0.7; }
  50%      { opacity: 1; }
}
.output-text.loading .loading-dots {
  display: inline-block;
  margin-left: 2px;
  letter-spacing: 1px;
}
.output-text.loading .loading-dots span {
  display: inline-block;
  opacity: 0.2;
  animation: dotPulse 1.4s infinite;
}
.output-text.loading .loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.output-text.loading .loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  40%      { opacity: 1;   transform: translateY(-2px); }
}

.output-actions {
  position: relative; /* anchor for absolute-positioned bless burst */
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
  justify-content: center; /* center the whole action row */
  align-items: center;
}

.btn-ghost {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: calc(8px * var(--vp-scale, 1)) calc(12px * var(--vp-scale, 1));
  border-radius: 999px;
  font-size: calc(13px * var(--text-scale, 1) * var(--vp-scale, 1));
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: calc(6px * var(--vp-scale, 1));
  min-height: calc(36px * var(--vp-scale, 1));
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #fff;
}
.btn-ghost:active:not(:disabled) { transform: translateY(1px); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost.copied,
.btn-ghost.saved {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
}

/* ---------- Bless button (replaces thumbs in v1.8.0) ----------
   Sits in the .output-actions row alongside Copy/Share/Save. Builds
   on .btn-ghost (inherits its base styling) and adds:
   - Sparkle icon + label structure
   - .is-blessed state: gradient bg + animated celebration on click
     (icon pulse + golden ring-expand on the button border)

   Same pattern as merch.html's .merch-product-bless — positive-only
   signal, persists for the duration of the current cast (resets when
   a new spell is cast). */
.btn-bless {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* btn-ghost provides base padding, border, font-size — we just need
     to add the bless-specific identity layer on top */
}
.btn-bless-icon {
  display: inline-block; /* required for transform to apply reliably */
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 209, 102, 0.5));
}
.btn-bless.is-blessed {
  background: rgba(139, 92, 246, 0.16);
  border-color: var(--accent);
  color: var(--text);
  cursor: default;
}
.btn-bless.is-blessed .btn-bless-icon {
  animation: blessIconPulse 1.5s ease-out;
}
.btn-bless.is-blessed {
  animation: blessButtonGlow 1.5s ease-out;
}
@keyframes blessIconPulse {
  0%   { transform: scale(1)   rotate(0deg);   }
  20%  { transform: scale(2.5) rotate(180deg); }
  50%  { transform: scale(1.8) rotate(360deg); }
  80%  { transform: scale(1.3) rotate(540deg); }
  100% { transform: scale(1)   rotate(720deg); }
}
@keyframes blessButtonGlow {
  0%   { box-shadow: 0 0 0 0   rgba(255, 209, 102, 0.85); }
  30%  { box-shadow: 0 0 0 14px rgba(255, 209, 102, 0.00); }
  100% { box-shadow: 0 0 0 0   rgba(255, 209, 102, 0.00); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-bless.is-blessed .btn-bless-icon,
  .btn-bless.is-blessed { animation: none; }
}

/* ---------- Aux row: quiet text links beneath the action row ----------
   v1.9.3 — collapsed the previous stacked "Put this on a mug" CTA and
   "Whisper to the wizard ↗" button into a single inline row so the
   output card stays compact. Both children start hidden; the row
   itself collapses to zero height when both are hidden via the
   :not(:has(...)) selector below, so the dashed divider only appears
   when there's actually something to show.

   Visual treatment: both items render as quiet underline-on-hover text
   links. No button chrome — they're auxiliary actions, not primary
   CTAs (which are Copy / Share / Save / Bless above). */
.output-aux-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: calc(18px * var(--vp-scale, 1));
  row-gap: 6px;
  margin-top: calc(10px * var(--vp-scale, 1));
  padding-top: calc(8px * var(--vp-scale, 1));
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}
/* Collapse the row entirely if both children are hidden — keeps the
   divider from sitting there as orphan ornament. */
.output-aux-row:not(:has(> :not([hidden]))) {
  display: none;
}
.output-aux-item { display: inline-flex; }

.aux-link {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-mute);
  cursor: pointer;
  padding: 4px 2px;
  margin: 0;
  font: inherit;
  font-size: calc(12.5px * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.04em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s;
}
.aux-link:hover,
.aux-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.aux-link-icon {
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(255, 200, 100, 0.4));
}

/* Legacy class — kept as a no-op alias so any external page/style
   referencing .whisper-link still finds something. Visual identity
   now lives on .aux-link above. */
.whisper-link { /* aliased to .aux-link via the class on the element */ }

.feedback-form {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feedback-form textarea {
  width: 100%;
  resize: vertical;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  min-height: 60px;
}
.feedback-form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.feedback-submit { align-self: flex-start; }

/* (v1.9.3 — removed .output-mug-cta + .mug-cta-link styles. The mug
   CTA was promoted out of its own row and into the .output-aux-row
   above, rendered as a quiet text link via .aux-link.) */

/* (Old side-column feedback-thanks/submitted rules removed — the
   "thanks" UX is now handled entirely by the toast.) */

/* ---------- Level-up modal ----------
   The big celebration moment on level-up. Centered card, glowing
   wizard image, level-themed gradient title, optional Konami
   keycaps for the L4-locked variant. */
.level-up-modal { z-index: 70; }
.level-up-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 8px 28px 26px;
  position: relative;
  overflow: visible;
  /* Animated border tint matches the current level */
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad) border-box;
  border: 1.5px solid transparent;
}

.level-up-image {
  width: 160px;
  height: 200px;
  margin: 12px auto 8px;
  position: relative;
  animation: levelUpFloat 3.4s ease-in-out infinite;
  filter: drop-shadow(0 0 28px var(--accent-glow));
}
.level-up-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
@keyframes levelUpFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* Orbital sparkles around the wizard image */
.level-up-sparkle {
  position: absolute;
  color: var(--gold);
  font-size: 18px;
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.7));
  animation: levelUpSparkleTwinkle 2.4s ease-in-out infinite;
}
.level-up-sparkle.s1 { top:  8%; left:  4%; font-size: 14px; animation-delay: 0s; }
.level-up-sparkle.s2 { top: 24%; right: 0%; font-size: 18px; animation-delay: 0.7s; }
.level-up-sparkle.s3 { top: 64%; left: -2%; font-size: 12px; animation-delay: 1.3s; }
@keyframes levelUpSparkleTwinkle {
  0%, 100% { opacity: 0.25; transform: translateY(0) scale(0.85); }
  50%      { opacity: 1;    transform: translateY(-4px) scale(1.15); }
}

.level-up-eyebrow {
  font-size: 11px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 4px;
}
.level-up-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 36px;
  letter-spacing: 0.4px;
  margin: 0 0 14px;
  line-height: 1.1;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.level-up-flavor {
  font-family: var(--font-display);
  font-size: 19px;
  line-height: 1.45;
  font-style: italic;
  color: var(--text);
  margin: 0 0 10px;
}
.level-up-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 18px;
  line-height: 1.5;
}

/* Konami keycaps section (only shown for L4-locked variant) */
.level-up-konami {
  margin: 4px 0 18px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 12px;
  border: 1px solid var(--border);
}
.level-up-konami-prompt {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 10px;
  letter-spacing: 0.04em;
}
.konami-keys {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}
.konami-keys kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Bumped up from 24×26 / 12.5px so the ancient code reads clearly
     in the L4-locked modal — these are the headline of that screen,
     not a footnote. */
  min-width: 36px;
  height: 38px;
  padding: 0 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom-width: 3px;
  border-radius: 6px;
  color: var(--text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}

.level-up-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.level-up-actions .btn-cast { padding: 12px 26px; }

.level-up-dismiss-link {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 999px;
  transition: color 0.2s;
}
.level-up-dismiss-link:hover { color: var(--text-dim); }

/* ---------- Spellbook modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 6, 18, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease both;
}
.modal-card {
  position: relative;
  width: min(540px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: modalRise 0.25s ease both;
}
@keyframes modalRise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad) border-box;
}
.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.4px;
}
.modal-close {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.modal-close:hover { background: var(--surface-2); }

.spellbook-list {
  padding: 12px 18px;
  overflow-y: auto;
  flex: 1;
}
.spell-entry {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.spell-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.spell-entry-mode {
  color: var(--accent);
  font-weight: 600;
}
.spell-entry-text {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.4;
  color: var(--text);
}
.spell-entry-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.spell-entry-actions .btn-ghost { padding: 6px 10px; font-size: 12px; min-height: 32px; }

.spellbook-empty {
  padding: 24px 18px;
  text-align: center;
  color: var(--text-mute);
  font-style: italic;
}

/* ---------- About modal ---------- */
.about-card { width: min(460px, 100%); }

/* ---------- Favorites modal (v1.9.0) ----------
   Top-10 blessed spells leaderboard. Wider than About to give the
   3-line haikus room to breathe; capped at 540px so it doesn't feel
   like a wall on desktop. */
.favorites-card { width: min(540px, 100%); }
.favorites-intro {
  margin: 18px 22px 12px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}
.favorites-intro strong {
  color: var(--text);
  font-weight: 600;
}
.favorites-list {
  list-style: none;
  margin: 0;
  padding: 4px 22px 14px;
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.favorites-entry {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-items: start;
  transition: border-color 0.2s, background 0.2s;
}
.favorites-entry:hover {
  border-color: var(--border-strong);
  background: var(--surface-3, var(--surface-2));
}
/* Top 3 get a subtle gold accent on the rank number — implied podium */
.favorites-entry:nth-child(1) .favorites-rank,
.favorites-entry:nth-child(2) .favorites-rank,
.favorites-entry:nth-child(3) .favorites-rank {
  color: #ffd866;
  text-shadow: 0 0 8px rgba(255, 216, 102, 0.45);
}
.favorites-rank {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-mute);
  line-height: 1;
  text-align: right;
  padding-top: 3px;
  letter-spacing: -0.5px;
}
.favorites-entry-body {
  min-width: 0; /* prevent grid blowout on long quotes */
}
.favorites-quote {
  margin: 0 0 6px;
  padding: 0;
  border: none;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}
.favorites-source {
  margin: 0;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.favorites-coda {
  margin: 0 22px 18px;
  padding: 12px 0 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  text-align: center;
  color: var(--text-mute);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  font-style: italic;
}
.about-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
}
.about-line {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.about-line em {
  font-style: normal;
  color: var(--accent);
  font-weight: 600;
}
.about-section-label {
  margin: 18px 0 10px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 600;
}
.about-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.about-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
}
.about-list-icon {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
  margin-top: 2px;
}
.about-outro {
  margin: 14px 0 8px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}
.about-coda {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-mute);
  font-style: italic;
}

/* About-modal credits section — studio link + Ko-fi badge.
   Mirrors the placements in the page footer but with more context
   (lead-in copy, slightly more visual weight) since users who open
   the About modal are already engaged. */
.about-credits {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 4px 0 0;
}
.about-credits-line {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  flex-wrap: wrap;
}
.about-credits-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 13.5px;
  border-radius: 999px;
  padding: 5px 12px 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s;
}
.about-credits-link:hover,
.about-credits-link:focus-visible {
  border-color: var(--accent);
  background: var(--surface-3);
  color: #fff;
  transform: translateY(-1px);
}
.about-credits-logo {
  display: block;
  width: 18px;
  height: auto;
  fill: var(--accent);
  flex-shrink: 0;
  transition: fill 0.2s;
}
.about-credits-link:hover .about-credits-logo,
.about-credits-link:focus-visible .about-credits-logo {
  fill: #fff;
}
.about-credits-tip {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  border-radius: 8px;
  transition: transform 0.15s ease, filter 0.2s ease;
}
.about-credits-tip:hover,
.about-credits-tip:focus-visible {
  transform: translateY(-1px);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
}
.about-credits-tip img { display: block; }

/* ---------- Share modal ---------- */
.share-card { width: min(440px, 100%); }

.share-preview {
  margin: 0;
  padding: 14px 18px 4px;
  /* Bottom separator moved to .share-preview-byline so the byline
     stays grouped with the quote as one visual block. */
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-dim);
  font-style: italic;
  white-space: pre-wrap;
  text-align: center;
}
.share-preview::before { content: '\201C'; margin-right: 2px; opacity: 0.6; }
.share-preview::after  { content: '\201D'; margin-left: 2px;  opacity: 0.6; }

/* Byline beneath the share-preview blockquote — mirrors the mug
   product byline ("— The Workday Wizard") so the share preview
   reads like a properly-attributed piece of writing. */
.share-preview-byline {
  display: block;
  text-align: center;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12.5px;
  color: var(--text-mute);
  letter-spacing: 0.03em;
  margin: -6px 18px 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* The link that will actually be shared. Truncated with ellipsis;
   full URL is in the title attribute so it shows on hover. */
.share-url-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 18px 4px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11.5px;
  color: var(--text-mute);
  overflow: hidden;
}
.share-url-icon { font-size: 12px; opacity: 0.7; }
.share-url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 18px 18px;
}
.share-option {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.share-option:hover {
  background: var(--surface-3);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.share-option:active { transform: translateY(0); }
.share-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--grad-soft);
  font-size: 18px;
  font-weight: 700;
  font-style: normal;
  font-family: var(--font);
}

@media (max-width: 480px) {
  .share-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad) border-box;
  border: 1.5px solid transparent;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease both;
}
.toast.out { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, 0); }
  to   { opacity: 0; transform: translate(-50%, 8px); }
}

/* ---------- Footer ----------
   v1.9.3 — collapsed from 4 stacked rows into a single horizontal
   flex row. Order (from left): the "not responsible" tagline, the
   321Enterprise logo, the version stamp, the Ko-fi tip image. Wraps
   gracefully on narrow viewports.

   Note: top-level `.foot` margin/positioning is set above by the
   layout block (margin-top: auto), so we omit `margin-top` here. */
.foot {
  text-align: center;
  color: var(--text-mute);
  font-size: calc(11.5px * var(--text-scale, 1) * var(--vp-scale, 1));
  letter-spacing: 0.06em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: calc(14px * var(--vp-scale, 1));
}
.foot-line { margin: 0; opacity: 0.85; }

/* 321Enterprise studio logo — replaces the wordmark credit line.
   Subtle dark purple, brightens on hover. */
.foot-studio {
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
}
.foot-studio-link {
  display: inline-block;
  color: #5a4d7a; /* subtle dark purple — visible on dark bg, not loud */
  transition: color 0.25s ease, transform 0.18s ease;
  border-radius: 50%;
}
.foot-studio-link:hover,
.foot-studio-link:focus-visible { color: var(--accent); transform: translateY(-2px); }
.foot-studio-logo {
  display: block;
  width: calc(22px * var(--vp-scale, 1));
  height: auto;
  fill: currentColor;
}
.foot-studio-logo path,
.foot-studio-logo circle { fill: currentColor; }

.foot-version {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: calc(10px * var(--text-scale, 1));
  letter-spacing: 0.05em;
  color: var(--text-mute);
  opacity: 0.55;
}
/* Ko-fi tip image — sits inline with the rest of the footer row.
   The image is naturally ~36px tall, larger than the surrounding
   text, so we cap it to keep the row visually balanced. */
.foot-tip {
  margin: 0;
  line-height: 0;
  display: inline-flex;
  align-items: center;
}
.foot-tip a {
  display: inline-block;
  transition: transform 0.15s ease, filter 0.2s ease;
  border-radius: 8px;
}
.foot-tip a:hover { transform: translateY(-2px); filter: drop-shadow(0 6px 12px rgba(0,0,0,0.4)); }
.foot-tip img { display: block; height: calc(28px * var(--vp-scale, 1)) !important; width: auto; }
.foot-link {
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 1px dashed rgba(168, 164, 199, 0.5);
  transition: color 0.2s, border-color 0.2s;
}
.foot-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- Compact mode for short viewports ----------
   v1.9.3 — Per L.A.'s feedback we now KEEP the intro paragraph here
   (only line-height tightens), and shrink mascot + title further so
   the canvas still fits without scrolling on 1366×768 and 1440×900.
   The user's text-scale (A−/A+) is still respected since every
   font-size below also multiplies by var(--text-scale).

   Targets typical laptop viewports (1366×768, 1440×900 → ~720px
   effective, MacBook 13" Retina → ~690px). */
@media (max-height: 900px) and (min-width: 720px) {
  .topbar { padding: calc(4px + var(--safe-top)) 16px 4px; }
  /* v1.9.6 — added top padding (was 4) so the hero has breathing room
     between topbar and title even on laptop heights. */
  .wrap   { padding: 14px 24px 12px; }

  .mascot-wrap { width: 95px; height: 133px; }
  .intro       { font-size: calc(13px * var(--text-scale, 1)); line-height: 1.35; }
  .title       { font-size: calc(clamp(24px, 3.6vw, 36px) * var(--text-scale, 1)); margin-bottom: 2px; }
  .subtitle    { margin-bottom: 2px; }

  /* v1.9.6 — laptop-height hero gets 14px below (was 6) so intro
     paragraph has visible space before "Pick your magic". */
  .hero { margin-bottom: 14px; gap: 16px; max-width: 660px; }
  /* v1.9.5 — bumped the laptop-height spacing too. Cast still ~14/16,
     section-label gets a little breathing room, grid gets a bit more
     separation between cards. */
  .cast { margin: 14px 0 16px; }

  .section-label { margin-bottom: 10px; }
  .modes         { margin-bottom: 12px; }
  .mode-grid     { gap: 12px; }
  .mode-card {
    min-height: 68px;
    padding: 6px 8px;
    gap: 3px;
  }
  .mode-icon {
    width: 34px;
    height: 34px;
    font-size: 20px;
    border-radius: 9px;
  }
  .mode-title { font-size: calc(12.5px * var(--text-scale, 1)); }
  .mode-desc  { font-size: calc(10.5px * var(--text-scale, 1)); line-height: 1.2; }

  .btn-cast {
    padding: 9px 18px;
    min-height: 38px;
    font-size: calc(14.5px * var(--text-scale, 1));
  }
  .hint { margin-top: 6px; font-size: calc(12px * var(--text-scale, 1)); }

  .output-section { margin-top: 10px; }
  .output-card    {
    padding: 10px 12px 8px;
    border-radius: 14px;
    margin-bottom: 8px;
  }
  .output-header  { margin-bottom: 4px; }
  .foot           { gap: 10px; }

  .output-text {
    min-height: 44px;
    font-size: calc(clamp(16px, 1.9vw, 19px) * var(--text-scale, 1));
    padding-bottom: 6px;
  }
  .output-text.empty {
    min-height: 28px;
    font-size: calc(13px * var(--text-scale, 1));
  }
  .output-actions .btn-ghost {
    padding: 6px 10px;
    font-size: calc(12px * var(--text-scale, 1));
    min-height: 32px;
  }
  .output-aux-row { margin-top: 8px; padding-top: 6px; gap: 14px; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .wrap { padding: 12px 16px 16px; }
  .hero { margin-bottom: 16px; }
  /* Mobile keeps a larger mascot — there's vertical room here, and the
     wizard reads as the hero on phone-shaped screens. */
  .mascot-wrap { width: 140px; height: 196px; }
  .intro { font-size: calc(14px * var(--text-scale, 1)); }

  /* v1.9.10 — Outer shell stays overflow-visible so #topbarLeft popover
     is not clipped. Horizontal scroll lives on .topbar-inner instead. */
  .topbar {
    display: block;
    grid-template-columns: none;
    padding: calc(8px + var(--safe-top)) 12px 8px;
    overflow: visible;
  }
  /* v1.9.5 — on mobile, dissolve the three desktop groups back into a
     single horizontal flex row that scrolls. `display: contents` on
     the groups makes their children behave as if they were direct
     children of .topbar-inner. Status panel stays at the end, keeping
     "your wizard journey" on the right edge as on desktop. */
  .topbar-inner {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    /* Soft fade on the right edge — communicates that more buttons
       are available by scrolling. Mirrors the .mode-grid carousel
       fade pattern below for visual consistency. */
    mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 18px), transparent 100%);
  }
  .topbar-inner::-webkit-scrollbar { display: none; }
  .topbar-group { display: contents; }
  .topbar-btn { flex-shrink: 0; min-height: 36px; }
  .topbar-btn-icon { width: 36px; }
  .topbar-btn-text { min-width: 36px; padding: 0 8px; }
  .status-panel { flex-shrink: 0; }

  /* v1.9.8 — Mobile settings overflow gear.
     Hide the three preference buttons (audio/confetti/text size)
     by collapsing the entire .topbar-left group, then surface a
     single ⚙️ gear button in its place. ID beats .topbar-group's
     display: contents above. */
  #topbarLeft { display: none; }
  .settings-toggle { display: inline-flex; }

  /* Popover state: the same #topbarLeft group, but rendered as a
     fixed-position card below the topbar with labeled rows.
     Fixed positioning sidesteps the sticky-vs-absolute containing-
     block problem and keeps the popover anchored to the viewport
     even if the page scrolls underneath. */
  #topbarLeft.is-open {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: fixed;
    top: calc(8px + var(--safe-top) + 44px); /* topbar padding + button height */
    left: 12px;
    width: 220px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    z-index: 20;
  }

  /* Each preference row: label on the left, control on the right. */
  #topbarLeft.is-open .settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  #topbarLeft.is-open .settings-row-label {
    display: inline;
    font-size: 13px;
    color: var(--text);
    flex: 1 1 auto;
  }

  /* Text-size sub-control: when inside the open settings popover,
     skip the nested popover-on-popover pattern and show the three
     step buttons inline. Cleaner than a popover-inside-a-popover. */
  #topbarLeft.is-open .textsize-control {
    position: static;
  }
  #topbarLeft.is-open #textSizeBtn { display: none; }
  #topbarLeft.is-open #textSizePopover {
    display: inline-flex;
    position: static;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    gap: 4px;
  }
  #topbarLeft.is-open #textSizePopover[hidden] {
    /* Force-visible even when the desktop JS hasn't opened it,
       since the parent settings popover is the trigger now. */
    display: inline-flex !important;
  }

  /* "Wizard's Scroll" — horizontal scroll-snap carousel
     for the 8 main modes. The 9th lives in .featured-mode
     below and stays centered. */
  .mode-grid {
    display: flex;
    grid-template-columns: none;
    overflow-x: auto;
    overflow-y: visible;
    scroll-snap-type: x mandatory;
    gap: 12px;
    /* bleed to the screen edges so cards can scroll past, with
       inner padding restoring breathing room at the snap point */
    margin: 0 -16px;
    padding: 6px 16px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* fade the left/right edges so cards seem to unroll from the scroll */
    mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  }
  .mode-grid::-webkit-scrollbar { display: none; }

  .mode-card {
    flex: 0 0 60%;
    scroll-snap-align: center;
    padding: 10px 12px;
    min-height: 96px;
  }
  .mode-icon {
    width: 46px;
    height: 46px;
    font-size: 26px;
    border-radius: 12px;
  }
  .mode-title { font-size: 14px; }
  .mode-desc  { font-size: 12px; }

  /* Show the dots on mobile only */
  .mode-dots { display: flex; }

  .btn-cast { width: 100%; max-width: 360px; justify-content: center; }
  .output-card { padding: 18px 16px 14px; border-radius: 16px; }
  .output-text { min-height: 90px; }
  .output-actions .btn-ghost { flex: 0 1 auto; }

  .topbar-btn-label { display: none; } /* keep just the book icon on small screens */
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  /* The smoke band is a frozen fog blob without its drift — hide it
     so reduced-motion users get clean static spicy theming instead
     of a stationary "what is that" smear at the bottom of the page. */
  body.spicy-unlocked::after { display: none !important; }
  /* Candlelight can stay; without flicker it reads as a warm static
     glow, which is fine — we just hold it at a moderate intensity. */
  body.spicy-unlocked::before { opacity: 0.85 !important; }
}
