/* ==========================================================
   NZ Tax Adventure — restyled to consume hub design tokens
   (Kauri & Paua palette from /styles/tokens.css).

   Token usage (chrome):
     --paper   page + section background
     --ink     primary text, borders, dark accents
     --deep    secondary text
     --rule    dashed dividers, subtle borders
     --kauri   primary accent (active states, "money-in")
     --paua    secondary accent (links, "money-out", compare)
     --manuka  warning / emphasis ("dodge", villain, highlight)

   Diagram semantic colours (--money-in, --money-out, --dodge,
   --gold, --villain) are aliased to the new tokens so the
   cartoon pipes still read as IN / OUT / DODGE without
   re-authoring every SVG rule.
   ========================================================== */

:root {
  /* surfaces / structure (now driven by tokens) */
  --bg:           var(--paper);
  --bg-card:      var(--paper);
  --ink-soft:     var(--deep);
  --line:         var(--rule);

  /* diagram-flow semantic colours — re-aliased onto the new palette
     so the cartoon's IN / OUT / DODGE narrative survives */
  --money-in:     var(--kauri);
  --money-in-bg:  color-mix(in srgb, var(--kauri) 14%, var(--paper));
  --money-out:    var(--paua);
  --money-out-bg: color-mix(in srgb, var(--paua) 14%, var(--paper));
  --dodge:        var(--manuka);
  --dodge-bg:     color-mix(in srgb, var(--manuka) 16%, var(--paper));
  --gold:         var(--manuka);
  --villain:      var(--manuka);

  /* hero gets a calm gradient over the kauri / paua / manuka stack */
  --hero-bg:      linear-gradient(135deg,
                    color-mix(in srgb, var(--kauri) 18%, var(--paper)) 0%,
                    color-mix(in srgb, var(--paua)  18%, var(--paper)) 50%,
                    color-mix(in srgb, var(--manuka) 18%, var(--paper)) 100%);

  --shadow-sm:    0 2px 0 color-mix(in srgb, var(--ink) 12%, transparent),
                  0 4px 12px color-mix(in srgb, var(--ink) 8%, transparent);
  --shadow-md:    0 4px 0 color-mix(in srgb, var(--ink) 15%, transparent),
                  0 8px 24px color-mix(in srgb, var(--ink) 10%, transparent);
  --shadow-lg:    0 8px 0 color-mix(in srgb, var(--ink) 18%, transparent),
                  0 16px 40px color-mix(in srgb, var(--ink) 14%, transparent);

  --radius-sm:    10px;
  --radius-md:    18px;
  --radius-lg:    28px;

  /* Typography — Inter for body / UI, Fraunces for display.
     Cartoon-character display fonts (Bangers, Fredoka, Patrick Hand)
     remain available for speech bubbles and emoji captions. */
  --font-fun:     "Inter", "Fredoka", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-hand:    "Patrick Hand", "Comic Sans MS", cursive;
  --font-impact:  "Fraunces", "Bangers", "Impact", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-fun);
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--paua); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--manuka); }

