:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #d9d9d6;
  --accent: #2f6f4f;
  --red: #b5372f;
  --black: #1a1a1a;
  --card-back: #2f4f6f;
  --selected: #d98e2c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14151a;
    --surface: #1f2128;
    --text: #f0f0ef;
    --text-muted: #9a9a9a;
    --border: #33353d;
    --accent: #5fb98a;
    --red: #e0665c;
    --black: #f0f0ef;
    --card-back: #4a6fa5;
    --selected: #f0a93c;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* #site-header spans the full viewport width (a real top bar), so its own
   padding lives here rather than on body — body used to center #app via
   `justify-content: center` on a row-flex container, which would have put
   the header and #app side by side once the header became a sibling;
   flex-direction: column + align-items: center keeps #app centered while
   letting the header stretch edge to edge above it. */
#app {
  width: 100%;
  max-width: 640px;
  padding: 1.5rem 1rem 3rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  margin: 0 0 0.25rem;
  letter-spacing: 0.02em;
}

#day-label {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.modifier-banner {
  display: inline-block;
  margin: 0.5rem auto 0;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--selected) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--selected) 40%, transparent);
  color: var(--text);
  font-size: 0.85rem;
}

.hand-row {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.card {
  position: relative;
  width: 72px;
  height: 100px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  backface-visibility: hidden;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

/* Compound selectors so flip transforms always win over .card--selected's
   translateY, since the cards being flipped are exactly the selected ones.
   --flip-duration is set inline per-card by animations.js — rare cards get
   a longer, more deliberate flip than common ones. */
.card.card--flip-out,
.card.card--flip-in {
  transition: transform var(--flip-duration, 180ms) ease-in;
}

.card.card--flip-out {
  transform: rotateY(90deg);
}

.card.card--flip-in {
  transform: rotateY(90deg);
}

@media (min-width: 480px) {
  .card {
    width: 84px;
    height: 118px;
  }
}

.card:hover:not(:disabled) {
  transform: translateY(-4px);
}

.card:disabled {
  cursor: default;
}

.card--selected {
  border-color: var(--selected);
  box-shadow: 0 0 0 2px var(--selected);
  transform: translateY(-8px);
}

.card--red .card__corner,
.card--red .card__center {
  color: var(--red);
}

.card--black .card__corner,
.card--black .card__center {
  color: var(--black);
}

.card__corner {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.card__corner--top {
  top: 8px;
  left: 8px;
}

.card__corner--bottom {
  bottom: 8px;
  right: 8px;
  transform: rotate(180deg);
}

.card__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.8rem;
}

/* Rarity tiers (src/core/rarity.js) — a persistent colored border/glow so a
   rare card reads as special even outside the reveal moment (e.g. sitting
   in the initial hand). Each tier also defines --rarity-glow, used by the
   .card--reveal-rare pulse below during the flip-in reveal.
   Deliberately bold and clearly distinct from each other (thicker border +
   a background tint on top of the glow, not just a thin colored outline) —
   a quick glance should never mistake one tier for another. Silver in
   particular is a darker, more saturated blue-grey than --border so it
   doesn't quietly blend into the default card outline. */
.card--rarity-bronze {
  --rarity-glow: #8b5a2b;
  border-width: 3px;
  border-color: var(--rarity-glow);
  box-shadow: 0 0 8px color-mix(in srgb, var(--rarity-glow) 55%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rarity-glow) 16%, var(--surface)), var(--surface));
}

.card--rarity-silver {
  --rarity-glow: #8a94a6;
  border-width: 3px;
  border-color: var(--rarity-glow);
  box-shadow: 0 0 10px color-mix(in srgb, var(--rarity-glow) 60%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rarity-glow) 18%, var(--surface)), var(--surface));
}

.card--rarity-gold {
  --rarity-glow: #d4a017;
  border-width: 3px;
  border-color: var(--rarity-glow);
  box-shadow: 0 0 14px color-mix(in srgb, var(--rarity-glow) 70%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rarity-glow) 20%, var(--surface)), var(--surface));
}

