/* Flag Fusion (flagfusion.io) — Atlas Vexillology Studio Design System
 * Original cartographic editorial aesthetic: Warm Archival Ivory + Maritime Navy + Signal Vermilion + Heraldic Gold.
 * Supports light/dark color schemes, 100dvh above-the-fold play, and WCAG AA accessibility.
 */

:root {
  --bg: #f6f4ed;
  --bg-elev: #ffffff;
  --bg-muted: #ece8dc;
  --bg-stage: #e9e4d5;
  --ink: #0f1e36;
  --ink-soft: #43536b;
  --ink-muted: #4b5b73;
  --border: #d5cfc0;
  --border-strong: #b8b09c;
  --accent: #c83328;
  --accent-hover: #a8271d;
  --accent-solid: #c83328;
  --accent-solid-hover: #a8271d;
  --accent-soft: #fdecea;
  --navy: #142a4c;
  --navy-hover: #1d3c6b;
  --navy-solid: #142a4c;
  --navy-solid-hover: #1d3c6b;
  --gold: #8c5d00;
  --gold-soft: #fef5e0;
  --success: #157a3c;
  --success-soft: #e6f6ec;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --shadow-sm: 0 2px 8px rgba(15, 30, 54, 0.06);
  --shadow-md: 0 10px 30px rgba(15, 30, 54, 0.11);
  --shadow-flag: 0 14px 36px rgba(15, 30, 54, 0.18), 0 2px 6px rgba(15, 30, 54, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-display: 'Segoe UI Variable Display', 'Trebuchet MS', 'Aptos', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Segoe UI Variable Text', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'SFMono-Regular', Consolas, monospace;
}

html[data-theme='dark'] {
  --bg: #0b1320;
  --bg-elev: #121e31;
  --bg-muted: #182740;
  --bg-stage: #0f1a2c;
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --ink-muted: #94a3b8;
  --border: #253652;
  --border-strong: #395075;
  --accent: #f87166;
  --accent-hover: #fca5a5;
  --accent-solid: #c83328;
  --accent-solid-hover: #b42b21;
  --accent-soft: rgba(239, 83, 71, 0.16);
  --navy: #60a5fa;
  --navy-hover: #93c5fd;
  --navy-solid: #1d4ed8;
  --navy-solid-hover: #1e40af;
  --gold: #f0b429;
  --gold-soft: rgba(240, 180, 41, 0.16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.15);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.15);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shadow-flag: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 64px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: clip;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Subtle archival cartographic dot grid on stage background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(rgba(15, 30, 54, 0.055) 1px, transparent 1px);
  background-size: 24px 24px;
}
html[data-theme='dark'] body::before {
  background-image: radial-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px);
}

/* Visually hidden utility (accessible skip link & SR text) */
.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 9999;
  background: var(--navy-solid);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
}

:where(a:any-link, button, input, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* === TOP BAR (Single-row, crisp, zero overflow) === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 20px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.mode-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-muted);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
}
.mode-nav::-webkit-scrollbar {
  display: none;
}

.mode-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.mode-nav a:hover {
  color: var(--ink);
  background: color-mix(in srgb, var(--bg-elev) 75%, transparent);
}

.mode-nav a[aria-current='page'] {
  background: var(--navy-solid);
  color: #ffffff;
}
html[data-theme='dark'] .mode-nav a[aria-current='page'] {
  background: var(--accent-solid);
  color: #ffffff;
}

.nav-pill-tag {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success);
}
.mode-nav a[aria-current='page'] .nav-pill-tag {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  padding: 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-muted);
}

/* === PLAY STAGE (Above-the-Fold 100dvh Arena) === */
main {
  flex: 1 0 auto;
}

.arena-shell {
  min-height: calc(100dvh - 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px 26px;
}

.arena-card {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.arena-hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.arena-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--ink);
}

.badge-accent {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
}

.badge-gold {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 35%, transparent);
  color: var(--gold);
}

.badge-success {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--success);
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
}

.hud-stat-chip {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Difficulty segmented picker (Unlimited / Fragments) */
.diff-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  flex-wrap: wrap;
  justify-content: center;
}

