/* Shut the Box - single screen, the box is the whole game.
   Brand chrome (header, buttons, footer) matches Game On Family; the board
   itself is wood and felt so it reads as the physical game. */

:root {
  --gof-primary-dark: #157623;
  --gof-primary: #9bca3e;
  --gof-bg-light: #dde5ed;
  --gof-bg-mint: #defff0;
  --gof-accent: #ffb920;
  --gof-warm: #de6739;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --card-bg: #ffffff;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);

  /* The box: maple frame, dark recessed interior, green felt dice well. */
  --wood-light: #dcae69;
  --wood-mid: #bd8546;
  --wood-dark: #9a6631;
  --wood-edge: #7d5024;
  --box-interior: #6f4620;
  --box-interior-deep: #533418;
  --slot: #3d2611;
  --tile-face: #fffaf0;
  --tile-face-low: #f0e3c8;
  --tile-edge: #e0cfa8;
  --tile-num: #3a2b16;
  --felt: #1d7339;
  --felt-deep: #13512a;

  /* One tile width drives the whole board; 9 or 12 tiles across one row. */
  --tile-w: clamp(28px, 8.4vw, 44px);
  --tile-h: calc(var(--tile-w) * 1.32);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Arimo', sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--gof-bg-light) 0%, var(--gof-bg-mint) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  margin-bottom: 0.25rem;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}

.header-left { flex: 1; min-width: 0; max-width: 85%; }
.header-right { flex-shrink: 0; min-width: 52px; }

.game-title-wrap { position: relative; display: inline-block; }

.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
}

.game-title-heading {
  margin: 0;
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.game-title-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.game-title-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 160px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.game-title-dropdown[aria-hidden="false"] { display: block; }

.game-nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
}

.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-bg-mint); }

/* ===== Mode + CPU difficulty pills ===== */
.mode-row,
.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

/* `display: flex` above would otherwise override the [hidden] attribute. */
.difficulty-row[hidden] { display: none; }

.difficulty-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.mode-btn,
.diff-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  min-height: 28px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.mode-btn:hover,
.diff-btn:hover {
  border-color: var(--gof-primary);
  background: var(--gof-bg-mint);
}

.mode-btn[aria-pressed="true"],
.diff-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
  padding: 2px 10px;
}

/* ===== Players strip (Vs CPU / Pass & Play) ===== */
.players-strip {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 480px;
}

.players-strip[hidden] { display: none; }

.player-card {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.5rem;
  text-align: center;
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: border-color 0.15s, transform 0.15s;
}

/* Whose round it is right now. */
.player-card.is-current {
  border-color: var(--gof-primary-dark);
  transform: translateY(-2px);
}

/* Lowest score once everyone has played. */
.player-card.is-winner { border-color: var(--gof-accent); background: #fffdf3; }

.player-name {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-card.is-current .player-name { color: var(--gof-primary-dark); }

.player-score {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1.15;
  color: var(--text-primary);
}

.player-score.is-pending { color: #c3c8cd; }

/* ===== Final standings ===== */
.standings {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}

.standings[hidden] { display: none; }

.standing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: #f5f8fa;
}

.standing-row.is-winner {
  background: #fffdf3;
  border: 1px solid var(--gof-accent);
  color: #8a5a00;
}

.standing-points {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-primary);
}

/* ===== Tagline ===== */
.tagline {
  font-family: 'Trocchi', Georgia, serif;
  color: var(--text-secondary);
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.35;
}

/* ===== Score strip: live round value + the bar to beat ===== */
.score-strip {
  display: flex;
  gap: 0.6rem;
  width: 100%;
  max-width: 480px;
}

.score-chip {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  background: var(--card-bg);
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 0.45rem 0.6rem;
  box-shadow: var(--card-shadow);
}

.score-chip-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.score-chip-value {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-primary);
}