.card--rarity-joker {
  --rarity-glow: #a64ce0;
  border-width: 3px;
  border-color: var(--rarity-glow);
  box-shadow: 0 0 18px color-mix(in srgb, var(--rarity-glow) 80%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rarity-glow) 22%, var(--surface)), var(--surface));
}

/* Diamond (owner request: "added rarities higher than gold... very rare,
   insanely high multiplier") — the rarest tier in the game, so it gets the
   biggest glow of all, bigger than Joker's, plus a subtle shimmer pulse
   (unlike every other tier, which is a static glow) to set it apart even at
   a glance. Icy cyan-blue, deliberately far from gold's warm yellow. */
.card--rarity-diamond {
  --rarity-glow: #4fd8ff;
  border-width: 3px;
  border-color: var(--rarity-glow);
  box-shadow: 0 0 22px color-mix(in srgb, var(--rarity-glow) 85%, transparent);
  background: linear-gradient(135deg, color-mix(in srgb, var(--rarity-glow) 24%, var(--surface)), var(--surface));
  animation: diamond-shimmer 2.2s ease-in-out infinite;
}

@keyframes diamond-shimmer {
  0%,
  100% {
    box-shadow: 0 0 22px color-mix(in srgb, var(--rarity-glow) 85%, transparent);
  }
  50% {
    box-shadow: 0 0 32px color-mix(in srgb, var(--rarity-glow) 100%, transparent);
  }
}

/* A Joker's own flavor (owner request: "i want the joker to just have the
   same rarities as the normal cards, bronze, silver and gold") — layered on
   top of .card--rarity-joker above, reusing the exact same glow colors as
   the plain bronze/silver/gold/diamond cards so "this Joker is gold-flavored"
   reads consistently with everything else. Only overriding --rarity-glow is
   enough: border-color/box-shadow/background all reference var(--rarity-glow)
   already, so they pick up the matching color automatically via the
   cascade. Declared after .card--rarity-joker so same-specificity rules
   resolve in the flavor's favor. */
.card--joker-tier-bronze {
  --rarity-glow: #8b5a2b;
}

.card--joker-tier-silver {
  --rarity-glow: #8a94a6;
}

.card--joker-tier-gold {
  --rarity-glow: #d4a017;
}

.card--joker-tier-diamond {
  --rarity-glow: #4fd8ff;
  animation: diamond-shimmer 2.2s ease-in-out infinite;
}

/* Selecting a rare card for discard (owner-reported: "kind of hard to see
   that it is selected other than when it is raised up"). .card--rarity-*
   sets its own border-color/box-shadow and is declared after .card--selected
   above, so at equal (single-class) specificity the rarity glow was quietly
   winning and swallowing the selection ring. These compound selectors have
   higher specificity than either alone, so they win regardless of source
   order: a bright selected-color ring INSIDE the rarity glow, so a selected
   rare card unmistakably reads as both "selected" and "still rare" at once. */
.card--rarity-bronze.card--selected,
.card--rarity-silver.card--selected,
.card--rarity-gold.card--selected,
.card--rarity-joker.card--selected,
.card--rarity-diamond.card--selected {
  border-color: var(--selected);
  box-shadow:
    0 0 0 3px var(--selected),
    0 0 16px color-mix(in srgb, var(--rarity-glow) 70%, transparent);
  /* Diamond's shimmer (above) animates box-shadow too, which would keep
     overriding this every frame and hide the selection ring the same way
     the plain specificity issue did for the other tiers — pause it while
     selected instead of trying to blend two live animations of the same
     property. */
  animation: none;
}

.card__rarity-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.7rem;
  line-height: 1;
}

/* Locked Card (Daily Modifiers, DESIGN.md §4) — this slot can't be
   discarded today; opposite corner from the rarity badge so both can show
   at once without colliding. */