/* visually hidden, but still read out by screen readers */
.vis-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
h1, h2, h3 { font-family: var(--font-impact); font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.4em; }
h2 { font-size: clamp(1.4rem, 2.6vw, 2.1rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8em; }

/* ==================== HERO ==================== */
.hero {
  position: relative;
  background: var(--hero-bg);
  padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 60px) clamp(60px, 8vw, 110px);
  overflow: hidden;
  border-bottom: 4px solid var(--ink);
}
.hero::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -1px; height: 30px;
  background: radial-gradient(ellipse at center top, transparent 60%, var(--bg) 61%) repeat-x;
  background-size: 60px 30px;
}
.hero-inner { max-width: 880px; margin: 0 auto; text-align: center; position: relative; z-index: 2; }
.kiwi-badge {
  display: inline-block; font-size: 2.6rem;
  background: var(--paper);
  border-radius: 50%; width: 80px; height: 80px;
  line-height: 80px;
  border: 4px solid var(--ink);
  box-shadow: var(--shadow-md);
  margin-bottom: 0.6em;
  transform: rotate(-4deg);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50%      { transform: rotate(4deg) translateY(-6px); }
}
.hero h1 {
  font-family: var(--font-impact);
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow:
    3px 3px 0 var(--paper),
    6px 6px 0 var(--ink);
  margin-bottom: 0.4em;
  line-height: 1.0;
}
.hero-sub {
  font-family: var(--font-hand);
  font-size: clamp(1.1rem, 2.2vw, 1.5rem);
  color: var(--ink);
  max-width: 640px; margin: 0.4em auto 1.4em;
}
.hero-cta {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-fun); font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  font-size: 1rem;
}
.hero-coins {
  position: absolute; inset: 0;
  pointer-events: none;
  font-size: 2rem;
  z-index: 1;
}
.hero-coins span {
  position: absolute;
  opacity: 0.7;
  animation: floatCoin 8s linear infinite;
}
.hero-coins span:nth-child(1){ left: 6%;  top: 20%; animation-delay: 0s;   font-size: 2.2rem; }
.hero-coins span:nth-child(2){ left: 18%; top: 70%; animation-delay: 1s;   font-size: 1.6rem; }
.hero-coins span:nth-child(3){ left: 30%; top: 30%; animation-delay: 2s;   font-size: 2.4rem; }
.hero-coins span:nth-child(4){ left: 50%; top: 78%; animation-delay: 0.5s; font-size: 1.8rem; }
.hero-coins span:nth-child(5){ left: 65%; top: 25%; animation-delay: 1.5s; font-size: 2rem; }
.hero-coins span:nth-child(6){ left: 78%; top: 65%; animation-delay: 3s;   font-size: 2.6rem; }
.hero-coins span:nth-child(7){ left: 88%; top: 18%; animation-delay: 2.5s; font-size: 1.6rem; }
.hero-coins span:nth-child(8){ left: 92%; top: 75%; animation-delay: 0.8s; font-size: 2rem; }
@keyframes floatCoin {
  0%   { transform: translateY(0)   rotate(0deg); }
  50%  { transform: translateY(-30px) rotate(180deg); }
  100% { transform: translateY(0)   rotate(360deg); }
}

/* ==================== STORY INTRO ==================== */
.intro-section {
  max-width: 1200px;
  margin: 30px auto 10px;
  padding: 0 clamp(16px, 3vw, 40px);
}
.intro-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
  align-items: stretch;
}
.intro-cast, .intro-rules {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.intro-cast h2, .intro-rules h2 {
  font-family: var(--font-impact);
  letter-spacing: 0.04em;
  font-size: 1.5rem;
}
.cast-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.cast-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 12px 8px;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.15s ease;
}
.cast-card:hover { transform: rotate(-1deg) translateY(-2px); }
.cast-card span { font-size: 1.8rem; line-height: 1; }
.cast-card strong { font-size: 0.95rem; }
.cast-card em { font-size: 0.78rem; color: var(--deep); font-style: normal; font-family: var(--font-hand); }
.cast-card.bad { border-color: var(--manuka); }
.cast-card.bad strong { color: var(--manuka); }
.rules-list { margin: 12px 0 0; padding: 0; list-style: none; counter-reset: rule; }
.rules-list li {
  counter-increment: rule;
  position: relative;
  padding: 8px 0 8px 38px;
  font-size: 0.95rem;
  border-bottom: 2px dashed var(--rule);
}
.rules-list li:last-child { border-bottom: none; }
.rules-list li::before {
  content: counter(rule);
  position: absolute; left: 0; top: 6px;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--manuka);
  color: var(--paper);
  border: 2px solid var(--ink);
  font-family: var(--font-impact);
  text-align: center; line-height: 22px;
}
.rules-list .badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 2px solid var(--ink);
  vertical-align: middle;
  margin: 0 2px;
}
.rules-list .badge.in    { background: var(--money-in-bg);  color: var(--money-in); }
.rules-list .badge.out   { background: var(--money-out-bg); color: var(--money-out); }
.rules-list .badge.dodge { background: var(--dodge-bg);     color: var(--dodge); }
.intro-tip {
  margin-top: 14px;
  background: var(--paper);
  border: 2px dashed var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-hand);
  font-size: 1rem;
}
@media (max-width: 820px) {
  .intro-grid { grid-template-columns: 1fr; }
}