.score-chip-unit {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.score-chip--best { border-color: var(--gof-accent); background: #fffdf3; }
.score-chip--best .score-chip-value { color: #8a5a00; }

/* ===== The box ===== */
.box-frame {
  width: 100%;
  max-width: 480px;
  padding: 13px;
  border-radius: 18px;
  border: 1px solid var(--wood-edge);
  background:
    repeating-linear-gradient(
      92deg,
      rgba(255, 255, 255, 0.05) 0px,
      rgba(255, 255, 255, 0.05) 2px,
      rgba(0, 0, 0, 0.04) 2px,
      rgba(0, 0, 0, 0.04) 5px
    ),
    linear-gradient(158deg, var(--wood-light) 0%, var(--wood-mid) 48%, var(--wood-dark) 100%);
  box-shadow:
    0 12px 28px rgba(60, 36, 12, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}

.box-inner {
  border-radius: 11px;
  padding: 14px 11px 12px;
  background: linear-gradient(180deg, var(--box-interior) 0%, var(--box-interior-deep) 100%);
  box-shadow: inset 0 3px 11px rgba(0, 0, 0, 0.5);
}

/* ===== Tiles ===== */
.tiles {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 5px;
  min-height: calc(var(--tile-h) + 4px);
}

/* 12 tiles still hold one row - shrink them rather than wrap. */
.tiles.tiles--12 { --tile-w: clamp(21px, 6.1vw, 32px); gap: 4px; }

.tile {
  position: relative;
  width: var(--tile-w);
  height: var(--tile-h);
  padding: 0;
  border: 0;
  background: transparent;
  perspective: 420px;
  cursor: pointer;
}

/* The empty slot the tile sits in - visible once the tile flips down. */
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background: var(--slot);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65);
}

.tile-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform-origin: center bottom;
  transition: transform 0.34s cubic-bezier(0.3, 1.35, 0.5, 1);
}

.tile-front,
.tile-back {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile-front {
  background: linear-gradient(180deg, var(--tile-face) 0%, var(--tile-face-low) 100%);
  border: 1px solid var(--tile-edge);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: calc(var(--tile-w) * 0.6);
  line-height: 1;
  color: var(--tile-num);
  user-select: none;
}

/* Seen only once the tile has flipped past vertical - the blank underside. */
.tile-back {
  transform: rotateX(180deg);
  background: linear-gradient(180deg, var(--wood-dark) 0%, var(--wood-edge) 100%);
  border: 1px solid var(--box-interior-deep);
}

.tile:hover:not(.is-shut):not(.is-disabled) .tile-inner { transform: translateY(-4px); }

.tile:focus-visible { outline: none; }
.tile:focus-visible .tile-front {
  outline: 3px solid var(--gof-accent);
  outline-offset: 2px;
}

/* Picked for this roll but not yet committed - lifted out of the slot. */
.tile.is-selected .tile-inner { transform: translateY(-8px) rotateX(-9deg); }
.tile.is-selected .tile-front {
  outline: 3px solid var(--gof-accent);
  outline-offset: 1px;
  background: linear-gradient(180deg, #fff6dc 0%, #ffe9b0 100%);
}

/* Can't take part in this roll. */
.tile.is-disabled { cursor: default; }
.tile.is-disabled .tile-front { opacity: 0.4; filter: grayscale(0.55); }

/* Flipped down for good. */
.tile.is-shut { cursor: default; pointer-events: none; }
.tile.is-shut .tile-inner { transform: rotateX(-108deg); }

/* ===== Hinge line between tiles and dice ===== */
.box-hinge {
  height: 3px;
  margin: 12px 2px 11px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.4), rgba(255, 255, 255, 0.14));
}

/* ===== Dice well (green felt) ===== */
.dice-well {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 11px 10px 9px;
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 25%, var(--felt) 0%, var(--felt-deep) 100%);
  box-shadow: inset 0 3px 11px rgba(0, 0, 0, 0.55);
}

/* The tray is a GofDice container; app.js sets it inline, so the responsive
   size has to win with !important. Loaded after dice.css. */
#diceTray {
  --gof-dice-size: clamp(40px, 12vw, 56px) !important;
  gap: 0.85rem;
  min-height: clamp(40px, 12vw, 56px);
}