.diff-btn {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.diff-btn:hover {
  color: var(--ink);
}

.diff-btn[aria-pressed='true'] {
  background: var(--bg-elev);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Challenge / Archive context banner */
.context-banner {
  width: 100%;
  background: var(--gold-soft);
  border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.context-banner[hidden] {
  display: none;
}

/* === FLAG STAGE === */
.flag-stage {
  width: 100%;
  max-width: 520px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.flag-frame {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-stage);
  box-shadow: var(--shadow-flag);
  border: 2px solid color-mix(in srgb, var(--ink) 12%, transparent);
  position: relative;
}

.flag-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.flag-type-strip {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === FLAG PEEK (/peek/) CANVAS POKE-HOLE STAGE === */
.peek-canvas-wrap {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #0f1e36;
  box-shadow: var(--shadow-flag);
  border: 2px solid color-mix(in srgb, var(--ink) 16%, transparent);
  position: relative;
}

.peek-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.peek-meters {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.peek-meter {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1px;
}

.peek-meter-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.peek-meter-value {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.peek-meter.is-score .peek-meter-value {
  color: var(--accent);
}

/* === GUESS SLOTS GRID === */
.guess-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slots-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.slot-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.slot-status-tag {
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
}

.slot-box.is-solved .slot-status-tag {
  background: var(--success-soft);
  color: var(--success);
}

.slot-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.slot-input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 600;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.slot-input:focus {
  border-color: var(--navy);
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--navy) 22%, transparent);
}
html[data-theme='dark'] .slot-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

.slot-box.is-solved .slot-input {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
  font-weight: 800;
}

.slot-box.is-solved:has(.slot-solved-flag) .slot-input {
  padding-left: 44px;
}

.slot-solved-flag {
  position: absolute;
  left: 9px;
  width: 26px;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.slot-box.is-shake .slot-input {
  border-color: var(--accent);
  animation: ff-shake 0.34s ease;
}

.slot-box.is-misplaced .slot-input {
  border-color: var(--warn);
  background: var(--warn-soft);
  animation: ff-shake 0.34s ease;
}

@keyframes ff-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Autocomplete Dropdown — opens UPWARD above inputs so it NEVER covers Submit Guess or mobile keyboards */
.ac-list {
  position: absolute;
  bottom: calc(100% + 4px);
  top: auto;
  left: 0;
  right: 0;
  z-index: 80;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 215px;
  overflow-y: auto;
}

.ac-list[hidden] {
  display: none;
}

.ac-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.ac-item:hover,
.ac-item[aria-selected='true'] {
  background: var(--bg-muted);
}

.ac-flag {
  width: 24px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.ac-continent {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-weight: 600;
}

/* === ACTION ROW & LIVES METER === */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.lives-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.life-pips {
  display: inline-flex;
  gap: 5px;
}

.life-pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.2s ease, opacity 0.2s ease, background-color 0.2s ease;
}

.life-pip.is-spent {
  background: var(--border-strong);
  opacity: 0.45;
  transform: scale(0.8);
}

.btn-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 44px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent-solid);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--accent-solid-hover);
}

.btn-navy {
  background: var(--navy-solid);
  color: #ffffff;
}
.btn-navy:hover {
  background: var(--navy-solid-hover);
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--bg-muted);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.84rem;
}

.btn-full {
  width: 100%;
}

/* Feedback & "Did you mean?" strip */
.feedback-strip {
  width: 100%;
  min-height: 24px;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  text-align: center;
}

.feedback-strip.is-warn { color: var(--warn); }
.feedback-strip.is-error { color: var(--accent); }
.feedback-strip.is-success { color: var(--success); }

.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--ink);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.chip-btn:hover {
  background: var(--bg-muted);
}

/* === PROGRESSIVE 4-TIER HINTS PANEL === */
.hints-panel {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hints-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.hints-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.hint-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 0.8rem;
}

.hint-card-title {
  font-weight: 800;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.hint-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.hint-pill {
  font-size: 0.76rem;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg-muted);
  color: var(--ink-muted);
  border: 1px dashed var(--border-strong);
}

.hint-pill.is-open {
  background: var(--gold-soft);
  color: var(--ink);
  border-style: solid;
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  font-weight: 700;
}

