/* Lingua Mixta — Mercado / Tropicál design system.
   Light/dark via [data-theme] on <html>. Tokens follow the design handoff
   (design_handoff/README.md). Old --bg/--fg/etc. names kept for backwards
   compatibility with components written before the redesign. */

:root {
  --font-display: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans:    var(--font-body);   /* legacy alias */
  --font-mono:    ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 8px;
  --radius-sm: 6px;
  --radius-card: 12px;
  --radius-pill: 999px;

  /* Diamond motif palette — same across light/dark */
  --diamond-1: #E55A2B;
  --diamond-2: #FFC230;
  --diamond-3: #0F7A4A;

  /* Activity tile gradients — same across light/dark */
  --tile-primary-from:  #E55A2B;
  --tile-primary-to:    #B03E18;
  --tile-secondary-from:#FFC230;
  --tile-secondary-to:  #C99A22;
  --tile-tertiary-from: #0F7A4A;
  --tile-tertiary-to:   #0A5836;
  /* Felt: cantonese-pack jade billiard surface — matches the
     in-game backdrop on the Tile Solitaire screens. */
  --tile-felt-from:     #0E5340;
  --tile-felt-to:       #073527;
}

/* Tropicál — Light */
html[data-theme="light"] {
  --bg:         #FFF6E8;
  --card-bg:    #FFFCF4;
  --band-bg:    #FBE7CB;
  --bg-elev:    var(--card-bg);   /* legacy aliases */
  --bg-elev-2:  var(--band-bg);
  --ink:        #2A1A04;
  --ink-soft:   #7A5C2A;
  --fg:         var(--ink);
  --fg-muted:   var(--ink-soft);
  --line:       #F0DBB0;
  --border:     var(--line);
  --accent:     #E55A2B;
  --accent-fg:  #FFFCF4;
  --brand-accent: #0F7A4A;
  --nav-bg:     rgba(255, 246, 232, 0.92);
  --motif-opacity: 0.28;
  --success:    #0F7A4A;
  --danger:     #C8392B;
  --hover:      #FBE7CB;
}

/* Tropicál — Dark */
html[data-theme="dark"] {
  --bg:         #1B0F03;
  --card-bg:    #241606;
  --band-bg:    #1F1304;
  --bg-elev:    var(--card-bg);
  --bg-elev-2:  var(--band-bg);
  --ink:        #FCE6C2;
  --ink-soft:   #B08850;
  --fg:         var(--ink);
  --fg-muted:   var(--ink-soft);
  --line:       #3A2410;
  --border:     var(--line);
  --accent:     #FF7B45;
  --accent-fg:  #1B0F03;
  --brand-accent: #3FB075;
  --nav-bg:     rgba(27, 15, 3, 0.92);
  --motif-opacity: 0.22;
  --success:    #3FB075;
  --danger:     #E85645;
  --hover:      #1F1304;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----- Diamond motif band (full-bleed, top of pages) ----- */
.diamond-band {
  width: 100%;
  height: 14px;
  display: block;
  opacity: var(--motif-opacity);
}
.diamond-band svg { display: block; width: 100%; height: 100%; }

/* ----- Site header / navbar ----- */
.site-header {
  background: var(--nav-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .nav { padding: 12px 20px; }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-mark { height: 32px; width: auto; display: block; }
.brand-text .mixta {
  font-style: italic;
  font-weight: 700;
  color: var(--brand-accent);
}

/* Legacy aliases — old templates still reference .brand-logo */
.brand-logo { height: 32px; width: auto; display: block; }
.brand-logo-mono { color: var(--ink); }

.hero-logo { max-width: 720px; width: 100%; height: auto; display: block; margin: 0 auto 1.5rem; }
.auth-logo { max-width: 360px; width: 100%; height: auto; display: block; margin: 0 auto 1rem; }
.hero { text-align: center; }

/* Hero/auth-card legacy hero logos baked dark text into the SVG — keep the
   invert trick so they remain legible in dark mode. The new mark-tropical
   SVG is gradient-only (no dark text) so this filter doesn't apply to it. */
html[data-theme="dark"] .hero-logo,
html[data-theme="dark"] .auth-logo {
  filter: invert(1) hue-rotate(180deg);
}

.nav-links {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-wrap: wrap;
}
.nav-links a, .nav-links .link-button {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 450;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  position: relative;
  padding: 6px 0;
  transition: color 0.12s;
}
.nav-links a:hover, .nav-links .link-button:hover {
  color: var(--ink);
  text-decoration: none;
}
.nav-links a.active {
  color: var(--accent);
  font-weight: 600;
}
.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}
.nav-divider {
  display: inline-block;
  width: 1px;
  height: 16px;
  background: var(--line);
}

.logout-form { display: inline; margin: 0; padding: 0; }
.link-button {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

/* Global sound toggle in the navbar. Inherits the nav-link ink-soft
   color so it sits quietly next to the link list. Muted state turns
   it dark red and swaps the sound waves for a slash. The shake
   animation fires when an app calls linguaCanPlaySound() and gets
   blocked — visual reminder that audio is off. */
.nav-sound {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: none; border: 0; cursor: pointer;
  color: var(--ink-soft);
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}
.nav-sound:hover { color: var(--ink); background: rgba(0, 0, 0, 0.05); }
.nav-sound .nav-sound-slash { display: none; }
.nav-sound-muted { color: #8B0000; }    /* dark red — clearly "off" */
.nav-sound-muted:hover { color: #B30000; background: rgba(139, 0, 0, 0.08); }
.nav-sound-muted .nav-sound-wave { display: none; }
.nav-sound-muted .nav-sound-slash { display: inline; }

@keyframes nav-sound-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-4px) rotate(-3deg); }
  40%      { transform: translateX(4px)  rotate(3deg); }
  60%      { transform: translateX(-3px) rotate(-2deg); }
  80%      { transform: translateX(3px)  rotate(2deg); }
}
.nav-sound-shaking { animation: nav-sound-shake 0.55s ease-in-out; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.link-button:hover { color: var(--fg); }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px;
}
@media (max-width: 640px) {
  .container { padding: 24px 20px; }
}

/* ===== Hero ===== */
.hero-stage {
  text-align: center;
  padding: 64px 32px 40px;
}
.hero-stage .hero-row {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  margin-bottom: 24px;
}
@media (max-width: 640px) {
  .hero-stage { padding: 40px 16px 24px; }
  .hero-stage .hero-row { flex-direction: column; gap: 12px; }
}
.hero-mark { height: 132px; width: auto; display: block; }
.hero-text { text-align: left; }
.hero-text h1 {
  font-family: var(--font-display);
  font-size: 88px;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 0;
  color: var(--ink);
}
.hero-text h1 .mixta {
  font-style: italic;
  font-weight: 700;
  color: var(--brand-accent);
}
@media (max-width: 720px) {
  .hero-text h1 { font-size: 56px; }
  .hero-text { text-align: center; }
}
.hero-tagline {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 18px;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-soft);
}
.hero-welcome {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 520px;
  margin: 28px auto 0;
  line-height: 1.5;
}
.hero-welcome strong { color: var(--accent); font-weight: 600; }

/* Old hero (used by core/home.html legacy template) */
.hero h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.lede { color: var(--fg-muted); font-size: 1.05rem; }

/* ===== Generic page header — used by every non-activities page ===== */
.page-header {
  margin: 16px 0 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0;
  color: var(--ink);
}
.page-header .page-eyebrow {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: block;
  margin-bottom: 6px;
}
.page-header .page-desc {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.5;
  flex-basis: 100%;
}
.page-header-actions { display: flex; gap: 12px; align-items: center; }
.page-header-actions a { color: var(--accent); font-size: 14px; }

/* ===== Voice settings (account settings page) ===== */
.voice-section {
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 14px 0;
}
.voice-section legend {
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, #D14B2C);
  font-weight: 700;
  padding: 0 6px;
}
.voice-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  margin: 14px 0 18px;
}
.voice-bucket h3 {
  font-size: 13px;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}
.voice-bucket-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.voice-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  background: rgba(0,0,0,0.03);
  border-radius: 4px;
  font-size: 13px;
}
.voice-row-name {
  min-width: 0;
  word-break: break-word;
}
.voice-row-guess {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent, #D14B2C);
  margin-left: 6px;
}
.voice-row-radios {
  display: flex;
  gap: 6px;
}
.voice-radio {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
}
.voice-radio:has(input:checked) {
  background: var(--accent, #D14B2C);
  color: #fff;
  border-color: var(--accent, #D14B2C);
}
.voice-radio input { margin: 0; }
.voice-audition-btn {
  background: rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
}
.voice-audition-btn:hover { background: rgba(0,0,0,0.12); }
.voice-routing {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(0,0,0,0.15);
}
.voice-routing h3 {
  font-size: 13px;
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}
.voice-routing-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}
.voice-routing-row > span { flex: 1; }
.voice-routing select {
  padding: 4px 8px;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 4px;
  font-size: 13px;
}

/* ===== Activity grid (Activities landing) ===== */
.activity-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 16px 0 24px;
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
}
.activity-section-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.activity-section-head .pair-label {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

.activity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 980px;
  margin: 0 auto;
}
@media (max-width: 800px) {
  .activity-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .activity-grid { grid-template-columns: 1fr; }
}

.activity-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
}
.activity-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  text-decoration: none;
}
.activity-card.is-soon { opacity: 0.78; cursor: default; }
.activity-card.is-soon:hover { transform: none; border-color: var(--line); }

.activity-tile {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.activity-tile.tone-primary  { background: linear-gradient(180deg, var(--tile-primary-from)  0%, var(--tile-primary-to)  100%); }
.activity-tile.tone-secondary{ background: linear-gradient(180deg, var(--tile-secondary-from) 0%, var(--tile-secondary-to) 100%); }
.activity-tile.tone-tertiary { background: linear-gradient(180deg, var(--tile-tertiary-from)  0%, var(--tile-tertiary-to)  100%); }
.activity-tile.tone-felt {
  /* Bigger fibers + higher contrast than the in-game felt — this is
     a thumbnail-scale felt, so the texture has to read at a glance.
     Fiber stripes ~3px on a ~10px pitch give the eye something
     pickup-able. */
  background:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.07) 0 2px, transparent 2px 10px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.16)       0 2px, transparent 2px 11px),
    radial-gradient(120% 80% at 50% 30%, var(--tile-felt-from) 0%, var(--tile-felt-to) 100%);
  position: relative;
  /* Double-line brass frame (carved-stone-trim feel). Three stacked
     inset rings: 2px brass / 2px deep gap / 2px brass = 6px total,
     same recipe as the cantonese pack's edge palette. */
  box-shadow:
    inset 0 0 0 2px #C2A858,
    inset 0 0 0 4px rgba(0,0,0,0.55),
    inset 0 0 0 6px #C2A858;
}
/* Inset gap for the SVG so the framing rings don't get clipped by
   the tile-img object-fit. Felt shows through the gap as a small
   margin around the carved tile. The filter brightens the sandstone
   (the SVG itself is rendered with darker pre-baked shadows for the
   in-game scale; at thumbnail size it reads dull, so we lift it). */
.activity-tile.tone-felt .activity-tile-img {
  width: calc(100% - 12px);
  height: calc(100% - 12px);
  margin: 6px;
  filter: brightness(1.14) saturate(1.06) contrast(1.03);
}
.activity-tile.tile-cartouche { background: #000; padding: 0; }
.activity-tile .cartouche-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.activity-tile .activity-tile-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.activity-tile svg { display: block; width: 100%; height: 100%; }
.activity-tile-emoji {
  font-size: 56px;
  line-height: 1;
  color: rgba(255, 248, 235, 0.96);
}

.activity-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.activity-card-meta h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 550;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.activity-card-stat {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.activity-card-soon {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 3px 7px;
  background: var(--line);
  border-radius: var(--radius-pill);
}
.activity-card-desc {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 6px 0 0;
}

/* ===== Vocabulary band (on activities landing) ===== */
.vocab-band {
  margin-top: 40px;
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
  padding: 24px 28px;
  background: var(--band-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.vocab-band-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.vocab-band-stats {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}
.vocab-band-count {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.vocab-band-detail { font-size: 14px; color: var(--ink-soft); }
.vocab-band-detail strong { color: var(--accent); font-weight: 600; }
.vocab-band .btn-primary { white-space: nowrap; }

/* ===== Phrase of the day card (the "mixta moment") ===== */
.phrase-card {
  position: relative;
  margin-top: 32px;
  max-width: 980px;
  margin-left: auto;
  margin-right: auto;
  padding: 32px 56px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-card);
}
.phrase-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.phrase-card-label {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.phrase-card-date-wrap {
  position: relative;
}
.phrase-card-date {
  font-family: var(--font-display, inherit);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms, border-color 120ms;
}
.phrase-card-date:hover,
.phrase-card-date:focus-visible {
  color: var(--ink);
  border-color: var(--ink-soft);
}
/* Native date input lives off-screen but stays interactive — we open
   it via showPicker() (or fallback click) when the user taps the
   visible date pill. Hidden via opacity/size, NOT display:none, so
   showPicker remains valid in browsers that require visibility. */
.phrase-card-date-picker {
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}
.phrase-card-empty {
  font-style: italic;
  color: var(--ink-soft);
  font-size: 18px !important;
}
.phrase-card-empty a {
  color: var(--accent);
  text-decoration: underline;
}

/* Prev/next nav arrows. Sit at the card edges. Fade in on hover for
   pointing devices; always visible on touch (no hover affordance). */
.phrase-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  text-decoration: none;
  user-select: none;
  transition: opacity 120ms, color 120ms, border-color 120ms;
}
.phrase-arrow:hover {
  color: var(--ink);
  border-color: var(--ink-soft);
}
.phrase-arrow-prev { left: 12px; }
.phrase-arrow-next { right: 12px; }
.phrase-arrow-disabled {
  opacity: 0.25;
  cursor: not-allowed;
}
@media (hover: hover) {
  .phrase-arrow { opacity: 0; }
  .phrase-card:hover .phrase-arrow,
  .phrase-arrow:focus-visible {
    opacity: 1;
  }
  .phrase-card:hover .phrase-arrow-disabled { opacity: 0.25; }
}
.phrase-card-body {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-weight: 450;
  margin: 0;
  color: var(--ink);
}
.phrase-card-body .target {
  color: var(--accent);
  font-style: italic;
}
.phrase-card-glosses {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-soft);
}
.phrase-card-glosses strong { color: var(--accent); font-weight: 600; }

/* Legacy .cards / .card classes used by core/home.html — kept for now */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}
.card {
  display: block;
  padding: 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  color: var(--ink);
}
.card:hover { background: var(--hover); text-decoration: none; }
.card h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }
.card p { margin: 0; color: var(--ink-soft); }
.card-muted { opacity: 0.55; pointer-events: none; }

/* App-tile grid (Activities landing) — phone-home-screen style. */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1.5rem 1rem;
  margin-top: 2rem;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--fg);
  transition: transform 0.12s ease;
}
.app-tile:hover { text-decoration: none; transform: translateY(-2px); }
.app-tile:hover .app-icon { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }

.app-icon {
  width: 100%;
  aspect-ratio: 1;
  max-width: 160px;
  border-radius: 24%;
  overflow: hidden;
  background: var(--bg-elev-2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.15s ease;
}
.app-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.app-icon-emoji {
  font-size: 3.5rem;
  line-height: 1;
}

.app-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: var(--fg);
  line-height: 1.2;
}
.app-status {
  font-size: 0.75rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.app-tile-muted { cursor: default; }
.app-tile-muted .app-icon { opacity: 0.5; }
.app-tile-muted .app-name { color: var(--fg-muted); }

.quick-links {
  margin-top: 2rem;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.auth-card {
  max-width: 420px;
  margin: 64px auto;
  padding: 32px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  text-align: center;
}
.auth-card h1 {
  margin: 16px 0 8px;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.auth-card form { text-align: left; margin-top: 24px; }
.auth-card .auth-tagline {
  color: var(--ink-soft);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 4px;
}

.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack label { display: flex; flex-direction: column; gap: 0.35rem; }
.stack label > span { font-weight: 500; color: var(--fg); }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-family: var(--font-body);
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

.btn-primary {
  padding: 12px 20px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: filter 0.12s, transform 0.05s;
}
.btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary[disabled] { opacity: 0.55; cursor: not-allowed; filter: none; }

.check-label {
  flex-direction: row !important;
  align-items: flex-start !important;
  gap: 0.65rem !important;
}
.check-label input[type="checkbox"] {
  width: auto;
  margin-top: 0.3rem;
}
.check-label small { display: block; color: var(--fg-muted); font-weight: 400; }

.messages { list-style: none; padding: 0; margin: 1rem auto; max-width: 1100px; }
.message {
  padding: 0.7rem 1rem;
  margin: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.message-success { border-color: var(--success); }
.message-error { border-color: var(--danger); }

.muted { color: var(--fg-muted); }
.form-errors { color: var(--danger); }

.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--line);
}
.site-footer .site-footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  text-align: center;
}
.site-footer-inner p { margin: 0; }
.site-footer-inner a { color: var(--accent); }

/* While the chunked auto-translate is in flight on a field/form. */
.auto-translating {
  outline: 2px dashed color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 1px;
  transition: outline-color 0.15s;
}
form.auto-translating .btn-primary {
  opacity: 0.6;
  cursor: progress;
}

/* Toast notifications (used by auto-translate when it's force-disabled). */
#lingua-toast-host {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1000;
  pointer-events: none;
}
.lingua-toast {
  pointer-events: auto;
  max-width: 380px;
  padding: 0.8rem 1rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  font-size: 0.9rem;
  transition: opacity 0.3s, transform 0.3s;
}
.lingua-toast-fade {
  opacity: 0;
  transform: translateY(8px);
}

/* ===== Gilded trivia stage (Million Dollar Trivia in-game screens) =====
   Wraps question / feedback / result content in a Newport-drawing-room
   oxblood-and-gold framing that echoes the cartouche tile artwork. The
   class scopes its own gold variables so it doesn't have to mutate the
   site-wide palette. */
.trivia-stage-gilded {
  --gold:       #E8C56A;
  --gold-light: #F8E8A8;
  --gold-deep:  #8E6620;
  --gold-grad:  linear-gradient(180deg, #F8E8A8, #E8C56A 35%, #C99A3E 55%, #8E6620 80%, #6A4A14);
  --field:      #240509;
  --field-mid:  #3A0F12;

  position: relative;
  margin: 8px 0;
  padding: 40px 36px;
  border-radius: var(--radius-card);
  background: radial-gradient(ellipse at 50% 22%, #5C1A1A 0%, var(--field-mid) 55%, var(--field) 100%);
  color: var(--gold-light);
  font-family: var(--font-body);
}
@media (max-width: 640px) {
  .trivia-stage-gilded { padding: 24px 16px; }
}
.trivia-stage-gilded::before,
.trivia-stage-gilded::after {
  content: "";
  position: absolute;
  border-radius: 8px;
  pointer-events: none;
}
.trivia-stage-gilded::before {
  inset: 8px;
  border: 1px solid rgba(232, 197, 106, 0.55);
}
.trivia-stage-gilded::after {
  inset: 13px;
  border: 1px solid rgba(232, 197, 106, 0.28);
}
.trivia-stage-gilded > * { position: relative; z-index: 1; }

/* Bead-and-reel decorative band (rendered inline in the templates) */
.gilded-band {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: -6px 0 16px;
}
.gilded-band > span {
  width: 6px;
  height: 6px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.85;
}
.gilded-band > .gilded-bead-sm {
  width: 3px;
  height: 3px;
  opacity: 0.7;
}
.gilded-band > .gilded-rule {
  flex: 0 0 auto;
  width: 80px;
  height: 1px;
  background: var(--gold);
  opacity: 0.55;
  border-radius: 1px;
}

/* Money ladder, gilded */
.trivia-stage-gilded .money-ladder {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(232, 197, 106, 0.4);
  border-radius: var(--radius-card);
  padding: 14px 10px;
}
.trivia-stage-gilded .money-ladder h3 {
  color: var(--gold);
  letter-spacing: 0.12em;
  border-bottom: 1px solid rgba(232, 197, 106, 0.3);
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.trivia-stage-gilded .money-ladder li {
  color: rgba(248, 232, 168, 0.55);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}
.trivia-stage-gilded .money-ladder li.won { color: rgba(248, 232, 168, 0.88); }
.trivia-stage-gilded .money-ladder li.current {
  background: linear-gradient(90deg, rgba(232,197,106,0.28), rgba(232,197,106,0.06));
  color: #FFFCE5;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(232, 197, 106, 0.6);
}
.trivia-stage-gilded .money-ladder li.safe-haven { color: rgba(232, 197, 106, 0.95); font-weight: 600; }
.trivia-stage-gilded .rung-badge {
  background: var(--gold-grad);
  color: var(--field);
}

/* Stage header & prompt */
.trivia-stage-gilded .trivia-stage-header { color: rgba(248, 232, 168, 0.75); }
.trivia-stage-gilded .trivia-stage-header .muted { color: rgba(248, 232, 168, 0.7); }
.trivia-stage-gilded .trivia-stage-header strong { color: var(--gold-light); }

.trivia-stage-gilded .trivia-prompt {
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 28px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
  letter-spacing: -0.005em;
  margin: 16px 0 28px;
}
@media (max-width: 640px) {
  .trivia-stage-gilded .trivia-prompt { font-size: 20px; margin: 12px 0 20px; }
}

/* Options as gilded panels with embossed gold letter */
.trivia-stage-gilded .trivia-options { margin: 16px 0 28px; }
.trivia-stage-gilded .trivia-option {
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(232, 197, 106, 0.4);
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.01em;
  padding: 14px 16px;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  border-radius: var(--radius);
}
.trivia-stage-gilded .trivia-option:hover {
  background: rgba(232, 197, 106, 0.13);
  border-color: rgba(232, 197, 106, 0.85);
  transform: translateY(-1px);
}
.trivia-stage-gilded .trivia-option:active { transform: translateY(1px); }
.trivia-stage-gilded .trivia-option-letter {
  background: var(--gold-grad);
  border: 1px solid rgba(232, 197, 106, 0.85);
  color: var(--field);
  text-shadow: 0 1px 0 rgba(248, 232, 168, 0.4);
  font-family: var(--font-display);
  font-weight: 700;
  width: 2.1rem;
  height: 2.1rem;
}
.trivia-stage-gilded .trivia-option-eliminated { opacity: 0.32; }
.trivia-stage-gilded .trivia-option-eliminated .trivia-option-letter { background: rgba(232,197,106,0.18); color: rgba(248,232,168,0.4); }

/* Actions row */
.trivia-stage-gilded .trivia-actions {
  border-top: 1px solid rgba(232, 197, 106, 0.3);
  padding-top: 18px;
  margin-top: 8px;
}
.trivia-stage-gilded .lifeline-btn {
  background: rgba(0, 0, 0, 0.3);
  color: var(--gold-light);
  border: 1px solid rgba(232, 197, 106, 0.4);
  padding: 9px 14px;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}
.trivia-stage-gilded .lifeline-btn:hover:not([disabled]) {
  background: rgba(232, 197, 106, 0.16);
  border-color: rgba(232, 197, 106, 0.85);
}
.trivia-stage-gilded .lifeline-btn[disabled] {
  text-decoration: line-through;
  color: rgba(248, 232, 168, 0.35);
}
.trivia-stage-gilded .walk-away-btn {
  background: transparent;
  color: rgba(248, 232, 168, 0.7);
  border: 1px solid rgba(232, 197, 106, 0.35);
}
.trivia-stage-gilded .walk-away-btn:hover {
  background: rgba(232, 197, 106, 0.1);
  color: var(--gold-light);
  border-color: rgba(232, 197, 106, 0.7);
}

/* Stakes & complain */
.trivia-stage-gilded .trivia-stakes {
  color: rgba(248, 232, 168, 0.65);
  text-align: center;
  margin-top: 14px;
}
.trivia-stage-gilded .trivia-stakes strong { color: var(--gold-light); }
.trivia-stage-gilded .complain-btn {
  background: transparent;
  color: rgba(248, 232, 168, 0.55);
  border: 1px dashed rgba(232, 197, 106, 0.4);
}
.trivia-stage-gilded .complain-btn:hover:not([disabled]) {
  color: var(--gold-light);
  border-color: rgba(232, 197, 106, 0.85);
}

/* Lifeline result panels */
.trivia-stage-gilded .lifeline-result {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(232, 197, 106, 0.35);
  border-left: 3px solid var(--gold);
  color: var(--gold-light);
}
.trivia-stage-gilded .lifeline-result h4 { color: var(--gold); }
.trivia-stage-gilded .audience-bar { background: rgba(0, 0, 0, 0.5); }
.trivia-stage-gilded .audience-bar > span { background: var(--gold-grad); }
.trivia-stage-gilded .audience-pct { color: rgba(248, 232, 168, 0.75); }
.trivia-stage-gilded .audience-letter { color: var(--gold); }

/* Feedback (Correct! / Not quite.) inside the gilded stage */
.trivia-stage-gilded .trivia-feedback {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  text-align: center;
  margin: 0;
}
.trivia-stage-gilded .trivia-feedback h1 {
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 8px 0 12px;
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.trivia-stage-gilded .feedback-wrong-bg h1 {
  background: linear-gradient(180deg, #FFB7A8, #E8755C 50%, #A23A28 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.trivia-stage-gilded .trivia-prompt-recap {
  color: var(--gold-light);
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 16px;
}
.trivia-stage-gilded .trivia-correct-line {
  color: rgba(248, 232, 168, 0.88);
  font-size: 16px;
}
.trivia-stage-gilded .trivia-correct-line strong { color: var(--gold); }
.trivia-stage-gilded .feedback-money {
  color: var(--gold-light);
  font-size: 18px;
  margin: 24px 0 32px;
}
.trivia-stage-gilded .feedback-money strong {
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
}
.trivia-stage-gilded .btn-primary {
  background: var(--gold-grad);
  color: var(--field);
  font-weight: 700;
  letter-spacing: 0.03em;
  border: 1px solid rgba(232, 197, 106, 0.85);
}
.trivia-stage-gilded .btn-primary:hover { filter: brightness(1.08); }

/* Result hero — celebratory gilded amount */
.trivia-stage-gilded .trivia-result-hero {
  background: transparent;
  border: none;
  padding: 0;
  text-align: center;
}
.trivia-stage-gilded .trivia-result-hero h1 {
  color: var(--gold-light);
  font-family: var(--font-display);
  margin: 8px 0;
}
.trivia-stage-gilded .result-headline {
  color: var(--gold);
  letter-spacing: 0.12em;
}
.trivia-stage-gilded .result-amount {
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-family: var(--font-display);
  font-size: 88px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 16px 0 12px;
}
@media (max-width: 640px) {
  .trivia-stage-gilded .result-amount { font-size: 56px; }
  .trivia-stage-gilded .trivia-feedback h1 { font-size: 36px; }
}
.trivia-stage-gilded .muted { color: rgba(248, 232, 168, 0.6); }
.trivia-stage-gilded a { color: var(--gold-light); }
.trivia-stage-gilded a:hover { color: var(--gold); }

/* ===== Gilded page variant (settings, etc.) =====
   Same backdrop / palette tokens as .trivia-stage-gilded but tuned for
   non-game pages: tighter top padding, optional inner section dividers,
   and styling for .page-header + cartouche-grid living inside.
   The .trivia-stage-page modifier just relaxes the in-game-only sizing
   so longer content (lists, forms) breathes. */
.trivia-stage-gilded.trivia-stage-page {
  padding: 32px 36px 36px;
}

/* page-header inside the gilded stage — flip text colours so they're
   readable on the dark backdrop. Ivory variant is handled separately
   below since its backdrop is cream. */
.trivia-stage-gilded .page-header h1 { color: var(--gold-light); }
.trivia-stage-gilded .page-header .page-eyebrow { color: var(--gold); }
.trivia-stage-gilded .page-header .page-desc { color: rgba(248, 232, 168, 0.75); }
.trivia-stage-gilded .page-header-actions a { color: var(--gold-light); }
.trivia-stage-gilded .page-header-actions a:hover { color: var(--gold); }

/* Optional section divider inside the stage */
.gilded-section {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(232, 197, 106, 0.3);
}
.gilded-section h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--gold-light);
}
.trivia-stage-gilded .muted { color: rgba(248, 232, 168, 0.7); }

/* Cartouche options sitting on the gilded backdrop */
.trivia-stage-gilded .cartouche-option {
  background: rgba(0, 0, 0, 0.32);
  border-color: rgba(232, 197, 106, 0.3);
}
.trivia-stage-gilded .cartouche-option:hover { border-color: var(--gold); }
.trivia-stage-gilded .cartouche-option.is-selected,
.trivia-stage-gilded .cartouche-option:has(input[type="radio"]:checked) {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 35%, transparent);
}
.trivia-stage-gilded .cartouche-name { color: var(--gold-light); }
.trivia-stage-gilded .cartouche-sub { color: rgba(248, 232, 168, 0.65); }

/* ---- Trivia sub-nav (Home / In-Play / History / Settings) ---- */
.trivia-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 28px;
  margin: 0 -8px 24px;
  padding: 0 0 14px;
  border-bottom: 1px solid rgba(232, 197, 106, 0.28);
  flex-wrap: wrap;
}
.trivia-nav a, .trivia-nav-disabled {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(248, 232, 168, 0.65);
  padding: 6px 2px;
  position: relative;
  transition: color 0.12s;
}
.trivia-nav a:hover {
  color: var(--gold-light);
  text-decoration: none;
}
.trivia-nav a.active {
  color: var(--gold);
}
.trivia-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}
.trivia-nav-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Ivory variant — light field, dark gold ink */
.trivia-stage-gilded.gilded-ivory .trivia-nav {
  border-bottom-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .trivia-nav a,
.trivia-stage-gilded.gilded-ivory .trivia-nav-disabled {
  color: rgba(90, 61, 14, 0.65);
}
.trivia-stage-gilded.gilded-ivory .trivia-nav a:hover { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .trivia-nav a.active {
  color: #8E6620;
}
.trivia-stage-gilded.gilded-ivory .trivia-nav a.active::after {
  background: #8E6620;
}

/* ---- Dashboard / topics / history components on the gilded backdrop ---- */
.trivia-stage-gilded .trivia-dashboard { max-width: none; }

.trivia-stage-gilded .resume-banner {
  background: rgba(0, 0, 0, 0.32);
  border-color: rgba(232, 197, 106, 0.55);
}
.trivia-stage-gilded .resume-banner h2 { color: var(--gold-light); }
.trivia-stage-gilded .resume-label { color: var(--gold); }
.trivia-stage-gilded .resume-banner p { color: rgba(248, 232, 168, 0.78); }
.trivia-stage-gilded .resume-banner p strong { color: var(--gold-light); }

.trivia-stage-gilded .stat-card {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(232, 197, 106, 0.32);
}
.trivia-stage-gilded .stat-label { color: var(--gold); letter-spacing: 0.12em; }
.trivia-stage-gilded .stat-value { color: var(--gold-light); }
.trivia-stage-gilded .stat-sub { color: rgba(248, 232, 168, 0.65); }

.trivia-stage-gilded .play-row small { color: rgba(248, 232, 168, 0.7); }
.trivia-stage-gilded .recent-section h2 {
  color: var(--gold);
  letter-spacing: 0.06em;
}
.trivia-stage-gilded .recent-section-head a { color: var(--gold-light); }
.trivia-stage-gilded .recent-rounds li {
  border-bottom-color: rgba(232, 197, 106, 0.22);
  color: rgba(248, 232, 168, 0.85);
}
.trivia-stage-gilded .recent-rounds li a { color: var(--gold-light); }
.trivia-stage-gilded .recent-rounds li a:hover { color: var(--gold); }
.trivia-stage-gilded .recent-rounds li strong { color: var(--gold); }

.trivia-stage-gilded .topics-panel {
  background: rgba(0, 0, 0, 0.30);
  border-color: rgba(232, 197, 106, 0.35);
}
.trivia-stage-gilded .topics-panel-header h2 { color: var(--gold-light); }
.trivia-stage-gilded .chip {
  background: rgba(232, 197, 106, 0.18);
  color: var(--gold-light);
  border-color: rgba(232, 197, 106, 0.45);
}
.trivia-stage-gilded .chip:hover { background: rgba(232, 197, 106, 0.28); }
.trivia-stage-gilded .chip-x { color: rgba(248, 232, 168, 0.7); }
.trivia-stage-gilded .chip-x:hover { background: var(--danger); color: var(--gold-light); }
.trivia-stage-gilded .chip-available {
  background: rgba(0, 0, 0, 0.28);
  border-color: rgba(232, 197, 106, 0.3);
}
.trivia-stage-gilded .chip-available:hover {
  background: rgba(232, 197, 106, 0.18);
  border-color: var(--gold);
}
.trivia-stage-gilded .chip-add { color: var(--gold-light); }
.trivia-stage-gilded .chip-meta { color: rgba(248, 232, 168, 0.55); }
.trivia-stage-gilded .topic-add-summary { color: var(--gold); }
.trivia-stage-gilded .topic-add-panel { border-top-color: rgba(232, 197, 106, 0.25); }

/* Topics page list (alternate layout — older topics.html) */
.trivia-stage-gilded .topic-list li {
  border-bottom-color: rgba(232, 197, 106, 0.22);
  color: var(--gold-light);
}
.trivia-stage-gilded .topic-list a, .trivia-stage-gilded .topic-list .link-button {
  color: var(--gold-light);
}
.trivia-stage-gilded .topic-list .link-button:hover { color: var(--gold); }

/* History data-table on gilded backdrop */
.trivia-stage-gilded .data-table {
  background: rgba(0, 0, 0, 0.30);
  border-color: rgba(232, 197, 106, 0.35);
  color: var(--gold-light);
}
.trivia-stage-gilded .data-table th {
  background: rgba(0, 0, 0, 0.42);
  color: var(--gold);
  border-bottom-color: rgba(232, 197, 106, 0.25);
}
.trivia-stage-gilded .data-table td {
  border-bottom-color: rgba(232, 197, 106, 0.18);
}
.trivia-stage-gilded .data-table a { color: var(--gold-light); }
.trivia-stage-gilded .data-table a:hover { color: var(--gold); }
.trivia-stage-gilded .data-table small { color: rgba(248, 232, 168, 0.6); }
.trivia-stage-gilded .data-table .pill-replay {
  background: rgba(232, 197, 106, 0.22);
  color: var(--gold);
}

/* Form inputs sitting on the gilded backdrop */
.trivia-stage-gilded input[type="text"],
.trivia-stage-gilded input[type="number"],
.trivia-stage-gilded select,
.trivia-stage-gilded textarea {
  background: rgba(0, 0, 0, 0.30);
  border-color: rgba(232, 197, 106, 0.4);
  color: var(--gold-light);
}
.trivia-stage-gilded input::placeholder { color: rgba(248, 232, 168, 0.45); }
.trivia-stage-gilded input:focus,
.trivia-stage-gilded select:focus,
.trivia-stage-gilded textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent);
}
.trivia-stage-gilded label > span { color: var(--gold-light); }