.roll-total {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: #d9f2df;
  min-height: 1.2em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ===== Status line ===== */
/* Fixed-height slot so the message appearing or clearing never shifts the
   roll buttons underneath it. */
.status-area {
  width: 100%;
  max-width: 480px;
  /* Tall enough to hold the longest hint plus the Undo chip on a narrow
     screen, so the slot never resizes and never nudges the buttons below. */
  min-height: 4.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Plain text on purpose. This slot sits directly above the Roll button, and a
   card / pill treatment here made it read as a second button. */
.status-msg {
  width: 100%;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  padding: 0.25rem 0.5rem;
}

.status-msg.is-target {
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  color: var(--gof-primary-dark);
}

.status-msg.is-target strong { font-size: 1.5rem; }

.status-msg.is-hint {
  color: var(--text-secondary);
  font-weight: 600;
}

.status-msg.is-dead {
  color: #b3261e;
}

/* ===== Buttons ===== */
.play-actions {
  display: flex;
  gap: 0.625rem;
  width: 100%;
  max-width: 380px;
  justify-content: center;
}

.primary-btn,
.secondary-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem 1.25rem;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  flex: 1;
}

.primary-btn {
  background: var(--gof-primary-dark);
  color: white;
  border: 2px solid var(--gof-primary-dark);
}

.primary-btn:hover { background: #11631d; }

.secondary-btn {
  background: white;
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
}

.secondary-btn:hover { background: var(--gof-bg-mint); }

.primary-btn:active,
.secondary-btn:active { transform: scale(0.97); }

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ===== Undo (lives inside the fixed-height status slot) ===== */
.undo-btn {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 3px 10px;
  min-height: 28px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gof-primary-dark);
  background: white;
  border: 1.5px solid var(--gof-primary-dark);
  border-radius: 999px;
  cursor: pointer;
}

.undo-btn:hover { background: var(--gof-bg-mint); }
.undo-btn:active { transform: scale(0.97); }

/* ===== New round: quiet on purpose ===== */
.newround-row {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 34px;
}

.newround-btn {
  font-family: 'Arimo', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.newround-btn:hover { color: var(--text-primary); background: rgba(0, 0, 0, 0.04); }

/* Second tap confirms. Loud enough that you notice you armed it. */
.newround-btn.is-armed {
  color: #b3261e;
  background: #ffe5e2;
  border: 1px solid #f3a9a2;
  text-decoration: none;
  font-weight: 700;
}

.ghost-btn {
  font-family: 'Arimo', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 0.6rem;
  cursor: pointer;
  text-decoration: underline;
}

.ghost-btn:hover { color: var(--text-primary); }
.ghost-btn--danger { color: #b3261e; }
.ghost-btn--danger:hover { color: #8c1c16; }

/* ===== Settings (secondary - below the gameplay) ===== */
.settings-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  padding: 0.6rem 0.9rem;
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: white;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  cursor: pointer;
}

.settings-summary:hover { border-color: var(--gof-primary); background: var(--gof-bg-mint); }

.settings-summary .gear { font-size: 1rem; }
.settings-summary #settingsSummaryText { flex: 1; text-align: left; }

.settings-chevron { font-size: 0.7rem; transition: transform 0.15s; }
.settings-summary[aria-expanded="true"] .settings-chevron { transform: rotate(180deg); }

.settings-panel {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding: 1rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
}

.settings-panel[hidden] { display: none; }

.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.cfg-field--toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.cfg-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cfg-hint {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.35;
}

.cfg-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.choice-row { display: flex; gap: 6px; }

.choice-btn {
  min-width: 52px;
  padding: 6px 14px;
  min-height: 36px;
  font-family: 'League Spartan', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
}

.choice-btn:hover { border-color: var(--gof-primary); background: var(--gof-bg-mint); }

.choice-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border-color: var(--gof-primary-dark);
  border-width: 2px;
}

.toggle {
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  padding: 3px;
  border-radius: 999px;
  border: none;
  background: #cbd5e0;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle[aria-checked="true"] { background: var(--gof-primary-dark); }

.toggle-knob {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}

.toggle[aria-checked="true"] .toggle-knob { transform: translateX(20px); }

/* ===== How to play ===== */
.how-to {
  width: 100%;
  max-width: 520px;
}

.how-to details {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

.how-to-toggle {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.how-to-toggle::-webkit-details-marker { display: none; }

.how-to-chevron { font-size: 0.7rem; color: var(--text-secondary); transition: transform 0.15s; }
.how-to details[open] .how-to-chevron { transform: rotate(180deg); }

.how-to-body {
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.how-to-body p { margin-bottom: 0.5rem; }
.how-to-body p:last-child { margin-bottom: 0; }

.how-to-steps {
  padding-left: 1.2rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.how-to-steps li::marker { font-weight: 800; color: var(--gof-primary-dark); }

.how-to-subhead {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.how-to-link {
  color: var(--gof-primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.how-to-link:hover { text-decoration: underline; }
.how-to-body ul { padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.5rem; }
.how-to-body strong { color: var(--text-primary); }

/* ===== Long-form guide ===== */
.guide {
  width: 100%;
  max-width: 640px;
  padding: 1.25rem 1.25rem 1.5rem;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.guide h2 {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.25;
  color: var(--text-primary);
  margin: 1.6rem 0 0.6rem;
}

.guide h2:first-child { margin-top: 0; }

.guide p { margin-bottom: 0.75rem; }
.guide strong { color: var(--text-primary); }
.guide em { font-style: italic; }

.guide-steps,
.guide-list {
  margin: 0 0 0.9rem;
  padding-left: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.guide-steps li::marker { font-weight: 700; color: var(--gof-primary-dark); }

/* Wide content scrolls inside its own box rather than the page. */
.guide-table-wrap {
  overflow-x: auto;
  margin: 0 0 0.9rem;
  -webkit-overflow-scrolling: touch;
}

.guide-table {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.guide-table th,
.guide-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.guide-table th {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--gof-bg-mint);
  white-space: nowrap;
}

.guide-table td + td,
.guide-table th + th { text-align: right; }

.guide-table tbody tr:last-child td {
  border-bottom: none;
  font-weight: 700;
  color: var(--text-primary);
}

.guide-faq { display: flex; flex-direction: column; gap: 0.4rem; }

.guide-faq details {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.guide-faq summary {
  list-style: none;
  padding: 0.65rem 0.85rem;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.guide-faq summary::-webkit-details-marker { display: none; }
.guide-faq summary::after { content: ' \25BE'; color: var(--text-secondary); font-size: 0.75rem; }
.guide-faq details[open] summary::after { content: ' \25B4'; }
.guide-faq summary:hover { background: var(--gof-bg-mint); }
.guide-faq details p { padding: 0 0.85rem 0.75rem; margin: 0; }

/* ===== Overlays (result + stats) ===== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(29, 26, 22, 0.55);
  overflow-y: auto;
}

.overlay.hidden { display: none; }

.overlay-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin: auto;
  padding: 1.5rem 1.25rem 1rem;
  text-align: center;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.32);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.overlay-card--wide { max-width: 400px; }

.close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.overlay-emoji { font-size: 2.4rem; line-height: 1; }

.overlay-title {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.45rem;
  color: var(--gof-primary-dark);
  line-height: 1.2;
}

.overlay-detail {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.15rem 0;
}

/* `display: flex` on these would otherwise beat the [hidden] attribute. */
.result-score[hidden],
.score-chip[hidden] { display: none; }

.result-score-value {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 3rem;
  line-height: 1;
  color: var(--text-primary);
}

.result-score-unit {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.result-verdict {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  line-height: 1.35;
  min-height: 2.4rem;
}

.result-verdict.is-best { color: #8a5a00; }

/* ===== Stats ===== */
.stats-scope {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.stat-cell {
  padding: 0.6rem 0.4rem;
  background: #f5f8fa;
  border-radius: 10px;
}

.stat-value {
  display: block;
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  line-height: 1.1;
  color: var(--text-primary);
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 0.1rem;
}

.stats-subhead {
  font-family: 'League Spartan', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: left;
  color: var(--text-primary);
  margin-top: 0.6rem;
}

.stats-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
  text-align: left;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: #f5f8fa;
}

.history-row.is-best { background: #fffdf3; border: 1px solid var(--gof-accent); }

.history-score {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-primary);
}

.history-note { flex: 1; font-size: 0.78rem; }
.history-date { font-size: 0.75rem; }

.stats-empty {
  padding: 0.9rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--gof-primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .tile-inner { transition: none; }
}