/* Attempt log chips */
.attempt-log {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.attempt-chip {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
}
.attempt-chip.is-wrong { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.attempt-chip.is-misplaced { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.attempt-chip.is-solve { background: var(--success-soft); color: var(--success); border-color: transparent; }

/* Post-game inline banner for completed rounds */
.postgame-inline {
  width: 100%;
  background: var(--bg-elev);
  border: 2px solid var(--success);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.postgame-inline.is-loss {
  border-color: var(--accent);
}
.postgame-inline[hidden] {
  display: none;
}

/* === NATIVE <dialog> (Modern Web Guidance compliant) === */
dialog:modal {
  overscroll-behavior: contain;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  color: var(--ink);
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

dialog::backdrop {
  background: rgba(10, 18, 32, 0.65);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
}

.modal-body {
  padding: 16px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.decomp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.decomp-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.decomp-role {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.decomp-flag {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.decomp-name {
  font-weight: 800;
  font-size: 0.92rem;
}

.decomp-fact {
  font-size: 0.8rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.modal-cta-hero {
  background: linear-gradient(135deg, var(--navy), #1e40af);
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-cta-hero p {
  margin: 0;
  font-size: 0.88rem;
  opacity: 0.92;
}

.modal-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

/* === FUSION KITCHEN STUDIO (/kitchen/) === */
.kitchen-grid {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 20px;
  align-items: start;
}

.kitchen-panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.control-group label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.control-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 700;
}

/* === BELOW-THE-FOLD EDITORIAL SEO CONTENT === */
.seo-section {
  max-width: 980px;
  margin: 0 auto;
  padding: 36px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.seo-hero-block {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.seo-section h1 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.2vw, 2.25rem);
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  text-wrap: balance;
}

.seo-section h2 {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.2vw, 1.5rem);
  line-height: 1.25;
  margin: 0 0 10px;
  text-wrap: balance;
}

.seo-section h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 6px;
  text-wrap: balance;
}

.seo-section p,
.seo-section li {
  color: var(--ink-soft);
  font-size: 0.98rem;
  text-wrap: pretty;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.info-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.info-card p {
  margin: 0;
  font-size: 0.92rem;
}

.mini-flag-preview {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

/* Cheat sheet table */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elev);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg-muted);
  font-weight: 800;
  color: var(--ink);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

/* Native <details> FAQ accordion */
.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 16px;
}

.faq-item summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 800;
  color: var(--ink);
  font-size: 0.98rem;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-item p {
  margin: 0 0 14px;
  font-size: 0.94rem;
}

/* Archive Calendar Grid */
.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
}

.archive-tile {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-decoration: none;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.archive-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.archive-tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.archive-tile-date {
  font-weight: 800;
  font-size: 0.96rem;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--ink-muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.breadcrumb a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}
.breadcrumb a:hover {
  text-decoration: underline;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  padding: 28px 16px;
  margin-top: auto;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--ink);
  text-decoration: underline;
}

/* === RESPONSIVE & SHORT-SCREEN SAFETY === */
/* Order strictly wide-to-narrow so narrow rules always win! */
@media (max-width: 860px) {
  .kitchen-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .brand {
    order: 1;
    font-size: 0.96rem;
  }
  .brand-text {
    display: inline;
  }
  .topbar-tools {
    order: 2;
  }
  .mode-nav {
    order: 3;
    flex: 1 0 100%;
    justify-content: space-between;
    padding: 3px;
    gap: 2px;
  }
  .mode-nav a {
    flex: 1 1 auto;
    justify-content: center;
    padding: 5px 4px;
    font-size: 0.74rem;
    min-height: 32px;
  }
  .nav-pill-tag {
    display: none;
  }
  .icon-btn {
    min-width: 32px;
    min-height: 32px;
    padding: 4px;
  }
  .arena-shell {
    padding: 8px 12px 18px;
    justify-content: flex-start;
  }
  .arena-card {
    gap: 8px;
  }
  .flag-stage {
    max-width: 100%;
  }
  .slots-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .slot-input {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 16px; /* Prevents iOS auto-zoom */
  }
  .action-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .lives-wrap {
    justify-content: center;
  }
  .btn-group {
    width: 100%;
  }
  .btn-group .btn {
    flex: 1 1 auto;
    padding-inline: 10px;
    font-size: 0.84rem;
  }
  .peek-mode-bar {
    width: 100%;
  }
  .peek-mode-bar .diff-btn {
    flex: 1 1 auto;
    padding: 5px 8px;
    font-size: 0.76rem;
  }
  .peek-meter {
    padding: 4px 6px;
  }
  .peek-meter-value {
    font-size: 0.84rem;
  }
  .badge,
  .hud-stat-chip {
    font-size: 0.72rem;
    padding: 3px 8px;
  }
}

/* Wide short-viewport compaction FIRST */
@media (max-height: 700px) {
  .arena-shell {
    padding-top: 6px;
    padding-bottom: 12px;
    justify-content: flex-start;
  }
  .flag-stage {
    max-width: 310px;
  }
  .arena-card {
    gap: 6px;
  }
  .slot-input {
    min-height: 36px;
    padding: 6px 10px;
  }
  .btn {
    min-height: 36px;
    padding: 6px 14px;
  }
}

/* Narrow short-viewport compaction SECOND (never overridden by 700px!) */
@media (max-height: 620px) {
  .flag-stage {
    max-width: 225px;
  }
  .arena-card {
    gap: 5px;
  }
  .peek-meter {
    padding: 4px 6px;
  }
  .peek-meter-value {
    font-size: 0.82rem;
  }
  .hints-panel {
    padding: 7px 10px;
  }
}

@media (pointer: coarse) {
  .diff-btn,
  .chip-btn {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