.card__lock-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 0.7rem;
  line-height: 1;
}

.card--locked {
  opacity: 0.85;
  cursor: not-allowed;
}

.card--locked::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px dashed var(--border);
  pointer-events: none;
}

.card__joker-face {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  font-size: 1.9rem;
}

.card__joker-label {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--rarity-glow);
}

/* The dramatic "it landed" pulse, added once a rare card's flip completes
   (board.js). Bigger/longer than anything a common card does — the whole
   point is that it should feel unmistakably different. */
@keyframes reveal-rare-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 6px color-mix(in srgb, var(--rarity-glow, gold) 40%, transparent);
  }
  35% {
    transform: scale(1.16);
    box-shadow: 0 0 28px color-mix(in srgb, var(--rarity-glow, gold) 90%, transparent);
  }
  65% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 12px color-mix(in srgb, var(--rarity-glow, gold) 70%, transparent);
  }
}

.card--reveal-rare {
  animation: reveal-rare-pulse 700ms ease-out;
}

/* A brief glow on a card the instant it "gives up" points to the score
   total (owner request — animations.js's flySparks() is the actual flight,
   this is just the card-side departure flash). */
@keyframes card-score-pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--selected) 65%, transparent);
  }
  35% {
    box-shadow: 0 0 14px 4px color-mix(in srgb, var(--selected) 55%, transparent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.card--score-pulse {
  animation: card-score-pulse 480ms ease-out;
}

/* The flying spark itself (animations.js's flySparks) — a small glowing dot
   that travels from a contributing card to the score total, then vanishes.
   --dx/--dy/--spark-duration are set inline per-spark in JS. */
@keyframes score-spark-fly {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  55% {
    transform: translate(calc(var(--dx) * 0.55), calc(var(--dy) * 0.55 - 46px)) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) scale(0.25);
    opacity: 0;
  }
}

.score-spark {
  position: fixed;
  left: 0;
  top: 0;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--selected);
  box-shadow: 0 0 10px 3px color-mix(in srgb, var(--selected) 80%, transparent);
  pointer-events: none;
  z-index: 999;
  animation: score-spark-fly var(--spark-duration, 550ms) cubic-bezier(0.3, 0.1, 0.4, 1) forwards;
}

.card__back-pattern {
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  background: repeating-linear-gradient(
    45deg,
    var(--card-back),
    var(--card-back) 6px,
    transparent 6px,
    transparent 12px
  );
  background-color: var(--card-back);
  opacity: 0.85;
}

#controls {
  text-align: center;
  margin-bottom: 2rem;
}

#discard-hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

#lock-in-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 2rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

#lock-in-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.wager-prompt {
  margin-bottom: 0.75rem;
}

#wager-prompt-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.wager-prompt-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.wager-btn {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.wager-btn--risk {
  background: var(--red);
  color: white;
}

.wager-btn--safe {
  background: var(--accent);
  color: white;
}

.result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
}

.result h2 {
  margin-top: 0;
}

.score-total {
  font-size: 2.75rem;
  font-weight: 800;
  margin: 0.25rem 0 1rem;
  font-variant-numeric: tabular-nums;
}