/* Ivory parallels for the new components */
.trivia-stage-gilded.gilded-ivory .resume-banner {
  background: rgba(255, 252, 244, 0.55);
  border-color: rgba(142, 102, 32, 0.55);
}
.trivia-stage-gilded.gilded-ivory .resume-banner h2,
.trivia-stage-gilded.gilded-ivory .resume-banner p strong { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .resume-banner p { color: rgba(90, 61, 14, 0.85); }
.trivia-stage-gilded.gilded-ivory .resume-label { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .stat-card {
  background: rgba(255, 252, 244, 0.5);
  border-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .stat-label { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .stat-value { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .stat-sub { color: rgba(90, 61, 14, 0.7); }
.trivia-stage-gilded.gilded-ivory .recent-section h2 { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .recent-section-head a { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .recent-rounds li {
  border-bottom-color: rgba(142, 102, 32, 0.22);
  color: rgba(90, 61, 14, 0.85);
}
.trivia-stage-gilded.gilded-ivory .recent-rounds li a { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .recent-rounds li a:hover { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .recent-rounds li strong { color: #8E6620; }

.trivia-stage-gilded.gilded-ivory .topics-panel {
  background: rgba(255, 252, 244, 0.5);
  border-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .topics-panel-header h2 { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .chip {
  background: rgba(232, 197, 106, 0.32);
  color: #2A1A04;
  border-color: rgba(142, 102, 32, 0.5);
}
.trivia-stage-gilded.gilded-ivory .chip-available {
  background: rgba(255, 252, 244, 0.55);
  border-color: rgba(142, 102, 32, 0.35);
}
.trivia-stage-gilded.gilded-ivory .chip-add { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .chip-meta { color: rgba(90, 61, 14, 0.6); }
.trivia-stage-gilded.gilded-ivory .topic-add-summary { color: #8E6620; }

.trivia-stage-gilded.gilded-ivory .data-table {
  background: rgba(255, 252, 244, 0.5);
  border-color: rgba(142, 102, 32, 0.4);
  color: #2A1A04;
}
.trivia-stage-gilded.gilded-ivory .data-table th {
  background: rgba(232, 197, 106, 0.25);
  color: #8E6620;
  border-bottom-color: rgba(142, 102, 32, 0.3);
}
.trivia-stage-gilded.gilded-ivory .data-table td { border-bottom-color: rgba(142, 102, 32, 0.18); }
.trivia-stage-gilded.gilded-ivory .data-table a { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .data-table small { color: rgba(90, 61, 14, 0.6); }

.trivia-stage-gilded.gilded-ivory input[type="text"],
.trivia-stage-gilded.gilded-ivory input[type="number"],
.trivia-stage-gilded.gilded-ivory select,
.trivia-stage-gilded.gilded-ivory textarea {
  background: rgba(255, 252, 244, 0.7);
  border-color: rgba(142, 102, 32, 0.4);
  color: #2A1A04;
}
.trivia-stage-gilded.gilded-ivory input:focus,
.trivia-stage-gilded.gilded-ivory select:focus,
.trivia-stage-gilded.gilded-ivory textarea:focus {
  border-color: #8E6620;
  box-shadow: 0 0 0 3px rgba(142, 102, 32, 0.28);
}
.trivia-stage-gilded.gilded-ivory label > span { color: #2A1A04; }

/* Ivory page-page overrides — light field needs dark text */
.trivia-stage-gilded.gilded-ivory .page-header h1,
.trivia-stage-gilded.gilded-ivory .gilded-section h2 { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .page-header .page-eyebrow { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .page-header .page-desc { color: rgba(90, 61, 14, 0.75); }
.trivia-stage-gilded.gilded-ivory .page-header-actions a { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .page-header-actions a:hover { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .gilded-section { border-top-color: rgba(142, 102, 32, 0.3); }
.trivia-stage-gilded.gilded-ivory .cartouche-option {
  background: rgba(255, 252, 244, 0.55);
  border-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .cartouche-name { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .cartouche-sub { color: rgba(90, 61, 14, 0.7); }

/* ----- Per-cartouche gilded variant overrides -----
   The defaults above are the oxblood palette. Each variant class adjusts
   the field-gradient backdrop and gold ramp to match the cartouche the
   user picked under /trivia/settings/. Field stops are pulled directly
   from each cartouche SVG so the in-game stage and the activity-tile
   art share a palette. */

.trivia-stage-gilded.gilded-forest {
  --gold-grad: linear-gradient(180deg, #F8E8A8, #E8C56A 35%, #C99A3E 55%, #8E6620 80%, #6A4A14);
  background: radial-gradient(ellipse at 50% 22%, #2A6740 0%, #1F4A2E 55%, #061509 100%);
}

.trivia-stage-gilded.gilded-midnight {
  --gold-grad: linear-gradient(180deg, #F8E8A8, #E8C56A 35%, #C99A3E 55%, #8E6620 80%, #6A4A14);
  background: radial-gradient(ellipse at 50% 22%, #2D3A78 0%, #1B2750 55%, #050818 100%);
}

.trivia-stage-gilded.gilded-aubergine {
  --gold:       #B89858;
  --gold-light: #FBEFC8;
  --gold-deep:  #7A5E26;
  --gold-grad:  linear-gradient(180deg, #FBEFC8, #EBD8A0 35%, #B89858 65%, #7A5E26 100%);
  background: radial-gradient(ellipse at 50% 22%, #6A2D78 0%, #4A2050 55%, #170620 100%);
}

.trivia-stage-gilded.gilded-onyx {
  --gold:       #F0C84A;
  --gold-light: #FFE89A;
  --gold-deep:  #5A3D0E;
  --gold-grad:  linear-gradient(180deg, #FFE89A, #F0C84A 35%, #C99A3E 55%, #8E6620 80%, #5A3D0E);
  background: radial-gradient(ellipse at 50% 22%, #2A2A2A 0%, #1A1A1A 55%, #000000 100%);
}

/* Ivory is the only LIGHT field — needs different ink colours. */
.trivia-stage-gilded.gilded-ivory {
  --gold:       #C99A3E;
  --gold-light: #5A3D0E;   /* "light" = the high-contrast ink on cream */
  --gold-deep:  #5A3D0E;
  --gold-grad:  linear-gradient(180deg, #E8C56A, #C99A3E 35%, #8E6620 65%, #5A3D0E 100%);
  --field:      #5A3D0E;
  --field-mid:  #8E6620;
  background: radial-gradient(ellipse at 50% 22%, #FBF3DE 0%, #F2E5C2 55%, #E5D2A4 100%);
  color: #5A3D0E;
}
.trivia-stage-gilded.gilded-ivory::before { border-color: rgba(90, 61, 14, 0.55); }
.trivia-stage-gilded.gilded-ivory::after  { border-color: rgba(90, 61, 14, 0.28); }
.trivia-stage-gilded.gilded-ivory .gilded-band > span { background: #C99A3E; }
.trivia-stage-gilded.gilded-ivory .gilded-band > .gilded-rule { background: #C99A3E; }

.trivia-stage-gilded.gilded-ivory .money-ladder {
  background: rgba(255, 252, 244, 0.6);
  border-color: rgba(90, 61, 14, 0.4);
}
.trivia-stage-gilded.gilded-ivory .money-ladder h3 { color: #8E6620; border-color: rgba(90, 61, 14, 0.3); }
.trivia-stage-gilded.gilded-ivory .money-ladder li { color: rgba(90, 61, 14, 0.55); }
.trivia-stage-gilded.gilded-ivory .money-ladder li.won { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .money-ladder li.current {
  background: linear-gradient(90deg, rgba(201, 154, 62, 0.30), rgba(201, 154, 62, 0.06));
  color: #2A1A04;
  box-shadow: inset 0 0 0 1px rgba(142, 102, 32, 0.6);
}
.trivia-stage-gilded.gilded-ivory .money-ladder li.safe-haven { color: #8E6620; }

.trivia-stage-gilded.gilded-ivory .trivia-stage-header { color: rgba(90, 61, 14, 0.7); }
.trivia-stage-gilded.gilded-ivory .trivia-stage-header strong { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory .trivia-stage-header .muted { color: rgba(90, 61, 14, 0.65); }
.trivia-stage-gilded.gilded-ivory .trivia-prompt { color: #2A1A04; text-shadow: none; }

.trivia-stage-gilded.gilded-ivory .trivia-option {
  background: rgba(255, 252, 244, 0.65);
  border-color: rgba(142, 102, 32, 0.5);
  color: #2A1A04;
}
.trivia-stage-gilded.gilded-ivory .trivia-option:hover {
  background: rgba(232, 197, 106, 0.25);
  border-color: rgba(142, 102, 32, 0.9);
}
.trivia-stage-gilded.gilded-ivory .trivia-option-letter {
  border: 1px solid rgba(90, 61, 14, 0.85);
  color: #FBF3DE;
}

.trivia-stage-gilded.gilded-ivory .trivia-actions { border-top-color: rgba(142, 102, 32, 0.35); }
.trivia-stage-gilded.gilded-ivory .lifeline-btn {
  background: rgba(255, 252, 244, 0.6);
  border-color: rgba(142, 102, 32, 0.5);
  color: #2A1A04;
}
.trivia-stage-gilded.gilded-ivory .lifeline-btn:hover:not([disabled]) {
  background: rgba(232, 197, 106, 0.25);
  border-color: rgba(142, 102, 32, 0.9);
}
.trivia-stage-gilded.gilded-ivory .walk-away-btn {
  color: rgba(90, 61, 14, 0.75);
  border-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .walk-away-btn:hover {
  background: rgba(232, 197, 106, 0.18);
  color: #2A1A04;
  border-color: rgba(142, 102, 32, 0.8);
}
.trivia-stage-gilded.gilded-ivory .trivia-stakes { color: rgba(90, 61, 14, 0.7); }
.trivia-stage-gilded.gilded-ivory .trivia-stakes strong { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .complain-btn {
  color: rgba(90, 61, 14, 0.6);
  border-color: rgba(142, 102, 32, 0.4);
}
.trivia-stage-gilded.gilded-ivory .complain-btn:hover:not([disabled]) {
  color: #2A1A04;
  border-color: rgba(142, 102, 32, 0.85);
}
.trivia-stage-gilded.gilded-ivory .lifeline-result {
  background: rgba(255, 252, 244, 0.6);
  border-color: rgba(142, 102, 32, 0.4);
  border-left-color: #C99A3E;
  color: #2A1A04;
}
.trivia-stage-gilded.gilded-ivory .lifeline-result h4 { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .audience-letter { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .audience-pct { color: rgba(90, 61, 14, 0.7); }
.trivia-stage-gilded.gilded-ivory .audience-bar { background: rgba(90, 61, 14, 0.15); }

.trivia-stage-gilded.gilded-ivory .trivia-feedback h1,
.trivia-stage-gilded.gilded-ivory .trivia-result-hero h1 { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .trivia-prompt-recap { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .trivia-correct-line { color: rgba(90, 61, 14, 0.85); }
.trivia-stage-gilded.gilded-ivory .trivia-correct-line strong { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .feedback-money { color: #2A1A04; }
.trivia-stage-gilded.gilded-ivory .feedback-money strong { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .result-headline { color: #8E6620; }
.trivia-stage-gilded.gilded-ivory .muted { color: rgba(90, 61, 14, 0.65); }
.trivia-stage-gilded.gilded-ivory a { color: #5A3D0E; }
.trivia-stage-gilded.gilded-ivory a:hover { color: #8E6620; }

/* Trivia — game stage (WWtbam-style) */
.trivia-game {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 720px) {
  .trivia-game { grid-template-columns: 1fr; }
}

.money-ladder {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem;
}
.money-ladder h3 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
  padding: 0 0.5rem;
}
.money-ladder ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-variant-numeric: tabular-nums;
}
.money-ladder li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--fg-muted);
}
.money-ladder li.won { color: var(--fg); }
.money-ladder li.current {
  background: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--fg);
  font-weight: 600;
}
.money-ladder li.safe-haven { color: var(--success); font-weight: 600; }
.money-ladder li.safe-haven.current { color: var(--fg); }
.rung-num { width: 1.6rem; text-align: right; font-size: 0.8rem; opacity: 0.7; }
.rung-amount { flex: 1; }
.rung-badge {
  font-size: 0.65rem;
  background: var(--success);
  color: var(--accent-fg);
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.trivia-stage-header {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}
.trivia-prompt {
  font-size: 1.4rem;
  line-height: 1.45;
  margin: 0.5rem 0 1.25rem;
}

.trivia-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}
@media (max-width: 540px) {
  .trivia-options { grid-template-columns: 1fr; }
}
.trivia-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
.trivia-option:hover { background: var(--hover); border-color: var(--accent); }
.trivia-option:active { transform: translateY(1px); }
.trivia-option-letter {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.trivia-option-eliminated {
  opacity: 0.35;
  cursor: not-allowed;
}
.trivia-option-eliminated:hover { background: var(--bg-elev); border-color: var(--border); }

.trivia-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.lifelines { display: flex; gap: 0.5rem; }
.lifeline-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.lifeline-btn:hover:not([disabled]) { background: var(--hover); border-color: var(--accent); }
.lifeline-btn[disabled] {
  opacity: 0.35;
  text-decoration: line-through;
  cursor: not-allowed;
}
.lifeline-icon { font-weight: 700; }

.walk-away-btn {
  background: transparent;
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.walk-away-btn:hover { background: var(--hover); color: var(--fg); }

.trivia-complain-row {
  margin-top: 0.75rem;
  text-align: right;
}
.complain-btn {
  background: transparent;
  color: var(--fg-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.complain-btn:hover:not([disabled]) { color: var(--fg); border-color: var(--accent); }
.complain-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.trivia-complain-row form { display: inline; margin: 0; padding: 0; }
.complaint-disagreed { border-left-color: var(--fg-muted) !important; }

.trivia-stakes { margin-top: 0.75rem; font-size: 0.85rem; }

.lifeline-result {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.lifeline-result h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--fg-muted);
}
.lifeline-result p { margin: 0; }

.audience-bars { list-style: none; padding: 0; margin: 0; }
.audience-bars li {
  display: grid;
  grid-template-columns: 1.4rem 1fr 3rem;
  gap: 0.6rem;
  align-items: center;
  padding: 0.18rem 0;
  font-variant-numeric: tabular-nums;
}
.audience-letter { font-weight: 700; text-align: center; }
.audience-bar {
  height: 0.65rem;
  background: var(--bg-elev-2);
  border-radius: 999px;
  overflow: hidden;
}
.audience-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--success)));
}
.audience-pct { text-align: right; font-size: 0.9rem; color: var(--fg-muted); }

.trivia-feedback {
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 1.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.feedback-correct-bg { border-left: 4px solid var(--success); }
.feedback-wrong-bg { border-left: 4px solid var(--danger); }
.trivia-prompt-recap { font-size: 1.05rem; line-height: 1.45; margin: 0.5rem 0 1rem; }
.trivia-correct-line { margin: 0.5rem 0; }
.feedback-money { font-size: 1.1rem; margin: 1rem 0 1.5rem; }

.trivia-result-hero {
  text-align: center;
  padding: 40px 24px 32px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.trivia-result-hero h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
}
.result-headline {
  color: var(--ink-soft);
  margin: 0;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.result-amount {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 12px 0 16px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, var(--accent), var(--brand-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.recap-options {
  list-style: none;
  padding: 0.5rem 0 0;
  margin: 0;
}
.recap-options li {
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.recap-correct { background: color-mix(in srgb, var(--success) 18%, transparent); }
.recap-chosen-wrong { background: color-mix(in srgb, var(--danger) 18%, transparent); text-decoration: line-through; }
.result-item { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.result-item:last-child { border-bottom: none; }

/* Trivia — cartouche picker (user_settings.html) */
.cartouche-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.cartouche-option {
  display: block;
  cursor: pointer;
  border: 2px solid var(--line);
  border-radius: var(--radius-card);
  padding: 8px;
  background: var(--card-bg);
  transition: border-color 0.12s, transform 0.08s;
  position: relative;  /* containing block for the abs-positioned radio */
}
.cartouche-option:hover { border-color: var(--accent); }
/* The is-selected class is server-rendered (matches the saved choice).
   The :has() rule fires immediately when you click a different radio so
   the selection ring tracks your click before you Save. */
.cartouche-option.is-selected,
.cartouche-option:has(input[type="radio"]:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
/* Hide the radio visually but keep it interactive — pointer-events:none
   would have stopped some browsers from activating the radio through the
   wrapping <label>, which silently broke the picker. */
.cartouche-option input[type="radio"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.cartouche-thumb {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
  background: #000;
}
.cartouche-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cartouche-rotate-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 252, 244, 0.92);
  color: var(--ink);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.cartouche-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding: 0 4px 4px;
}
.cartouche-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
}
.cartouche-sub { font-size: 11px; }
.cartouche-actions {
  grid-column: 1 / -1;
  margin-top: 8px;
}

/* Trivia dashboard */
.trivia-dashboard { max-width: 880px; margin: 0 auto; }
.trivia-dashboard-header h1 { margin: 0 0 0.25rem; }

.resume-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 22%, var(--bg-elev)),
    var(--bg-elev));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.resume-banner h2 { margin: 0.1rem 0 0.25rem; font-size: 1.15rem; }
.resume-label {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
}
.resume-banner p { margin: 0; }

.play-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 1.5rem 0 2rem;
  flex-wrap: wrap;
}
.play-btn { font-size: 1rem; padding: 0.75rem 1.5rem; }

.recent-section { margin-top: 2rem; }
.recent-section h2 { font-size: 1rem; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.5px; }

.topics-section { margin-top: 2.25rem; }

.topics-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 0.75rem;
}
.topics-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.topics-panel-header h2 { margin: 0; font-size: 1.05rem; }

.chip-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.5rem 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-elev-2));
  color: var(--fg);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  transition: background 0.12s, border-color 0.12s;
}
.chip:hover { background: color-mix(in srgb, var(--accent) 22%, var(--bg-elev-2)); }
.chip-name { font-weight: 500; }

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--fg-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.chip-x:hover { background: var(--danger); color: var(--accent-fg); }

.chip-available {
  background: var(--bg-elev-2);
  border-color: var(--border);
  padding: 0;
}
.chip-add {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem;
  background: transparent;
  color: var(--fg);
  border: none;
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.chip-available:hover { background: color-mix(in srgb, var(--accent) 18%, var(--bg-elev-2)); border-color: var(--accent); }
.chip-meta {
  font-size: 0.75rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.topic-add-panel { margin-top: 0.75rem; border-top: 1px dashed var(--border); padding-top: 0.5rem; }
.topic-add-summary {
  cursor: pointer;
  padding: 0.4rem 0;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}
.topic-add-summary:hover { text-decoration: underline; }
.topic-add-body { margin-top: 0.5rem; }

.topic-search {
  width: 100%;
  max-width: 320px;
  margin-bottom: 0.5rem;
}

/* Existing trivia styles below */
.topic-grid {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
}
.topic-grid legend { padding: 0 0.5rem; color: var(--fg-muted); }
.topic-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.topic-chip:hover { background: var(--hover); }
.topic-chip input { width: auto; }

.form-row {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.trivia-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.question-card {
  max-width: 640px;
  margin: 1rem auto;
  padding: 28px 24px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
}
.question-prompt { font-size: 1.15rem; line-height: 1.5; }
.answer-line { margin-top: 1rem; }
.feedback-correct { color: var(--success); font-size: 1.1rem; margin-top: 0.5rem; }
.feedback-wrong { color: var(--danger); font-size: 1.05rem; margin-top: 0.5rem; }

.score-callout {
  padding: 16px 20px;
  background: var(--band-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  font-size: 1.1rem;
  margin: 20px 0;
}

.result-list { padding-left: 1.25rem; }
.result-item {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.result-item:last-child { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-left: 0.25rem;
}
.pill-correct { background: color-mix(in srgb, var(--success) 20%, transparent); color: var(--success); }
.pill-wrong { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.pill-replay { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.recent-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.recent-rounds, .topic-list { list-style: none; padding: 0; }
.recent-rounds li, .topic-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.vocab-table th, .vocab-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.vocab-table tr:last-child td { border-bottom: none; }
.vocab-row-delete { margin: 0; }
.vocab-row-delete-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-soft);
  font-size: 0.95rem;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.vocab-row-delete-btn:hover {
  background: rgba(200, 68, 45, 0.10);
  color: #c8442d;
  border-color: rgba(200, 68, 45, 0.35);
}
.vocab-table th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--band-bg);
}

/* Admin dashboard */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.admin-alert {
  background: color-mix(in srgb, var(--danger) 12%, var(--bg-elev));
  border: 1px solid var(--danger);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1rem 0 0;
}
.admin-alert details { margin-top: 0.6rem; }
.admin-alert summary { cursor: pointer; color: var(--fg-muted); }
.admin-alert ul { margin: 0.5rem 0 0; padding-left: 1.2rem; }

.admin-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.admin-section:first-of-type { border-top: none; padding-top: 0; }
.admin-section h2 { margin: 0 0 0.5rem; font-size: 1.15rem; }

/* App-settings picker — single expandable box; one app at a time
   takes over the content area so the dashboard scales as new apps
   register their admin sections. */
.admin-app-box {
  margin-top: 1.4rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.admin-app-box > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  cursor: pointer;
  list-style: none;
  background: var(--band-bg);
  border-bottom: 1px solid var(--border);
}
.admin-app-box > summary::-webkit-details-marker { display: none; }
.admin-app-box > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.5rem;
  color: var(--fg-muted);
  transition: transform 140ms ease;
}
.admin-app-box[open] > summary::before { transform: rotate(90deg); }
.admin-app-box-label {
  font-weight: 600;
  font-size: 1rem;
}
.admin-app-box-hint {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.admin-app-picker {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.admin-app-picker-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  white-space: nowrap;
}
.admin-app-picker select {
  flex: 1;
  max-width: 320px;
  padding: 0.45rem 0.7rem;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.admin-app-content {
  padding: 1.1rem 1.25rem 1.4rem;
}
.admin-app-content > .muted {
  color: var(--fg-muted);
  margin: 0;
}
.admin-app-section-head {
  margin: 0 0 0.6rem;
  font-size: 1.1rem;
}
.admin-app-section-desc {
  color: var(--fg-muted);
  margin: 0 0 1rem;
}
.admin-app-stats {
  display: flex;
  gap: 1.6rem;
  flex-wrap: wrap;
  padding: 0.8rem 1rem;
  margin: 0 0 1.2rem;
  background: var(--band-bg);
  border-radius: var(--radius-sm);
}
.admin-app-stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
}
.admin-app-stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin-top: 0.25rem;
}
.admin-app-form .form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}
.admin-app-form .form-row label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.admin-app-form .form-row input[type=number],
.admin-app-form .form-row input[type=text] {
  width: 120px;
  padding: 0.4rem 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.admin-app-form .form-hint {
  font-size: 0.82rem;
  color: var(--fg-muted);
  margin: 0.2rem 0 0;
}
.admin-app-form .form-error {
  font-size: 0.82rem;
  color: var(--danger, #b00);
  margin: 0.2rem 0 0;
}
.admin-app-form .form-row-checkbox label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.admin-app-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.6rem 0 1.1rem;
}
.admin-app-subhead {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.ws-photo-review-search {
  display: flex;
  gap: 0.5rem;
  margin: 0.6rem 0 1rem;
}
.ws-photo-review-search input {
  flex: 1;
  max-width: 320px;
  padding: 0.45rem 0.7rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.ws-photo-review-result { min-height: 1rem; }
.ws-photo-review-result > .muted { color: var(--fg-muted); margin: 0; }

.ws-photo-review-card {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
}
.ws-photo-review-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.ws-photo-review-target { font-size: 1.4rem; font-weight: 700; }
.ws-photo-review-en { color: var(--fg-muted); }
.ws-photo-review-pools {
  flex-basis: 100%;
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.ws-photo-review-pools code {
  background: var(--band-bg);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.78rem;
}

.ws-photo-review-image {
  width: 240px;
  height: 240px;
  background: var(--band-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ws-photo-review-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ws-photo-review-image.is-missing { padding: 1rem; text-align: center; }
.ws-photo-review-image.is-missing p { margin: 0.2rem 0; }

.ws-photo-review-banner {
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.ws-photo-review-banner-ok {
  background: color-mix(in srgb, var(--success, #2a8) 14%, var(--card-bg));
  border: 1px solid var(--success, #2a8);
}
.ws-photo-review-banner-err {
  background: color-mix(in srgb, var(--danger, #b00) 12%, var(--card-bg));
  border: 1px solid var(--danger, #b00);
  color: var(--danger, #b00);
}
.ws-photo-review-banner-stage {
  background: color-mix(in srgb, var(--warning, #d97706) 14%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--warning, #d97706) 60%, var(--card-bg));
}

/* Card-level "Working…" indicator. Hidden by default; revealed via
   the :has(.htmx-request) descendant selector whenever any button
   inside the card has an HTMX request in flight. The spinner spins,
   the message tells the user to expect 30–90 seconds. Buttons get
   `hx-disabled-elt="this"` so they grey out during the request and
   can't be re-clicked. Together: no more silent lag. */
.ws-card-progress {
  display: none;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  background: color-mix(in srgb, var(--warning, #d97706) 14%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--warning, #d97706) 50%, var(--card-bg));
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--ink);
}
.ws-photo-review-card:has(.htmx-request) .ws-card-progress {
  display: flex;
}
.ws-card-progress-text { line-height: 1.4; }
.ws-spinner {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: ws-spin 800ms linear infinite;
  opacity: 0.8;
}
@keyframes ws-spin { to { transform: rotate(360deg); } }

/* Greyed look for buttons that HTMX has disabled mid-request. */
.man-btn[disabled],
.btn-primary[disabled],
.btn-secondary[disabled],
.man-btn.htmx-request,
.btn-primary.htmx-request,
.btn-secondary.htmx-request {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}

.ws-photo-review-verdict {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.ws-photo-review-verdict-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}
.ws-photo-review-verdict-keep .ws-photo-review-verdict-tag {
  background: color-mix(in srgb, var(--success, #2a8) 22%, var(--card-bg));
  color: var(--success, #2a8);
}
.ws-photo-review-verdict-replace .ws-photo-review-verdict-tag {
  background: color-mix(in srgb, var(--danger, #b00) 18%, var(--card-bg));
  color: var(--danger, #b00);
}
.ws-photo-review-verdict-reason { line-height: 1.45; }
.ws-photo-review-verdict-meta {
  margin-top: 0.5rem;
  font-size: 0.74rem;
  font-family: var(--font-mono, monospace);
}
.ws-photo-review-suggested {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border);
}
.ws-photo-review-suggested summary { cursor: pointer; font-size: 0.85rem; color: var(--fg-muted); }
.ws-photo-review-suggested p { margin: 0.4rem 0 0; font-size: 0.9rem; }

.ws-photo-review-form { display: grid; gap: 0.4rem; }
.ws-photo-review-form label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); }
.ws-photo-review-form input[type=text],
.ws-photo-review-form textarea {
  width: 100%;
  padding: 0.45rem 0.7rem;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--ink);
}
.ws-photo-review-form textarea { resize: vertical; }
.ws-photo-review-form .form-hint {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin: 0;
}
.ws-photo-review-divider {
  margin: 0.6rem 0 0.4rem;
  border: none;
  border-top: 1px dashed var(--border);
}
.ws-photo-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.2rem;
}

.admin-limits-form {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1rem;
  max-width: 520px;
}
.limit-row { padding: 0.4rem 0; }
.limit-row input[type="number"] { max-width: 180px; font-variant-numeric: tabular-nums; }
.limit-row span { font-weight: 500; }
.limit-row small { display: block; margin-top: 0.25rem; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
}
.stat-label {
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 500;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  margin-top: 6px;
  color: var(--ink);
}
.stat-sub { font-size: 13px; margin-top: 4px; color: var(--ink-soft); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  overflow: hidden;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table th {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--band-bg);
}
.data-table td.num, .data-table th.num { text-align: right; }
.data-table code { background: var(--band-bg); padding: 2px 6px; border-radius: var(--radius-sm); font-size: 0.85rem; font-family: var(--font-mono); }


/* ============================================================
   Word Search — Mañana direction (Polaroid Wall).
   Editorial paper-warm cream + poppy/saffron/jade accents.
   Newsreader serif for display + italic emphasis; Inter Tight
   for kickers + UI labels in uppercase letterspacing.
   ============================================================ */
:root {
  --man-page:     #F4E5C8;
  --man-card:     #FBF5E6;
  --man-ink:      #2A1A0E;
  --man-ink-soft: #7A5D3E;
  --man-accent:   #D14B2C;
  --man-accent2:  #E89A2A;
  --man-accent3:  #1F6A5A;
  --man-serif: 'Newsreader', 'Times New Roman', serif;
  --man-sans:  'Inter Tight', 'DM Sans', system-ui, sans-serif;
}

.man-page {
  position: relative;
  margin: 18px 0 0;
  padding: 28px 0 56px;
  background: var(--man-page);
  border-radius: var(--radius-lg, 18px);
  color: var(--man-ink);
}

.man-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 50px;
}

@media (max-width: 760px) {
  .man-container { padding: 0 24px; }
}

/* ---- Sub-nav ---- */
.man-nav {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 20px;
  padding: 4px;
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 0;
  box-shadow: 3px 3px 0 var(--man-ink);
}
.man-nav a, .man-nav-disabled {
  font-family: var(--man-sans);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 18px;
  text-decoration: none;
  color: var(--man-ink);
  border-radius: 0;
  transition: background 120ms ease, color 120ms ease;
}
.man-nav a:hover { background: rgba(209,75,44,0.12); }
.man-nav a.active { background: var(--man-accent); color: var(--man-card); }
.man-nav-disabled { color: rgba(42,26,14,0.32); cursor: default; }

/* ---- Editorial type ---- */
.man-kicker {
  font-family: var(--man-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--man-accent);
}
.man-kicker-soft { color: var(--man-ink-soft); }

.man-display {
  font-family: var(--man-serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 6px 0 0;
  color: var(--man-ink);
}
.man-display-xl { font-size: 72px; line-height: 0.96; letter-spacing: -0.04em; }
.man-display-em {
  font-style: italic;
  color: var(--man-accent);
}
.man-subhead {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--man-ink-soft);
  margin: 10px 0 0;
}
.man-rule {
  border: none;
  border-top: 1px solid rgba(42,26,14,0.33);
  margin: 22px 0;
}
.man-muted {
  font-family: var(--man-serif);
  font-size: 16px;
  color: var(--man-ink-soft);
}
.man-muted a { color: var(--man-accent); text-decoration: underline; text-underline-offset: 3px; }

/* ---- Buttons ---- */
.man-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--man-sans);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 12px 22px;
  border: 1.5px solid var(--man-ink);
  background: transparent;
  color: var(--man-ink);
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
  transition: transform 100ms ease, box-shadow 100ms ease;
}
.man-btn-primary {
  background: var(--man-accent);
  color: var(--man-card);
  border-color: var(--man-accent);
  box-shadow: 4px 4px 0 var(--man-ink);
}
.man-btn-primary:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--man-ink);
}
.man-btn-secondary {
  background: transparent;
  border-color: rgba(42,26,14,0.55);
}
.man-btn-secondary:hover { background: rgba(42,26,14,0.05); }
.man-btn-lg { padding: 16px 32px; font-size: 12px; }

/* ---- Masthead (home / result / history) ---- */
.man-masthead {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
}
.man-masthead-meta {
  text-align: right;
  font-family: var(--man-sans);
}
.man-meta-line {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 18px;
  color: var(--man-ink);
  margin-top: 4px;
}

/* ---- Resume / start strip on home ---- */
.man-resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.16);
}
.man-resume-body {
  font-family: var(--man-serif);
  font-size: 17px;
  margin: 6px 0 0;
}
.man-resume-body em {
  font-style: italic;
  color: var(--man-accent);
}
.man-start {
  display: flex;
  justify-content: center;
  margin-top: 26px;
}

/* ---- History list ---- */
.man-history-list { list-style: none; padding: 0; margin: 14px 0 0; }
.man-history-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  gap: 20px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42,26,14,0.18);
  font-family: var(--man-serif);
  font-size: 16px;
}
.man-history-id {
  font-family: var(--man-sans);
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--man-ink-soft);
}
.man-history-date { color: var(--man-ink); }
.man-history-score em { color: var(--man-accent); font-style: italic; }
.man-history-link {
  font-family: var(--man-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--man-accent);
  text-decoration: none;
}
.man-history-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---- Result word grid ---- */
.man-result-grid {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.man-result-card {
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.16);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}
.man-result-word {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 22px;
  color: var(--man-ink);
  line-height: 1;
}
.man-result-en {
  font-family: var(--man-sans);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  margin-top: 4px;
}

.man-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
}

/* ---- Play screen ---- */
.man-play-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(42,26,14,0.33);
  margin-bottom: 22px;
}
.man-counter {
  text-align: right;
}
.man-counter-num {
  font-family: var(--man-serif);
  font-size: 44px;
  line-height: 1;
  color: var(--man-accent);
}
.man-counter-denom { color: var(--man-ink-soft); font-weight: 300; }
.man-counter-label {
  font-family: var(--man-sans);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  margin-top: 4px;
}

.man-play-grid {
  display: grid;
  grid-template-columns: 560px 1fr;
  gap: 36px;
  align-items: start;
}
@media (max-width: 1080px) {
  .man-play-grid { grid-template-columns: 1fr; }
}

.man-grid-frame {
  border: 1px solid rgba(42,26,14,0.33);
  background: rgba(42,26,14,0.06);
  margin-bottom: 18px;
  padding: 6px;
}
.ws-grid {
  display: grid;
  gap: 4px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.ws-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--man-serif);
  font-weight: 500;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  letter-spacing: 0.06em;
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.10);
  color: var(--man-ink);
  border-radius: 0;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}
.ws-cell:hover { background: rgba(232,154,42,0.18); }
.ws-cell.is-selecting {
  background: var(--man-accent);
  color: var(--man-card);
}
.ws-cell.is-found {
  background: #F4C56A;
  color: #5A3A18;
  border-color: rgba(90,58,24,0.25);
}
.ws-cell.just-found { animation: ws-cell-flash 700ms ease; }
@keyframes ws-cell-flash {
  0%   { background: var(--man-accent2); }
  60%  { background: #F4C56A; }
  100% { background: #F4C56A; }
}
/* Letter-highlight (the "Highlight" button hint mode). Bright outline
   so it's visually distinct from selecting / found / just-found. */
.ws-cell.ws-cell-letter-hl {
  background: rgba(31,106,90,0.18);
  outline: 2px solid var(--man-jade, #1F6A5A);
  outline-offset: -2px;
  z-index: 1;
}
/* "Click a letter" cursor cue while the highlight button is armed. */
.ws-grid.ws-grid-armed-hl { cursor: crosshair; }
.ws-grid.ws-grid-armed-hl .ws-cell { cursor: crosshair; }

/* ---- Remaining-words pills + timer panel ---- */
.man-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.man-pill {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 17px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.18);
  color: var(--man-ink);
}
.man-pill-target {
  /* Wrapper for the target-language word so the hide-target toggle
     can collapse it without removing the whole pill. */
}
.man-pill-en {
  font-style: normal;
  font-family: var(--man-sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--man-ink-soft);
  margin-left: 6px;
}
.man-pill-en::before {
  content: "· ";
}

/* When the user toggles target-language text off, hide the .man-pill-target
   wrapper and grow the primary text up to roughly the original target size
   so the pill stays legible. The bullet separator goes too — there's
   nothing to separate from. */
.man-pills.man-pills-hide-target .man-pill-target {
  display: none;
}
.man-pills.man-pills-hide-target .man-pill-en {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0;
  color: var(--man-ink);
  text-transform: none;
  margin-left: 0;
}
.man-pills.man-pills-hide-target .man-pill-en::before {
  content: "";
}

.man-kicker-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.man-pill-toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.man-pill-toggle {
  font-family: var(--man-sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  background: transparent;
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 999px;
  padding: 4px 12px;
  cursor: pointer;
}
.man-pill-toggle:hover {
  color: var(--man-ink);
  border-color: rgba(42,26,14,0.35);
}
.man-pill-toggle[aria-pressed="true"] {
  color: var(--man-ink);
  background: rgba(42,26,14,0.06);
  border-color: rgba(42,26,14,0.35);
}

/* ---- Cork board + polaroids ---- */
.man-board-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}
.man-board-helper {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 13px;
  color: var(--man-ink-soft);
}

.man-cork {
  position: relative;
  min-height: 460px;
  padding: 18px;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.05) 0 1px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(0,0,0,0.06) 0 1px, transparent 2px),
    linear-gradient(135deg, #C99764 0%, #B07A3D 100%);
  background-size: 12px 12px, 16px 16px, 100% 100%;
  border: 1px solid rgba(42,26,14,0.33);
  box-shadow: inset 0 0 60px rgba(0,0,0,0.18);
}
.man-cork-spacer {
  /* Height set inline by the view (cork_inner_height()): rows * 217 - 4. */
}

.man-polaroid {
  position: absolute;
  padding: 10px 10px 18px;
  background: var(--man-card);
  border: 1px solid rgba(42,26,14,0.18);
  box-shadow: 0 10px 22px rgba(42,26,14,0.18);
  transform-origin: 50% 0%;
  z-index: 30;
}
.man-polaroid.is-latest {
  z-index: 60;
  box-shadow: 0 18px 36px rgba(42,26,14,0.32);
  animation: man-pin 480ms cubic-bezier(.2,1.4,.4,1);
}
@keyframes man-pin {
  0%   { transform: rotate(var(--rot)) scale(0.7) translateY(-30px); opacity: 0; }
  60%  { transform: rotate(calc(var(--rot) - 4deg)) scale(1.04) translateY(2px); opacity: 1; }
  100% { transform: rotate(var(--rot)) scale(1) translateY(0); opacity: 1; }
}
.man-tape {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  width: 70px;
  height: 18px;
  border-left: 1px dashed rgba(255,255,255,0.4);
  border-right: 1px dashed rgba(255,255,255,0.4);
}
.man-photo {
  aspect-ratio: 1;
  position: relative;
  overflow: hidden;
  margin-bottom: 10px;
}
.man-photo-word {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 10px;
  font-family: var(--man-serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1;
  letter-spacing: -0.005em;
  color: #FFE8C4;
  word-break: break-word;
  hyphens: auto;
}
.man-photo-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.man-caption {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 22px;
  color: var(--man-ink);
  line-height: 1;
}
.man-caption-target {
  /* Handwritten signature on the polaroid label — Spanish word in
     thick marker. Slight tilt so it doesn't read like a label print. */
  font-family: 'Caveat', 'Bricolage Grotesque', cursive;
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  color: var(--man-ink);
  text-align: center;
  margin-top: 8px;
  transform: rotate(-1.2deg);
  transform-origin: 30% 50%;
  word-break: break-word;
  hyphens: auto;
}
.man-caption-en {
  font-family: var(--man-sans);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  margin-top: 6px;
  text-align: center;
}
.ws-illo-stamp {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFE8C4;
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 18px;
}
.ws-illo-plane {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFE8C4;
  font-size: 60px;
  line-height: 1;
}

/* ---- Empty placeholder slots ---- */
.man-empty {
  position: absolute;
  padding: 10px 10px 30px;
  border: 1.5px dashed rgba(42,26,14,0.18);
  background: transparent;
  pointer-events: none;
  z-index: 1;
}
.man-empty-photo {
  aspect-ratio: 1;
  background: rgba(42,26,14,0.04);
  margin-bottom: 10px;
  position: relative;
}
.man-empty-pin {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(209,75,44,0.27);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.man-empty-bar {
  background: rgba(42,26,14,0.06);
  margin-bottom: 6px;
}
.man-empty-bar-tall { height: 16px; }
.man-empty-bar-short { height: 8px; width: 60%; }

/* ---- Last pinned line ---- */
.man-last-pinned {
  margin-top: 14px;
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 14px;
  color: var(--man-ink);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.man-last-word { color: var(--man-ink); }
.man-last-en { color: var(--man-ink-soft); }

/* ---- Flashcard review ---- */
.man-flashcard-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 32px 20px 56px;
}
.man-flashcard-progress {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 320px;
  max-width: 100%;
  justify-content: space-between;
}
.man-flashcard-count {
  font-family: var(--man-serif);
  font-style: italic;
  font-size: 16px;
  color: var(--man-ink-soft);
}
.man-flashcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
/* The flashcard polaroid is the same base .man-polaroid as the cork
   board, just larger, centered, and unwobbled. The Spanish handwriting
   sits hidden until .is-revealed is added (3-second auto-timer or on
   user grade), so the learner has a beat to recall before the answer
   surfaces. */
.man-flashcard-polaroid {
  position: static;
  width: 320px;
  max-width: 92vw;
  padding: 16px 16px 22px;
  transform: none !important;
}
.man-flashcard-polaroid .man-tape {
  width: 110px;
  height: 22px;
  top: -10px;
}
.man-flashcard-polaroid .man-photo {
  margin-bottom: 14px;
}
.man-flashcard-polaroid .man-photo-word {
  font-size: clamp(28px, 4vw, 44px);
}
.man-flashcard-polaroid .man-caption-target {
  font-size: 44px;
  margin-top: 14px;
  opacity: 0;
  transition: opacity 320ms ease-out;
}
.man-flashcard-polaroid.is-revealed .man-caption-target {
  opacity: 1;
}
.man-flashcard-polaroid .man-caption-en {
  font-size: 14px;
  letter-spacing: 0.22em;
  margin-top: 8px;
}
.man-flashcard-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Gap and margin together fix the meta row's y-position. Reducing
     margin-top by 10 and bumping gap by 10 lifts the grading row
     (Missed/Got) without moving the audio + flip toolbar. */
  gap: 46px;
  margin-top: 30px;
}
.man-flashcard-actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.man-flashcard-actions .man-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

/* Subtle disclosure toggle for the meta row. Low contrast + no
   border so it doesn't add to the visual weight of the action
   area. Hover lifts the contrast as an affordance hint. */
.ws-meta-toggle {
  background: none;
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--man-ink-soft, #7A5D3E);
  opacity: 0.55;
  transition: opacity 0.12s, color 0.12s;
}
.ws-meta-toggle:hover {
  opacity: 1;
  color: var(--man-ink, #2A1A0E);
}
.ws-meta-toggle-arrow { font-size: 13px; line-height: 1; }

/* Collapsed state — hide row 2, tighten the gap so the toggle
   docks just below the grading row. */
.man-flashcard-actions-collapsed { gap: 14px; }
.man-flashcard-actions-collapsed .man-flashcard-actions-meta {
  display: none;
}

.man-flashcard-summary {
  text-align: center;
  padding: 32px 20px 56px;
}
.man-flashcard-summary .man-actions { justify-content: center; }

/* ============================================================
   Crossword — placeholder styling. Just enough structure that
   the screens are usable. Claude Design will redo this pass.
   Reuses Mañana tokens (var(--man-page) etc.) where convenient.
   ============================================================ */
.cw-page {
  background: var(--man-page, #F4E5C8);
  border-radius: var(--radius-lg, 18px);
  padding: 24px 0 48px;
  margin-top: 14px;
  color: var(--man-ink, #2A1A0E);
}
.cw-container { max-width: 1180px; margin: 0 auto; padding: 0 50px; }
@media (max-width: 760px) { .cw-container { padding: 0 24px; } }

.cw-nav {
  display: flex;
  gap: 6px;
  width: fit-content;
  margin: 0 auto 18px;
  padding: 4px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  box-shadow: 3px 3px 0 var(--man-ink, #2A1A0E);
}
.cw-nav a, .cw-nav-disabled {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 8px 18px;
  text-decoration: none;
  color: var(--man-ink, #2A1A0E);
}
.cw-nav a:hover { background: rgba(209,75,44,0.12); }
.cw-nav a.active { background: var(--man-accent, #D14B2C); color: var(--man-card, #FBF5E6); }
.cw-nav-disabled { color: rgba(42,26,14,0.35); cursor: default; }

.cw-kicker {
  font-family: 'Inter Tight', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--man-accent, #D14B2C);
}
.cw-kicker-soft { color: var(--man-ink-soft, #7A5D3E); }
.cw-title {
  font-family: 'Newsreader', serif;
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 6px 0 0;
}
.cw-title-em { font-style: italic; color: var(--man-accent, #D14B2C); }
.cw-subhead {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--man-ink-soft, #7A5D3E);
  margin: 10px 0 0;
}
.cw-rule { border: none; border-top: 1px solid rgba(42,26,14,0.33); margin: 22px 0; }
.cw-muted { color: var(--man-ink-soft, #7A5D3E); }
.cw-muted a { color: var(--man-accent, #D14B2C); text-underline-offset: 3px; }

.cw-masthead { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; }
.cw-meta-block { text-align: right; }
.cw-meta-line {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 18px;
  margin-top: 4px;
}

.cw-resume {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  background: var(--man-card, #FBF5E6);
  border: 1px dashed var(--man-accent, #D14B2C);
}
.cw-resume-body { font-family: 'Newsreader', serif; font-size: 17px; margin: 6px 0 0; }

.cw-start { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 26px; }
.cw-mode-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.cw-mode-blurb { max-width: 540px; font-size: 13px; line-height: 1.5; text-align: center; margin: 0; }
.cw-mode-tag {
  font-weight: 700; color: var(--man-accent, #D14B2C);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.cw-mode-tag-soft {
  font-weight: 600; color: var(--man-ink-soft, #7A5D3E);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.cw-beaten-tag {
  font-weight: 700; color: var(--success, #2a8);
  letter-spacing: 0.04em; text-transform: uppercase;
}
.cw-banner-win {
  padding: 10px 14px; border-radius: 4px; margin: 12px 0;
  background: color-mix(in srgb, var(--success, #2a8) 18%, var(--man-card, #FBF5E6));
  color: var(--man-ink, #2A1A0E);
}
.cw-clue-lang {
  font-size: 10px; font-weight: 600;
  color: var(--man-accent, #D14B2C);
  letter-spacing: 0.05em;
  margin-right: 2px;
}

.cw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 12px 22px;
  border: 1.5px solid var(--man-ink, #2A1A0E);
  background: transparent;
  color: var(--man-ink, #2A1A0E);
  cursor: pointer;
  border-radius: 0;
  text-decoration: none;
}
.cw-btn-primary {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FBF5E6);
  border-color: var(--man-accent, #D14B2C);
  box-shadow: 4px 4px 0 var(--man-ink, #2A1A0E);
}
.cw-btn-primary:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--man-ink, #2A1A0E); }
.cw-btn-secondary { background: transparent; border-color: rgba(42,26,14,0.55); }
.cw-btn-lg { padding: 16px 32px; font-size: 12px; }

.cw-banner {
  padding: 0.6rem 0.9rem;
  margin: 12px 0;
  border-radius: var(--radius-sm, 6px);
}
.cw-banner-warn {
  background: color-mix(in srgb, var(--warning, #d97706) 14%, var(--man-card, #FBF5E6));
  border: 1px solid color-mix(in srgb, var(--warning, #d97706) 50%, var(--man-card, #FBF5E6));
}

/* ---- Play layout ---- */
.cw-play-grid {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
  margin-top: 16px;
}
@media (max-width: 920px) { .cw-play-grid { grid-template-columns: 1fr; } }

/* Floating clue banner — shows the active clue while typing on
   narrow viewports where the clue list is stacked BELOW the puzzle.
   Fixed-position so toggling it on/off doesn't shift the puzzle's
   vertical position; hidden entirely on wider screens because the
   side-panel clue list is right there. */
.cw-clue-banner {
  /* Plain inline strip above the puzzle on narrow viewports. No
     border / background / shadow — just red text. Always rendered
     with a reserved line of space so the puzzle doesn't shift when
     the text appears or clears between cell taps. */
  min-height: 1.4em;
  margin: 6px auto 4px;
  max-width: 720px;
  text-align: center;
  font-family: "Newsreader", serif;
  font-size: 15px;
  font-style: italic;
  color: var(--cw-cherry, #D9434F);
}
.cw-clue-banner[hidden] { display: none !important; }
@media (min-width: 921px) {
  /* Side-panel layout already shows clues — banner not needed. */
  .cw-clue-banner { display: none !important; }
}

.cw-grid {
  display: grid;
  gap: 1px;
  background: rgba(42,26,14,0.5);
  padding: 1px;
  border: 2px solid var(--man-ink, #2A1A0E);
  width: fit-content;
}
.cw-cell {
  position: relative;
  width: clamp(28px, 3.6vw, 44px);
  height: clamp(28px, 3.6vw, 44px);
  background: var(--man-card, #FBF5E6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cw-cell-black { background: var(--man-ink, #2A1A0E); }
.cw-cell-number {
  position: absolute;
  top: 1px; left: 2px;
  font-size: 9px;
  font-family: 'Inter Tight', sans-serif;
  color: var(--man-ink-soft, #7A5D3E);
  pointer-events: none;
}
.cw-cell input[type="text"] {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-family: 'Newsreader', serif;
  font-size: clamp(15px, 2.2vw, 22px);
  text-transform: uppercase;
  color: var(--man-ink, #2A1A0E);
  padding: 0;
  caret-color: var(--man-accent, #D14B2C);
}
.cw-cell input[type="text"]:focus {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 18%, var(--man-card, #FBF5E6));
}
.cw-cell-wrong { background: color-mix(in srgb, var(--danger, #b00) 18%, var(--man-card, #FBF5E6)); }
.cw-cell-won { background: color-mix(in srgb, var(--success, #2a8) 22%, var(--man-card, #FBF5E6)); }
.cw-cell-active { background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6)); }
.cw-cell-current { background: color-mix(in srgb, var(--man-accent, #D14B2C) 22%, var(--man-card, #FBF5E6)); }
.cw-cell-current input[type="text"] { background: transparent; }
.cw-cell-solved {
  background: color-mix(in srgb, var(--success, #2a8) 16%, var(--man-card, #FBF5E6));
}
.cw-cell-letter {
  font-family: 'Newsreader', serif;
  font-size: clamp(15px, 2.2vw, 22px);
  text-transform: uppercase;
  color: var(--man-ink, #2A1A0E);
}

/* ---- Clue list ---- */
.cw-clues { display: grid; gap: 18px; }
.cw-clues h3 { margin: 0 0 0.4rem; }
.cw-clue-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.4rem;
  font-family: 'Newsreader', serif;
  font-size: 16px;
}
/* Every li keeps the same padding/margin whether highlighted or
   not, so adding the active class doesn't shift other clues. */
.cw-clue-list li {
  line-height: 1.4;
  padding: 3px 8px;
  margin: 0 -8px;
  border-radius: 3px;
  border-left: 4px solid transparent;
  transition: background 100ms, border-color 100ms;
}
/* Click-to-jump on play page (data-clue-num is only set there, not
   on the result page). Hover hint reinforces the affordance. */
.cw-clue-list li[data-clue-num] { cursor: pointer; }
.cw-clue-list li[data-clue-num]:hover {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 18%, transparent);
}
.cw-clue-list strong { font-weight: 700; margin-right: 4px; }
.cw-clue-len { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; }

.cw-play-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.cw-flashcard-escape {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.cw-autosave-note {
  margin: 0.5rem 0 0;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--man-ink-soft, #7A5D3E);
}

/* ---- History rail ---- */
.cw-history-list { list-style: none; padding: 0; margin: 14px 0 0; }
.cw-history-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  gap: 20px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42,26,14,0.18);
  font-family: 'Newsreader', serif;
  font-size: 16px;
}
.cw-history-id {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  letter-spacing: 0.18em;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--man-ink-soft, #7A5D3E);
}
.cw-history-link {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--man-accent, #D14B2C);
  text-decoration: none;
}
.cw-history-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ============================================================ */
/* Tower of Babylon (Mahjong-solitaire variant).                */
/* ============================================================ */

/* ============================================================ */
/* Tile Solitaire — Phase 1 reskin tokens                       */
/* Culture packs drive felt + lacquer rail + accent + tile      */
/* colors via CSS variables. Default pack: cantonese.           */
/* ============================================================ */
:root {
  /* Cantonese (default) — jade billiard felt, vermilion accent */
  --bb-felt:           #0E5340;
  --bb-felt-deep:      #073527;
  --bb-rail:           #3A1816;
  --bb-rail-hi:        #7A2A1F;
  --bb-tile-face:      #F4EBD2;
  --bb-tile-face-shadow: #D9CFB2;
  --bb-tile-edge:      #C9B98E;
  --bb-tile-edge-dark: #8C7B4C;
  --bb-ink-primary:    #1F1A12;
  --bb-ink-spanish:    #A21B22;
  --bb-ink-english:    #1F1A12;
  --bb-accent:         #A21B22;
  --bb-bone:           #F5EEDC;       /* warm body text, never per-pack */
}

/* Lift the site's max-width + padding off the wrapping <main>
   when a felt page is inside, so the felt can fill the viewport. */
main.container:has(.bb-page-felt) {
  max-width: none;
  padding: 0;
}

/* Per-pack scrollbar palette. Body / html scroll for the document, so
   the rule needs to live above .bb-page-felt where the pack vars don't
   reach — using literal pack colors keeps each rule self-contained.
   thumb-color first, track-color second. */
body:has(.bb-page-felt[data-pack="cantonese"]) {
  scrollbar-color: #7A2A1F #073527;
}
body:has(.bb-page-felt[data-pack="shanghai"]) {
  scrollbar-color: #B58A2A #06221F;
}
body:has(.bb-page-felt[data-pack="vietnamese"]) {
  scrollbar-color: #E5A82A #5C150A;
}
body:has(.bb-page-felt[data-pack="riichi"]) {
  scrollbar-color: #C8392B #0D1A38;
}
body:has(.bb-page-felt[data-pack="tibetan"]) {
  scrollbar-color: #E5A82A #2E140A;
}

/* Compound selector beats the .bb-page tan-cream fallback that's
   defined later in the file. Both classes are on the element so
   the 0,2,0 specificity here wins. */
.bb-page.bb-page-felt {
  /* Per-pack culture variables can land here via inline style. */
  width: 100%;
  background:
    repeating-linear-gradient(45deg,  rgba(255,255,255,0.02) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,0.04) 0 1px, transparent 1px 3px),
    radial-gradient(120% 80% at 50% 30%, var(--bb-felt) 0%, var(--bb-felt-deep) 90%);
  color: var(--bb-bone);
  font-family: 'Inter Tight', system-ui, sans-serif;
  min-height: 100vh;
  padding-top: 0;
}

/* Lacquer rail at the top — full-bleed band with content lined up
   to the same horizontal axis as .bb-container below it.
   .bb-rail paints the lacquer (full window width); .bb-rail-inner
   is the max-width content container so text/buttons sit flush
   with the game card. */
.bb-rail {
  width: 100%;
  background: linear-gradient(180deg, var(--bb-rail-hi) 0%, var(--bb-rail) 100%);
  border-bottom: 2px solid var(--bb-tile-edge-dark);
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
  position: relative; z-index: 1;
}
.bb-rail-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 10px 36px;
  color: var(--bb-bone);
  font-family: 'Inter Tight', sans-serif;
  flex-wrap: wrap;
}
.bb-rail-left, .bb-rail-right {
  display: flex; align-items: center; gap: 10px;
}
.bb-rail-tag {
  font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase;
  opacity: 0.75;
}
.bb-rail-context {
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--bb-accent);
  font-weight: 700;
  font-family: 'Inter Tight', sans-serif;
}
button.bb-rail-context {
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--bb-accent, #A21B22) 60%, transparent);
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
}
button.bb-rail-context:hover {
  background: rgba(255,255,255,0.06);
  border-style: solid;
}
.bb-rail-context-static {
  /* Non-clickable label variant (Settings / Home / History pages). */
  padding: 0;
  border: 0;
  background: transparent;
}
.bb-goto-form {
  display: inline-flex; align-items: center; gap: 6px;
}
.bb-goto-form[hidden] { display: none; }
.bb-goto-label {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  opacity: 0.7;
}
.bb-goto-form input[type="number"] {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 4px;
  background: rgba(0,0,0,0.25);
  color: var(--bb-bone, #F5EEDC);
  font-family: 'Inter Tight', sans-serif; font-weight: 700;
}
.bb-rail-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  background: rgba(255,255,255,0.06);
  color: var(--bb-bone, #F5EEDC);
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em;
  text-decoration: none;
  cursor: pointer;
}
.bb-rail-btn:hover { background: rgba(255,255,255,0.12); }
.bb-rail-btn-ghost {
  background: transparent;
  border-color: rgba(255,255,255,0.18);
  opacity: 0.85;
}
/* Current-tab indicator. Uses the pack accent so it picks up each
   culture pack's signature color (red on cantonese, brass on
   shanghai, vermilion on riichi, etc.). */
.bb-rail-btn-active,
.bb-rail-btn-active:hover {
  background: var(--bb-accent, #A21B22);
  border-color: var(--bb-accent, #A21B22);
  color: var(--bb-bone, #F5EEDC);
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset,
              0 -1px 0 rgba(0,0,0,0.25) inset;
  cursor: default;
}

.bb-page { background: var(--man-page, #F4E5C8); min-height: 100vh; padding-top: 32px; }
.bb-container { max-width: 1280px; margin: 0 auto; padding: 24px 36px; background: var(--man-card, #FBF5E6); border-radius: 12px; box-shadow: 0 8px 36px rgba(0,0,0,0.08); }
/* On the felt-themed pages, the container is a translucent panel
   so the felt shows through, not an opaque cream card. */
.bb-page-felt .bb-container {
  background: rgba(0,0,0,0.18);
  box-shadow: none;
  border: 1px solid var(--bb-tile-edge-dark);
  color: var(--bb-bone);
}
.bb-masthead { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.bb-kicker { font-family: 'Inter Tight', sans-serif; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--man-accent, #D14B2C); font-weight: 600; }
.bb-kicker-soft { color: var(--man-ink-soft, #7A5D3E); }
.bb-page-felt .bb-kicker { color: var(--bb-accent); letter-spacing: 0.28em; font-weight: 800; }
.bb-page-felt .bb-kicker-soft { color: rgba(245,238,220, 0.75); }
.bb-title { font-family: 'Bricolage Grotesque', serif; font-size: 48px; line-height: 1; margin: 8px 0; }
/* Stone-carved headline placeholder — Phase 3 will swap the JS
   StoneHeadline rendering in. For now: Cinzel set with debossed
   shadow so the page already reads "carved stone". */
.bb-page-felt .bb-title {
  font-family: 'Cinzel', 'Newsreader', serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--bb-bone);
  text-shadow:
    0 1px 0 rgba(0,0,0,0.4),
    0 -1px 0 rgba(255,255,255,0.08);
}
/* Stone headline — multi-span layout so the accent word can use the
   pack accent color while the rest stays bone. Letter-spacing per
   the design tokens (0.10–0.18em on the carved face). */
.bb-stone-headline {
  display: inline-flex; flex-wrap: wrap;
  gap: 0.32em; align-items: baseline;
  font-size: clamp(48px, 6vw, 88px); line-height: 0.95;
  letter-spacing: 0.10em;
}
.bb-stone-accent {
  color: var(--bb-accent, #A21B22);
  text-shadow:
    0 1px 0 rgba(0,0,0,0.55),
    0 -1px 0 rgba(255,255,255,0.06);
}
.bb-subhead { color: var(--man-ink-soft, #7A5D3E); margin: 4px 0 0; max-width: 600px; }
.bb-meta-block { text-align: right; }
.bb-meta-line { font-family: 'Newsreader', serif; font-size: 14px; }
.bb-rule { border: 0; border-top: 1px dashed rgba(0,0,0,0.18); margin: 24px 0; }
.bb-beaten-tag { font-weight: 700; color: var(--success, #2a8); letter-spacing: 0.04em; text-transform: uppercase; }

.bb-scoreboard { display: flex; gap: 18px; align-items: flex-end; }
.bb-scoreboard > div { display: flex; flex-direction: column; align-items: flex-start; }
.bb-scoreboard strong { font-size: 28px; font-family: 'Bricolage Grotesque', serif; line-height: 1; }
.bb-scoreboard span:not(.bb-kicker):not(.bb-kicker-soft) { font-size: 16px; font-family: 'Newsreader', serif; }

.bb-banner { padding: 8px 14px; border-radius: 4px; margin: 12px 0; min-height: 1em; color: var(--man-ink-soft, #7A5D3E); }
.bb-banner-win { background: color-mix(in srgb, var(--success, #2a8) 18%, var(--man-card, #FBF5E6)); color: var(--man-ink, #2A1A0E); font-weight: 600; }
.bb-banner-stuck { background: color-mix(in srgb, var(--man-accent, #D14B2C) 16%, var(--man-card, #FBF5E6)); color: var(--man-ink, #2A1A0E); }

/* Board: tile positions are calculated in JS via --row/--col/--layer.
   On the felt page we drop the gray tray + give it a soft vignette
   so the tiles read as resting on the table, not in a card. */
/* Outer scroll wrapper. The .bb-board itself is fixed-pixel sized
   to its shape's bounding box (which can exceed the viewport on the
   wedge or wide-pyramid shapes); the wrap keeps the rest of the
   page intact and lets the user pan horizontally when needed. */
/* Stage wrapper for the scrollable board — anchors the absolute-
   positioned scroll arrows so they don't move with the inner scroll
   content. Visible only when the board overflows horizontally; the
   JS toggles the buttons' [hidden] attribute. */
.bb-board-stage {
  position: relative;
  width: 100%;
}
.bb-board-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  /* Plain block-level layout — bb-board uses margin: 0 auto to
     center when it fits, and naturally left-aligns when it
     overflows. We dropped the flex-based centering because the
     `safe center` fallback was leaving asymmetric horizontal
     offsets in some browsers. */
  padding: 0;
}
/* Pending-selection callout — a pill that floats at the top of the
   board when the pending tile has been scrolled out of view, so the
   player still knows what they picked. Click it to scroll the tile
   back into view. */
.bb-pending-pill {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,0.78);
  color: var(--bb-bone, #F5EEDC);
  border: 1px solid var(--bb-accent, #A21B22);
  box-shadow: 0 4px 10px rgba(0,0,0,0.45);
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.bb-pending-pill[hidden] { display: none; }
.bb-pending-pill:hover { background: rgba(0,0,0,0.9); }
.bb-pending-pill-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.7;
}
.bb-pending-pill strong {
  font-family: 'Cinzel', 'Newsreader', serif;
  letter-spacing: 0.05em;
  font-size: 13px;
  color: var(--bb-accent, #A21B22);
}
.bb-pending-pill-hint {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Tall vertical hover strips on each edge of the board. Invisible
   until the cursor enters; reveals a translucent dark gradient with
   a centered triangle pointing toward the center. The whole strip
   is one big button — click anywhere in it to smooth-scroll to the
   opposite end. Bottom inset clears the scrollbar so the strip
   ends just above it. */
.bb-scroll-arrow {
  position: absolute;
  top: 0;
  bottom: 18px;
  width: 28px;
  z-index: 5;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease;
}
.bb-scroll-arrow:hover { opacity: 1; }
/* After the user clicks a strip we keep it hidden even though the
   cursor is still over it — restored on mouseleave. Stand-in for
   "snap the cursor to center", which JS can't actually do. */
.bb-scroll-arrow.bb-scroll-arrow-dismissed,
.bb-scroll-arrow.bb-scroll-arrow-dismissed:hover {
  opacity: 0;
}
.bb-scroll-arrow:active .bb-scroll-arrow-glyph { transform: scale(0.92); }

.bb-scroll-arrow-left {
  left: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.0) 100%);
}
.bb-scroll-arrow-right {
  right: 0;
  background: linear-gradient(270deg, rgba(0,0,0,0.62) 0%, rgba(0,0,0,0.0) 100%);
}

/* Triangles drawn with CSS borders. Both arrows point toward the
   center and sit just inside the outer edge of the strip. */
.bb-scroll-arrow-glyph {
  display: block;
  width: 0; height: 0;
  border-style: solid;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
  transition: transform 0.12s ease;
}
.bb-scroll-arrow-left .bb-scroll-arrow-glyph {
  /* points right */
  border-width: 9px 0 9px 12px;
  border-color: transparent transparent transparent var(--bb-bone, #F5EEDC);
  margin-right: auto;
  margin-left: 6px;
}
.bb-scroll-arrow-right .bb-scroll-arrow-glyph {
  /* points left */
  border-width: 9px 12px 9px 0;
  border-color: transparent var(--bb-bone, #F5EEDC) transparent transparent;
  margin-left: auto;
  margin-right: 6px;
}
@media (min-width: 1100px) {
  /* On wide screens, give the wrap a max so the felt vignette
     doesn't stretch absurdly behind a small board. */
  .bb-board-wrap { max-width: 100%; }
}

.bb-board {
  position: relative;
  /* Promote the board to its own GPU compositor layer so the
     hundred-plus absolutely-positioned tiles (each with their own
     rotate(jitter) transform) scroll together as a single unit.
     Without this, individual tile transforms can land on separate
     compositor layers and re-composite at slightly different times
     during horizontal scroll, looking choppy / desynced. `contain`
     additionally tells the browser the board is a self-contained
     paint/layout subtree, which keeps repaint costs bounded. */
  will-change: transform;
  contain: layout paint style;
  /* `margin: 0 auto` centers the board horizontally when it fits in
     the wrap; when it's wider than the wrap, the auto margins
     collapse to 0 and the board left-aligns naturally — letting the
     wrap scroll. Vertical 16px stays as breathing room above/below. */
  margin: 16px auto;
  /* Sized exactly to the active shape's bounding box plus enough
     room above/left for the topmost layer's negative shift. Tile
     positioning formulas (below) bake the same layer offset into
     left/top so absolutely-positioned children stay inside the box
     even when the layer-up shift would otherwise push them above
     the masthead or beyond the action row.
       STEP_X    = 104px  (col stride)
       STEP_Y    =  52px  (row stride)
       LAYER_DX  =  14px  (per layer left shift)
       LAYER_DY  =  16px  (per layer up shift) */
  /* +30px right buffer: leaves 30px of empty board background past
     the rightmost tile to visually balance the felt margin Shi sees
     on the left edge. Tiles still position at +0 from the board's
     left edge (no left interior padding), so the cluster sits flush
     against the left and gains breathing room on the right. */
  width: calc(var(--bb-cols, 14) * 104px + var(--bb-layers, 0) * 14px + 30px);
  min-height: calc(var(--bb-rows, 7) * 52px + var(--bb-layers, 0) * 16px + 32px);
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  flex-shrink: 0;
}
.bb-page-felt .bb-board {
  background:
    radial-gradient(80% 60% at 50% 40%, rgba(0,0,0,0.18), rgba(0,0,0,0));
  border-radius: 12px;
}

/* Carved-stone tile face — landscape per the design (78×51).
   Geometry tokens from tile-component.jsx:
     TILE_W = 78, TILE_H = 51
     STEP_X = 78, STEP_Y = 51 * 0.92 + 5 ≈ 52
     LAYER_DX = -10 (each layer up shifts LEFT)
     LAYER_DY = -16 (each layer up lifts UP)
   Each tile is a button positioned via CSS variables
   (--row, --col, --layer set inline by the template). Pack tokens
   drive every color; the side faces are simulated by stacked
   box-shadows in the pack edge colors. */
.bb-tile {
  position: absolute;
  /* Wide oblong — fits ~10 chars/line on a single line at 12px
     Inter Tight 800. Cinzel was too wide for vacation vocabulary
     (CALOR, CONCHA, BREEZE all forced two lines); Inter Tight at
     heavy weight keeps a "carved" look while leaving room.
     --jx / --jy / --jrot are seeded per tile in the view so the
     stack reads as hand-laid stone rather than a perfect grid. */
  width: 104px; height: 50px;
  /* Position math: the topmost layer sits flush with the board's
     left edge (offset 0). Lower layers shift right by
     `(layers - layer) * dx` from there. The board no longer
     reserves +16 of horizontal interior padding — the bb-container's
     felt padding is the sole symmetric buffer regardless of scroll. */
  left: calc(var(--col) * 104px + 0px + (var(--bb-layers, 0) - var(--layer)) * 14px + var(--jx, 0px));
  top:  calc(var(--row) * 52px  + 16px + (var(--bb-layers, 0) - var(--layer)) * 16px + var(--jy, 0px));
  transform: rotate(var(--jrot, 0deg));
  z-index: calc(10 + var(--layer) * 100);
  background:
    linear-gradient(135deg,
      var(--bb-tile-face, #F4EBD2) 0%,
      var(--bb-tile-face, #F4EBD2) 55%,
      var(--bb-tile-face-shadow, #D9CFB2) 100%);
  color: var(--bb-ink-primary, #1F1A12);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 5px;
  cursor: not-allowed;
  font-family: 'Inter Tight', 'Helvetica Neue', sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55),
    inset -1px -1px 0 rgba(0,0,0,0.08),
    3px 0 0 var(--bb-tile-edge, #C9B98E),
    0 4px 0 var(--bb-tile-edge-dark, #8C7B4C),
    4px 6px 8px rgba(0,0,0,0.34);
  padding: 4px 8px;
  transition: transform 0.15s, opacity 0.25s, box-shadow 0.15s, filter 0.2s;
  text-align: center;
  user-select: none;
  text-transform: uppercase;
  /* Two-line max via line-clamp on .bb-tile-text. Anything longer
     should be filtered server-side at game build (see
     babylon/views.py::_shape_words). */
  overflow: hidden;
}
/* Inscription panel is now a recessed plaque on the tile face,
   drawn via ::before so it sits at a uniform inset from each
   edge — independent of how long the inscribed word is. */
.bb-tile::before {
  content: "";
  position: absolute;
  inset: 5px 7px;        /* a touch wider on the long axis */
  border-radius: 3px;
  background: rgba(0,0,0,0.05);
  box-shadow: inset 0 1px 1.5px rgba(0,0,0,0.18),
              inset 0 -1px 0 rgba(255,255,255,0.18);
  pointer-events: none;
}
.bb-tile-text {
  position: relative;     /* sit above ::before */
  display: block;
  font-weight: 800; line-height: 1.05;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4),
               0 -1px 0 rgba(0,0,0,0.18);
  /* Soft hyphens are inserted server-side by babylon.services.hyphenate
     so the browser breaks long words on real syllable boundaries
     ("an­ti­cy­clone" → "ANTI-/CYCLONE") rather than falling back to
     character-level break-word. `hyphens: manual` honors only those
     pre-inserted breaks — deterministic, no dictionary involved. */
  hyphens: manual;
  -webkit-hyphens: manual;     /* Safari */
  -ms-hyphens: manual;
  /* Don't pre-empt hyphenation with a character-level break. Only fall
     back to break-word for pathological cases where the dictionary
     finds no break point at all. */
  overflow-wrap: break-word;
  max-height: 2.2em;
  overflow: hidden;
  max-width: 100%;
}
.bb-tile-primary { color: var(--bb-ink-english, #1F1A12); }
.bb-tile-target  { color: var(--bb-ink-spanish, #A21B22); }

.bb-tile-open {
  cursor: pointer;
  border-color: var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-tile-open:hover {
  /* Compose the lift with the seeded rotation so the tile keeps
     its individual angle when hovered. */
  transform: rotate(var(--jrot, 0deg)) translate(0, -2px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.65),
    inset -1px -1px 0 rgba(0,0,0,0.08),
    3px 0 0 var(--bb-tile-edge, #C9B98E),
    0 4px 0 var(--bb-tile-edge-dark, #8C7B4C),
    4px 9px 12px rgba(0,0,0,0.45);
}
.bb-tile-pending {
  outline: 3px solid var(--bb-accent, #A21B22);
  outline-offset: 2px;
  z-index: 9999;
}
.bb-tile-preview {
  outline: 2px dashed color-mix(in srgb, var(--bb-accent, #A21B22) 65%, transparent);
  outline-offset: 1px;
}
/* Blocked = covered. Desaturate so it visibly "drops back" without
   the user thinking the tile is broken. */
.bb-tile:not(.bb-tile-open):not(.bb-tile-removed) {
  filter: brightness(0.78) saturate(0.7);
}
.bb-tile-hint {
  outline: 3px solid #2faa55;
  outline-offset: 2px;
  z-index: 9998;
}
/* When a tile is both hinted AND pending, the pending (red) outline
   wins so the user sees their current selection clearly — but keep
   a subtle green tint via a thin secondary outline. */
.bb-tile-hint.bb-tile-pending {
  outline-color: var(--bb-accent, #A21B22);
}
.bb-score-flash-undo {
  color: var(--man-ink-soft, #7A5D3E) !important;
  font-style: italic;
}
.bb-tile-removed {
  opacity: 0;
  transform: scale(0.6) rotate(8deg);
  pointer-events: none;
}
.bb-tile-shake {
  animation: bb-shake 0.4s;
}
@keyframes bb-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

.bb-score-flash {
  position: absolute;
  margin-left: 8px;
  font-weight: 700;
  color: var(--success, #2a8);
  animation: bb-flash 1.2s ease-out forwards;
  pointer-events: none;
  font-family: 'Bricolage Grotesque', serif;
  font-size: 22px;
}
.bb-score-flash-cross {
  color: var(--man-accent, #D14B2C);
}
@keyframes bb-flash {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  100% { transform: translateY(-30px); opacity: 0; }
}

/* End-of-round summary panel — three stat columns side-by-side under
   the win banner: this round, this game's all-time, and same-config
   aggregates. Stacks on narrow widths. */
.bb-win-stats {
  display: grid;
  /* Each column sized to its content (with a gentle minimum), then
     the whole row centered inside the panel — this leaves a clear
     gap between the three logical groups instead of stretching
     each column to fill 1fr. */
  grid-template-columns: repeat(3, minmax(min-content, 280px));
  justify-content: center;
  gap: 56px;
  margin: 14px 0 18px;
  padding: 16px 18px;
  border: 2px solid var(--bb-accent, #A21B22);
  border-radius: 8px;
  background: rgba(0,0,0,0.55);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  color: var(--bb-bone, #F5EEDC);
  font-family: 'Inter Tight', sans-serif;
  position: relative;
  z-index: 2;
}
@media (max-width: 760px) {
  /* Stack the three groups on narrow widths. */
  .bb-win-stats {
    grid-template-columns: 1fr;
    gap: 18px;
  }
}
.bb-win-stats-col { min-width: 0; }
.bb-win-stats-head {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--bb-accent, #A21B22);
  font-weight: 800;
  margin-bottom: 6px;
  border-bottom: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  padding-bottom: 5px;
}
.bb-win-stats dl { margin: 0; }
.bb-win-stats dl > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
  font-size: 14px;
}
.bb-win-stats dt {
  color: rgba(245,238,220, 0.72);
}
.bb-win-stats dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.bb-win-stats-pb {
  color: #7BC891;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  margin-left: 6px;
}

/* Action row: a centered cluster of in-play buttons (hint / reveal /
   undo / shuffle) and a separate Reset/Play-again button anchored to
   the right. Wraps cleanly on narrow widths — the reset drops to its
   own row centered below the cluster. */
.bb-play-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin: 16px 0;
}
.bb-play-actions-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
}
.bb-play-actions-reset {
  margin-left: auto;
}
@media (max-width: 720px) {
  .bb-play-actions { justify-content: center; }
  .bb-play-actions-reset { margin: 0 auto; }
}
.bb-btn {
  padding: 8px 16px;
  border: 1px solid var(--man-ink, #2A1A0E);
  background: var(--man-card, #FBF5E6);
  color: var(--man-ink, #2A1A0E);
  text-decoration: none;
  border-radius: 4px;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600;
  cursor: pointer;
}
.bb-btn-primary { background: var(--man-accent, #D14B2C); color: white; border-color: var(--man-accent, #D14B2C); }
.bb-btn-secondary { background: var(--man-card, #FBF5E6); }
.bb-btn-lg { padding: 12px 24px; font-size: 16px; }
.bb-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Felt-page button skin — translucent + bone text. Pack accent for
   the primary; subtle for the secondary. */
.bb-page-felt .bb-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  color: var(--bb-bone, #F5EEDC);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.bb-page-felt .bb-btn:hover { background: rgba(255,255,255,0.10); }
.bb-page-felt .bb-btn-primary {
  background: var(--bb-accent, #A21B22);
  border-color: var(--bb-accent, #A21B22);
  color: #fff;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}
.bb-page-felt .bb-btn-primary:hover { filter: brightness(1.08); }
.bb-page-felt .bb-btn-secondary {
  background: rgba(0,0,0,0.32);
  color: var(--bb-bone, #F5EEDC);
  border-color: var(--bb-tile-edge-dark, #8C7B4C);
}

/* ---- Culture pack picker (used on home + play side-rail) ---- */
.bb-culture-picker {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 10px;
  padding: 14px;
  color: var(--bb-bone, #F5EEDC);
}
.bb-culture-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 10px; flex-wrap: wrap;
}
.bb-culture-head .bb-kicker {
  color: var(--bb-accent, #A21B22) !important;
  letter-spacing: 0.22em; font-weight: 800;
}
.bb-culture-note {
  font-family: 'Newsreader', serif; font-style: italic; font-size: 13px;
  color: rgba(245,238,220, 0.7);
}
.bb-culture-pills {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 0; padding: 0;
}
.bb-culture-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 6px;
  color: var(--bb-bone, #F5EEDC);
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif; font-size: 11px;
  font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
}
.bb-culture-pill:hover { background: rgba(255,255,255,0.10); }
.bb-culture-pill-active {
  background: var(--bb-accent, #A21B22) !important;
  border-color: var(--bb-accent, #A21B22) !important;
  color: #fff !important;
}
.bb-culture-flag { font-size: 14px; line-height: 1; }

/* ---- Stat strip on the play page ---- */
.bb-page-felt .bb-scoreboard {
  display: flex; gap: 18px; flex-wrap: wrap;
}
.bb-page-felt .bb-scoreboard > div {
  text-align: center; min-width: 56px;
  display: flex; flex-direction: column-reverse; align-items: center;
  gap: 2px;
}
.bb-page-felt .bb-scoreboard strong {
  font-family: 'Newsreader', serif; font-size: 22px; line-height: 1;
  font-weight: 600; color: var(--bb-bone, #F5EEDC);
}
.bb-page-felt .bb-scoreboard span:not(.bb-kicker):not(.bb-kicker-soft) {
  font-family: 'Newsreader', serif; font-size: 18px;
  color: var(--bb-bone, #F5EEDC);
}
.bb-page-felt .bb-scoreboard .bb-kicker,
.bb-page-felt .bb-scoreboard .bb-kicker-soft {
  font-size: 9px; letter-spacing: 0.22em; font-weight: 700;
  color: rgba(245,238,220, 0.6) !important;
}

/* Compact play-page header strip — single line that holds the
   game-context label on the left and the stat chips on the right.
   Replaces the giant stone headline + subhead on play screens, so
   the tower has the page real estate. */
.bb-play-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding: 8px 0 10px;
  border-bottom: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  margin: 0 0 10px;
}
.bb-play-strip-left {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--bb-accent, #A21B22);
}
.bb-play-strip .bb-beaten-tag {
  margin-left: 6px;
  color: #7BC891;
}
/* Tighten the felt-page container's padding on the play screen so
   the felt + strip + tower sit closer together. Horizontal buffer
   is the SOLE source of left/right felt padding — the bb-board-wrap
   inside has padding 0 to avoid Chromium's overflow-padding-right
   asymmetry. Both sides therefore render exactly 10px of felt. */
.bb-page-felt .bb-container { padding: 14px 10px 18px; }

/* ---- Felt-page banner ---- */
.bb-page-felt .bb-banner {
  background: rgba(0,0,0,0.32);
  border: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  color: var(--bb-bone, #F5EEDC);
}
.bb-page-felt .bb-banner-win {
  border-color: #7BC891;
  color: #7BC891; font-weight: 600;
}
.bb-page-felt .bb-banner-stuck {
  border-color: var(--bb-accent, #A21B22);
  color: var(--bb-accent, #A21B22);
}

/* ---- Felt-page subhead + history rows + difficulty pills ---- */
.bb-page-felt .bb-subhead {
  color: rgba(245,238,220, 0.85);
  font-family: 'Newsreader', serif; font-style: italic;
}
.bb-page-felt .bb-rule {
  border-top-color: var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-page-felt .bb-history-row {
  border-bottom: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-page-felt .bb-history-row,
.bb-page-felt .bb-history-id,
.bb-page-felt .bb-history-date,
.bb-page-felt .bb-history-score,
.bb-page-felt .bb-history-meta { color: var(--bb-bone, #F5EEDC); }
.bb-page-felt .bb-history-meta {
  font-style: italic;
  opacity: 0.78;
  font-size: 13px;
}
.bb-page-felt .bb-history-link { color: var(--bb-accent, #A21B22); }
.bb-history-goto {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 6px;
  background: rgba(0,0,0,0.18);
}
.bb-history-goto-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--bb-bone, #F5EEDC);
  opacity: 0.85;
}
.bb-history-goto input[type="number"] {
  width: 90px;
  padding: 5px 8px;
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 4px;
  background: rgba(0,0,0,0.25);
  color: var(--bb-bone, #F5EEDC);
  font-family: 'Inter Tight', sans-serif; font-weight: 700;
}

/* History toolbar — goto box + filter form share a row at the top
   of the list. The filters wrap on narrow widths so each select
   stays usable. */
.bb-history-toolbar {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.bb-history-filters {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 14px;
  padding: 10px 14px;
  border: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 6px;
  background: rgba(0,0,0,0.18);
}
.bb-history-filters label {
  display: flex; flex-direction: column; gap: 4px;
}
.bb-history-filters label > span {
  font-family: 'Inter Tight', sans-serif;
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgba(245,238,220, 0.7);
}
.bb-history-filters select {
  padding: 5px 8px;
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 4px;
  background: rgba(0,0,0,0.25);
  color: var(--bb-bone, #F5EEDC);
  font-family: 'Inter Tight', sans-serif;
}

/* Tabular history. Replaces the old <ul> rows so we can show
   column headers and lose the inline labels. */
.bb-history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter Tight', sans-serif;
  color: var(--bb-bone, #F5EEDC);
}
.bb-history-table th, .bb-history-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  font-size: 14px;
}
.bb-history-table thead th {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(245,238,220, 0.7);
  border-bottom: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-history-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bb-history-table tbody tr:hover {
  background: rgba(255,255,255,0.04);
}
.bb-history-pager {
  display: flex; align-items: center; gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.bb-history-pager-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  color: rgba(245,238,220, 0.75);
}
.bb-page-felt .bb-difficulty-pill {
  background: rgba(255,255,255,0.06);
  border-color: var(--bb-tile-edge-dark, #8C7B4C);
  color: var(--bb-bone, #F5EEDC);
}
.bb-page-felt .bb-difficulty-pill > small { color: rgba(245,238,220, 0.7); }
.bb-page-felt .bb-difficulty-pill:has(input:checked) {
  background: rgba(255,255,255,0.12);
  outline-color: var(--bb-accent, #A21B22);
}
.bb-page-felt .bb-resume {
  background: rgba(0,0,0,0.28);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
  border-radius: 10px;
}
.bb-page-felt .bb-resume-body { color: rgba(245,238,220, 0.75); }
.bb-page-felt .bb-meta-line { color: var(--bb-bone, #F5EEDC); }
.bb-page-felt .bb-beaten-tag { color: #7BC891; }

.bb-page-felt .bb-modal-card {
  background: var(--bb-rail, #3A1816);
  color: var(--bb-bone, #F5EEDC);
  border: 1px solid var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-page-felt .bb-modal-close { color: var(--bb-bone, #F5EEDC); }
.bb-page-felt .bb-modal-target {
  font-family: 'Cinzel', serif; color: var(--bb-bone, #F5EEDC);
}
.bb-page-felt .bb-modal-primary {
  color: rgba(245,238,220, 0.7);
}

.bb-start { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 26px; }
/* 3-column new-game section: tile-count selector / shape override
   / start button. Equal-width columns with a generous gap so each
   reads as a distinct group. Stacks vertically on narrow screens. */
.bb-start-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 56px;
  align-items: stretch;
  width: 100%;
  max-width: 1100px;
  min-height: 200px;
  padding: 24px 0;
}
.bb-start-col {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  gap: 8px; min-width: 0;
  padding: 0 8px;
}
.bb-start-col + .bb-start-col {
  border-left: 1px dashed var(--bb-tile-edge-dark, #8C7B4C);
  padding-left: 24px;
}
.bb-start-col > .bb-kicker {
  position: absolute;
  top: 14px;
  left: 8px;
  margin: 0;
}
.bb-start-col + .bb-start-col > .bb-kicker { left: 24px; }
.bb-start-col-hint {
  font-size: 12px; font-style: italic;
  color: rgba(245,238,220, 0.7);
  margin: 0;
}
.bb-difficulty-row-stack {
  flex-direction: column; align-items: stretch; gap: 6px;
}
/* Shape selection — same pill styling as the difficulty column,
   stacked vertically, scrollable when there are many shapes
   (built-ins + customs can run long on the Large size). */
.bb-shape-pill-stack {
  display: flex; flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.bb-start-col-action {
  align-items: center; justify-content: center;
  gap: 10px;
}
@media (max-width: 760px) {
  .bb-start-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* Pill-styled dropdown — used for the Tile count + Shape selectors
   on the home page. Trigger reuses .bb-difficulty-pill so the look
   matches everything else; menu sits below as an absolute popup
   with the same pills stacked vertically. */
.bb-pill-dropdown { position: relative; width: 100%; }
.bb-pill-dropdown-trigger {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px;
  text-align: left;
  padding: 12px 24px;
  font-size: 16px;
  line-height: 1.2;
  box-sizing: border-box;
}
/* Force the dropdown triggers and the start button to share the
   same height so all three buttons line up across the row. */
.bb-start-grid .bb-pill-dropdown-trigger,
.bb-start-grid .bb-btn-lg {
  min-height: 50px;
}
.bb-pill-dropdown-trigger .bb-pill-dropdown-label {
  font-weight: 600;
  flex: 1 1 auto;
}
.bb-pill-dropdown-trigger .bb-pill-dropdown-sub {
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 11px;
  flex: 0 0 auto;
}
.bb-page-felt .bb-pill-dropdown-trigger .bb-pill-dropdown-sub {
  color: rgba(245,238,220, 0.7);
}
.bb-pill-dropdown-chevron {
  font-size: 12px;
  opacity: 0.7;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.bb-pill-dropdown-open .bb-pill-dropdown-chevron {
  transform: rotate(180deg);
}
.bb-pill-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(0,0,0,0.18);
  box-shadow: 0 12px 28px rgba(0,0,0,0.25);
  max-height: 320px;
  overflow-y: auto;
}
.bb-pill-dropdown-menu[hidden] { display: none; }
.bb-page-felt .bb-pill-dropdown-menu {
  background: var(--bb-rail, #3A1816);
  border-color: var(--bb-tile-edge-dark, #8C7B4C);
}
.bb-pill-dropdown-item {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}
.bb-pill-dropdown-item > span { flex: 1 1 auto; font-weight: 600; }
.bb-pill-dropdown-item > small {
  flex: 0 0 auto;
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 11px;
}
.bb-page-felt .bb-pill-dropdown-item > small { color: rgba(245,238,220, 0.7); }
.bb-pill-dropdown-item[aria-selected="true"] {
  outline: 2px solid var(--man-accent, #D14B2C);
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6));
}
.bb-page-felt .bb-pill-dropdown-item[aria-selected="true"] {
  outline-color: var(--bb-accent, #A21B22);
  background: rgba(255,255,255,0.12);
}

/* Shape column: keep the Shape dropdown centered (so it lines up with
   the Topics dropdown in column 2) and float the small S/M/L size
   selector below it without shifting the dropdown's vertical center. */
.bb-start-col-shape { position: relative; }
.bb-size-checks {
  position: absolute;
  top: calc(50% + 50px);
  left: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.bb-size-checks-list {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
}
.bb-size-check-detail {
  flex: 1 1 auto;
  text-align: right;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(245,238,220, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bb-size-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(245,238,220, 0.7);
  user-select: none;
}
.bb-size-check input[type="radio"] {
  /* Hide the native control; the visual is the bb-size-check-box span
     so we get a square box (not a round dot) regardless of browser. */
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.bb-size-check-box {
  display: inline-block;
  width: 12px; height: 12px;
  border: 1.5px solid rgba(245,238,220, 0.55);
  border-radius: 2px;
  background: transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.bb-size-check:has(input:checked) {
  color: var(--bb-bone, #F5EEDC);
}
.bb-size-check:has(input:checked) .bb-size-check-box {
  background: var(--bb-accent, #A21B22);
  border-color: var(--bb-accent, #A21B22);
}
.bb-size-check:hover .bb-size-check-box {
  border-color: rgba(245,238,220, 0.85);
}
.bb-size-check input[type="radio"]:focus-visible + .bb-size-check-box {
  outline: 2px solid rgba(245,238,220, 0.6);
  outline-offset: 2px;
}
@media (max-width: 760px) {
  /* Stack naturally on narrow screens. */
  .bb-size-checks { position: static; margin-top: 8px; justify-content: flex-start; }
}

/* Topic multi-select popup body — felt-themed equivalent of the
   wordsearch ws-topic-menu. */
.bb-topic-menu { padding: 10px 12px; }
.bb-topic-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px dashed rgba(245,238,220, 0.18);
}
.bb-topic-clear {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bb-accent, #A21B22);
}
.bb-topic-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
  color: var(--bb-bone, #F5EEDC);
  border-radius: 4px;
  cursor: pointer;
}
.bb-topic-check:hover { background: rgba(255,255,255,0.08); }
.bb-topic-check input { accent-color: var(--bb-accent, #A21B22); }
.bb-topic-menu-empty {
  padding: 12px 8px;
  font-family: 'Newsreader', serif;
  font-size: 13px;
  color: rgba(245,238,220, 0.7);
  font-style: italic;
}
.bb-topic-menu-empty a { color: var(--bb-accent, #A21B22); }
.bb-resume { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0,0,0,0.04); border-radius: 6px; margin: 16px 0; }
.bb-resume-body { margin: 4px 0 0; color: var(--man-ink-soft, #7A5D3E); font-size: 14px; }

.bb-history-list { list-style: none; padding: 0; }
.bb-history-row { display: flex; gap: 16px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,0.06); font-size: 14px; }
.bb-history-id { font-weight: 600; min-width: 60px; }
.bb-history-date { color: var(--man-ink-soft, #7A5D3E); min-width: 60px; }
.bb-history-score { color: var(--man-ink-soft, #7A5D3E); min-width: 80px; }
.bb-history-tag { color: var(--success, #2a8); font-weight: 600; }
.bb-history-link { margin-left: auto; color: var(--man-accent, #D14B2C); text-decoration: none; font-weight: 600; }

/* Babylon: difficulty pills (home form) + reveal modal. */
.bb-difficulty-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; justify-content: center; }
.bb-difficulty-pill {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 16px;
  border: 1px solid rgba(0,0,0,0.18);
  background: var(--man-card, #FBF5E6);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Newsreader', serif;
  min-width: 140px;
  text-align: center;
}
.bb-difficulty-pill input { display: none; }
.bb-difficulty-pill > span { font-weight: 600; }
.bb-difficulty-pill > small { color: var(--man-ink-soft, #7A5D3E); font-size: 11px; }
.bb-difficulty-pill:has(input:checked) {
  outline: 2px solid var(--man-accent, #D14B2C);
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6));
}

.bb-modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
}
.bb-modal[hidden] { display: none !important; }
.bb-modal-card {
  position: relative;
  background: var(--man-card, #FBF5E6);
  padding: 16px;
  border-radius: 8px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}
.bb-modal-close {
  position: absolute; top: 8px; right: 12px;
  background: none; border: 0; font-size: 28px; line-height: 1;
  cursor: pointer; color: var(--man-ink-soft, #7A5D3E);
}
.bb-modal-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: rgba(0,0,0,0.06);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.bb-modal-img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bb-modal-noimg { color: var(--man-ink-soft, #7A5D3E); padding: 24px; text-align: center; }
.bb-modal-text { padding: 16px 4px 0; text-align: center; }
.bb-modal-target {
  font-family: 'Bricolage Grotesque', serif;
  font-size: 28px;
  color: var(--man-ink, #2A1A0E);
}
.bb-modal-primary {
  font-family: 'Newsreader', serif;
  font-style: italic;
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 14px;
  margin-top: 4px;
}

/* ============================================================ */
/* Crossword: Beach Café handoff tokens + country-pack motifs.  */
/* Layered alongside the existing Mañana .cw-* rules so the     */
/* motif system can land without rewriting every screen at once.*/
/* ============================================================ */
:root {
  --cw-page:    #FFF1D6;   /* warm cream page background */
  --cw-paper:   #FFFAEC;   /* slightly cooler cream */
  --cw-cream:   #FFFBF0;   /* brightest cream — cards, cells */
  --cw-pageInk: #1F2E2A;   /* primary ink (near-black green) */
  --cw-ink2:    #5C6E69;   /* secondary ink */
  --cw-citrus:  #F2A22C;   /* warm yellow accent */
  --cw-jade:    #1F8F6E;   /* green accent */
  --cw-cherry:  #D9434F;   /* red accent */
}

/* Block cells now host an inset SVG motif. The .cw-cell-black
   styling stays as the fallback when no pack is active. */
.cw-cell-motif {
  background: var(--cw-pageInk, #1F2E2A);
  position: relative;
  padding: 0;
}
.cw-cell-motif > svg.cw-block-motif {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
}

/* ============================================================ */
/* Crossword: Beach Café direction (Phase 2A).                  */
/* `.cw-page-cafe` opts a page into the new look — awning at    */
/* the very top, cream/citrus/jade/cherry palette overriding    */
/* the Mañana defaults, handwritten Caveat eyebrows.            */
/* ============================================================ */

/* ---- Awning (12 stripes + scalloped bottom edge) ---- */
.cw-awning {
  position: relative;
  height: 28px;
  margin: 0;
}
.cw-awning-stripes {
  display: flex;
  height: 18px;
}
.cw-awning-stripes > span { flex: 1; height: 100%; }
.cw-awning-scallop {
  position: absolute; left: 0; right: 0; bottom: 0;
  width: 100%; height: 14px;
  display: block;
}

/* ---- Page-cafe palette overrides ---- */
.cw-page-cafe {
  background: var(--cw-page, #FFF1D6);
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-container {
  background: var(--cw-cream, #FFFBF0);
  border-radius: 0;
}
.cw-page-cafe .cw-rule {
  border-top: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 33%, transparent);
}
.cw-page-cafe .cw-kicker {
  color: var(--cw-cherry, #D9434F);
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
}
.cw-page-cafe .cw-kicker-hand {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  color: var(--cw-cherry, #D9434F);
}
.cw-page-cafe .cw-title {
  font-family: 'Newsreader', serif;
  font-weight: 400;
  letter-spacing: -0.025em;
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-subhead {
  color: var(--cw-ink2, #5C6E69);
  font-family: 'Newsreader', serif;
  font-style: italic;
}
.cw-page-cafe .cw-mode-tag,
.cw-page-cafe .cw-mode-tag-soft {
  color: var(--cw-cherry, #D9434F);
}
.cw-page-cafe .cw-beaten-tag {
  color: var(--cw-jade, #1F8F6E);
}

/* Buttons get hard drop-shadows in Beach Café direction */
.cw-page-cafe .cw-btn {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  border-radius: 0;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 100ms, box-shadow 100ms;
}
.cw-page-cafe .cw-btn-primary {
  background: var(--cw-citrus, #F2A22C);
  color: var(--cw-pageInk, #1F2E2A);
  box-shadow: 4px 4px 0 var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-btn-primary:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-btn-secondary {
  background: var(--cw-cream, #FFFBF0);
  color: var(--cw-pageInk, #1F2E2A);
  box-shadow: 2px 2px 0 var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-btn-secondary:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-btn-secondary:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--cw-pageInk, #1F2E2A);
}

/* Cell colors — Café palette dominates the grid */
.cw-page-cafe .cw-grid {
  background: var(--cw-pageInk, #1F2E2A);
  border-color: var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-cell {
  background: var(--cw-cream, #FFFBF0);
}
.cw-page-cafe .cw-cell-black { background: var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell input[type="text"] {
  font-family: 'Newsreader', serif;
  caret-color: var(--cw-citrus, #F2A22C);
}
.cw-page-cafe .cw-cell input[type="text"]:focus {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 36%, var(--cw-cream, #FFFBF0));
}
.cw-page-cafe .cw-cell-active {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 16%, var(--cw-cream, #FFFBF0));
}
.cw-page-cafe .cw-cell-current {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 36%, var(--cw-cream, #FFFBF0));
}
.cw-page-cafe .cw-cell-wrong {
  background: color-mix(in srgb, var(--cw-cherry, #D9434F) 24%, var(--cw-cream, #FFFBF0));
}
.cw-page-cafe .cw-cell-won {
  background: color-mix(in srgb, var(--cw-jade, #1F8F6E) 30%, var(--cw-cream, #FFFBF0));
}
.cw-page-cafe .cw-cell-number {
  color: var(--cw-cherry, #D9434F);
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 11px;
}

/* Banners */
.cw-page-cafe .cw-banner-warn {
  background: color-mix(in srgb, var(--cw-cherry, #D9434F) 20%, var(--cw-cream, #FFFBF0));
  color: var(--cw-pageInk, #1F2E2A);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  font-family: 'Newsreader', serif;
}
.cw-page-cafe .cw-banner-win {
  background: color-mix(in srgb, var(--cw-jade, #1F8F6E) 20%, var(--cw-cream, #FFFBF0));
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  font-family: 'Newsreader', serif;
}

/* Clue list — handwritten section headers */
.cw-page-cafe .cw-clues h3.cw-kicker {
  font-family: 'Caveat', cursive;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: lowercase;
}
.cw-page-cafe .cw-clue-list {
  font-family: 'Newsreader', serif;
}
.cw-page-cafe .cw-clue-len {
  font-family: 'Inter Tight', sans-serif;
  color: var(--cw-ink2, #5C6E69);
  font-size: 11px;
}

/* ---- Reduce the heaviness of the autosave note ---- */
.cw-page-cafe .cw-autosave-note {
  color: var(--cw-ink2, #5C6E69);
  font-family: 'Newsreader', serif;
  font-style: italic;
}

/* ============================================================ */
/* Crossword Phase 2B: Beach Café screens (home / win / hist).  */
/* ============================================================ */

.cw-cafe-wide { max-width: 1180px; }

/* ---- Display headlines (Newsreader 64-96, mixed roman+italic) ---- */
.cw-cafe-display {
  font-family: 'Newsreader', serif;
  font-weight: 400;
  font-size: clamp(48px, 6vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  margin: 4px 0 14px;
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-cafe-display-md { font-size: clamp(36px, 4.4vw, 56px); }
.cw-cafe-display-em {
  font-style: italic;
  color: var(--cw-cherry, #D9434F);
  font-weight: 400;
}
.cw-cafe-display-dot {
  color: var(--cw-citrus, #F2A22C);
}
.cw-cafe-lede {
  font-family: 'Newsreader', serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--cw-ink2, #5C6E69);
  max-width: 540px;
  margin: 0 0 18px;
}

/* ---- Home: 2-col grid (1.3fr / 1fr) ---- */
.cw-cafe-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 44px;
  align-items: start;
}
@media (max-width: 880px) {
  .cw-cafe-grid { grid-template-columns: 1fr; }
}

.cw-cafe-side {
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  padding: 18px 20px;
  box-shadow: 4px 4px 0 var(--cw-citrus, #F2A22C);
}
.cw-cafe-side-pair {
  font-family: 'Newsreader', serif;
  font-size: 22px;
  line-height: 1;
  margin: 6px 0 14px;
}

/* Small home-page stats card — placeholder content for now. Sized
   to fit the right column without dominating; intentionally short so
   the grid doesn't pull tall. */
.cw-cafe-stats {
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  padding: 14px 18px 16px;
  box-shadow: 4px 4px 0 var(--cw-jade, #1F8F6E);
  align-self: start;          /* don't stretch with the left column */
  max-width: 280px;
  justify-self: end;
}
.cw-cafe-stat-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin: 10px 0 0;
  padding: 0;
}
.cw-cafe-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 22%, transparent);
}
.cw-cafe-stat:last-child { border-bottom: 0; }
.cw-cafe-stat dt {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cw-ink2, #5C6E69);
  margin: 0;
}
.cw-cafe-stat dd {
  font-family: 'Newsreader', serif;
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
  color: var(--cw-pageInk, #1F2E2A);
  margin: 0;
}

.cw-cafe-continue {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 14px 18px;
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  box-shadow: 5px 5px 0 var(--cw-jade, #1F8F6E);
  text-decoration: none; color: var(--cw-pageInk, #1F2E2A);
  margin: 12px 0 22px;
  transition: transform 100ms, box-shadow 100ms;
}
.cw-cafe-continue:hover {
  transform: translate(-1px, -1px);
  box-shadow: 6px 6px 0 var(--cw-jade, #1F8F6E);
}
.cw-cafe-continue-line {
  font-family: 'Newsreader', serif; font-size: 15px;
  color: var(--cw-ink2, #5C6E69);
  margin-top: 4px;
}

.cw-cafe-start { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 12px; }
.cw-cafe-modeline {
  font-family: 'Newsreader', serif;
  font-style: italic; font-size: 13px;
  color: var(--cw-ink2, #5C6E69); margin: 4px 0 0;
}

/* ---- Recibos list (recent + history) ---- */
.cw-cafe-recent { margin-top: 18px; }
.cw-cafe-recibo-list { list-style: none; padding: 0; margin: 12px 0 0; }
.cw-cafe-recibo-row {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto auto;
  gap: 18px; align-items: baseline;
  padding: 12px 0;
  border-bottom: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 22%, transparent);
  font-family: 'Newsreader', serif;
  font-size: 14px;
}
.cw-cafe-recibo-num {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--cw-pageInk, #1F2E2A);
  min-width: 80px;
}
.cw-cafe-recibo-date { color: var(--cw-ink2, #5C6E69); min-width: 72px; }
.cw-cafe-recibo-topic {
  font-style: italic;
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-cafe-recibo-words { color: var(--cw-ink2, #5C6E69); }
.cw-cafe-recibo-status { min-width: 80px; text-align: right; }
.cw-cafe-recibo-link {
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--cw-cherry, #D9434F);
  text-decoration: none;
  text-align: right;
}
.cw-cafe-recibo-link:hover { text-decoration: underline; }

.cw-cafe-topic-chip {
  display: inline-block;
  padding: 4px 10px;
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 26%, var(--cw-cream, #FFFBF0));
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--cw-pageInk, #1F2E2A);
  white-space: nowrap;
}
.cw-cafe-recibo-tag {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 18px;
}
.cw-cafe-recibo-tag-paid { color: var(--cw-jade, #1F8F6E); }

/* ---- Win-receipt screen ---- */
.cw-cafe-receipt-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 60px; align-items: center;
  padding: 20px 0;
}
@media (max-width: 880px) {
  .cw-cafe-receipt-grid { grid-template-columns: 1fr; gap: 36px; }
}
.cw-cafe-receipt-card {
  position: relative;
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  /* Stacked drop shadows from the handoff: cherry then citrus */
  box-shadow:
    10px 10px 0 var(--cw-cherry, #D9434F),
    20px 20px 0 var(--cw-citrus, #F2A22C);
  aspect-ratio: 5 / 7;
  display: flex;
  flex-direction: column;
  max-width: 360px;
}
.cw-cafe-receipt-stripe {
  display: flex;
  height: 12px;
  border-bottom: 1.5px solid var(--cw-pageInk, #1F2E2A);
}
.cw-cafe-receipt-stripe > span { flex: 1; }
.cw-cafe-receipt-stamp {
  position: absolute;
  top: 32px; right: -16px;
  background: var(--cw-cherry, #D9434F);
  color: var(--cw-cream, #FFFBF0);
  border: 2px solid var(--cw-pageInk, #1F2E2A);
  border-radius: 50%;
  width: 78px; height: 78px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive;
  font-size: 18px; font-weight: 700;
  transform: rotate(-12deg);
  box-shadow: 3px 3px 0 var(--cw-pageInk, #1F2E2A);
  z-index: 2;
}
.cw-cafe-receipt-body { padding: 24px 22px; flex: 1; display: flex; flex-direction: column; }
.cw-cafe-receipt-headline {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(40px, 4vw, 64px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  margin: 6px 0 12px;
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-cafe-receipt-rule {
  border: 0; border-top: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 33%, transparent);
  margin: 10px 0;
}
.cw-cafe-receipt-stats {
  display: grid; grid-template-columns: 1fr; gap: 8px;
  margin: 12px 0; padding: 0;
  font-family: 'Newsreader', serif;
}
.cw-cafe-receipt-stats div { display: flex; justify-content: space-between; align-items: baseline; }
.cw-cafe-receipt-stats dt {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; font-weight: 700;
  color: var(--cw-ink2, #5C6E69);
}
.cw-cafe-receipt-stats dd {
  font-family: 'Newsreader', serif;
  font-size: 18px; margin: 0;
}
.cw-cafe-receipt-note {
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--cw-ink2, #5C6E69);
  text-align: center;
  margin-top: auto;
}
.cw-cafe-receipt-archive {
  margin-top: 24px;
  background: var(--cw-cream, #FFFBF0);
  padding: 12px 18px;
  border: 1px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 22%, transparent);
}
.cw-cafe-receipt-archive summary {
  cursor: pointer;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--cw-cherry, #D9434F);
}
.cw-cafe-receipt-archive[open] summary { margin-bottom: 14px; }

/* ============================================================ */
/* Crossword Phase 2B+: nav pills, mode-button group,           */
/* perimeter cell borders, active-clue highlight.               */
/* ============================================================ */

/* Sub-nav restyled as Caveat lowercase pills with citrus active
   state inside the Beach Café page. The base .cw-nav is used by
   pre-cafe screens; the .cw-page-cafe scope rewrites the look. */
.cw-page-cafe .cw-nav {
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  box-shadow: 4px 4px 0 var(--cw-pageInk, #1F2E2A);
  padding: 4px 6px;
  gap: 4px;
}
.cw-page-cafe .cw-nav a,
.cw-page-cafe .cw-nav-disabled {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0;
  text-transform: lowercase;
  padding: 4px 16px;
  color: var(--cw-pageInk, #1F2E2A);
  border-radius: 0;
  line-height: 1.1;
}
.cw-page-cafe .cw-nav a:hover {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 22%, transparent);
}
.cw-page-cafe .cw-nav a.active {
  background: var(--cw-citrus, #F2A22C);
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-page-cafe .cw-nav-disabled {
  color: color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 35%, transparent);
}

/* Bottom action row, left-to-right:
   modes trio | flash buttons | check + fresh.
   Each group sits behind a dashed divider so its purpose reads
   independently of the others. */
.cw-play-actions {
  align-items: flex-start;
}
.cw-modes-group {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.cw-play-actions-flash {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding-left: 18px;
  border-left: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 33%, transparent);
}
.cw-play-actions-main {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-left: auto;
  padding-left: 18px;
  border-left: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 33%, transparent);
}
.cw-play-actions-fresh {
  margin: 0;
  display: inline;
}
.cw-page-cafe .cw-btn-mode {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0;
  text-transform: lowercase;
  padding: 6px 18px;
}
.cw-page-cafe .cw-btn-mode-current,
.cw-page-cafe .cw-btn-mode-current:hover {
  background: var(--cw-cream, #FFFBF0);
  color: color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 50%, transparent);
  border-color: color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 35%, transparent);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
@media (max-width: 720px) {
  .cw-play-actions-flash,
  .cw-play-actions-main {
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1.5px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 33%, transparent);
    width: 100%;
  }
}

/* Single-clue flashcard modal — themed for the Mañana cafe page
   (cream card, Caveat headline, soft brown ink). Mirrors babylon's
   reveal modal in structure but uses the crossword palette. */
.cw-modal {
  position: fixed; inset: 0;
  background: rgba(31, 46, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  padding: 24px;
}
.cw-modal[hidden] { display: none !important; }
.cw-modal-card {
  position: relative;
  background: var(--cw-cream, #FFFBF0);
  color: var(--cw-pageInk, #1F2E2A);
  border: 1.5px solid color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 60%, transparent);
  border-radius: 6px;
  padding: 28px 28px 22px;
  max-width: 460px;
  width: 100%;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  font-family: 'Newsreader', serif;
}
.cw-modal-close {
  position: absolute; top: 8px; right: 12px;
  background: transparent; border: 0;
  color: var(--cw-pageInk, #1F2E2A);
  font-size: 26px; line-height: 1;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
}
.cw-modal-clue-tag {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 22px;
  color: var(--man-accent, #D14B2C);
  margin-bottom: 10px;
  text-align: center;
}
.cw-modal-img-wrap {
  display: flex; justify-content: center;
  margin: 0 0 16px;
  background: rgba(0,0,0,0.04);
  border-radius: 4px;
  min-height: 120px;
  align-items: center;
  overflow: hidden;
}
.cw-modal-img-wrap img {
  max-width: 100%; max-height: 360px;
  display: block;
  border-radius: 4px;
}
.cw-modal-noimg {
  color: var(--man-ink-soft, #7A5D3E);
  font-style: italic;
  padding: 24px;
  text-align: center;
}
.cw-modal-text { text-align: center; }
.cw-modal-target {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: 32px;
  line-height: 1.1;
  color: var(--cw-pageInk, #1F2E2A);
}
.cw-modal-primary {
  font-family: 'Newsreader', serif;
  font-style: italic;
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 16px;
  margin-top: 4px;
}

/* Perimeter borders on character cells where they touch a block
   cell or the grid edge — keeps tiles legible against busy motifs.
   Each border is its own style so we can stack 1–4 sides cleanly
   without box-shadow overlap. */
.cw-page-cafe .cw-cell-bd-t { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-r { box-shadow: inset -2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-b { box-shadow: inset 0 -2px 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-l { box-shadow: inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
/* When a cell has multiple touching edges, combine the inset shadows. */
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-r { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset -2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-b { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-l { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-r.cw-cell-bd-b { box-shadow: inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-r.cw-cell-bd-l { box-shadow: inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-b.cw-cell-bd-l { box-shadow: inset 0 -2px 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-r.cw-cell-bd-b { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-r.cw-cell-bd-l { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-b.cw-cell-bd-l { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-r.cw-cell-bd-b.cw-cell-bd-l { box-shadow: inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }
.cw-page-cafe .cw-cell-bd-t.cw-cell-bd-r.cw-cell-bd-b.cw-cell-bd-l { box-shadow: inset 0 2px 0 var(--cw-pageInk, #1F2E2A), inset -2px 0 0 var(--cw-pageInk, #1F2E2A), inset 0 -2px 0 var(--cw-pageInk, #1F2E2A), inset 2px 0 0 var(--cw-pageInk, #1F2E2A); }

/* Active-clue highlight: when a cell is selected (and while the user
   is typing into it), its matching Across or Down clue lights up so
   the player doesn't have to scan the list. Padding/margin/border-
   width are inherited from the base .cw-clue-list li rule above so
   the row doesn't shift when this class toggles. */
.cw-clue-list li.cw-clue-active {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 55%, var(--cw-cream, #FFFBF0));
  border-left-color: var(--cw-cherry, #D9434F);
  font-weight: 600;
}
.cw-clue-list li.cw-clue-active strong { color: var(--cw-cherry, #D9434F); }
/* Pre-cafe (Mañana) palette fallback for the legacy crossword pages. */
.cw-page:not(.cw-page-cafe) .cw-clue-list li.cw-clue-active {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 16%, var(--man-card, #FBF5E6));
  border-left-color: var(--man-accent, #D14B2C);
}

/* ---- Crossword settings: topic-set picker ---- */
.cw-settings-topics { max-width: 880px; margin: 0 auto 16px; }
.cw-fieldset-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 0 0 6px;
}
.cw-fieldset-legend {
  font-family: 'Inter Tight', sans-serif; font-weight: 700; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--cw-cherry, #D9434F);
}
.cw-topics-select {
  display: grid; gap: 8px; margin-top: 10px;
}
.cw-topic-set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--cw-cream, #FFFBF0);
  border: 1.5px solid color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 18%, transparent);
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Newsreader', serif;
  transition: border-color 100ms, background 100ms;
}
.cw-topic-set-row:hover {
  border-color: color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 35%, transparent);
}
.cw-topic-set-row input { margin: 0; cursor: pointer; }
.cw-topic-set-row strong {
  font-family: 'Newsreader', serif; font-weight: 600; font-size: 16px;
  display: block; line-height: 1.2;
}
.cw-topic-set-row small {
  display: block;
  color: var(--cw-ink2, #5C6E69);
  font-size: 12px;
}
.cw-topic-set-row-active {
  background: color-mix(in srgb, var(--cw-citrus, #F2A22C) 14%, var(--cw-cream, #FFFBF0));
  border-color: var(--cw-citrus, #F2A22C);
  border-width: 2px;
  padding: 11.5px 13.5px;          /* compensate for the thicker border */
}

.cw-topics-builder, .cw-topics-manage {
  margin-top: 12px;
  padding: 8px 14px;
  background: var(--cw-cream, #FFFBF0);
  border: 1px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 22%, transparent);
  border-radius: 6px;
}
.cw-topics-builder summary, .cw-topics-manage summary {
  cursor: pointer;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--cw-cherry, #D9434F);
  list-style: none;
}
.cw-topics-builder[open] summary, .cw-topics-manage[open] summary { margin-bottom: 12px; }
.cw-topics-builder-form { display: grid; gap: 12px; }
.cw-topics-name-field {
  display: flex; flex-direction: column; gap: 4px;
  font-family: 'Inter Tight', sans-serif; font-size: 12px;
  color: var(--cw-ink2, #5C6E69);
}
.cw-topics-name-field input {
  padding: 8px 10px; border: 1.5px solid var(--cw-pageInk, #1F2E2A);
  border-radius: 4px; background: var(--cw-cream, #FFFBF0);
  font-family: 'Newsreader', serif; font-size: 16px;
}
.cw-topics-checklist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 14px;
  font-family: 'Newsreader', serif; font-size: 14px;
}
.cw-topic-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.cw-topic-check input { margin: 0; cursor: pointer; }

.cw-topics-manage-list {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 6px;
}
.cw-topics-manage-list li {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--cw-pageInk, #1F2E2A) 18%, transparent);
  font-family: 'Newsreader', serif; font-size: 15px;
}
.cw-topics-manage-list li:last-child { border-bottom: 0; }
.cw-topics-manage-list small {
  color: var(--cw-ink2, #5C6E69); font-size: 12px;
}
.cw-link-danger {
  background: none; border: 0; padding: 0;
  color: var(--cw-cherry, #D9434F);
  font-family: 'Caveat', cursive; font-size: 18px;
  cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}

/* ---- Flashcards review: "Flip through" button ----
   Looks identical to its neighbor man-btn buttons. The ON state fills
   with the accent color and adds a small pulsing dot to the left of
   the label — obvious but not distracting. The trio of audio + flip
   sits at the left of the action row; Missed ✗ + Got it ✓ pin right. */
.ws-flip-btn {
  display: inline-flex; align-items: center; gap: 8px;
}
.ws-flip-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background 120ms;
}
.ws-flip-btn-on {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FBF5E6);
  border-color: var(--man-accent, #D14B2C);
}
.ws-flip-btn-on .ws-flip-dot {
  background: var(--man-card, #FBF5E6);
  animation: ws-flip-pulse 1.4s ease-in-out infinite;
}
@keyframes ws-flip-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.78); }
}

/* Per-language audio toggles. OFF = plain secondary skin so they
   stay quiet. ON = gold border + gold text on the same plain
   background — visible but unobtrusive. */
.ws-audio-btn {
  display: inline-flex; align-items: center; gap: 6px;
}
.ws-audio-icon { font-size: 14px; line-height: 1; }
.ws-audio-lang {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em;
}
.ws-audio-btn-on {
  border-color: var(--cw-citrus, #F2A22C);
  color: var(--cw-citrus, #F2A22C);
}

/* Replay button — tighter padding so the "🔊 Replay" label reads as
   a small secondary tool rather than a peer of Missed/Got. */
.ws-replay-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  font-size: 11px;
}

/* Vertical divider in the meta row — separates the sound-related
   cluster (audio toggles + replay) from the flip-through control
   so the two sub-groups read as distinct categories. */
.ws-actions-divider {
  display: inline-block;
  width: 1px;
  height: 24px;
  background: rgba(0, 0, 0, 0.22);
  margin: 0 6px;
  align-self: center;
}

/* Missed ✗ / Got it ✓ — three states with progressively stronger
   color: plain background by default, faded color tint on hover,
   full saturation on click (active). Descendant selector beats the
   base .man-btn-primary on Got it without needing a class swap. */
/* Default state keeps the standard man-btn skin (cream bg, ink
   border) so the buttons read as "normal" buttons that just happen
   to have colored text. Hover paints a faded color tint; click
   flashes the full saturation. */
.man-flashcard-actions [data-action="missed"] {
  color: var(--cw-cherry, #D9434F);
}
.man-flashcard-actions [data-action="missed"]:not(:disabled):hover {
  background: color-mix(in srgb, var(--cw-cherry, #D9434F) 22%, var(--man-card, #FBF5E6));
  color: var(--cw-cherry, #D9434F);
}
.man-flashcard-actions [data-action="missed"]:not(:disabled):active {
  background: var(--cw-cherry, #D9434F);
  border-color: var(--cw-cherry, #D9434F);
  color: var(--man-card, #FBF5E6);
}

.man-flashcard-actions [data-action="got"] {
  /* Transparent matches Missed (which inherits .man-btn-secondary's
     transparent fill), so both show the page background through —
     no white-card-on-cream-page mismatch. The base .man-btn-primary
     would otherwise paint a strong --man-accent fill here, plus a
     cream override; both are explicitly squashed. */
  background: transparent;
  color: var(--cw-jade, #1F8F6E);
  border-color: var(--man-ink, #2A1A0E);
  box-shadow: none;
}
.man-flashcard-actions [data-action="got"]:hover {
  /* The base .man-btn-primary:hover applies a translate transform
     and box-shadow lift; the hover rule below already paints the
     faded jade tint, but we need to clear the inherited transform
     and shadow so Got it sits flush like Missed does. */
  transform: none;
  box-shadow: none;
}
.man-flashcard-actions [data-action="got"]:not(:disabled):hover {
  background: color-mix(in srgb, var(--cw-jade, #1F8F6E) 22%, var(--man-card, #FBF5E6));
  color: var(--cw-jade, #1F8F6E);
}
.man-flashcard-actions [data-action="got"]:not(:disabled):active {
  background: var(--cw-jade, #1F8F6E);
  border-color: var(--cw-jade, #1F8F6E);
  color: var(--man-card, #FBF5E6);
}

/* Fade-in animation between cards. Runs on every render (each card
   is a freshly-inserted element via innerHTML), so transitions feel
   continuous without requiring per-card teardown. The animation
   duration is intentionally NOT factored into the flip timing —
   visible card time = flipDurationMs() exactly. */
.man-flashcard {
  animation: ws-flashcard-fade-in 220ms ease-out;
}
@keyframes ws-flashcard-fade-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---- Flashcards admin cost meter ---- */
.fc-cost-meter {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px;
  margin: 8px 0 0;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 6%, var(--man-card, #FBF5E6));
  border: 1px solid color-mix(in srgb, var(--man-ink, #2A1A0E) 18%, transparent);
  border-radius: 6px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  color: var(--man-ink, #2A1A0E);
}
.fc-cost-icon { font-size: 16px; }
.fc-cost-segment { display: inline-flex; align-items: baseline; gap: 6px; }
.fc-cost-segment strong {
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--man-ink-soft, #7A5D3E);
  font-weight: 700;
}
.fc-cost-amount {
  font-family: 'Bricolage Grotesque', serif;
  font-size: 17px; font-weight: 700;
  color: var(--man-accent, #D14B2C);
}
.fc-cost-segment small { color: var(--man-ink-soft, #7A5D3E); font-size: 11px; }
.fc-cost-divider { color: var(--man-ink-soft, #7A5D3E); }
.fc-cost-breakdown { margin-left: auto; font-size: 12px; }
.fc-cost-breakdown summary {
  cursor: pointer;
  color: var(--man-ink-soft, #7A5D3E);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.fc-cost-breakdown[open] summary { margin-bottom: 6px; }
.fc-cost-breakdown div div { margin: 2px 0; }
.fc-cost-breakdown hr {
  border: 0; border-top: 1px dashed color-mix(in srgb, var(--man-ink, #2A1A0E) 22%, transparent);
  margin: 4px 0;
}

/* ============================================================
   Vocabulary section — dashboard / topics / words.
   Uses the global Tropicál palette since it's site content,
   not a game. Patterned after the Mañana / cw- styles.
   ============================================================ */
.vocab-page { max-width: 1180px; margin: 0 auto; padding: 0 50px; }
.vocab-container { padding: 0 0 60px; }
.vocab-nav {
  display: flex; gap: 6px;
  padding: 16px 0 14px;
  border-bottom: 1px solid rgba(42,26,14,0.18);
  margin-bottom: 22px;
}
.vocab-nav a {
  padding: 6px 14px;
  border-radius: 4px;
  color: var(--man-ink, #2A1A0E);
  text-decoration: none;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.vocab-nav a:hover { background: rgba(209,75,44,0.12); }
.vocab-nav a.active {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FBF5E6);
}
.vocab-kicker {
  font-family: 'Inter Tight', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--man-ink-soft, #7A5D3E);
}
.vocab-kicker-soft { color: var(--man-ink-soft, #7A5D3E); }
.vocab-title {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  margin: 4px 0 10px;
}
.vocab-title-em { font-style: italic; color: var(--man-accent, #D14B2C); }
.vocab-subhead {
  font-family: 'Newsreader', serif;
  font-size: 17px;
  line-height: 1.5;
  margin: 0;
  color: var(--man-ink, #2A1A0E);
  max-width: 640px;
}
.vocab-rule { border: none; border-top: 1px solid rgba(42,26,14,0.33); margin: 22px 0; }
.vocab-muted { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; }
.vocab-muted a { color: var(--man-accent, #D14B2C); }
.vocab-h2 {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0;
}
.vocab-section { margin: 26px 0; }
.vocab-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}

/* --- buttons + inputs (vocabulary-scoped) --- */
.vocab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(42,26,14,0.4);
  background: var(--man-card, #FBF5E6);
  color: var(--man-ink, #2A1A0E);
  border-radius: 4px;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600; font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.vocab-btn:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6)); }
.vocab-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.vocab-btn-primary {
  background: var(--man-accent, #D14B2C);
  color: white;
  border-color: var(--man-accent, #D14B2C);
}
.vocab-btn-primary:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 88%, black); }
.vocab-btn-secondary { background: var(--man-card, #FBF5E6); }
.vocab-btn-ghost { background: transparent; border-color: rgba(42,26,14,0.22); }
.vocab-btn-danger { color: #b03525; border-color: rgba(176,53,37,0.4); }
.vocab-input {
  font-family: 'Newsreader', serif;
  font-size: 16px;
  padding: 8px 12px;
  border: 1px solid rgba(42,26,14,0.35);
  border-radius: 4px;
  background: var(--man-card, #FBF5E6);
  color: var(--man-ink, #2A1A0E);
  min-width: 0;
}
.vocab-input:focus {
  outline: none;
  border-color: var(--man-accent, #D14B2C);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--man-accent, #D14B2C) 25%, transparent);
}
.vocab-input-inline { padding: 4px 10px; font-size: 14px; }

/* --- dashboard --- */
.vocab-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 18px 0 32px;
}
.vocab-stat-card {
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 6px;
  padding: 14px 16px;
}
.vocab-stat-num {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  color: var(--man-ink, #2A1A0E);
}
.vocab-stat-label {
  margin-top: 4px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--man-ink-soft, #7A5D3E);
}
.vocab-spark {
  display: flex; align-items: flex-end; gap: 4px;
  height: 64px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(42,26,14,0.18);
}
.vocab-spark-bar {
  flex: 1 1 0;
  min-height: 2px;
  background: var(--man-accent, #D14B2C);
  border-radius: 2px 2px 0 0;
  opacity: 0.7;
}
.vocab-spark-bar:hover { opacity: 1; }
.vocab-recent-list { list-style: none; padding: 0; margin: 0; }
.vocab-recent-list li {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(42,26,14,0.15);
  font-family: 'Newsreader', serif;
  font-size: 16px;
}
.vocab-recent-target { font-weight: 600; }
.vocab-recent-sep { color: var(--man-ink-soft, #7A5D3E); }
.vocab-recent-primary { color: var(--man-ink-soft, #7A5D3E); font-style: italic; }
.vocab-recent-when { margin-left: auto; color: var(--man-ink-soft, #7A5D3E); font-size: 12px; }

/* --- topics page --- */
.vocab-topic-add {
  display: flex; gap: 10px; align-items: center;
  margin: 20px 0 24px;
}
.vocab-topic-add .vocab-input { flex: 1 1 auto; max-width: 420px; }
.vocab-topic-list { list-style: none; padding: 0; margin: 0; }
.vocab-topic-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(42,26,14,0.12);
  flex-wrap: wrap;
}
.vocab-topic-rename { display: flex; gap: 6px; align-items: center; }
.vocab-topic-rename .vocab-input { width: 240px; }
.vocab-topic-count {
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 13px;
  margin-right: auto;
}
.vocab-topic-delete { margin-left: auto; }

/* --- words page --- */
.vocab-lookup {
  background: color-mix(in srgb, var(--man-card, #FBF5E6) 65%, transparent);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  padding: 18px;
  margin: 18px 0 24px;
}
.vocab-lookup-form {
  display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap;
}
.vocab-lookup-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; min-width: 0; }
.vocab-lookup-field .vocab-input { width: 100%; }
.vocab-radio-row { display: flex; gap: 12px; }
.vocab-radio { display: inline-flex; align-items: center; gap: 6px; font-family: 'Newsreader', serif; font-size: 15px; }
.vocab-radio input { accent-color: var(--man-accent, #D14B2C); }
.vocab-lookup-result {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed rgba(42,26,14,0.25);
}
.vocab-lookup-pair {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-family: 'Newsreader', serif;
  margin-bottom: 12px;
}
.vocab-lookup-target { font-size: 26px; font-weight: 600; }
.vocab-lookup-sep { color: var(--man-ink-soft, #7A5D3E); font-size: 20px; }
.vocab-lookup-primary { font-size: 22px; color: var(--man-ink, #2A1A0E); font-style: italic; }
.vocab-lookup-cached {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--man-ink-soft, #7A5D3E);
}
.vocab-lookup-assign { margin-top: 8px; }
.vocab-topic-checks {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 6px 0 12px;
}
.vocab-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(42,26,14,0.25);
  border-radius: 14px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  cursor: pointer;
  background: var(--man-card, #FBF5E6);
}
.vocab-check input { accent-color: var(--man-accent, #D14B2C); }
.vocab-check:has(input:checked) {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 12%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
}
.vocab-lookup-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.vocab-error {
  margin-top: 10px;
  padding: 8px 12px;
  background: #fbeae7;
  border: 1px solid #e3a89c;
  border-radius: 4px;
  color: #b03525;
  font-size: 13px;
}
.vocab-saved {
  margin-top: 10px;
  padding: 8px 12px;
  background: #e7f4eb;
  border: 1px solid #a4cfae;
  border-radius: 4px;
  color: #1f6b35;
  font-size: 13px;
}

/* Describe-the-word — collapsible block under the lookup form. Mirrors
   the flashcards deck-edit feature in look + feel, with the vocab
   palette. */
.vocab-describe {
  margin-top: 14px;
  padding: 10px 14px;
  border: 1px dashed rgba(42,26,14,0.28);
  border-radius: 6px;
  background: color-mix(in srgb, var(--man-card, #FBF5E6) 50%, transparent);
}
.vocab-describe summary {
  cursor: pointer;
  font-family: 'Caveat', cursive;
  font-weight: 600;
  font-size: 18px;
  color: var(--man-accent, #D14B2C);
  list-style: none;
}
.vocab-describe summary::before {
  content: '▶ ';
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  color: var(--man-accent, #D14B2C);
}
.vocab-describe[open] summary::before { content: '▼ '; }
.vocab-describe[open] summary { margin-bottom: 8px; }
.vocab-describe-hint { margin: 6px 0 10px; }
.vocab-describe-form {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 4px;
}
.vocab-describe-text {
  flex: 1 1 auto;
  min-height: 44px;
  resize: vertical;
  font-family: 'Newsreader', serif;
  font-size: 15px;
  line-height: 1.4;
}
.vocab-describe-results { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.vocab-suggest-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
}
.vocab-suggest-card > div:first-child { flex: 1 1 auto; min-width: 0; }
.vocab-suggest-pair {
  font-family: 'Newsreader', serif;
  font-size: 17px;
}
.vocab-suggest-pair strong { font-weight: 600; }
.vocab-suggest-arrow { color: var(--man-ink-soft, #7A5D3E); margin: 0 4px; }
.vocab-suggest-note {
  margin: 4px 0 0;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 13px;
  line-height: 1.4;
  color: var(--man-ink-soft, #7A5D3E);
}

/* ============================================================
   20 Questions ("twenty") — chat-style game.
   Uses the global Mañana cream palette, scoped to .tq-*.
   ============================================================ */
.tq-page { max-width: 1100px; margin: 0 auto; padding: 0 50px; }
.tq-container { padding: 0 0 60px; }
.tq-nav {
  display: flex; gap: 6px;
  padding: 16px 0 14px;
  border-bottom: 1px solid rgba(42,26,14,0.18);
  margin-bottom: 22px;
}
.tq-nav a, .tq-nav-disabled {
  padding: 6px 14px;
  border-radius: 4px;
  color: var(--man-ink, #2A1A0E);
  text-decoration: none;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.tq-nav a:hover { background: rgba(209,75,44,0.12); }
.tq-nav a.active {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FBF5E6);
}
.tq-nav-disabled { color: rgba(42,26,14,0.35); cursor: default; }

.tq-kicker {
  font-family: 'Inter Tight', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--man-ink-soft, #7A5D3E);
}
.tq-kicker-soft { color: var(--man-ink-soft, #7A5D3E); }
.tq-kicker-aside {
  text-transform: none;
  letter-spacing: 0.04em;
  font-style: italic;
  margin-left: 6px;
  font-size: 11px;
  color: rgba(42,26,14,0.45);
}
.tq-title {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  margin: 4px 0 10px;
}
.tq-title-em { font-style: italic; color: var(--man-accent, #D14B2C); }
.tq-subhead {
  font-family: 'Newsreader', serif;
  font-size: 17px;
  line-height: 1.5;
  margin: 0;
  max-width: 640px;
}
.tq-rule { border: none; border-top: 1px solid rgba(42,26,14,0.33); margin: 22px 0; }
.tq-muted { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; }
.tq-muted a { color: var(--man-accent, #D14B2C); }

.tq-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(42,26,14,0.4);
  background: var(--man-card, #FBF5E6);
  color: var(--man-ink, #2A1A0E);
  border-radius: 4px;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600; font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.tq-btn:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6)); }
.tq-btn-primary {
  background: var(--man-accent, #D14B2C); color: white; border-color: var(--man-accent, #D14B2C);
}
.tq-btn-primary:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 88%, black); }
.tq-btn-secondary { background: var(--man-card, #FBF5E6); }
.tq-btn-ghost { background: transparent; border-color: rgba(42,26,14,0.22); }
.tq-btn-danger { color: #b03525; border-color: rgba(176,53,37,0.4); }
.tq-btn-lg { padding: 12px 24px; font-size: 16px; }

/* Resume bar */
.tq-resume {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: rgba(0,0,0,0.04);
  border-radius: 6px; margin: 16px 0;
}
.tq-resume-body { margin: 4px 0 0; color: var(--man-ink-soft, #7A5D3E); font-size: 14px; }

/* Mode picker */
.tq-start { display: flex; flex-direction: column; gap: 18px; margin: 18px 0 24px; }
.tq-mode-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.tq-mode-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.tq-mode-card input[type="radio"] { margin-top: 5px; accent-color: var(--man-accent, #D14B2C); }
.tq-mode-card-body { flex: 1 1 auto; }
.tq-mode-title { font-family: 'Newsreader', serif; font-weight: 600; font-size: 18px; }
.tq-mode-desc { margin: 4px 0 0; font-size: 13px; color: var(--man-ink-soft, #7A5D3E); line-height: 1.45; }
.tq-mode-card:has(input:checked) {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 6%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
}

.tq-topics { padding: 8px 4px; }
.tq-topic-checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tq-topic-check {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(42,26,14,0.22);
  border-radius: 14px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  cursor: pointer;
  background: var(--man-card, #FBF5E6);
}
.tq-topic-check input { accent-color: var(--man-accent, #D14B2C); }
.tq-topic-check:has(input:checked) {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 12%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
}

/* Play strip */
.tq-play-strip {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 6px 0;
}
.tq-play-mode { font-family: 'Newsreader', serif; font-weight: 600; font-size: 18px; margin-top: 2px; }
.tq-play-strip-right { display: flex; align-items: center; gap: 14px; }
.tq-counter {
  display: inline-flex; align-items: baseline; gap: 2px;
  font-family: 'Inter Tight', sans-serif;
}
.tq-counter-num { font-size: 28px; font-weight: 700; color: var(--man-accent, #D14B2C); }
.tq-counter-sep { color: rgba(42,26,14,0.35); margin: 0 2px; }
.tq-counter-tot { font-size: 16px; font-weight: 600; }
.tq-counter-label {
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 10px; color: var(--man-ink-soft, #7A5D3E);
  margin-left: 6px;
}
.tq-status-active {
  font-family: 'Inter Tight', sans-serif; font-weight: 700;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--success, #2a8);
}
.tq-status-done {
  font-family: 'Inter Tight', sans-serif; font-weight: 700;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--man-ink-soft, #7A5D3E);
}

/* Chat log */
.tq-chat {
  display: flex; flex-direction: column; gap: 10px;
  margin: 18px 0;
  padding: 14px 16px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  max-height: 460px;
  overflow-y: auto;
}
.tq-msg {
  display: flex; align-items: flex-start; gap: 10px;
  font-family: 'Newsreader', serif;
  font-size: 16px;
  line-height: 1.45;
}
.tq-msg-who {
  flex: 0 0 auto;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--man-ink-soft, #7A5D3E);
  min-width: 36px;
  padding-top: 3px;
}
.tq-msg-ai .tq-msg-who { color: var(--man-accent, #D14B2C); }
.tq-msg-user { padding-left: 14px; border-left: 2px solid color-mix(in srgb, var(--man-accent, #D14B2C) 30%, transparent); }
.tq-msg-note .tq-msg-text { font-style: italic; color: var(--man-ink-soft, #7A5D3E); }
.tq-msg-reveal .tq-msg-text { font-weight: 600; }
.tq-msg-guess .tq-msg-text { font-weight: 600; color: var(--man-accent, #D14B2C); }
.tq-msg-correct_guess .tq-msg-text { font-weight: 700; color: var(--success, #1f6b35); }

/* Ask input */
.tq-ask-form { display: flex; gap: 8px; margin: 4px 0 14px; }
.tq-ask-input {
  flex: 1 1 auto;
  font-family: 'Newsreader', serif;
  font-size: 16px;
  padding: 10px 14px;
  border: 1px solid rgba(42,26,14,0.32);
  border-radius: 6px;
  background: var(--man-card, #FBF5E6);
}
.tq-ask-input:focus {
  outline: none;
  border-color: var(--man-accent, #D14B2C);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--man-accent, #D14B2C) 25%, transparent);
}
.tq-ask-input-small { max-width: 280px; font-size: 14px; padding: 8px 12px; }
.tq-confirm-row {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6));
  border: 1px solid color-mix(in srgb, var(--man-accent, #D14B2C) 35%, transparent);
  border-radius: 8px;
  margin-bottom: 14px;
}
.tq-confirm-text { margin: 0 8px 0 0; font-family: 'Newsreader', serif; font-size: 16px; }
.tq-end-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.tq-reveal-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* "AI is thinking…" indicator — appears between the ask input and
   the end-row while a Sonnet call is in flight. Reuses the
   .vocab-spinner animation (defined elsewhere in this file). */
.tq-thinking {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 12px;
  padding: 6px 12px;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--man-ink-soft, #7A5D3E);
}
.tq-thinking[hidden] { display: none; }
.tq-thinking-label { line-height: 1; }

/* ============================================================
   Boggle ("bg") — letter-grid word-finding score-attack.
   Uses the global Mañana cream palette; scoped to .bg-*.
   ============================================================ */
.bg-page { max-width: 1100px; margin: 0 auto; padding: 0 50px; }
.bg-container { padding: 0 0 60px; }
.bg-nav {
  display: flex; gap: 6px;
  padding: 16px 0 14px;
  border-bottom: 1px solid rgba(42,26,14,0.18);
  margin-bottom: 22px;
}
.bg-nav a, .bg-nav-disabled {
  padding: 6px 14px;
  border-radius: 4px;
  color: var(--man-ink, #2A1A0E);
  text-decoration: none;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600; font-size: 13px;
}
.bg-nav a:hover { background: rgba(209,75,44,0.12); }
.bg-nav a.active {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FBF5E6);
}
.bg-nav-disabled { color: rgba(42,26,14,0.35); cursor: default; }

.bg-kicker {
  font-family: 'Inter Tight', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  color: var(--man-ink-soft, #7A5D3E);
}
.bg-kicker-soft { color: var(--man-ink-soft, #7A5D3E); }
.bg-title {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 36px;
  line-height: 1.1;
  margin: 4px 0 10px;
}
.bg-title-em { font-style: italic; color: var(--man-accent, #D14B2C); }
.bg-subhead {
  font-family: 'Newsreader', serif;
  font-size: 17px;
  line-height: 1.5;
  margin: 0;
  max-width: 640px;
}
.bg-rule { border: none; border-top: 1px solid rgba(42,26,14,0.33); margin: 22px 0; }
.bg-muted { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; }
.bg-muted-small { font-size: 12px; }
.bg-muted a { color: var(--man-accent, #D14B2C); }

.bg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(42,26,14,0.4);
  background: var(--man-card, #FBF5E6);
  color: var(--man-ink, #2A1A0E);
  border-radius: 4px;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600; font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.bg-btn:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 8%, var(--man-card, #FBF5E6)); }
.bg-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bg-btn-primary {
  background: var(--man-accent, #D14B2C); color: white;
  border-color: var(--man-accent, #D14B2C);
}
.bg-btn-primary:hover { background: color-mix(in srgb, var(--man-accent, #D14B2C) 88%, black); }
.bg-btn-secondary { background: var(--man-card, #FBF5E6); }
.bg-btn-ghost { background: transparent; border-color: rgba(42,26,14,0.22); }
.bg-btn-danger { color: #b03525; border-color: rgba(176,53,37,0.4); }
.bg-btn-lg { padding: 12px 24px; font-size: 16px; }

.bg-resume {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  margin: 16px 0;
}
.bg-resume-body { margin: 4px 0 0; color: var(--man-ink-soft, #7A5D3E); font-size: 14px; }

/* Mode picker */
.bg-start { display: flex; flex-direction: column; gap: 16px; margin: 18px 0 24px; }
.bg-mode-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.bg-mode-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.bg-mode-card input[type="radio"] { margin-top: 5px; accent-color: var(--man-accent, #D14B2C); }
.bg-mode-card-body { flex: 1 1 auto; }
.bg-mode-title { font-family: 'Newsreader', serif; font-weight: 600; font-size: 18px; }
.bg-mode-desc { margin: 4px 0 0; font-size: 13px; color: var(--man-ink-soft, #7A5D3E); }
.bg-mode-card:has(input:checked) {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 6%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
}

/* Play strip + counters */
.bg-play-strip {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; padding: 6px 0;
}
.bg-play-mode { font-family: 'Newsreader', serif; font-weight: 600; font-size: 18px; margin-top: 2px; }
.bg-play-strip-right { display: flex; align-items: center; gap: 22px; }
.bg-counter {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-family: 'Inter Tight', sans-serif;
}
.bg-counter-num {
  font-size: 28px; font-weight: 700;
  color: var(--man-accent, #D14B2C);
}
.bg-counter-label {
  text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 10px; color: var(--man-ink-soft, #7A5D3E);
}
.bg-timer-low { color: #b03525; }
.bg-timer-done { color: rgba(42,26,14,0.5); }

/* The grid */
.bg-play-grid-wrap { display: flex; justify-content: center; margin: 18px 0; }
.bg-grid {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 10px;
}
.bg-grid-4 { grid-template-columns: repeat(4, 60px); grid-template-rows: repeat(4, 60px); }
.bg-grid-5 { grid-template-columns: repeat(5, 56px); grid-template-rows: repeat(5, 56px); }
.bg-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #F2D7A6 0%, #D9B97E 100%);
  color: var(--man-ink, #2A1A0E);
  border: 1px solid rgba(42,26,14,0.32);
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45),
              0 1px 0 rgba(0,0,0,0.18);
  font-family: 'Cinzel', 'Newsreader', serif;
  font-weight: 700;
  font-size: 28px;
  user-select: none;
  /* The cell itself is non-interactive — the inner .bg-cell-hit
     catches pointer events. Shrinking the hit zone gives a small
     buffer around each tile so corner drags don't grab the cell
     by accident. */
  pointer-events: none;
  transition: background 0.08s ease, box-shadow 0.08s ease;
}
.bg-cell-hit {
  position: absolute;
  inset: 8px;
  border-radius: 4px;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;          /* prevents scroll-vs-drag fights on mobile */
}
.bg-grid-5 .bg-cell-hit { inset: 7px; }   /* tighter cells -> smaller buffer */
.bg-cell.bg-cell-selected {
  background: linear-gradient(180deg, #E8853F 0%, #C95A2B 100%);
  color: #FFE8C4;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.32),
              0 1px 0 rgba(0,0,0,0.28),
              0 0 0 2px rgba(209,75,44,0.55);
}
.bg-cell.bg-cell-current {
  outline: 2px solid #FBF5E6;
  outline-offset: -4px;
}

/* Word entry */
.bg-input-form {
  display: flex; gap: 8px; margin: 14px 0 6px;
  align-items: center;
}
.bg-input-form-hidden {
  /* Form stays in the DOM so the play JS still reads its
     data-* config, but the visible controls are gone in
     swipe-only mode. */
  margin: 0; gap: 0;
  height: 0; overflow: hidden;
}
.bg-check {
  display: flex; align-items: flex-start; gap: 10px;
  font-family: 'Newsreader', serif; font-size: 14px;
  cursor: pointer;
}
.bg-check input[type="checkbox"] {
  margin-top: 4px;
  accent-color: var(--man-accent, #D14B2C);
}
.bg-check small { display: block; font-size: 12px; color: var(--man-ink-soft, #7A5D3E); margin-top: 2px; }
.bg-check-inline {
  /* Compact variant for the timer toggle on home + result pages.
     Sits inline with the start button rather than as a fieldset. */
  flex-direction: row; align-items: center; gap: 8px;
  font-size: 13px;
}
.bg-check-inline small { display: inline; font-size: 11px; }
.bg-replay-form {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.bg-counter-untimed {
  font-size: 32px;
  color: var(--man-ink-soft, #7A5D3E);
}

/* Pause button + grid overlay. Overlay sits inside .bg-grid-shell
   (a positioned wrapper around the cell grid) so it covers exactly
   the letters when active. */
.bg-grid-shell { position: relative; display: inline-block; }
.bg-pause-btn {
  align-self: center;
  padding: 6px 12px;
  font-size: 12px;
}
.bg-pause-overlay {
  position: absolute; inset: 0;
  z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--man-ink, #2A1A0E) 92%, transparent);
  color: var(--man-card, #FBF5E6);
  border-radius: 10px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.bg-pause-overlay[hidden] { display: none; }
.bg-pause-overlay-card {
  text-align: center;
  padding: 18px 22px;
  max-width: 280px;
}
.bg-pause-overlay-card .bg-kicker {
  color: rgba(245,238,220, 0.78);
  font-size: 12px;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}
.bg-pause-overlay-msg {
  font-family: 'Newsreader', serif;
  font-size: 15px;
  line-height: 1.4;
  margin: 0 0 14px;
  color: var(--man-card, #FBF5E6);
}
.bg-word-input {
  flex: 1 1 auto;
  font-family: 'Newsreader', serif;
  font-size: 18px;
  text-transform: lowercase;
  padding: 10px 14px;
  border: 1px solid rgba(42,26,14,0.32);
  border-radius: 6px;
  background: var(--man-card, #FBF5E6);
}
.bg-word-input:focus {
  outline: none;
  border-color: var(--man-accent, #D14B2C);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--man-accent, #D14B2C) 25%, transparent);
}
.bg-status-err { color: #b03525; }
.bg-status-ok { color: #1f6b35; }

/* Candidates list */
.bg-candidates { margin: 12px 0 18px; }
.bg-cand-list {
  list-style: none; padding: 0; margin: 8px 0 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.bg-cand-row {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 6px 28px 6px 12px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.22);
  border-radius: 12px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
}
.bg-cand-row-real {
  background: color-mix(in srgb, #1f6b35 10%, var(--man-card, #FBF5E6));
  border-color: color-mix(in srgb, #1f6b35 35%, transparent);
}
.bg-cand-word { font-weight: 600; line-height: 1.15; }
.bg-cand-trans {
  display: block;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 12px;
  line-height: 1.2;
  color: var(--man-ink-soft, #7A5D3E);
  margin-top: 1px;
  min-height: 14px;            /* reserves room while pending */
}
.bg-cand-trans-pending::before {
  content: '…';
  opacity: 0.5;
}
.bg-cand-remove {
  position: absolute;
  top: 4px; right: 8px;
  background: transparent;
  border: none;
  color: var(--man-ink-soft, #7A5D3E);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.bg-cand-remove:hover { color: #b03525; }
/* Floating "+N" celebration badge — appears, hangs briefly, fades.
   Position is anchored to the chip's top-right so it never affects
   layout, and animationend cleanup removes it from the DOM. */
.bg-cand-badge {
  position: absolute;
  top: -10px; right: -8px;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 12px;
  padding: 1px 7px;
  background: var(--man-accent, #D14B2C);
  color: white;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  pointer-events: none;
  animation: bg-badge-fade 2.4s ease-out forwards;
}
@keyframes bg-badge-fade {
  0%   { opacity: 0; transform: translateY(4px) scale(0.7); }
  12%  { opacity: 1; transform: translateY(-2px) scale(1.05); }
  18%  { transform: translateY(-2px) scale(1); }
  65%  { opacity: 1; transform: translateY(-2px) scale(1); }
  100% { opacity: 0; transform: translateY(-12px) scale(0.85); }
}
.bg-cand-remove {
  background: transparent;
  border: none;
  color: var(--man-ink-soft, #7A5D3E);
  cursor: pointer;
  font-size: 14px;
  padding: 0 0 0 4px;
  line-height: 1;
}
.bg-cand-remove:hover { color: #b03525; }

/* End row + thinking indicator (mirrors twenty's pattern) */
.bg-end-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.bg-thinking {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0 12px;
  padding: 6px 12px;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--man-ink-soft, #7A5D3E);
}
.bg-thinking[hidden] { display: none; }
.bg-thinking-label { line-height: 1; }

/* Result page */
.bg-results { margin: 18px 0 8px; }
.bg-result-list { list-style: none; padding: 0; margin: 8px 0 0; }
.bg-result-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(42,26,14,0.15);
  font-family: 'Newsreader', serif;
  font-size: 16px;
}
.bg-result-word { font-weight: 600; min-width: 120px; }
.bg-result-gloss { color: var(--man-ink-soft, #7A5D3E); font-style: italic; flex: 1 1 auto; }
.bg-result-points {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  color: var(--man-accent, #D14B2C);
  min-width: 36px; text-align: right;
}
.bg-result-row-rejected { opacity: 0.7; }
.bg-result-row-rejected .bg-result-word { text-decoration: line-through; color: var(--man-ink-soft, #7A5D3E); }
.bg-result-reason {
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--man-ink-soft, #7A5D3E);
  margin-left: auto;
}

/* History list (shared shape with twenty / babylon) */
.bg-history-list { list-style: none; padding: 0; margin: 12px 0 0; }
.bg-history-row {
  display: flex; gap: 14px; align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(42,26,14,0.18);
  font-family: 'Newsreader', serif; font-size: 15px;
}
.bg-history-id { font-weight: 700; min-width: 60px; }
.bg-history-mode { color: var(--man-ink, #2A1A0E); min-width: 130px; font-style: italic; }
.bg-history-date { color: var(--man-ink-soft, #7A5D3E); min-width: 90px; }
.bg-history-score { font-weight: 600; color: var(--man-accent, #D14B2C); min-width: 60px; }
.bg-history-status {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--man-ink-soft, #7A5D3E);
  min-width: 90px;
}
.bg-history-link { margin-left: auto; color: var(--man-accent, #D14B2C); text-decoration: none; font-weight: 600; }

/* Settings page */
.bg-settings-form { display: flex; flex-direction: column; gap: 18px; max-width: 640px; }
.bg-settings-field {
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--man-card, #FBF5E6);
}
.bg-settings-field legend {
  padding: 0 6px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--man-ink-soft, #7A5D3E);
}
.bg-radio-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.bg-radio {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 4%, var(--man-card, #FBF5E6));
  border: 1px solid rgba(42,26,14,0.22);
  border-radius: 18px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
  cursor: pointer;
}
.bg-radio input { accent-color: var(--man-accent, #D14B2C); }
.bg-radio:has(input:checked) {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 18%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
  font-weight: 600;
}

/* History list */
.tq-history-list { list-style: none; padding: 0; margin: 12px 0 0; }
.tq-history-row {
  display: flex; gap: 14px; align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(42,26,14,0.18);
  font-family: 'Newsreader', serif; font-size: 15px;
}
.tq-history-id { font-weight: 700; min-width: 60px; }
.tq-history-date { color: var(--man-ink-soft, #7A5D3E); min-width: 90px; }
.tq-history-mode { color: var(--man-ink, #2A1A0E); min-width: 90px; font-style: italic; }
.tq-history-status {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--man-ink-soft, #7A5D3E);
  min-width: 110px;
}
.tq-history-q { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; }
.tq-history-link { margin-left: auto; color: var(--man-accent, #D14B2C); text-decoration: none; font-weight: 600; }

.vocab-filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.vocab-filter-pill {
  padding: 4px 10px;
  border: 1px solid rgba(42,26,14,0.22);
  border-radius: 12px;
  text-decoration: none;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  color: var(--man-ink, #2A1A0E);
  background: var(--man-card, #FBF5E6);
}
.vocab-filter-pill:hover { background: rgba(209,75,44,0.1); }
.vocab-filter-pill.active {
  background: var(--man-accent, #D14B2C);
  color: white;
  border-color: var(--man-accent, #D14B2C);
}

.vocab-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-family: 'Newsreader', serif;
}
.vocab-table th {
  text-align: left;
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600; font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--man-ink-soft, #7A5D3E);
  padding: 8px 8px;
  border-bottom: 1px solid rgba(42,26,14,0.25);
}
.vocab-table td {
  padding: 8px 8px;
  border-bottom: 1px dashed rgba(42,26,14,0.12);
  vertical-align: middle;
}
.vocab-cell-target { font-weight: 600; font-size: 18px; }
.vocab-cell-primary { color: var(--man-ink, #2A1A0E); font-style: italic; font-size: 16px; }
.vocab-cell-when { color: var(--man-ink-soft, #7A5D3E); font-size: 13px; white-space: nowrap; }
.vocab-cell-actions { text-align: right; }
.vocab-tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px 4px 2px 0;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 12%, var(--man-card, #FBF5E6));
  border: 1px solid color-mix(in srgb, var(--man-accent, #D14B2C) 35%, transparent);
  border-radius: 10px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
}
.vocab-tag-focus {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 28%, var(--man-card, #FBF5E6));
  border-color: var(--man-accent, #D14B2C);
  font-weight: 700;
}
.vocab-tag-ai {
  background: color-mix(in srgb, #1f6b35 14%, var(--man-card, #FBF5E6));
  border-color: color-mix(in srgb, #1f6b35 50%, transparent);
  color: #1f6b35;
}

/* Topic create / edit form layout */
.vocab-topic-create { margin: 18px 0 28px; padding: 16px; background: var(--man-card, #FBF5E6); border: 1px solid rgba(42,26,14,0.18); border-radius: 8px; }
.vocab-topic-create-row { display: grid; grid-template-columns: 1fr 100px 100px auto; gap: 12px; align-items: end; margin-bottom: 12px; }
.vocab-topic-create-actions { display: flex; align-items: center; gap: 12px; }
.vocab-topic-create-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--man-ink-soft, #7A5D3E);
}
.vocab-topic-create-status[hidden] { display: none; }
.vocab-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(42,26,14,0.2);
  border-top-color: var(--man-accent, #D14B2C);
  border-radius: 50%;
  animation: vocab-spin 0.8s linear infinite;
}
@keyframes vocab-spin {
  to { transform: rotate(360deg); }
}
.vocab-field { display: flex; flex-direction: column; gap: 4px; }
.vocab-field-grow { min-width: 0; }
.vocab-field .vocab-input { width: 100%; }
.vocab-field-check {
  flex-direction: row; align-items: center; gap: 6px;
  font-family: 'Newsreader', serif; font-size: 14px;
}
.vocab-field-check small { display: block; font-size: 11px; }
.vocab-input-num { width: 80px; }
@media (max-width: 700px) {
  .vocab-topic-create-row { grid-template-columns: 1fr; }
}

/* Topic list cards */
.vocab-topic-list { list-style: none; padding: 0; margin: 0; }
.vocab-topic-card {
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.18);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 10px 0;
}
.vocab-topic-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vocab-topic-name {
  font-family: 'Newsreader', serif;
  font-weight: 600;
  font-size: 20px;
  margin: 0;
}
.vocab-topic-meters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.vocab-meter {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 200px;
  height: 22px;
  background: rgba(42,26,14,0.08);
  border-radius: 11px;
  overflow: hidden;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
}
.vocab-meter-bar {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 35%, transparent);
  width: 0;
  transition: width 0.3s ease;
}
.vocab-meter-bar-focus { background: color-mix(in srgb, var(--man-accent, #D14B2C) 75%, transparent); }
.vocab-meter-label {
  position: relative;
  z-index: 1;
  padding: 0 12px;
  color: var(--man-ink, #2A1A0E);
  font-weight: 600;
}
.vocab-meter-aside { color: var(--man-ink-soft, #7A5D3E); font-size: 12px; }
.vocab-topic-edit {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(42,26,14,0.2);
}
.vocab-topic-edit summary {
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  color: var(--man-ink-soft, #7A5D3E);
}
.vocab-topic-edit-form {
  display: grid;
  grid-template-columns: 1fr 90px 90px auto auto;
  gap: 10px;
  align-items: end;
  margin: 10px 0;
}
@media (max-width: 700px) {
  .vocab-topic-edit-form { grid-template-columns: 1fr; }
}
.vocab-topic-delete { display: inline; }
.vocab-topic-delete button { margin-top: 6px; }

/* Words page additions */
.vocab-check-prominent {
  padding: 8px 12px;
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 6%, var(--man-card, #FBF5E6));
  border: 1px solid color-mix(in srgb, var(--man-accent, #D14B2C) 35%, transparent);
  border-radius: 6px;
  font-size: 14px;
}
.vocab-row-focus td { background: color-mix(in srgb, var(--man-accent, #D14B2C) 5%, transparent); }
.vocab-row-retired td { opacity: 0.55; text-decoration: line-through; }
.vocab-status-focus {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 700;
  font-size: 11px;
  color: var(--man-accent, #D14B2C);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.vocab-status-retired {
  font-family: 'Inter Tight', sans-serif;
  font-weight: 600;
  font-size: 11px;
  color: var(--man-ink-soft, #7A5D3E);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.vocab-stat-card-focus { background: color-mix(in srgb, var(--man-accent, #D14B2C) 12%, var(--man-card, #FBF5E6)); border-color: color-mix(in srgb, var(--man-accent, #D14B2C) 40%, transparent); }

/* ============================================================
   Word Search home — 3-column setup row (size · topics · start).
   Mirrors the babylon pill-dropdown pattern in the Mañana palette.
   ============================================================ */
.ws-start { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 26px; }
.ws-start-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 56px;
  align-items: stretch;
  width: 100%;
  max-width: 1100px;
  min-height: 200px;
  padding: 24px 0;
}
.ws-start-col {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  gap: 8px; min-width: 0;
  padding: 0 8px;
}
.ws-start-col + .ws-start-col {
  border-left: 1px dashed rgba(42,26,14,0.28);
  padding-left: 24px;
}
.ws-start-col > .man-kicker {
  position: absolute;
  top: 14px;
  left: 8px;
  margin: 0;
}
.ws-start-col + .ws-start-col > .man-kicker { left: 24px; }
.ws-start-col-action {
  align-items: center; justify-content: center;
  gap: 10px;
}
.ws-start-grid .man-btn-lg { min-height: 50px; }
@media (max-width: 760px) {
  .ws-start-grid { grid-template-columns: 1fr; gap: 16px; padding: 12px 0; min-height: 0; }
  .ws-start-col + .ws-start-col { border-left: 0; padding-left: 8px; }
  .ws-start-col > .man-kicker { position: static; }
}

/* Pill-styled dropdown — re-uses .bb-difficulty-pill metrics in spirit
   but Mañana-palette so it sits inside the cream-card surface. */
.ws-pill-dropdown { position: relative; width: 100%; }
.ws-pill-dropdown-trigger {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px;
  text-align: left;
  padding: 12px 18px;
  font-size: 16px;
  line-height: 1.2;
  box-sizing: border-box;
  min-height: 50px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.32);
  border-radius: 6px;
  font-family: 'Newsreader', serif;
  color: var(--man-ink, #2A1A0E);
  cursor: pointer;
}
.ws-pill-dropdown-trigger:hover {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 5%, var(--man-card, #FBF5E6));
}
.ws-pill-dropdown-trigger .ws-pill-dropdown-label { font-weight: 600; flex: 1 1 auto; }
.ws-pill-dropdown-trigger .ws-pill-dropdown-sub {
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 11px;
  flex: 0 0 auto;
}
.ws-pill-dropdown-chevron {
  font-size: 12px;
  opacity: 0.7;
  flex: 0 0 auto;
  transition: transform 0.15s ease;
}
.ws-pill-dropdown-open .ws-pill-dropdown-chevron { transform: rotate(180deg); }

.ws-pill-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: var(--man-card, #FBF5E6);
  border: 1px solid rgba(42,26,14,0.32);
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
  max-height: 320px;
  overflow-y: auto;
}
.ws-pill-dropdown-menu[hidden] { display: none; }
.ws-pill-dropdown-item {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 4px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
  color: var(--man-ink, #2A1A0E);
}
.ws-pill-dropdown-item > span { flex: 1 1 auto; font-weight: 600; }
.ws-pill-dropdown-item > small {
  flex: 0 0 auto;
  color: var(--man-ink-soft, #7A5D3E);
  font-size: 11px;
}
.ws-pill-dropdown-item:hover { background: rgba(209,75,44,0.08); }
.ws-pill-dropdown-item[aria-selected="true"] {
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 10%, var(--man-card, #FBF5E6));
  border-color: color-mix(in srgb, var(--man-accent, #D14B2C) 50%, transparent);
}

/* Crossword home — same 3-column setup row as wordsearch, slotted
   into the cafe page's grid. Mirrors the babylon spacing so the row
   has room to breathe (kicker labels float at top, dropdowns +
   action button vertically centered within a tall band). */
.cw-start-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 56px;
  align-items: stretch;
  width: 100%;
  min-height: 200px;
  padding: 24px 0;
}
.cw-start-col {
  position: relative;
  display: flex; flex-direction: column; justify-content: center;
  gap: 8px; min-width: 0;
  padding: 0 8px;
}
.cw-start-col + .cw-start-col {
  border-left: 1px dashed rgba(42,26,14,0.28);
  padding-left: 24px;
}
.cw-start-col > .cw-kicker {
  position: absolute;
  top: 14px;
  left: 8px;
  margin: 0;
}
.cw-start-col + .cw-start-col > .cw-kicker { left: 24px; }
.cw-start-col-action { align-items: stretch; justify-content: center; }
.cw-start-col-action .cw-btn-lg { width: 100%; min-height: 50px; }
.cw-start-grid .ws-pill-dropdown-trigger {
  /* Match the cw-btn-lg footprint per request — 50px tall like the
     order button, with a chevron + Newsreader label. */
  min-height: 50px;
  padding: 14px 18px;
}
@media (max-width: 760px) {
  .cw-start-grid { grid-template-columns: 1fr; gap: 16px; padding: 12px 0; min-height: 0; }
  .cw-start-col + .cw-start-col { border-left: 0; padding-left: 8px; }
  .cw-start-col > .cw-kicker { position: static; }
}

/* Topic multi-select popup body */
.ws-topic-menu { padding: 10px 12px; }
.ws-topic-menu-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 6px;
  margin-bottom: 6px;
  border-bottom: 1px dashed rgba(42,26,14,0.18);
}
.ws-topic-clear {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--man-accent, #D14B2C);
}
.ws-topic-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
  color: var(--man-ink, #2A1A0E);
  border-radius: 4px;
  cursor: pointer;
}
.ws-topic-check:hover { background: rgba(209,75,44,0.08); }
.ws-topic-check input { accent-color: var(--man-accent, #D14B2C); }
.ws-topic-menu-empty {
  padding: 14px 8px;
  font-family: 'Newsreader', serif;
  font-size: 14px;
  color: var(--man-ink-soft, #7A5D3E);
  font-style: italic;
}
.ws-topic-menu-empty a { color: var(--man-accent, #D14B2C); }


/* ---- Flashcards mini-games landing ---- */
.fc-game-active-banner {
  background: rgba(209,75,44,0.08);
  border: 1px dashed rgba(209,75,44,0.45);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Newsreader', serif;
  font-size: 16px;
  color: var(--man-ink, #2A1A0E);
  margin: 12px 0 18px;
}
.fc-game-active-banner a {
  color: var(--man-accent, #D14B2C);
  font-weight: 600;
}
.fc-games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.fc-game-tile {
  background: var(--man-card, #FFF6E2);
  border: 1.5px solid rgba(42,26,14,0.18);
  border-radius: 14px;
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fc-game-tile-icon { font-size: 28px; }
.fc-game-tile-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  margin: 0;
}
.fc-game-tile-blurb {
  font-family: 'Newsreader', serif;
  font-size: 15px;
  color: var(--man-ink-soft, #7A5D3E);
  margin: 0 0 8px;
  line-height: 1.4;
}
.fc-game-tile-foot {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--man-ink-soft, #7A5D3E);
  margin: 6px 0 0;
}

/* ---- Word Match play surface ---- */
.wm-page { max-width: 1080px; }
.wm-strip {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.wm-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 32px;
  margin: 4px 0 0;
}
.wm-strip-right { display: flex; gap: 18px; }
.wm-counter { display: flex; flex-direction: column; align-items: flex-end; }
.wm-counter-num {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--man-accent, #D14B2C);
  line-height: 1;
}
.wm-counter-denom {
  font-family: 'Newsreader', serif;
  font-size: 18px;
  color: var(--man-ink-soft, #7A5D3E);
  margin-left: 2px;
}
.wm-counter-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--man-ink-soft, #7A5D3E);
  margin-top: 4px;
}

.wm-stage {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 28px;
  margin-top: 18px;
  align-items: start;
}
@media (max-width: 720px) {
  .wm-stage { grid-template-columns: 1fr; }
}

.wm-candidates {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column;
  align-items: center;           /* center buttons within the left column */
  gap: 10px;
}
.wm-candidate {
  /* Auto-width, content-sized; taller than wide, non-italic legible
     sans face. The list grows naturally to fit the longest word. */
  display: inline-block;
  text-align: center;
  font-family: 'Inter Tight', 'Bricolage Grotesque', sans-serif;
  font-style: normal;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.005em;
  padding: 18px 22px;
  min-height: 56px;
  min-width: 140px;
  border: 1.5px solid rgba(42,26,14,0.18);
  border-radius: 10px;
  background: var(--man-card, #FFF6E2);
  color: var(--man-ink, #2A1A0E);
  cursor: pointer;
  transition: border-color 100ms, background 100ms, transform 80ms;
}
.wm-candidate:hover { border-color: var(--man-accent, #D14B2C); }
.wm-candidate:active { transform: translateY(1px); }
.wm-candidate-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  text-decoration: line-through;
}
.wm-candidate-pending {
  border-color: var(--man-accent, #D14B2C);
  background: rgba(209,75,44,0.06);
}

.wm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1.5px solid rgba(42,26,14,0.18);
  border-radius: 14px;
  background: var(--man-card, #FFF6E2);
}
.wm-card-img {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(42,26,14,0.16);
  background: rgba(42,26,14,0.04);
}
.wm-card-img-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--man-ink-soft, #7A5D3E);
  font-family: 'Newsreader', serif;
  font-style: italic;
}
.wm-card-en {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 28px;
  font-weight: 600;
  text-align: center;
  color: var(--man-ink, #2A1A0E);
}

.wm-end-row { display: flex; gap: 12px; margin-top: 24px; flex-wrap: wrap; }

/* Flash feedback animations */
@keyframes wm-flash-right-kf {
  0%   { background: rgba(31,143,110,0.55); }
  100% { background: var(--man-card, #FFF6E2); }
}
@keyframes wm-flash-wrong-kf {
  0%, 60% { background: rgba(217,67,79,0.45); }
  100%    { background: var(--man-card, #FFF6E2); }
}
.wm-flash-right { animation: wm-flash-right-kf 350ms ease-out; }
.wm-flash-wrong { animation: wm-flash-wrong-kf 350ms ease-out; }

/* Between-rounds congrats overlay */
.wm-stage { position: relative; }
.wm-roundup-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,246,226,0.92);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  z-index: 5;
}
/* The default `display: flex` above defeats the HTML `hidden`
   attribute, so the JS `overlay.hidden = true` left the modal still
   visible. Re-anchor `hidden` with the same specificity. */
.wm-roundup-overlay[hidden] {
  display: none;
}
.wm-roundup-card {
  background: var(--man-card, #FFF6E2);
  border: 1.5px solid rgba(42,26,14,0.18);
  border-radius: 14px;
  padding: 28px 32px;
  max-width: 460px;
  text-align: center;
  box-shadow: 0 14px 40px rgba(42,26,14,0.18);
}
.wm-roundup-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 30px;
  margin: 6px 0 14px;
}
.wm-roundup-stats {
  font-family: 'Newsreader', serif;
  font-size: 17px;
  color: var(--man-ink, #2A1A0E);
  margin: 0 0 22px;
  line-height: 1.5;
}
.wm-roundup-stats strong { color: var(--man-accent, #D14B2C); }
.wm-roundup-bonus {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--man-jade, #1F6A5A);
  margin: 4px 0 18px;
}


/* ===== Ask Now ===== */
.nav-utilities {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* Slight gap between the utility buttons (sound + Ask Now) and the
     navigation tabs that follow. Keeps the two clusters distinct
     without a hard divider. */
  margin-right: 18px;
}
.nav-ask-btn {
  /* Plain text button matching the other nav links — no pill border. */
  background: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  line-height: inherit;
}
.nav-ask-btn:hover {
  color: var(--accent);
}

.settings-section-title {
  font-family: var(--font-display, inherit);
  font-size: 22px;
  font-weight: 600;
  margin: 28px 0 6px;
  border-top: 1px dashed var(--line);
  padding-top: 24px;
}
.settings-form:first-of-type .settings-section-title {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

/* Modal: floating overlay anchored to the right side of the viewport
   so it doesn't blanket the activity. Backdrop dims the rest. */
.ask-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}
.ask-modal[hidden] { display: none; }
html.ask-modal-open { overflow: hidden; }
.ask-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20,12,4,0.32);
}
.ask-modal-card {
  position: relative;
  z-index: 1;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100vh;
  background: var(--man-card, #FFF6E2);
  border-left: 1.5px solid rgba(42,26,14,0.18);
  box-shadow: -16px 0 40px rgba(20,12,4,0.18);
  display: flex;
  flex-direction: column;
}
.ask-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42,26,14,0.12);
}
.ask-modal-tabs { display: flex; gap: 4px; }
.ask-tab {
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  color: var(--man-ink-soft, #7A5D3E);
}
.ask-tab:hover { color: var(--man-ink, #2A1A0E); }
.ask-tab-active {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FFF6E2);
}
.ask-modal-close {
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--man-ink-soft);
  cursor: pointer;
  padding: 0 4px;
}
.ask-modal-close:hover { color: var(--man-ink); }
.ask-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

/* Picker (chat tab default state) */
.ask-picker { display: flex; flex-direction: column; gap: 18px; }
.ask-new-btn { width: 100%; }
.ask-picker-recent { display: flex; flex-direction: column; gap: 8px; }
.ask-picker-label {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
}
.ask-picker-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ask-picker-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid rgba(42,26,14,0.12);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}
.ask-picker-item:hover {
  border-color: var(--man-accent, #D14B2C);
  background: color-mix(in srgb, var(--man-accent, #D14B2C) 6%, transparent);
}
.ask-picker-title {
  display: block;
  font-family: 'Newsreader', serif;
  font-size: 15px;
  color: var(--man-ink);
}
.ask-picker-meta {
  display: block;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  color: var(--man-ink-soft);
  margin-top: 2px;
}

/* Conversation surface */
.ask-conversation { display: flex; flex-direction: column; gap: 14px; }
.ask-thread { display: flex; flex-direction: column; gap: 12px; }
.ask-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(42,26,14,0.10);
}
.ask-msg-user { background: rgba(31,106,90,0.08); }
.ask-msg-assistant { background: var(--man-card, #FFF6E2); }
.ask-msg-error {
  background: rgba(217,67,79,0.08);
  border-color: rgba(217,67,79,0.35);
  color: #7A2A2F;
}

/* "Thinking…" placeholder — three dots that pulse while the AI call
   is in flight (or while we're polling for it after the user
   navigated away during a prior send). */
.ask-msg-thinking { opacity: 0.92; }
.ask-thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 18px;
}
.ask-thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--man-ink-soft, #7A5D3E);
  animation: ask-thinking-pulse 1.2s infinite ease-in-out both;
}
.ask-thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.ask-thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ask-thinking-pulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* While a send is in flight, dim the form and append an "Asking…"
   cue to the disabled submit button. HTMX adds .htmx-request to the
   element initiating the request — the form itself in this case. */
.ask-input.htmx-request { opacity: 0.7; }
.ask-input.htmx-request button[disabled]::after {
  content: "…";
  margin-left: 4px;
}
.ask-input button:disabled { cursor: wait; }
.ask-msg-role {
  font-family: 'Inter Tight', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
}
.ask-msg-body {
  font-family: 'Newsreader', serif;
  font-size: 15.5px;
  line-height: 1.5;
  color: var(--man-ink);
  white-space: pre-wrap;
}
.ask-input {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(42,26,14,0.10);
}
.ask-input input[type="text"] {
  flex: 1;
  font-family: 'Newsreader', serif;
  font-size: 15px;
  padding: 8px 12px;
  border: 1px solid rgba(42,26,14,0.20);
  border-radius: 8px;
  background: var(--man-card, #FFF6E2);
}
.ask-input input[type="text"]:focus {
  outline: 2px solid var(--man-accent, #D14B2C);
  outline-offset: 1px;
}

/* Session header (back link + title in chat view) */
.ask-session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}
.ask-session-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 16px;
  color: var(--man-ink);
  flex: 1;
  text-align: center;
}
.ask-link {
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--man-accent, #D14B2C);
  text-decoration: none;
}
.ask-link:hover { text-decoration: underline; }
.ask-link-danger { color: #b03030; }

/* Translation tab */
.ask-translation-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}
.ask-translation-input {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: 'Newsreader', serif;
  font-style: italic;
  color: var(--man-ink-soft, #7A5D3E);
}
.ask-translation-input-text {
  color: var(--man-ink, #2A1A0E);
  font-style: normal;
  font-weight: 600;
}
.ask-translation-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px;
  background: rgba(31,106,90,0.06);
  border: 1px solid rgba(42,26,14,0.10);
  border-radius: 10px;
}
.ask-translation-side { text-align: center; }
.ask-translation-lang {
  font-family: 'Inter Tight', sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  margin-bottom: 4px;
}
.ask-translation-word {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px;
  color: var(--man-ink);
}
.ask-translation-arrow {
  font-size: 22px;
  color: var(--man-accent, #D14B2C);
}
.ask-translation-candidates {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-translation-candidate {
  padding: 10px 12px;
  border: 1px solid rgba(42,26,14,0.12);
  border-radius: 8px;
  background: var(--man-card, #FFF6E2);
}
.ask-translation-candidate-pair {
  font-family: 'Newsreader', serif;
  font-size: 16px;
}
.ask-translation-candidate-gloss {
  color: var(--man-ink-soft);
  font-style: italic;
  margin-left: 4px;
}
.ask-translation-candidate-note {
  margin: 4px 0 0;
  font-family: 'Newsreader', serif;
  font-size: 13.5px;
  color: var(--man-ink);
}
.ask-translation-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}
.ask-translation-mode-toggle {
  display: inline-flex;
  gap: 4px;
  border: 1px solid rgba(42,26,14,0.12);
  border-radius: 999px;
  padding: 2px;
  align-self: flex-start;
}
.ask-translation-mode-btn {
  background: transparent;
  border: none;
  padding: 4px 14px;
  border-radius: 999px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--man-ink-soft);
  cursor: pointer;
}
.ask-translation-mode-active {
  background: var(--man-accent, #D14B2C);
  color: var(--man-card, #FFF6E2);
}
.ask-translation-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-translation-pane[hidden] { display: none; }
.ask-translation-pane input[type="text"],
.ask-translation-pane textarea {
  font-family: 'Newsreader', serif;
  font-size: 15px;
  padding: 8px 12px;
  border: 1px solid rgba(42,26,14,0.20);
  border-radius: 8px;
  background: var(--man-card, #FFF6E2);
  resize: vertical;
}
.ask-translation-direction {
  display: flex;
  gap: 14px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 12px;
  color: var(--man-ink-soft);
}
.ask-translation-direction input { margin-right: 4px; }

/* History list */
.ask-history-kind {
  display: inline-block;
  font-family: 'Inter Tight', sans-serif;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--man-card, #FFF6E2);
  background: var(--man-ink-soft, #7A5D3E);
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  vertical-align: middle;
}
.ask-history-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.ask-history-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(42,26,14,0.10);
  border-radius: 8px;
  padding: 4px;
}
.ask-history-open {
  flex: 1;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  color: inherit;
}
.ask-history-open:hover { background: rgba(42,26,14,0.04); }
.ask-history-title {
  display: block;
  font-family: 'Newsreader', serif;
  font-size: 15px;
}
.ask-history-meta {
  display: block;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  color: var(--man-ink-soft);
}
.ask-history-archive { padding-right: 6px; }

.ask-empty {
  font-family: 'Newsreader', serif;
  font-style: italic;
  color: var(--man-ink-soft);
  font-size: 14px;
  margin: 0;
}

/* Settings panel */
.ask-settings { display: flex; flex-direction: column; gap: 14px; }
.ask-settings-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 18px;
  margin: 0;
}
.ask-settings-blurb {
  font-family: 'Newsreader', serif;
  font-size: 14px;
  margin: 0;
  color: var(--man-ink, #2A1A0E);
}

/* Full-page Ask layout (when the user opens /ask/ directly) */
.ask-page {
  max-width: 720px;
  margin: 0 auto;
}
.ask-page-head {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ask-page-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 28px;
  margin: 0;
}
.ask-page-sub {
  font-family: 'Newsreader', serif;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0;
}
.ask-page-nav {
  display: flex;
  gap: 14px;
  border-bottom: 1px solid rgba(42,26,14,0.12);
  padding-bottom: 8px;
  margin-top: 8px;
}

.wm-newhigh {
  font-family: 'Caveat', cursive;
  font-size: 28px;
  color: var(--man-accent, #D14B2C);
  margin: 6px 0 0;
}

/* History list */
.wm-history-list { list-style: none; padding: 0; margin: 18px 0 0; }
.wm-history-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 12px 0;
  border-bottom: 1px dashed rgba(42,26,14,0.16);
}
.wm-history-meta {
  font-family: 'Newsreader', serif;
  font-size: 15px;
  color: var(--man-ink, #2A1A0E);
}
.wm-history-stats {
  font-style: italic;
  color: var(--man-ink-soft, #7A5D3E);
}