/* ==================== TIMELINE ==================== */
.timeline-section {
  max-width: 1200px;
  margin: -40px auto 30px;
  padding: 0 clamp(16px, 3vw, 40px);
  position: relative; z-index: 5;
}
.timeline-rail {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 26px 22px 16px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.timeline-track {
  position: absolute;
  left: 60px; right: 60px;
  top: 60px;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 12px, transparent 12px 22px);
  border-radius: 3px;
  z-index: 0;
}
.timeline-buttons {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  position: relative; z-index: 1;
}
.era-btn {
  appearance: none;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 12px 6px 10px;
  font-family: var(--font-fun); font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: center;
  color: var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  position: relative;
  line-height: 1.1;
}
.era-btn .era-btn-year { display: block; font-size: 1.3rem; font-family: var(--font-impact); letter-spacing: 0.04em; }
.era-btn .era-btn-label { display: block; font-size: 0.78rem; opacity: 0.75; margin-top: 4px; }
.era-btn:hover { transform: translateY(-2px); }
.era-btn.active {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink), 0 0 0 6px color-mix(in srgb, var(--manuka) 70%, transparent);
}
/* Party colours now drawn from the kauri / paua / manuka palette
   rather than literal NZ-party brand hexes. Active state stays
   high-contrast (paper on filled token). */
.era-btn[data-party="Labour"]   { border-color: var(--manuka); }
.era-btn[data-party="Labour"].active   {
  background: var(--manuka);
  color: var(--paper);
  box-shadow:
    0 2px 0 color-mix(in srgb, var(--manuka) 60%, var(--ink)),
    0 0 0 6px color-mix(in srgb, var(--manuka) 25%, transparent);
}
.era-btn[data-party="National"] { border-color: var(--paua); }
.era-btn[data-party="National"].active {
  background: var(--paua);
  color: var(--paper);
  box-shadow:
    0 2px 0 color-mix(in srgb, var(--paua) 60%, var(--ink)),
    0 0 0 6px color-mix(in srgb, var(--paua) 25%, transparent);
}
.era-btn[data-party="National + ACT + NZ First"] { border-color: var(--paua); }
.era-btn[data-party="National + ACT + NZ First"].active {
  background: var(--paua);
  color: var(--paper);
  box-shadow:
    0 2px 0 color-mix(in srgb, var(--paua) 60%, var(--ink)),
    0 0 0 6px color-mix(in srgb, var(--paua) 25%, transparent);
}
.era-btn[data-party="Greens / Te Pāti Māori platform"] { border-color: var(--kauri); }
.era-btn[data-party="Greens / Te Pāti Māori platform"].active {
  background: var(--kauri);
  color: var(--paper);
  box-shadow:
    0 2px 0 color-mix(in srgb, var(--kauri) 60%, var(--ink)),
    0 0 0 6px color-mix(in srgb, var(--kauri) 25%, transparent);
}

/* ==================== ERA CONTROLS (play / compare) ==================== */
.era-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.ctrl-btn {
  appearance: none;
  background: var(--ink);
  color: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 11px 22px;
  font-family: var(--font-fun); font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--ink) 32%, transparent);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  white-space: nowrap;
}
.ctrl-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 color-mix(in srgb, var(--ink) 32%, transparent); }
.ctrl-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 32%, transparent); }
.ctrl-btn.playing { background: var(--manuka); border-color: var(--manuka); }
.ctrl-btn.ctrl-compare.active { background: var(--paua); border-color: var(--paua); }
.play-progress {
  flex: 1 1 160px;
  min-width: 140px;
  height: 14px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.play-progress[hidden] { display: none; }
.play-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--manuka) 0%, var(--kauri) 100%);
  border-radius: 999px;
}
.play-status {
  font-family: var(--font-hand);
  font-size: 1.05rem;
  color: var(--deep);
  min-width: 0;
}

/* ==================== ERA CARD ==================== */
.era-card {
  margin-top: 18px;
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
}
.era-card .ec-title {
  font-family: var(--font-impact);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  letter-spacing: 0.03em;
  margin: 0 0 4px;
  text-transform: uppercase;
}
.era-card .ec-meta {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--deep);
}
.era-card .ec-headline {
  font-family: var(--font-fun); font-weight: 600;
  font-size: 1.15rem;
  margin-top: 6px;
}
.era-card .ec-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.ec-chip {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
  font-weight: 600;
}
.ec-chip strong { color: var(--kauri); }
.ec-chip.warn strong { color: var(--manuka); }
.ec-chip.danger strong { color: var(--manuka); }

/* ==================== COMPARE PANEL ==================== */
.era-btn-pick {
  position: absolute;
  top: -12px; right: -10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--paua);
  color: var(--paper);
  border: 3px solid var(--ink);
  font-family: var(--font-impact);
  font-size: 1rem;
  line-height: 22px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.era-btn.compare-pick { border-color: var(--paua); }