.score-breakdown {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

/* Badge breakdown cards (owner request: "an animation/example/description
   of the points that are given like the attached picture" — RNGDLE's badge
   breakdown). Each score line is a small card: icon + name + category tag +
   points, a one-line plain-English description, and a mini strip of all 5
   final-hand cards with the ones that actually justify it highlighted —
   built in board.js's buildScoreBadges()/badgeCardHtml(). */
.score-breakdown li.score-badge {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  animation: line-in 250ms ease both;
}

.score-badge-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.score-badge-icon {
  font-size: 1rem;
  line-height: 1;
}

.score-badge-label {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-badge-tag {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
  white-space: nowrap;
}

.score-badge-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
}

.score-badge-desc {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.mini-card-strip {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.45rem;
  flex-wrap: wrap;
}

.mini-card {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  opacity: 0.45;
  font-variant-numeric: tabular-nums;
}

.mini-card--red {
  color: var(--red);
}

.mini-card--black {
  color: var(--black);
}

.mini-card--highlight {
  opacity: 1;
  border-color: var(--selected);
  background: color-mix(in srgb, var(--selected) 18%, var(--surface));
  box-shadow: 0 0 0 1px var(--selected);
}

/* A Joker rendered at its wild substitution (e.g. a Pair-completing Jack) —
   marked so it doesn't read as an ordinary duplicate of that rank/suit. */
.mini-card--wild {
  border-style: dashed;
}

.mini-card--wild::before {
  content: '🃏';
  margin-right: 0.15rem;
  font-size: 0.6rem;
}

.score-badge-tag--hand,
.score-badge-tag--skill {
  background: color-mix(in srgb, #4c8bf5 25%, transparent);
  color: #4c8bf5;
}

.score-badge-tag--flavor {
  background: color-mix(in srgb, #e05fd0 25%, transparent);
  color: #e05fd0;
}

.score-badge-tag--suit,
.score-badge-tag--modifier {
  background: color-mix(in srgb, #2f9e8f 25%, transparent);
  color: #2f9e8f;
}

.score-badge-tag--card-value,
.score-badge-tag--pity {
  background: color-mix(in srgb, #6b6b6b 25%, transparent);
  color: var(--text-muted);
}

.score-badge-tag--bonus {
  background: color-mix(in srgb, #f0a93c 30%, transparent);
  color: #c07f1f;
}

.score-badge-tag--bronze {
  background: color-mix(in srgb, #8b5a2b 30%, transparent);
  color: #8b5a2b;
}

.score-badge-tag--silver {
  background: color-mix(in srgb, #8a94a6 35%, transparent);
  color: #6b7280;
}

.score-badge-tag--gold {
  background: color-mix(in srgb, #d4a017 30%, transparent);
  color: #a67c0d;
}

.score-badge-tag--diamond {
  background: color-mix(in srgb, #4fd8ff 30%, transparent);
  color: #1a9fc4;
}

.score-badge-tag--joker {
  background: color-mix(in srgb, #a64ce0 30%, transparent);
  color: #a64ce0;
}

.score-badge-tag--synergy {
  background: color-mix(in srgb, #e0489c 30%, transparent);
  color: #c02e7a;
}

/* Collapsed breakdown (owner request): once the count-up reveal finishes,
   the list shrinks down to the top badge plus half of the second, fading to
   transparent, with a Show More/Less button to toggle the rest — applied by
   board.js's setupBreakdownCollapse() only after the animation settles, so
   nothing clips mid-reveal. */
.score-breakdown--collapsible {
  position: relative;
  overflow: hidden;
  transition: max-height 420ms ease;
}

.score-breakdown--collapsed::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: linear-gradient(to bottom, transparent, var(--surface) 88%);
  pointer-events: none;
}

.breakdown-toggle {
  display: block;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  margin: 0.75rem auto 1rem;
}

.breakdown-toggle:hover {
  background: var(--accent);
  color: white;
}

@keyframes line-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.decision-rating {
  font-size: 1.1rem;
  animation: line-in 250ms ease both;
}

.come-back {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.test-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: repeating-linear-gradient(45deg, #f0a93c, #f0a93c 10px, #1a1a1a 10px, #1a1a1a 20px);
  color: #1a1a1a;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  text-align: center;
}

.test-banner span {
  background: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.test-banner a {
  background: #1a1a1a;
  color: #fff;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--surface);
  border: 1.5px dashed var(--selected);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
}

.admin-panel-title {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
}

.admin-panel-luck {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-panel-luck label {
  display: flex;
  align-items: baseline;
  gap: 0.3rem;
  font-weight: 600;
  white-space: nowrap;
}

.admin-panel-luck input[type='range'] {
  flex: 1;
  min-width: 100px;
  accent-color: var(--selected);
}

.admin-luck-hint {
  color: var(--text-muted);
  white-space: nowrap;
}

.admin-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-panel-actions button {
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1.5px solid var(--selected);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.admin-panel-actions button:hover {
  background: var(--selected);
  color: #1a1a1a;
}

.admin-panel-subtitle {
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
  margin-top: 0.3rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.6rem;
}

.admin-slots {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.admin-slot {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.admin-slot-label {
  font-weight: 700;
  color: var(--text-muted);
  width: 1.1rem;
  text-align: center;
  flex-shrink: 0;
}

.admin-slot select {
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.story-block {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  animation: line-in 400ms ease both;
}

.story-text {
  font-style: italic;
  color: var(--text);
  line-height: 1.6;
  max-width: 420px;
  margin: 0 auto 1rem;
  white-space: pre-line;
}

.copy-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--accent);
  color: white;
}

.story-builder {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.6rem;
  max-width: 560px;
  margin: 0 auto 1.25rem;
  text-align: left;
}

.story-slot {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
}

.story-slot-label {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.65rem;
}

.story-slot select {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.story-slot select:hover,
.story-slot select:focus {
  border-color: var(--accent);
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 320px;
  margin: 0 auto 1.25rem;
  animation: line-in 250ms ease both;
}

.meter {
  display: grid;
  grid-template-columns: 4.5rem 1fr 2.75rem;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.8rem;
}

.meter-label {
  color: var(--text-muted);
  text-align: left;
  white-space: nowrap;
}

.meter-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 500ms ease;
}

.meter-fill--luck {
  background: #4caf7d;
}

.meter-fill--skill {
  background: #4c8bf5;
}

.meter-fill--risk {
  background: #e0665c;
}

.meter-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
}

.personality-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  margin-bottom: 1.25rem;
  animation: line-in 250ms ease both;
}

.personality-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.personality-label {
  font-weight: 700;
  font-size: 1rem;
}

.personality-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 300px;
  text-align: center;
}

.achievements-toast {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  animation: line-in 400ms ease both;
}

.achievements-toast h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.achievements-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}

.achievements-list li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.achievement-emoji {
  font-size: 1.3rem;
  line-height: 1.2;
}

.achievement-text strong {
  color: var(--text);
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------- */
/* Site header (owner request: logo + help on the left, login/friends on
   the right) — DESIGN.md §11. Sticky so it stays reachable while scrolling
   a long score breakdown. */
/* ---------------------------------------------------------------------- */

#site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.site-header-left,
.site-header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header-logo {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.header-help {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.header-login-btn,
.header-user-btn,
.header-friends-btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  cursor: pointer;
}

.header-login-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ---------------------------------------------------------------------- */
/* Modal overlay (src/ui/modal.js) — shared by the help modal, login modal,
   username prompt, account modal, and friends panel. */
/* ---------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  padding: 1rem;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.modal-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.help-steps {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.6;
  font-size: 0.92rem;
}

.help-steps li {
  margin-bottom: 0.6rem;
}

.login-form {
  display: flex;
  gap: 0.5rem;
}

.login-form input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-form button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.login-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-status {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sign-out-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--red);
  background: none;
  color: var(--red);
  cursor: pointer;
}

.add-friend-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.add-friend-form input {
  flex: 1;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.add-friend-form button {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

.friends-subheading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 1rem 0 0.5rem;
}

.friends-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.friends-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
}

.friends-list-item button {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text);
  cursor: pointer;
}

.friend-accept-btn {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}

.friend-decline-btn,
.friend-remove-btn {
  border-color: var(--red) !important;
  color: var(--red) !important;
}

.friends-empty,
.friends-loading,
.friends-error {
  color: var(--text-muted);
  font-size: 0.9rem;
}