.compare-panel {
  margin-top: 18px;
  background: var(--bg-card);
  border: 4px solid var(--paua);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-md);
}
.compare-panel[hidden] { display: none; }
.compare-hint {
  margin: 0;
  text-align: center;
  font-family: var(--font-hand);
  font-size: 1.25rem;
  color: var(--deep);
}
.compare-title {
  font-family: var(--font-impact);
  font-size: clamp(1.2rem, 2.6vw, 1.7rem);
  letter-spacing: 0.03em;
  text-align: center;
  margin: 0 0 14px;
}
.compare-title .cmp-vs {
  font-family: var(--font-hand);
  color: var(--deep);
  font-size: 0.8em;
  margin: 0 4px;
}
.compare-table {
  width: 100%;
  border-collapse: collapse;
}
.compare-table th,
.compare-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 2px dashed var(--rule);
  font-size: 0.95rem;
}
.compare-table thead th {
  font-family: var(--font-impact);
  letter-spacing: 0.04em;
  font-size: 1.15rem;
  border-bottom: 3px solid var(--ink);
}
.compare-table thead th:first-child { width: 42%; }
.compare-table .cmp-metric {
  font-family: var(--font-fun); font-weight: 600;
  color: var(--deep);
}
.compare-table .cmp-val { font-weight: 700; }
.compare-table tr.changed { background: color-mix(in srgb, var(--manuka) 22%, transparent); }
.compare-table tr.changed .cmp-metric { color: var(--ink); }
.cmp-arrow {
  display: inline-block;
  margin-left: 7px;
  font-size: 0.8rem;
  vertical-align: 1px;
}
.cmp-arrow.up   { color: var(--kauri); }
.cmp-arrow.down { color: var(--manuka); }
.cmp-arrow.same { color: var(--paua); }
.compare-summary {
  margin: 14px 0 0;
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--ink);
}

/* ==================== DIAGRAM ==================== */
.diagram-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px clamp(10px, 2vw, 30px) 30px;
}
.diagram-frame {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
#taxDiagram { width: 100%; height: auto; display: block; }

.col-label {
  font-family: var(--font-impact);
  font-size: 22px;
  fill: var(--deep);
  letter-spacing: 0.06em;
}

/* SVG NODES — these are the cartoon characters / pipes.
   Their semantic colours (money-in / money-out / dodge / villain)
   are aliased to the new palette at the top of the file. */
.node-bubble {
  fill: var(--paper);
  stroke: var(--ink);
  stroke-width: 3;
  rx: 14;
  ry: 14;
  filter: url(#glow);
}
.node-emoji   { font-size: 38px; text-anchor: middle; dominant-baseline: central; }
.node-label   { font-family: var(--font-fun); font-weight: 700; font-size: 16px; fill: var(--ink); text-anchor: middle; }
.node-sub     { font-family: var(--font-hand);  font-size: 14px; fill: var(--deep); text-anchor: middle; }
.node-villain rect { stroke: var(--villain); stroke-width: 3.5; }
.node-villain .node-label { fill: var(--villain); }

.node-ird rect {
  fill: color-mix(in srgb, var(--manuka) 18%, var(--paper));
  stroke: var(--gold);
  stroke-width: 5;
  animation: irdPulse 3.4s ease-in-out infinite;
}
@keyframes irdPulse {
  0%, 100% { stroke-width: 5; filter: drop-shadow(0 0 0 color-mix(in srgb, var(--manuka) 0%, transparent)); }
  50%      { stroke-width: 7; filter: drop-shadow(0 0 14px color-mix(in srgb, var(--manuka) 60%, transparent)); }
}
.node { transition: transform 0.2s ease; transform-box: fill-box; transform-origin: center; }
.node:hover { transform: scale(1.04) rotate(-1deg); }
.node-villain:hover { transform: scale(1.04) rotate(1.5deg); }
.node-ird .node-emoji { font-size: 56px; }
.node-ird .node-label { font-size: 22px; }
.node-ird .node-sub   { font-size: 16px; }

.node-stash rect {
  fill: var(--dodge-bg);
  stroke: var(--dodge);
  stroke-width: 3.5;
  stroke-dasharray: 6 4;
}
.node-stash .node-label { fill: var(--dodge); }

/* SVG EDGES — money pipe flows.
   These are the cartoon's semantic colour channels and live on the
   token-driven --money-in / --money-out / --dodge aliases above. */
.edge {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width 0.6s ease, opacity 0.4s ease, stroke 0.4s ease;
  opacity: 0.85;
}
.edge.in    { stroke: var(--money-in);  }
.edge.out   { stroke: var(--money-out); }
.edge.dodge { stroke: var(--dodge); stroke-dasharray: 10 6; }

/* coin tokens animated along paths. Coin colours ride the same
   money-in / money-out / dodge aliases as the edges, so the
   cartoon narrative stays consistent. */
.coin {
  r: 7;
  fill: url(#coinGrad);
  stroke: color-mix(in srgb, var(--manuka) 70%, var(--ink));
  stroke-width: 1;
}
.coin.purple {
  fill: color-mix(in srgb, var(--paua) 50%, var(--paper));
  stroke: var(--paua);
}
.coin.dodge {
  fill: color-mix(in srgb, var(--manuka) 35%, var(--paper));
  stroke: var(--dodge);
}

/* badges that float above flows showing the rate */
.flow-badge {
  font-family: var(--font-fun); font-weight: 700;
  font-size: 14px;
  fill: var(--ink);
}
.flow-badge-bg { fill: var(--paper); stroke: var(--ink); stroke-width: 2; rx: 10; ry: 10; }

/* ==================== LEGEND ==================== */
.legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center;
  margin-top: 14px;
  font-size: 0.9rem;
}
.lg-pill {
  padding: 6px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 600;
}
.lg-pill.in    { background: var(--money-in-bg);  border-color: var(--money-in); }
.lg-pill.out   { background: var(--money-out-bg); border-color: var(--money-out); }
.lg-pill.dodge { background: var(--dodge-bg);     border-color: var(--dodge); }

/* ==================== GOTCHA / QUOTE ==================== */
.gotcha-section {
  max-width: 1100px; margin: 30px auto; padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 22px;
  align-items: start;
}
.speech-bubble {
  position: relative;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  font-family: var(--font-hand);
  font-size: 1.3rem;
  box-shadow: var(--shadow-md);
}
.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -22px; left: 50px;
  width: 28px; height: 28px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-top-color: transparent;
  border-left-color: transparent;
  transform: rotate(45deg);
}
.gotcha-card {
  background: var(--manuka);
  color: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.gotcha-card h3 {
  font-family: var(--font-impact);
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.4em;
}
.bullet-list {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  padding: 0; list-style: none;
}
.bullet-list li {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

/* ==================== EFFECTIVE RATES CHART ==================== */
.rates-section {
  max-width: 1100px; margin: 60px auto; padding: 0 20px;
}
.rates-section h2 { font-family: var(--font-impact); font-size: clamp(1.6rem, 4vw, 2.6rem); }
.rates-blurb { font-family: var(--font-hand); font-size: 1.15rem; max-width: 720px; }
.rates-chart {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
  display: grid; gap: 10px;
}
.rate-row {
  display: grid;
  grid-template-columns: 240px 1fr 60px;
  align-items: center;
  gap: 12px;
}
.rate-row .rr-label { font-size: 0.95rem; font-weight: 600; }
.rate-row .rr-label .rr-emoji { font-size: 1.4rem; margin-right: 6px; }
.rate-row .rr-bar-wrap {
  height: 22px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 11px;
  overflow: hidden;
  position: relative;
}
.rate-row .rr-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--paua) 0%, var(--kauri) 100%);
  border-radius: 11px 0 0 11px;
  transition: width 0.8s cubic-bezier(.18,.78,.32,1.1);
}
.rate-row.tycoon .rr-bar {
  background: linear-gradient(90deg, var(--manuka) 0%, var(--kauri) 100%);
}
.rate-row .rr-val { font-weight: 700; text-align: right; }
.rates-source { font-size: 0.85rem; color: var(--deep); margin-top: 10px; }

/* ==================== SANDBOX ==================== */
.sandbox-section {
  max-width: 1100px; margin: 60px auto; padding: 0 20px;
}
.sandbox-section h2 { font-family: var(--font-impact); font-size: clamp(1.6rem, 4vw, 2.6rem); }
.sliders {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px 26px;
  box-shadow: var(--shadow-md);
}
.sliders label {
  display: flex; flex-direction: column; gap: 8px;
  font-weight: 600;
}
.sliders label.checkbox {
  flex-direction: row; align-items: center; gap: 10px;
  background: var(--paper); padding: 10px 14px; border: 3px solid var(--ink); border-radius: var(--radius-md);
}
.sliders input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 12px; border-radius: 6px; background: var(--paper);
  border: 2px solid var(--ink);
}
.sliders input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--manuka);
  border: 3px solid var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.sliders input[type="range"]::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--manuka); border: 3px solid var(--ink); cursor: pointer;
}
.sliders output { font-family: var(--font-impact); font-size: 1.2rem; color: var(--manuka); margin-left: 6px; }
.sandbox-readout {
  margin-top: 14px;
  background: var(--bg-card);
  border: 4px dashed var(--ink);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font-family: var(--font-hand);
  font-size: 1.1rem;
}

/* ==================== DODGE GRID ==================== */
.dodge-section { max-width: 1200px; margin: 60px auto; padding: 0 20px; }
.dodge-section h2 { font-family: var(--font-impact); font-size: clamp(1.6rem, 4vw, 2.6rem); }
.dodge-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.dodge-card {
  background: var(--bg-card);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.dodge-card:hover { transform: translate(-2px, -4px); box-shadow: var(--shadow-lg); }
.dc-emoji { font-size: 2.4rem; display: block; margin-bottom: 6px; }
.dodge-card h3 { font-family: var(--font-impact); letter-spacing: 0.04em; }

/* ==================== CHARACTER TOAST ==================== */
.char-toast {
  position: fixed;
  left: 50%; bottom: 30px;
  transform: translate(-50%, 30px);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  max-width: min(520px, 92vw);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-fun);
  font-size: 1rem;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.char-toast.show { opacity: 1; transform: translate(-50%, 0); }
.char-toast strong { color: var(--manuka); }

/* ==================== FOOTER ==================== */
.footer {
  background: var(--ink);
  color: var(--paper);
  padding: 40px clamp(20px, 4vw, 60px) 60px;
  margin-top: 60px;
  border-top: 4px solid var(--manuka);
}
.footer h3 { color: var(--manuka); font-family: var(--font-impact); letter-spacing: 0.04em; font-size: 1.4rem; }
.footer a { color: color-mix(in srgb, var(--manuka) 70%, var(--paper)); text-decoration: underline; }
.source-list {
  list-style: none; padding: 0; margin: 0 0 18px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px 18px;
}
.footer-note { font-size: 0.9rem; color: color-mix(in srgb, var(--paper) 80%, var(--manuka)); max-width: 760px; }
.footer-credit { font-family: var(--font-hand); color: color-mix(in srgb, var(--manuka) 70%, var(--paper)); margin-top: 20px; }

/* ==================== KEYBOARD FOCUS ==================== */
:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}
/* on the dark footer an ink outline would vanish — switch to manuka */
.footer :focus-visible { outline-color: var(--manuka); }
/* SVG character nodes: outline the node and thicken its bubble */
.node:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.node:focus-visible .node-bubble { stroke-width: 6; }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 820px) {
  .timeline-buttons { grid-template-columns: repeat(4, 1fr); }
  .timeline-track { display: none; }
  .era-card { grid-template-columns: 1fr; }
  .gotcha-section { grid-template-columns: 1fr; }
  .rate-row { grid-template-columns: 1fr; gap: 4px; }
  .rate-row .rr-bar-wrap { height: 18px; }
  .rate-row .rr-val { text-align: left; }
  .hero h1 { text-shadow: 2px 2px 0 var(--paper), 4px 4px 0 var(--ink); }
  /* the diagram is detail-dense — keep it readable and let the user swipe to pan */
  .diagram-frame {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  #taxDiagram { min-width: 900px; }
  /* give the comparison table more room on small screens */
  .compare-panel { padding: 16px 14px; }
  .compare-table th,
  .compare-table td { padding: 8px 7px; font-size: 0.86rem; }
  .compare-table thead th { font-size: 1rem; }
  .compare-table thead th:first-child { width: 38%; }
}
@media (max-width: 480px) {
  .timeline-buttons { grid-template-columns: repeat(2, 1fr); }
  .era-btn { padding: 8px 4px 6px; }
  .era-btn .era-btn-year { font-size: 1.05rem; }
  .era-btn .era-btn-label { font-size: 0.7rem; }
}

/* Respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
