@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&family=Abril+Fatface&display=swap');

:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #f8f6f3;
  --bg-alt: #efecea;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --text: #0d0d0d;
  --text-secondary: #454545;
  --text-tertiary: #4a4a4a;
  --border: #e0dcd8;
  --border-light: #8f8b85;
  --accent: #9c2418;
  --accent-hover: #7e1d13;
  --accent-soft: rgba(156, 36, 24, 0.07);
  --btn-primary-text: #ffffff;
  --cell-white: #ffffff;
  --cell-black: #0d0d0d;
  --cell-selected: #f5c888;
  --cell-active: #f0d8a8;
  --cell-border: #8a8480;
  --correct: #18603a;
  --incorrect: #a90f1c;
  --revealed: #1d5286;
  --ink-color: #3a2820;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --color-error: #a32020;
  --color-success: #0f612f;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111111; --bg-alt: #191919; --surface: #1a1a1a; --surface-raised: #222;
    --text: #ededed; --text-secondary: #b5b5b5; --text-tertiary: #ababab;
    --border: #6b6b6b; --border-light: #8a8a8a;
    --accent: #ee8a82; --accent-hover: #f5a49d; --accent-soft: rgba(238, 138, 130, 0.12); --btn-primary-text: #161313;
    --cell-white: #1e1e1e; --cell-black: #090909;
    --cell-selected: #8a6a33; --cell-active: #7c6a3a; --cell-border: #7a7a7a;
    --correct: #4cb87a; --incorrect: #ed9f9f; --revealed: #7bb4e8; --ink-color: #d0b090;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2); --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
    --color-error: #f4a3a3;
    --color-success: #4ade80;
  }
}
:root[data-theme="dark"] {
  --bg: #111111; --bg-alt: #191919; --surface: #1a1a1a; --surface-raised: #222;
  --text: #ededed; --text-secondary: #b5b5b5; --text-tertiary: #ababab;
  --border: #6b6b6b; --border-light: #8a8a8a;
  --accent: #ee8a82; --accent-hover: #f5a49d; --accent-soft: rgba(238, 138, 130, 0.12); --btn-primary-text: #161313;
  --cell-white: #1e1e1e; --cell-black: #090909;
  --cell-selected: #8a6a33; --cell-active: #7c6a3a; --cell-border: #7a7a7a;
  --correct: #4cb87a; --incorrect: #ed9f9f; --revealed: #7bb4e8; --ink-color: #d0b090;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2); --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);
  --color-error: #f4a3a3;
  --color-success: #4ade80;
}
[data-colorblind="protanopia"] { --correct: #1d6fe0; --incorrect: #b45309; }
:root[data-theme="dark"][data-colorblind="protanopia"] { --correct: #7db4f0; --incorrect: #f5b078; }
[data-colorblind="deuteranopia"] { --correct: #1d6fe0; --incorrect: #b45309; }
:root[data-theme="dark"][data-colorblind="deuteranopia"] { --correct: #7db4f0; --incorrect: #f5b078; }
[data-colorblind="tritanopia"] { --correct: #dc2626; --incorrect: #0b6a82; }
:root[data-theme="dark"][data-colorblind="tritanopia"] { --correct: #f1a0a0; --incorrect: #74d0e8; }

.grid-sr-grid {
  position: absolute;
  inset: 0;
  display: grid;
}

.grid-sr-cell {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  pointer-events: none;
  outline: none;
  cursor: default;
}

/* hidden typing field so touch devices can summon the on-screen keyboard */
.grid-type-input {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 2px;
  height: 2px;
  padding: 0;
  border: 0;
  opacity: 0.01;
  background: transparent;
  color: transparent;
  caret-color: transparent;
}

.game-input-mode {
  display: flex;
  gap: 0.375rem;
  margin-top: 0.5rem;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
html { font-size: 100%; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.5; }

/* ====================== SKIP LINK ====================== */

.skip-link {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
  z-index: 10000; padding: 0.75rem 1.5rem;
  background: var(--accent); color: #fff;
  font-family: var(--font-body); font-size: 0.875rem;
  text-decoration: none;
}
.skip-link:focus {
  position: fixed; top: 0; left: 0;
  width: auto; height: auto;
}

/* ====================== APP SHELL ====================== */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.header {
  padding: 0.75rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  max-width: 68rem; width: 100%; margin: 0 auto;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-brand {
  font-family: var(--font-display); font-size: 1.125rem; font-weight: 700;
  color: var(--text); letter-spacing: -0.03em; text-transform: uppercase;
}
.header-streak {
  font-family: var(--font-mono); font-size: 0.625rem; font-weight: 500;
  color: var(--accent); letter-spacing: 0.1em; text-transform: uppercase;
}
.header-freeze {
  font-family: var(--font-mono); font-size: 0.625rem; font-weight: 500;
  color: #60a5fa; letter-spacing: 0.1em; text-transform: uppercase;
  cursor: default;
}
.header-actions { display: flex; align-items: center; gap: 0.375rem; }

.header-more-menu {
  position: absolute; top: 100%; right: 0; margin-top: 0.375rem;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); min-width: 10rem; z-index: 50;
  animation: popIn 0.15s var(--ease);
}

.header-menu-item {
  display: flex; align-items: center; gap: 0.5rem; width: 100%;
  padding: 0.5rem 0.75rem; background: none; border: none;
  border-bottom: 1px solid var(--border-light); cursor: pointer;
  font-family: var(--font-body); font-size: 0.75rem; color: var(--text);
  transition: background 150ms var(--ease); text-align: left;
}
.header-menu-item:last-child { border-bottom: none; }
.header-menu-divider { border-top: 1px solid var(--border); margin: 0.125rem 0; }
.header-menu-item:hover { background: var(--bg-alt); }

/* ====================== BUTTONS ====================== */

.btn {
  font-family: var(--font-body); font-size: 0.75rem; font-weight: 600;
  padding: 0.5rem 0.875rem; border-radius: 2px; letter-spacing: 0.03em;
  border: 1px solid var(--border); background: transparent; color: var(--text-secondary);
  cursor: pointer; transition: all 200ms var(--ease); text-transform: uppercase;
}
.btn:hover { color: var(--text); border-color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.3; cursor: default; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--btn-primary-text); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-sm { font-size: 0.625rem; padding: 0.5rem 0.75rem; min-height: 2.75rem; min-width: 2.75rem; }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { border-color: transparent; color: var(--accent); }
.btn-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-active:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ====================== WELCOME ====================== */

/* ====================== WELCOME - EDITORIAL LAYOUT ====================== */

.welcome {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 2rem 2rem 4rem; width: 100%; max-width: 52rem; margin: 0 auto;
}

/* masthead - newspaper nameplate */
.welcome-masthead { text-align: center; width: 100%; margin-bottom: 1.5rem; }
.welcome-rule {
  height: 2px; background: var(--text); width: 100%;
  margin: 0.25rem 0;
}
.welcome h1 {
  font-family: var(--font-display); font-size: 4rem; font-weight: 900;
  letter-spacing: -0.03em; line-height: 1; margin: 0.75rem 0 0.25rem;
  color: var(--text); text-transform: uppercase;
}
.welcome-edition {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.2em;
  color: var(--text-tertiary); margin: 0;
}
.welcome .welcome-sub {
  font-family: var(--font-display); font-size: 1rem; font-weight: 400;
  font-style: italic; color: var(--text-secondary);
  letter-spacing: 0.02em; margin: 0.375rem 0 1rem;
}

/* the daily five - cards */
.ed-feature { width: 100%; margin-bottom: 2rem; }
.ed-feature-header {
  text-align: center; margin-bottom: 1.25rem;
}
.ed-feature-title {
  font-family: var(--font-display); font-style: italic;
  font-size: 1.375rem; font-weight: 700; margin: 0;
  color: var(--text); letter-spacing: -0.01em;
}
.ed-feature-countdown {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin: 0.25rem 0 0;
}
.ed-countdown-time {
  font-weight: 600; color: var(--accent); letter-spacing: 0.06em;
}
.ed-flourish {
  font-size: 0.625rem; color: var(--text-tertiary);
  display: inline-block; margin: 0 0.5rem;
  vertical-align: middle; opacity: 0.5;
}
.ed-cards { display: flex; gap: 0; flex-wrap: wrap; justify-content: center; }
.ed-card {
  padding: 1.25rem 1.75rem; border: 1px solid var(--border); margin: -0.5px;
  background: var(--surface); cursor: pointer; transition: all 250ms var(--ease);
  text-align: center; min-width: 8rem;
  display: flex; flex-direction: column; align-items: center;
  animation: cardIn 0.5s var(--ease) both;
}
.ed-card:nth-child(1) { animation-delay: 0s; }
.ed-card:nth-child(2) { animation-delay: 0.06s; }
.ed-card:nth-child(3) { animation-delay: 0.12s; }
.ed-card:nth-child(4) { animation-delay: 0.18s; }
.ed-card:nth-child(5) { animation-delay: 0.24s; }
.ed-card:hover { background: var(--text); color: var(--bg); z-index: 1; }
.ed-card:hover .ed-card-name { color: inherit; }
.ed-card:hover .ed-card-desc { color: inherit; opacity: 0.6; }
.ed-card:hover .ed-card-icon { color: var(--bg); }
.ed-card:hover .ed-card-rating { color: inherit; opacity: 0.7; }
.ed-card-fav { }
.ed-card-fav .ed-card-icon { color: var(--accent); }
.ed-card-icon { color: var(--text-tertiary); margin-bottom: 0.25rem; transition: color 150ms; }
.ed-card-name {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  color: var(--text); letter-spacing: -0.02em;
}
.ed-card-desc {
  font-family: var(--font-mono); font-size: 0.5rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.12em; margin-top: 0.125rem;
}
.ed-card-rating {
  font-family: var(--font-mono); font-size: 0.5rem; color: #7a5b00;
  margin-top: 0.375rem; display: flex; align-items: center; gap: 0.2rem;
}
.wp-heart { color: #c53030; margin-left: 0.25rem; vertical-align: -1px; }
.ed-card-challenge-done { color: #d69e2e; margin-left: 0.25rem; vertical-align: -1px; }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* word of the day */
.ed-word {
  max-width: 32rem; margin: 0 auto 1.5rem;
  padding: 1.5rem 1.75rem;
  border: 2px solid var(--text);
  outline: 1px solid var(--text);
  outline-offset: 4px;
}
.ed-word-label {
  font-family: var(--font-mono); font-size: 0.5rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--accent); margin-bottom: 0.625rem;
}
.ed-word-content {
  display: flex; align-items: flex-start; gap: 1.25rem;
}
.ed-word-left { flex-shrink: 0; }
.ed-word-term {
  font-family: var(--font-display); font-size: 1.75rem; font-weight: 900;
  color: var(--text); letter-spacing: 0.04em;
  margin: 0; line-height: 1; text-transform: uppercase;
}
.ed-word-length {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.1em; display: block; margin-top: 0.25rem;
}
.ed-word-divider {
  width: 1px; align-self: stretch;
  background: var(--border); flex-shrink: 0;
}
.ed-word-right { flex: 1; min-width: 0; }
.ed-word-meaning {
  font-family: var(--font-display); font-style: italic;
  font-size: 0.875rem; color: var(--text-secondary);
  line-height: 1.6; margin: 0 0 0.375rem;
}
.ed-word-clue {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); margin: 0;
}

/* accordion drawers */
.ed-drawers { width: 100%; margin-top: 0.5rem; }
.ed-drawer { }
.ed-drawer-toggle {
  display: flex; align-items: center;
  width: 100%; padding: 1rem 0; cursor: pointer;
  gap: 0.75rem;
}
.ed-drawer-toggle::before {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.ed-drawer-toggle::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}
.ed-drawer-toggle:hover h2 { color: var(--accent); }
.ed-drawer-toggle:hover::before,
.ed-drawer-toggle:hover::after { background: var(--accent); opacity: 0.3; }
.ed-drawer-toggle h2 {
  font-family: var(--font-mono); font-size: 0.563rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.15em;
  margin: 0; transition: color 150ms;
  display: flex; align-items: center; gap: 0.375rem;
  color: var(--text-tertiary); flex-shrink: 0;
  white-space: nowrap;
}
.ed-drawer-badge {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--accent); font-weight: 600;
  min-width: 1.25rem; height: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--accent); flex-shrink: 0;
}
.ed-drawer-chevron {
  color: var(--text-tertiary); transition: transform 200ms;
  flex-shrink: 0;
}
.ed-drawer-inner { padding: 0 0 1.25rem; text-align: center; }

/* community puzzle grid */
.ed-puzzle-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem; padding-bottom: 0.75rem;
}
.ed-puzzle-card {
  display: flex; flex-direction: column;
  padding: 0.875rem 1rem; text-align: left;
  border: 1px solid var(--border);
  cursor: pointer; transition: all 200ms var(--ease);
  position: relative;
}
.ed-puzzle-card:hover { border-color: var(--text); }
.ed-puzzle-size {
  font-family: var(--font-mono); font-size: 1.25rem;
  font-weight: 500; color: var(--border); letter-spacing: 0.04em;
  line-height: 1; margin-bottom: 0.375rem;
  transition: color 200ms;
}
.ed-puzzle-card:hover .ed-puzzle-size { color: var(--accent); }
.ed-puzzle-title {
  font-family: var(--font-display); font-style: italic;
  font-size: 0.875rem; font-weight: 600; color: var(--text);
  line-height: 1.3; margin-bottom: 0.25rem;
}
.ed-puzzle-by {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: auto;
}
.ed-puzzle-report {
  position: absolute; top: 0.125rem; right: 0.125rem;
}
.ed-puzzle-report .report-btn { padding: 0.375rem; }

/* custom puzzle rich selects */
.ed-selects {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.ed-rich-select { flex: 1; min-width: 8rem; }
.ed-select-label {
  font-family: var(--font-mono); font-size: 0.5rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent); display: block; margin-bottom: 0.25rem;
}
.ed-rich-trigger {
  display: flex; align-items: center; gap: 0.375rem;
  width: 100%; padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text); cursor: pointer;
  transition: border-color 150ms var(--ease);
}
.ed-rich-trigger:hover { border-color: var(--text); }
.ed-rich-trigger-icon { color: var(--accent); flex-shrink: 0; }
.ed-rich-trigger-label { flex: 1; text-align: left; }
.ed-rich-trigger-chevron {
  color: var(--text-tertiary); flex-shrink: 0;
  transition: transform 200ms;
}

/* rich dropdown portal */
.ed-rich-dropdown {
  position: fixed; z-index: 9998;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-height: 22rem; overflow-y: auto;
  max-width: min(26rem, calc(100vw - 2rem));
}
.ed-rich-option {
  display: flex; align-items: flex-start; justify-content: space-between;
  width: 100%; padding: 0.75rem 1rem; gap: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  text-align: left; cursor: pointer;
  transition: background 100ms var(--ease);
}
.ed-rich-option:last-child { border-bottom: none; }
.ed-rich-option:hover { background: var(--bg-alt); }
.ed-rich-option-on { background: var(--accent-soft); }
.ed-rich-option-on:hover { background: var(--accent-soft); }
.ed-rich-option-left {
  display: flex; align-items: flex-start; gap: 0.75rem;
  flex: 1; min-width: 0;
}
.ed-rich-option-icon {
  color: var(--accent); flex-shrink: 0; margin-top: 0.1875rem;
}
.ed-rich-option-name {
  font-family: var(--font-display); font-size: 0.9375rem;
  font-weight: 700; color: var(--text); display: block;
  letter-spacing: -0.01em;
}
.ed-rich-option-desc {
  font-family: var(--font-body); font-size: 0.6875rem;
  color: var(--text-tertiary); display: block;
  margin-top: 0.1875rem; line-height: 1.5;
}
.ed-rich-option-on .ed-rich-option-desc { color: var(--text-secondary); }
.ed-rich-option-check { color: var(--accent); flex-shrink: 0; margin-top: 0.1875rem; }
.ed-generate-row { display: flex; gap: 0; margin-top: 0.75rem; }
.ed-generate-btn {
  flex: 1; padding: 0.625rem 0.5rem;
  border: 1px solid var(--border); margin: -0.5px;
  cursor: pointer; transition: all 200ms var(--ease); text-align: center;
}
.ed-generate-btn:hover { background: var(--text); color: var(--bg); z-index: 1; }
.ed-generate-btn:hover .ed-gen-name { color: inherit; }
.ed-generate-btn:hover .ed-gen-meta { color: inherit; opacity: 0.6; }
.ed-generate-btn:disabled { opacity: 0.4; pointer-events: none; }
.ed-gen-name {
  font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700; color: var(--text); display: block;
  letter-spacing: -0.02em;
}
.ed-gen-meta {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.12em; display: block; margin-top: 0.125rem;
}

.customize-explainer { overflow: hidden; }
.customize-explainer p {
  font-family: var(--font-body); font-size: 0.688rem;
  color: var(--text-tertiary); line-height: 1.5; padding: 0.25rem 0;
}
.theme-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.theme-chip {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.2rem 0.5rem; transition: all 150ms var(--ease);
}
.theme-chip:hover { border-color: var(--text); color: var(--text); }
.theme-chip-active { background: var(--text); color: var(--bg); border-color: var(--text); }
.theme-chip-active:hover { background: var(--text-secondary); border-color: var(--text-secondary); color: var(--bg); }
.theme-chips-wrap { max-width: 28rem; }

.welcome-import-btn {
  display: inline-flex; align-items: center; gap: 0.375rem;
  margin: 0.75rem 0 0; padding: 0.375rem 0.625rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  border: 1px solid var(--border);
  color: var(--text-tertiary); cursor: pointer; transition: all 200ms var(--ease);
}
.welcome-import-btn:hover { border-color: var(--text); color: var(--text); }
.welcome-import-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ====================== ACTIVE CLUE ====================== */

.active-clue-banner {
  display: block; width: 100%; max-width: 68rem; text-align: center;
  padding: 1rem 2rem; cursor: pointer; transition: all 200ms var(--ease);
  border-bottom: 1px solid var(--border);
}
.active-clue-banner:hover { background: var(--accent-soft); }
.active-clue-banner .clue-direction {
  font-family: var(--font-mono); font-size: 0.563rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.2em; color: var(--accent);
  margin-bottom: 0.375rem;
}
.active-clue-banner .clue-text {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 500;
  font-style: italic; color: var(--text); line-height: 1.3;
  min-height: 2rem;
}

/* ====================== GAME LAYOUT ====================== */

.main-content {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 0; gap: 0;
}

.game-area {
  display: flex; gap: 0; width: 100%; max-width: 68rem; align-items: stretch;
}

.grid-column {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  flex: 1; min-width: 0; padding: 2rem;
}

.grid-wrapper {
  position: relative; display: inline-block;
  box-shadow: var(--shadow-md); overflow: hidden;
  animation: gridReveal 0.5s var(--ease);
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.grid-wrapper svg { touch-action: manipulation; }
.grid-wrapper:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
@keyframes gridReveal {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

/* ====================== INFO BAR ====================== */

.info-bar {
  display: flex; align-items: center; justify-content: center;
  width: 100%; max-width: 36rem; padding: 0.5rem 0;
  border-top: 1px solid var(--border-light); gap: 0.25rem;
  flex-wrap: wrap;
}
.info-bar-sep {
  width: 1px; height: 1rem; background: var(--border-light);
  margin: 0 0.125rem; flex-shrink: 0;
}
.btn-icon {
  padding: 0.375rem; min-width: 2.25rem; min-height: 2.25rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.timer {
  font-family: var(--font-mono); font-size: 0.875rem; font-weight: 500;
  color: var(--text-tertiary); letter-spacing: 0.08em; font-variant-numeric: tabular-nums;
}
.timer-warning { color: var(--color-error); animation: pulse 1s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.marathon-count {
  font-size: 0.625rem; color: var(--text-tertiary); margin-left: 0.5rem;
}
.hints-used {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ====================== CLUE PANEL ====================== */

.clue-panel {
  width: 20rem; flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  max-height: 32rem;
  align-self: start;
}

.clue-tabs { display: flex; border-bottom: 1px solid var(--border); }
.clue-tab {
  flex: 1; padding: 1rem; border: none; background: transparent;
  font-family: var(--font-mono); font-size: 0.563rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.2em; color: var(--text-tertiary);
  cursor: pointer; transition: color 200ms; position: relative;
}
.clue-tab.active { color: var(--text); }
.clue-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; background: var(--accent);
}

.clue-list { flex: 1; overflow-y: auto; }

.clue-item {
  width: 100%; padding: 0.625rem 1.25rem; display: flex; gap: 0.75rem; cursor: pointer;
  transition: all 150ms var(--ease); border-bottom: 1px solid var(--border-light);
  text-align: left;
}
.clue-item:hover { background: var(--bg-alt); }
.clue-item.active { background: var(--accent-soft); }
.clue-item .clue-num {
  font-family: var(--font-display); font-size: 0.875rem; font-weight: 700;
  color: var(--text); min-width: 1.5rem;
}
.clue-item .clue-text { font-size: 0.813rem; line-height: 1.5; color: var(--text-secondary); flex: 1; }
.clue-item.active .clue-text { color: var(--text); }

.clue-panel-solved {
  transition: all 0.3s var(--ease);
}

.clue-suggest-btn {
  background: none; border: none; cursor: pointer; padding: 0.125rem;
  color: var(--text-tertiary); flex-shrink: 0;
}
.clue-suggest-btn:hover { color: var(--text); }

.clue-submitted {
  color: var(--color-success); flex-shrink: 0;
}

.clue-suggest-form {
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-alt);
}
.clue-suggest-word {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); display: block; margin-bottom: 0.375rem;
}
.clue-suggest-form input {
  width: 100%; padding: 0.375rem 0.5rem; margin-bottom: 0.375rem;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-family: var(--font-body); font-size: 0.75rem;
}
.clue-suggest-actions {
  display: flex; gap: 0.25rem; justify-content: flex-end;
}

.clue-hidden {
  color: var(--border); font-style: italic; letter-spacing: 0.2em;
}

.clue-wordplay-tag {
  display: inline-block; margin-left: 0.5rem;
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); border: 1px solid var(--border-light);
  padding: 0.0625rem 0.375rem; vertical-align: 1px;
}

/* ====================== LOADING ====================== */

.loading-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; backdrop-filter: blur(8px); animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.loading-card {
  background: var(--surface); padding: 2.5rem 4rem; text-align: center;
  animation: popIn 0.3s var(--ease);
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.loading-card .spinner {
  width: 1.5rem; height: 1.5rem; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-card p {
  font-family: var(--font-display); font-size: 0.875rem; font-style: italic;
  color: var(--text-secondary);
}

/* ====================== LEADERBOARD ====================== */

.leaderboard {
  width: 100%; max-width: 28rem; margin: 0 auto;
  padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
}
.leaderboard-header {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-bottom: 0.5rem;
}
.leaderboard-list {
  display: flex; flex-direction: column; gap: 2px;
}
.leaderboard-row {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text-secondary); padding: 0.2rem 0;
}
.leaderboard-top { color: var(--text); }
.leaderboard-rank {
  width: 1.5rem; text-align: center; flex-shrink: 0;
  font-size: 0.688rem;
}
.leaderboard-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.leaderboard-time {
  font-family: var(--font-mono); font-size: 0.688rem;
  display: flex; align-items: center; gap: 3px;
  color: var(--text-tertiary);
}
.leaderboard-hints {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
  display: flex; align-items: center; gap: 2px;
}
.leaderboard-you {
  margin-top: 0.5rem; padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-secondary); text-align: center;
}

/* ====================== LEADERBOARD MODAL ====================== */

.lb-modal {
  background: var(--bg); border: 1px solid var(--border);
  width: 90%; max-width: 36rem; max-height: 85vh;
  overflow-y: auto; padding: 0;
}
.lb-top {
  padding: 1.25rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.lb-title-row {
  display: flex; justify-content: space-between; align-items: center;
}
.lb-title {
  font-family: var(--font-display); font-size: 1.125rem;
  font-weight: 700; font-style: italic;
  margin: 0; color: var(--text);
}
.lb-subtitle {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--text-tertiary); margin: 0.25rem 0 0;
}

.lb-controls {
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.lb-tabs {
  display: flex; gap: 0;
  border: 1px solid var(--border);
}
.lb-tab {
  flex: 1; background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); padding: 0.5rem 0.25rem;
  transition: all 150ms var(--ease);
  display: flex; align-items: center; justify-content: center;
  white-space: nowrap;
}
.lb-tab:hover { color: var(--text-secondary); }
.lb-tab-active {
  background: var(--text); color: var(--bg);
}
.lb-tab-active:hover { color: var(--bg); }
.lb-tab + .lb-tab { border-left: 1px solid var(--border); }

.lb-presets {
  display: flex; gap: 0.25rem; justify-content: center;
}
.lb-preset {
  background: none; border: 1px solid var(--border);
  cursor: pointer; font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); padding: 0.25rem 0.5rem;
  transition: all 150ms var(--ease);
}
.lb-preset:hover { border-color: var(--text-secondary); color: var(--text-secondary); }
.lb-preset-active { background: var(--text); color: var(--bg); border-color: var(--text); }

.lb-table { padding: 0; min-height: 22rem; }
.lb-table-header {
  display: flex; align-items: center; gap: 0;
  padding: 0.625rem 1.5rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-tertiary);
}

.lb-row {
  display: flex; align-items: center; gap: 0;
  padding: 0.5rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text-secondary);
  transition: background 150ms var(--ease);
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: var(--bg-alt); }
.lb-row-top { color: var(--text); font-weight: 500; }
.lb-row-empty { color: var(--text-tertiary); opacity: 0.4; }
.lb-row-empty:hover { background: none; }

.lb-col-rank {
  width: 2rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.lb-col-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 0.5rem;
}
.lb-col-instance {
  width: 5rem; flex-shrink: 0;
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb-col-time {
  width: 4rem; flex-shrink: 0; text-align: right;
  font-family: var(--font-mono); font-size: 0.75rem;
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  color: var(--text-tertiary); padding-right: 0.5rem;
}
.lb-col-hints {
  width: 2.5rem; flex-shrink: 0; text-align: right;
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
  display: flex; align-items: center; justify-content: flex-end; gap: 2px;
}

.lb-rank-num {
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 500; color: var(--text-tertiary);
}
.lb-rank-dim { opacity: 0.35; }
.lb-empty-dash {
  color: var(--text-tertiary); opacity: 0.25;
  font-family: var(--font-mono);
}

.lb-loading {
  display: flex; justify-content: center; padding: 1rem 0;
}

.lb-date-input {
  background: var(--bg); border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-secondary); padding: 0.25rem 0.375rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  cursor: pointer; color-scheme: dark;
}
.lb-date-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.lb-clean-toggle {
  display: flex; align-items: center; gap: 0.375rem;
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); cursor: pointer;
}
.lb-clean-toggle input[type="checkbox"] {
  width: 12px; height: 12px; margin: 0; cursor: pointer;
  accent-color: var(--text);
}

.lb-col-date {
  width: 4.5rem; flex-shrink: 0; text-align: right;
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
}

/* ====================== BANNERS ====================== */

.solved-banner {
  width: 100%; text-align: center; padding: 1rem 2rem;
  background: var(--surface); color: var(--text);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  animation: solvedIn 0.5s var(--ease);
}
.challenge-banner {
  width: 100%; text-align: center; padding: 0.625rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
  display: flex; flex-direction: column; gap: 0.125rem;
}
.challenge-banner-title {
  font-family: var(--font-mono); font-size: 0.688rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary);
}
.challenge-banner-desc {
  font-family: var(--font-body); font-size: 0.6875rem;
  color: var(--text-tertiary);
}
.challenge-result {
  text-align: center; padding: 0.5rem 1rem;
  font-family: var(--font-mono); font-size: 0.688rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-light);
}
.challenge-success { color: #22c55e; }
.challenge-failed { color: var(--text-tertiary); }
.post-solve-actions {
  display: flex; justify-content: center; padding: 0.375rem;
  border-bottom: 1px solid var(--border-light);
}
.solve-heatmap {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem; gap: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
.solve-heatmap-title {
  font-family: var(--font-mono); font-size: 0.625rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin: 0;
}
.solve-heatmap-grid { display: block; }
.solve-heatmap-legend {
  display: flex; gap: 1rem; font-family: var(--font-mono);
  font-size: 0.563rem; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-secondary);
}
.solve-heatmap-legend span { display: flex; align-items: center; gap: 0.25rem; }
.heatmap-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
}
.puzzle-rating {
  display: flex; align-items: center; justify-content: center;
  gap: 0.75rem; padding: 0.625rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border-light);
}

.rating-label {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.rating-stars { display: flex; gap: 0.125rem; }

.rating-star {
  background: none; border: none; cursor: pointer; padding: 0.5rem;
  min-width: 2.75rem; min-height: 2.75rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--border); transition: color 150ms var(--ease), transform 150ms var(--ease);
}
.rating-star:hover { transform: scale(1.2); }
.rating-star-active { color: #fbbf24; }

.rating-info {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}

.solved-rank {
  display: block; font-family: var(--font-mono); font-size: 0.688rem;
  color: var(--text-secondary); margin-top: 0.25rem;
  font-weight: 400; text-transform: none; letter-spacing: 0;
}
.solved-hint {
  display: block; font-family: var(--font-body); font-size: 0.625rem;
  font-weight: 400; text-transform: none; letter-spacing: 0;
  color: var(--text-secondary); margin-top: 0.375rem;
}
.share-result-btn {
  display: inline-flex; align-items: center; gap: 4px;
  margin: 0.5rem auto 0; text-transform: none; letter-spacing: 0;
  font-family: var(--font-body); font-weight: 500; font-size: 0.75rem;
}
.error-banner {
  width: 100%; padding: 0.75rem 2rem; background: var(--incorrect); color: #fff;
  font-size: 0.813rem; text-align: center;
}

/* ====================== NEW GAME PANEL ====================== */

.new-game-panel {
  position: absolute; top: 100%; right: 0; margin-top: 0.5rem; padding: 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); z-index: 100; min-width: 18rem;
  animation: panelDrop 0.2s var(--ease);
}
@keyframes panelDrop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.new-game-panel h3 {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem;
}
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin-bottom: 1rem; }
.preset-card {
  padding: 0.75rem; border: 1px solid var(--border);
  background: transparent; cursor: pointer; transition: all 200ms var(--ease); text-align: center;
}
.preset-card:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.preset-card:hover .preset-name, .preset-card:hover .preset-desc { color: inherit; }
.preset-card .preset-name { font-family: var(--font-display); font-weight: 700; font-size: 0.875rem; color: var(--text); }
.preset-card .preset-desc { font-family: var(--font-mono); font-size: 0.563rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.1em; }
.custom-section { border-top: 1px solid var(--border); padding-top: 1rem; }
.custom-section h4 {
  font-family: var(--font-mono); font-size: 0.563rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-tertiary); margin-bottom: 0.75rem;
}
.custom-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.625rem; }
.custom-row label { font-size: 0.75rem; color: var(--text-secondary); min-width: 4rem; }
.custom-row select, .custom-row input[type="range"] { flex: 1; }
select {
  font-family: var(--font-body); font-size: 0.75rem; padding: 0.375rem 0.5rem;
  border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="range"] { accent-color: var(--accent); }
.custom-row .range-value { font-family: var(--font-mono); font-size: 0.625rem; color: var(--text-tertiary); min-width: 2rem; text-align: right; }

/* ====================== ZOOM STRIP ====================== */

.zoom-strip { position: relative; }

.zoom-tile {
  background: var(--cell-white);
  border: 1px solid var(--cell-border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  outline: 1px solid transparent; /* anti-aliasing during animation */
  -webkit-font-smoothing: antialiased;
}

.zoom-tile-rec {
  animation: fadeIn 0.15s ease;
}
.zoom-letter { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 500; user-select: none; color: var(--text); }
.zoom-num { position: absolute; top: 4px; left: 6px; font-family: var(--font-mono); font-size: 0.563rem; color: var(--text-tertiary); z-index: 1; user-select: none; }
.zoom-num-sm { position: absolute; top: 2px; left: 3px; font-family: var(--font-mono); font-size: 0.438rem; color: var(--text-tertiary); user-select: none; }
.ink-overlay {
  cursor: crosshair;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  contain: strict;
}
.scribble-trap {
  position: absolute; top: 0; left: 0; width: 1px; height: 1px;
  opacity: 0; padding: 0; margin: 0; border: none; resize: none;
  pointer-events: none; z-index: -1;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  font-size: 16px;
  caret-color: transparent;
}
.grid-wrapper.stylus-active,
.grid-wrapper.stylus-active * {
  user-select: none !important; -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  touch-action: none !important;
  -webkit-tap-highlight-color: transparent;
}
.grid-wrapper.stylus-active {
  contain: layout style;
  overflow: clip;
}
.grid-wrapper.stylus-active svg {
  touch-action: none !important;
  pointer-events: none !important;
}

/* ====================== MODALS ====================== */

.disambiguation {
  display: flex; gap: 3px; padding: 5px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-lg); z-index: 10;
}
.disambiguation-btn {
  width: 2.75rem; height: 2.75rem; border: 1px solid var(--border);
  background: transparent; color: var(--text); font-family: var(--font-mono);
  font-size: 0.875rem; font-weight: 500; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 150ms;
}
.disambiguation-btn:hover { background: var(--text); color: var(--bg); }
.disambiguation-btn.dismiss { font-size: 0.625rem; color: var(--text-tertiary); }

.settings-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; backdrop-filter: blur(8px); animation: fadeIn 0.15s;
}
.settings-panel {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 2rem; min-width: 20rem;
  max-width: 32rem; width: 90%; max-height: 90vh; overflow-y: auto;
  animation: popIn 0.25s var(--ease);
}
.settings-panel-tabs {
  max-width: 36rem; width: 95%; padding: 0; display: flex; flex-direction: column;
  max-height: 90vh;
}
.settings-panel-tabs .settings-header {
  padding: 1.25rem 1.5rem; margin-bottom: 0;
  border-bottom: 1px solid var(--border-light);
}
.settings-body {
  display: flex; flex-direction: row; flex: 1; min-height: 0;
}
.settings-sidebar {
  width: 8rem; flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 0.5rem 0;
  overflow-y: auto;
}
.settings-sidebar-tab {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary);
  transition: all 150ms var(--ease);
  text-align: left;
}
.settings-sidebar-tab:hover { color: var(--text-secondary); background: var(--bg-alt); }
.settings-sidebar-tab-active {
  color: var(--text); background: var(--bg-alt);
  border-right: 2px solid var(--text);
}
.settings-content {
  flex: 1; overflow-y: auto; padding: 1.25rem;
}
.settings-danger {
  border-top: 1px solid var(--color-error);
  padding-top: 1rem;
}
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.settings-header h3 { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.settings-section { margin-bottom: 1.25rem; }
.settings-section-heading {
  font-size: 0.688rem; font-weight: 600; color: var(--text);
  letter-spacing: 0.08em; margin-bottom: 0.375rem;
}
.settings-divider {
  height: 1px; background: var(--border-light); margin: 1rem 0;
}
.settings-sublabel {
  display: block; font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-bottom: 0.375rem;
}
.settings-range { width: 100%; accent-color: var(--accent); }
.settings-range-labels {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); margin-top: 0.125rem;
}
.settings-narrator-controls { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-narrator-detail { display: flex; flex-direction: column; gap: 0.75rem; padding-top: 0.5rem; }
.settings-narrator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.settings-narrator-item { display: flex; flex-direction: column; gap: 0.25rem; }
.settings-label {
  display: block; font-family: var(--font-mono); font-size: 0.563rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.15em; color: var(--text-tertiary); margin-bottom: 0.5rem;
}
.settings-row { display: flex; align-items: center; gap: 0.25rem; }
.settings-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.25rem; }

/* ====================== CELL FLIP ====================== */

.flip-scene {
  perspective: 500px;
  pointer-events: none;
  z-index: 2;
}

/* black backing behind the tile, visible while it rotates */
.flip-backing {
  position: absolute;
  inset: 0;
  background: var(--cell-black);
}

.flip-card {
  width: 100%;
  height: 100%;
  position: relative;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  will-change: transform;
}

.flip-card-animate {
  animation: flipReveal 0.5s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}

@keyframes flipReveal {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}

.flip-face {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  outline: 1px solid transparent;
}

/* front face: shows old content, faces viewer at start */
.flip-front {
  background: var(--cell-selected);
  border: 1px solid var(--cell-border);
}

/* back face: shows new letter, pre-rotated 180deg so it faces viewer at end */
.flip-back {
  background: var(--cell-selected);
  border: 1px solid var(--cell-border);
  transform: rotateY(180deg);
}

.flip-num {
  position: absolute;
  top: 2px;
  left: 3px;
  font-family: var(--font-body);
  color: var(--text-tertiary);
  line-height: 1;
}

.flip-letter {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

/* ====================== KEYBOARD SHORTCUTS ====================== */

.sk-modal {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 92%; max-width: 28rem;
}
.sk-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.5rem 1.5rem 1rem;
}
.sk-title {
  font-family: var(--font-display); font-style: italic;
  font-size: 1.125rem; font-weight: 700; margin: 0;
  letter-spacing: -0.01em;
}
.sk-subtitle {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-tertiary); margin: 0.25rem 0 0;
}
.sk-body {
  padding: 0 1.5rem 1.5rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.sk-section { }
.sk-section-title {
  font-family: var(--font-mono); font-size: 0.5rem;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.15em; color: var(--accent);
  margin: 0 0 0.625rem; padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-light);
}
.sk-grid {
  display: flex; flex-direction: column; gap: 0.25rem;
}
.sk-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.375rem 0.5rem;
  transition: background 100ms;
}
.sk-row:hover { background: var(--bg-alt); }
.sk-keys {
  display: flex; align-items: center; gap: 0.25rem;
  min-width: 9rem; flex-shrink: 0;
  font-size: 0.75rem; color: var(--text-tertiary);
}
.sk-desc {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text-secondary);
}
.sk-row kbd {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 0.625rem; font-weight: 500;
  min-width: 1.5rem; padding: 0.1875rem 0.375rem;
  background: var(--bg); border: 1px solid var(--border);
  border-bottom-width: 2px; color: var(--text);
  line-height: 1; white-space: nowrap;
}
@media (max-width: 24rem) {
  .sk-modal { max-width: 100%; }
  .sk-keys { min-width: 7rem; }
}

/* ====================== ACHIEVEMENTS ====================== */

.achievements-panel {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  min-width: 22rem; max-width: 28rem; width: 92%;
  max-height: 90vh; overflow: hidden;
  display: flex; flex-direction: column;
  animation: popIn 0.25s var(--ease);
}

.ach-sticky-header {
  padding: 1.5rem; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 0;
}

.ach-count {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary); margin-left: 0.5rem;
  letter-spacing: 0.05em;
}

.ach-grid {
  display: flex; flex-direction: column; gap: 0.5rem;
  overflow-y: auto; padding: 0.75rem 1.5rem 1.5rem;
}

.ach-badge {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border-light);
  transition: all 200ms var(--ease);
}

.ach-badge:hover { background: var(--bg-alt); }

.ach-unlocked .ach-icon {
  width: 2.25rem; height: 2.25rem;
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex-shrink: 0;
}

.ach-locked {
  opacity: 0.35;
}

.ach-locked .ach-icon {
  width: 2.25rem; height: 2.25rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-alt); color: var(--text-tertiary);
  flex-shrink: 0;
}

.ach-name {
  font-family: var(--font-display); font-size: 0.813rem;
  font-weight: 700; color: var(--text);
}

.ach-desc {
  font-size: 0.688rem; color: var(--text-tertiary);
  font-family: var(--font-body);
}

/* ====================== ONBOARDING ====================== */

.onboarding-panel {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 2rem;
  min-width: 20rem; max-width: 28rem; width: 92%;
  animation: popIn 0.25s var(--ease);
}

.onboarding-panel h2 {
  font-family: var(--font-display); font-size: 1.5rem;
  font-weight: 700; margin-bottom: 1.5rem; text-align: center;
}

.onboard-section {
  margin-bottom: 1.25rem;
}

.onboard-section h4 {
  font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700; margin-bottom: 0.375rem;
}

.onboard-section p {
  font-size: 0.75rem; color: var(--text-secondary);
  line-height: 1.5; font-family: var(--font-body);
}

.onboard-icon {
  float: left; margin-right: 0.75rem; margin-top: 0.125rem;
  color: var(--text-tertiary);
}

.onboard-divider {
  border-top: 1px solid var(--border-light);
  margin: 1.25rem 0; clear: both;
}

.onboard-username {
  width: 100%; padding: 0.5rem 0.75rem;
  font-family: var(--font-body); font-size: 0.875rem;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text); margin-bottom: 0.25rem;
  transition: border-color 150ms var(--ease);
}
.onboard-username:focus {
  outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--text);
}
.onboard-username::placeholder {
  color: var(--text-tertiary); font-style: italic;
}

.onboard-actions {
  display: flex; gap: 0.75rem; justify-content: stretch;
  align-items: stretch; margin-top: 1.5rem; clear: both;
}

.onboard-start-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 3rem; font-size: 0.875rem;
}

.onboard-import-btn {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 0; min-height: 3rem; padding: 0.5rem 0.75rem;
}
.onboard-import-text {
  display: flex; flex-direction: column; line-height: 1.3;
  text-align: left; font-size: 0.688rem;
}

.onboard-success {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--color-success); text-transform: uppercase;
  letter-spacing: 0.1em;
}

.onboard-error {
  font-size: 0.75rem; color: var(--color-error);
  margin-bottom: 0.5rem;
}

/* ====================== SETTINGS EXTRAS ====================== */

.settings-hint {
  font-size: 0.625rem; color: var(--text-tertiary);
  font-family: var(--font-body); margin-top: 0.375rem;
  line-height: 1.5;
}

.passkey-list {
  display: flex; flex-direction: column; gap: 0.375rem;
}

.passkey-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.625rem; border: 1px solid var(--border-light);
  font-size: 0.75rem; font-family: var(--font-body);
}

.passkey-date {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary);
}

.welcome-passkey {
  margin-top: 2rem; text-align: center;
}

/* ====================== COMMUNITY CLUES ====================== */

.community-panel {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 1.5rem;
  min-width: 22rem; max-width: 30rem; width: 92%;
  max-height: 90vh; overflow-y: auto;
  animation: popIn 0.25s var(--ease);
}

.cc-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; }

.cc-word-select { margin-bottom: 1rem; }
.cc-word-select select { width: 100%; }

.cc-submit-row {
  display: flex; gap: 0.375rem; margin-bottom: 1rem;
}
.cc-submit-row input {
  flex: 1; padding: 0.375rem 0.5rem;
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-family: var(--font-body); font-size: 0.75rem;
}

.cc-list { display: flex; flex-direction: column; gap: 0.375rem; }

.cc-empty {
  text-align: center; padding: 1.5rem; color: var(--text-tertiary);
  font-size: 0.75rem; font-family: var(--font-body);
}

.cc-clue {
  padding: 0.5rem 0.625rem; border: 1px solid var(--border-light);
  transition: background 200ms var(--ease);
}
.cc-clue:hover { background: var(--bg-alt); }

.cc-approved { border-left: 2px solid var(--color-success); }
.cc-rejected { opacity: 0.4; }

.cc-clue-word {
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-bottom: 0.25rem;
}

.cc-clue-text {
  font-size: 0.75rem; font-family: var(--font-body);
  color: var(--text); margin-bottom: 0.375rem;
}

.cc-clue-actions {
  display: flex; gap: 0.5rem; align-items: center;
}

.cc-vote {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem;
  background: none; border: 1px solid var(--border-light);
  color: var(--text-tertiary); cursor: pointer;
  font-family: var(--font-mono); font-size: 0.625rem;
  padding: 0.125rem 0.375rem;
  min-width: 2.75rem; min-height: 2.75rem;
  transition: all 150ms var(--ease);
}
.cc-vote:hover { border-color: var(--text-secondary); color: var(--text); }
.cc-voted { border-color: var(--text); color: var(--text); background: var(--bg-alt); }

.cc-status {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}
.cc-status-approved { color: var(--color-success); }
.cc-status-rejected { color: var(--color-error); }
.cc-status-pending { color: var(--text-tertiary); }

.cc-delete {
  background: none; border: none; cursor: pointer; padding: 0.125rem 0.25rem;
  color: var(--text-tertiary); margin-left: auto;
  min-width: 2.75rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 150ms var(--ease);
}
.cc-delete:hover { color: var(--color-error); }

.cc-vote-count {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary);
}

/* ====================== PRIVACY SECTION ====================== */

.settings-collapse-btn {
  display: flex; align-items: center; gap: 4px; width: 100%;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.625rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text); padding: 0;
}
.settings-collapse-arrow { margin-left: auto; font-size: 0.5rem; color: var(--text-tertiary); }

.privacy-presets {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem;
}

.privacy-preset {
  border: 1px solid var(--border); padding: 0.75rem 0.625rem;
  cursor: pointer; background: none; text-align: center;
  color: var(--text);
  transition: all 150ms var(--ease);
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
}
.privacy-preset:hover { border-color: var(--text-secondary); }
.privacy-preset-active { border-color: var(--text); background: var(--bg-alt); }
.privacy-preset strong {
  font-family: var(--font-mono); font-size: 0.688rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text);
}
.privacy-preset span {
  font-size: 0.5rem; color: var(--text-tertiary);
  font-family: var(--font-body); line-height: 1.4;
}

.privacy-toggle {
  display: flex; align-items: flex-start; gap: 0.5rem;
  font-size: 0.75rem; font-family: var(--font-body);
  color: var(--text-secondary); cursor: pointer;
  padding: 0.375rem 0;
}
.privacy-toggle input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--text);
  cursor: pointer; margin-top: 2px; flex-shrink: 0;
}
.privacy-toggle div { display: flex; flex-direction: column; }
.privacy-toggle-hint {
  font-size: 0.563rem; color: var(--text-tertiary);
  font-family: var(--font-body); margin-top: 1px;
}
.privacy-toggle-disabled {
  opacity: 0.4; cursor: default; pointer-events: none;
}
.settings-section-disabled {
  opacity: 0.4; pointer-events: none;
}

.privacy-purge-days {
  display: flex; align-items: center; gap: 0.5rem;
  padding-left: 1.75rem; font-size: 0.688rem;
  font-family: var(--font-body); color: var(--text-secondary);
}
.privacy-purge-days select {
  font-size: 0.688rem; padding: 0.125rem 0.25rem;
}

.privacy-blocked-list {
  display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.5rem;
}

.privacy-blocked-tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  background: var(--bg-alt); border: 1px solid var(--border);
  padding: 0.125rem 0.375rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-secondary);
}
.privacy-blocked-tag button {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--text-tertiary);
  min-width: 2.75rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.privacy-blocked-tag button:hover { color: var(--color-error); }

.privacy-actions {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
  margin-top: 1rem; padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
}

.privacy-delete-btn {
  color: var(--color-error) !important;
  border-color: var(--color-error) !important;
}

.privacy-delete-confirm {
  width: 100%; margin-top: 0.5rem;
}
.privacy-delete-confirm p {
  font-size: 0.75rem; color: var(--color-error);
  margin-bottom: 0.5rem;
}

/* ====================== REPORT BUTTON ====================== */

.cc-report-btn {
  background: none; border: none; cursor: pointer; padding: 0.125rem 0.25rem;
  color: var(--text-tertiary); margin-left: auto;
  min-width: 2.75rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 150ms var(--ease);
}
.cc-report-btn:hover { color: var(--color-error); }

.cc-reported {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
  margin-left: auto;
}

.cc-report-form {
  display: flex; gap: 0.375rem; margin-top: 0.375rem;
  padding-top: 0.375rem; border-top: 1px solid var(--border-light);
}
.cc-report-form input {
  flex: 1; font-size: 0.688rem;
  padding: 0.25rem 0.375rem; border: 1px solid var(--border);
  background: var(--bg-alt); color: var(--text);
  font-family: var(--font-body);
}

/* ====================== GENERIC REPORT BUTTON ====================== */

.report-wrap { position: relative; display: inline-block; }
.report-btn {
  background: none; border: none; cursor: pointer; padding: 0.125rem 0.25rem;
  color: var(--text-tertiary); transition: color 150ms var(--ease);
  line-height: 1;
  min-width: 2.75rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.report-btn:hover { color: var(--color-error); }
.report-done {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}
.report-form {
  position: absolute; right: 0; top: 100%; z-index: 10;
  display: flex; gap: 0.375rem; padding: 0.5rem;
  background: var(--bg); border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  white-space: nowrap;
}
.report-select { min-width: 8rem; }
.report-form .btn-sm {
  font-size: 0.625rem; padding: 0.25rem 0.5rem;
}

/* ====================== ORIGIN BADGES ====================== */

.cc-origin-badge {
  display: inline-block; margin-left: 0.375rem;
  font-family: var(--font-mono); font-size: 0.5rem;
  background: var(--bg-alt); border: 1px solid var(--border-light);
  padding: 0 0.25rem; color: var(--text-tertiary);
  vertical-align: middle; letter-spacing: 0.02em;
}

/* ====================== TOR-FRIENDLY ====================== */

.tor-friendly {
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
}

/* ====================== EDITOR ====================== */

.editor-fullscreen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 100;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.editor-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.5rem; border-bottom: 1px solid var(--border);
  flex-shrink: 0; max-width: 68rem; width: 100%; margin: 0 auto;
}

.editor-header h2 {
  font-family: var(--font-display); font-size: 1.125rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}

.editor-header-left {
  display: flex; align-items: center; gap: 0.5rem;
}

.editor-header-actions {
  display: flex; gap: 0.375rem; align-items: center; flex-wrap: wrap;
}

.editor-mode-toggle { display: flex; gap: 0; }
.editor-mode-toggle .btn { border-radius: 0; }
.editor-mode-toggle .btn:first-child { border-radius: 3px 0 0 3px; }
.editor-mode-toggle .btn:last-child { border-radius: 0 3px 3px 0; }

.editor-list-body {
  flex: 1; overflow-y: auto; padding: 2rem;
  max-width: 36rem; margin: 0 auto; width: 100%;
}

.editor-new-section { margin-bottom: 1.5rem; }

.editor-title-input {
  background: none; border: none; border-bottom: 1px solid var(--border-light);
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  color: var(--text); padding: 0.125rem 0; width: 14rem;
}
.editor-title-input:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--text); }

.editor-warnings {
  display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap;
  padding: 0.5rem 1.5rem; background: #fef3c7; color: #92400e;
  font-size: 0.75rem; font-family: var(--font-body);
  border-bottom: 1px solid #fcd34d;
}
[data-theme="dark"] .editor-warnings { background: #451a03; color: #fcd34d; border-color: #78350f; }

.editor-workspace {
  flex: 1; display: flex; gap: 1.5rem;
  padding: 1.5rem; overflow: hidden;
  max-width: 68rem; width: 100%; margin: 0 auto;
}

.editor-grid-area {
  flex-shrink: 0; display: flex; flex-direction: column;
  align-items: center; gap: 0.5rem;
}

.editor-grid-area svg { border: 1px solid var(--border); }

.editor-grid-hint {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.editor-clue-area {
  flex: 1; min-width: 0; overflow-y: auto;
}

.editor-clue-list {
  display: flex; flex-direction: column; gap: 0.125rem;
}

.editor-clue-item {
  display: flex; gap: 0.5rem; align-items: baseline;
  padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
}
.editor-clue-item:hover { background: var(--bg-alt); }
.editor-clue-active { background: var(--accent-soft, #e0e7ff); }

.editor-clue-num {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary); min-width: 2rem; flex-shrink: 0;
}

.editor-clue-answer {
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-secondary); min-width: 5rem; flex-shrink: 0;
}

.editor-clue-text {
  color: var(--text-secondary); cursor: pointer; flex: 1;
  font-family: var(--font-body);
}
.editor-clue-text:hover { color: var(--text); }

.editor-clue-input {
  flex: 1; border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); padding: 0.125rem 0.375rem;
  font-family: var(--font-body); font-size: 0.75rem;
}

.editor-clue-empty {
  padding: 2rem; text-align: center; color: var(--text-tertiary);
  font-size: 0.75rem; font-family: var(--font-body); line-height: 1.6;
}

.editor-saved { margin-top: 1.5rem; }

.editor-publish-dialog {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 1.5rem;
  max-width: 26rem; width: 90%;
  animation: popIn 0.2s var(--ease);
}

.editor-publish-dialog h3 {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  margin-bottom: 0.75rem;
}

.editor-publish-dialog p {
  font-size: 0.75rem; font-family: var(--font-body);
  color: var(--text-secondary); line-height: 1.5;
  margin-bottom: 0.625rem;
}

.editor-publish-check {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.75rem; font-family: var(--font-body);
  color: var(--text-secondary); margin: 1rem 0 0.75rem;
  cursor: pointer;
}

.editor-publish-actions {
  display: flex; gap: 0.375rem; justify-content: flex-end;
}

.editor-hint-text {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}

.editor-size-input {
  width: 5.5rem; padding: 0; text-align: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-family: var(--font-mono); font-size: 0.75rem;
}

.editor-autosave-indicator {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}

.editor-clue-edit-area { flex: 1; min-width: 0; }

.editor-clue-empty-text { color: var(--text-tertiary); font-style: italic; }

.editor-suggestions {
  display: flex; flex-direction: column; gap: 0.125rem;
  margin-top: 0.25rem; padding-left: 0.25rem;
  border-left: 2px solid var(--border-light);
}

.editor-suggestion {
  background: none; border: none; text-align: left; cursor: pointer;
  font-size: 0.688rem; font-family: var(--font-body);
  color: var(--text-secondary); padding: 0.125rem 0.375rem;
  transition: all 100ms var(--ease);
}
.editor-suggestion:hover { background: var(--bg-alt); color: var(--text); }

/* ====================== ADMIN ====================== */

.admin-fullscreen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 100;
  display: flex; flex-direction: column; overflow: hidden;
}

/* masthead */
.admin-header {
  border-bottom: 3px double var(--text);
  flex-shrink: 0;
  padding: 0.75rem 2rem;
  display: flex; justify-content: center;
}
.admin-header > div, .admin-header > button { /* direct children layout handled by inner wrapper */ }
.admin-header-inner {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 64rem; width: 100%;
}
.admin-header h2 {
  font-family: var(--font-display); font-size: 0.875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* login */
.admin-login {
  max-width: 22rem; margin: 6rem auto; text-align: center;
  padding: 2rem; border: 1px solid var(--border);
}
.admin-login-form {
  display: flex; flex-direction: column; gap: 0.625rem;
}
.admin-login-error {
  font-size: 0.75rem; color: var(--color-error);
  font-family: var(--font-body); text-align: center;
}
.admin-input {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-family: var(--font-mono); font-size: 0.75rem;
}

/* body: horizontal nav on top, content below */
.admin-body {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}

/* horizontal tab strip */
.admin-nav {
  flex-shrink: 0;
  display: flex; flex-direction: row; gap: 0;
  justify-content: center;
  padding: 0 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
}
.admin-nav-item {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.75rem 1rem; background: none; border: none;
  color: var(--text-tertiary); cursor: pointer;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  white-space: nowrap;
  transition: color 150ms var(--ease);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-nav-item:hover { color: var(--text); }
.admin-nav-active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.admin-badge {
  margin-left: 0.25rem; background: var(--accent); color: var(--bg);
  font-family: var(--font-mono); font-size: 0.5rem; font-weight: 700;
  padding: 0.0625rem 0.375rem;
}

/* content area - centered */
.admin-content {
  flex: 1; overflow-y: auto;
  padding: 2rem 2.5rem;
  max-width: 64rem;
  margin: 0 auto; width: 100%;
  box-sizing: border-box;
}

/* stat cards grid */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  background: var(--border);
  margin-bottom: 0.5rem;
}
.admin-stat-card {
  background: var(--bg);
  padding: 1rem 0.75rem;
  text-align: center;
}
.admin-stat-value {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700;
  color: var(--text); line-height: 1; font-style: italic;
}
.admin-stat-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-tertiary); margin-top: 0.5rem;
}
.admin-stat-sub {
  font-family: var(--font-body); font-size: 0.625rem;
  color: var(--text-tertiary); margin-top: 0.25rem;
}

/* section headings - editorial */
.admin-section-title {
  grid-column: 1 / -1;
  font-family: var(--font-display); font-size: 0.75rem;
  font-style: italic; font-weight: 400;
  color: var(--text-secondary); padding-top: 0.75rem;
  border-top: 1px solid var(--border-light); margin-top: 0.5rem;
}
.admin-section-heading {
  font-family: var(--font-display); font-size: 0.875rem;
  font-style: italic; font-weight: 400;
  color: var(--text);
  margin: 2rem 0 0.75rem; padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border);
}
.admin-section-heading:first-child { margin-top: 0; }

/* activity chart */
.admin-activity-chart {
  display: flex; gap: 0.375rem; align-items: flex-end;
  height: 6rem; padding: 0.5rem 0;
  border: 1px solid var(--border); background: var(--bg);
  padding: 1rem 0.75rem 0.5rem;
}
.admin-bar-col {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; height: 100%; justify-content: flex-end;
}
.admin-bar {
  width: 100%; max-width: 2.5rem; background: var(--text);
  min-height: 2px; transition: height 300ms var(--ease);
}
.admin-bar-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); margin-top: 0.375rem;
}
.admin-bar-value {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-secondary); margin-bottom: 0.25rem;
}

/* toolbar */
.admin-toolbar {
  display: flex; gap: 0.5rem; margin-bottom: 1rem;
  align-items: center; flex-wrap: wrap;
}
.admin-toolbar-count {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}

/* utility */
.admin-anon { color: var(--text-tertiary); font-style: italic; }
.admin-error { color: var(--color-error); }
.admin-mono { font-family: var(--font-mono); font-size: 0.625rem; }
.admin-empty {
  text-align: center; padding: 3rem; color: var(--text-tertiary);
  font-family: var(--font-display); font-size: 1rem;
  font-style: italic;
}

/* tables */
.admin-table {
  width: 100%; border-collapse: collapse; font-size: 0.75rem;
  margin-bottom: 0.5rem;
}
.admin-table th {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--text);
  border-top: 1px solid var(--border);
}
.admin-table td {
  padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border-light);
  font-family: var(--font-body); color: var(--text-secondary);
}
.admin-table tr:hover td { background: var(--bg-alt); }

/* moderation cards */
.admin-clue-card {
  border: 1px solid var(--border); padding: 0.75rem 1rem;
  margin-bottom: 0.5rem; background: var(--bg);
}
.admin-clue-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 0.5rem;
}
.admin-clue-word {
  font-family: var(--font-display); font-size: 0.8rem;
  font-style: italic;
  color: var(--text);
}
.admin-clue-text {
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text-secondary); margin-bottom: 0.5rem; line-height: 1.5;
}
.admin-clue-meta {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
}
.admin-clue-actions { display: flex; gap: 0.375rem; }

/* webhook/peer forms */
.admin-webhook-form {
  display: flex; gap: 0.375rem; margin-bottom: 1rem;
  flex-wrap: wrap; align-items: center;
}
.admin-webhook-form input { flex: 1; min-width: 10rem; }

/* dialog */
.admin-dialog {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); max-width: 24rem; width: 90%;
  animation: popIn 0.2s var(--ease);
}
.admin-dialog-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-light);
}
.admin-dialog-header h3 {
  font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700; font-style: italic;
}
.admin-dialog-body {
  padding: 1.25rem 1.5rem;
}
.admin-dialog-body p {
  font-size: 0.8rem; font-family: var(--font-body);
  color: var(--text-secondary); line-height: 1.6;
}
.admin-dialog-actions {
  display: flex; gap: 0.5rem; justify-content: flex-end;
  padding: 1rem 1.5rem; border-top: 1px solid var(--border-light);
}

/* notification toast */
.admin-notification {
  padding: 0.5rem 1.5rem; text-align: center;
  background: var(--text); color: var(--bg);
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  animation: solvedIn 0.3s var(--ease);
}

/* federation info */
.admin-federation-info {
  margin-top: 1.5rem; max-width: 36rem;
}
.admin-federation-info h4 {
  font-family: var(--font-display); font-size: 1rem;
  font-weight: 400; font-style: italic; margin-bottom: 0.75rem;
}
.admin-federation-info p {
  font-size: 0.8rem; font-family: var(--font-body);
  color: var(--text-secondary); line-height: 1.7; margin-bottom: 0.5rem;
}
.admin-federation-info code {
  font-family: var(--font-mono); font-size: 0.688rem;
  background: var(--bg-alt); padding: 0.125rem 0.5rem;
  border: 1px solid var(--border-light);
}
.admin-federation-info ul { padding-left: 1.5rem; margin: 0.5rem 0; }
.admin-federation-info li {
  font-size: 0.8rem; font-family: var(--font-body);
  color: var(--text-secondary); margin-bottom: 0.375rem;
}

/* config rows */
.admin-config-row {
  display: grid; grid-template-columns: 10rem 1fr auto;
  gap: 0.75rem; align-items: center;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border-light);
  font-size: 0.75rem;
}
.admin-config-name {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary);
}
.admin-config-value {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text);
}
.admin-config-value-true { color: var(--color-success); }
.admin-config-value-false { color: var(--text-tertiary); }
.admin-config-desc {
  font-size: 0.625rem; color: var(--text-tertiary);
  font-family: var(--font-body); text-align: right;
}
.admin-config-toggle {
  display: flex; align-items: center; gap: 0.5rem; cursor: pointer;
}
.admin-config-toggle input { accent-color: var(--text); cursor: pointer; }
.admin-config-input {
  font-family: var(--font-mono); font-size: 0.75rem;
  padding: 0.375rem 0.5rem; border: 1px solid var(--border);
  background: var(--bg-alt); color: var(--text); min-width: 10rem;
}

/* spinner */
.admin-spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: adminSpin 0.6s linear infinite;
}
@keyframes adminSpin { to { transform: rotate(360deg); } }

/* markdown editor */
.admin-md-toolbar {
  display: flex; gap: 2px;
  border: 1px solid var(--border); border-bottom: none;
  padding: 3px; background: var(--bg-alt);
}
.admin-md-toolbar button { padding: 3px 8px; }
.admin-md-preview {
  margin-top: 10px; padding: 12px 14px;
  border: 1px solid var(--border-light); background: var(--bg-alt);
}
.admin-md-rendered h3 { font-family: var(--font-display); font-size: 0.875rem; font-weight: 700; margin: 0.5rem 0 0.25rem; }
.admin-md-rendered h4 { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; margin: 0.375rem 0 0.25rem; }
.admin-md-rendered p { font-family: var(--font-body); font-size: 0.8rem; line-height: 1.7; color: var(--text-secondary); margin: 0 0 0.5rem; }
.admin-md-rendered ul { padding-left: 1.5rem; margin: 0.25rem 0; }
.admin-md-rendered li { font-family: var(--font-body); font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.admin-md-rendered strong { color: var(--text); }
.admin-md-rendered em { font-style: italic; }

/* mobile admin */
@media (max-width: 640px) {
  .admin-header { padding: 0.5rem 1rem; }
  .admin-nav { padding: 0 0.5rem; }
  .admin-nav-item { padding: 0.625rem 0.5rem; font-size: 0.5rem; }
  .admin-content { padding: 1.25rem 1rem; }
  .admin-grid { grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr)); }
  .admin-config-row { grid-template-columns: 1fr; gap: 0.25rem; }
  .admin-config-desc { text-align: left; }
}

/* ====================== INSTANCE PAGES ====================== */

.instance-page {
  min-height: 100vh; background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
}

.instance-page-header {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.5rem; width: 100%; max-width: 40rem;
}

.instance-page-header h1 {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 900;
  text-transform: lowercase; letter-spacing: -0.03em;
}

.instance-page-body {
  width: 100%; max-width: 40rem; padding: 0 1.5rem 3rem;
}

.instance-hero {
  text-align: center; padding: 2rem 0 1.5rem;
}

.instance-hero h2 {
  font-family: var(--font-display); font-size: 1.75rem; font-weight: 700;
  margin-bottom: 0.25rem;
}

.instance-tagline {
  font-family: var(--font-body); font-size: 0.875rem;
  color: var(--text-secondary);
}

.instance-section {
  margin-bottom: 1.5rem;
}

.instance-section h3 {
  font-family: var(--font-mono); font-size: 0.563rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--text-tertiary); margin-bottom: 0.75rem;
  padding-bottom: 0.375rem; border-bottom: 1px solid var(--border-light);
}

.instance-info-grid {
  display: flex; flex-direction: column; gap: 0.75rem;
}

.instance-info-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem; border: 1px solid var(--border);
}

.instance-info-card strong {
  display: block; font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700;
}

.instance-info-card span {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text-secondary);
}

.instance-rules {
  display: flex; flex-direction: column; gap: 0.375rem;
}

.instance-rule {
  padding: 0.5rem 0.75rem; border-left: 2px solid var(--text);
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text-secondary);
}

.instance-features {
  display: flex; flex-wrap: wrap; gap: 0.375rem;
}

.instance-feature {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.25rem 0.625rem; border: 1px solid var(--border);
  color: var(--text-secondary);
}

.instance-health-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  gap: 0.5rem;
}

.instance-health-item {
  text-align: center; padding: 0.75rem; border: 1px solid var(--border);
}

.instance-health-value {
  display: block; font-family: var(--font-display); font-size: 1.25rem;
  font-weight: 700; color: var(--text);
}

.instance-health-warn { color: var(--color-error); }

.instance-health-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-top: 0.25rem; display: block;
}

.instance-footer {
  display: flex; gap: 1rem; justify-content: center;
  padding: 2rem 0; border-top: 1px solid var(--border-light);
  margin-top: 2rem;
}

.instance-footer a {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); text-decoration: none;
  transition: color 150ms var(--ease);
}

.instance-footer a:hover { color: var(--text); }

/* ====================== OFFLINE ====================== */

.offline-banner {
  width: 100%; text-align: center; padding: 0.375rem;
  background: #fbbf24; color: #78350f;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
}

/* ====================== WORD OF THE DAY ====================== */

.wotd-card {
  padding: 1.25rem 1.5rem;
}
.wotd-label {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.15em;
  color: var(--text-tertiary);
}
.wotd-word {
  font-family: var(--font-display); font-size: 2rem;
  font-weight: 700; color: var(--accent); letter-spacing: 0.08em;
  margin: 0.25rem 0 0.5rem;
}
.wotd-definition {
  font-family: var(--font-body); font-size: 0.8125rem;
  color: var(--text-secondary); line-height: 1.5;
  margin: 0 0 0.625rem;
}
.wotd-clue {
  font-family: var(--font-mono); font-size: 0.6875rem;
  color: var(--text-tertiary); margin: 0;
}

/* ====================== CLUE TRAINER ====================== */

.trainer-modal {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 92%; max-width: 26rem;
}
.trainer-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 1.25rem 1.5rem 0.75rem;
}
.trainer-title {
  font-family: var(--font-display); font-size: 1.25rem;
  font-weight: 700; margin: 0;
}
.trainer-score {
  font-family: var(--font-mono); font-size: 0.6875rem;
  color: var(--text-tertiary); margin: 0.125rem 0 0;
}
.trainer-difficulty {
  display: flex; gap: 0; padding: 0 1.5rem; margin-bottom: 1rem;
}
.trainer-diff-btn {
  flex: 1; padding: 0.5rem; border: 1px solid var(--border);
  background: transparent; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.6875rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-secondary); margin: -0.5px;
  transition: all 150ms var(--ease);
}
.trainer-diff-btn:first-child { border-radius: 3px 0 0 3px; }
.trainer-diff-btn:last-child { border-radius: 0 3px 3px 0; }
.trainer-diff-btn:hover { color: var(--text); }
.trainer-diff-active {
  background: var(--text); color: var(--bg); border-color: var(--text);
  z-index: 1;
}
.trainer-diff-active:hover { color: var(--bg); }
.trainer-body { padding: 0 1.5rem 1.5rem; }
.trainer-loading {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-tertiary); text-align: center;
}
.trainer-clue {
  font-family: var(--font-display); font-size: 1.125rem;
  font-weight: 500; line-height: 1.4;
  margin: 0 0 0.75rem; text-align: center;
}
.trainer-meta {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-bottom: 1rem;
}
.trainer-len {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.1em;
}
.trainer-pattern {
  font-family: var(--font-mono); font-size: 0.875rem;
  font-weight: 500; color: var(--text); letter-spacing: 0.2em;
}
.trainer-input-row {
  display: flex; gap: 0.5rem; margin-bottom: 0.75rem;
}
.trainer-input {
  flex: 1; padding: 0.625rem 0.75rem;
  border: 1px solid var(--border); background: var(--bg);
  font-family: var(--font-mono); font-size: 0.875rem;
  font-weight: 500; color: var(--text);
  letter-spacing: 0.15em; text-transform: uppercase;
  outline: none; transition: border-color 150ms;
}
.trainer-input:focus { border-color: var(--text); }
.trainer-input:disabled { opacity: 0.5; }
.trainer-submit { white-space: nowrap; }
.trainer-result {
  display: flex; align-items: center; gap: 0.5rem; justify-content: center;
  padding: 0.625rem; font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 500;
}
.trainer-correct { color: var(--correct); }
.trainer-wrong { color: var(--incorrect); }

/* ====================== RESPONSIVE ====================== */

@media (max-width: 64rem) {
  .game-area { flex-direction: column; }
  .clue-panel { width: 100%; max-height: 14rem; border-left: none; border-top: 1px solid var(--border); }
  .grid-column { padding: 1rem; }
  .header { padding: 0.625rem 1rem; }
  .header-brand { font-size: 0.875rem; }
  .welcome h1 { font-size: 2.5rem; }
  .ed-cards { flex-direction: column; align-items: center; }
  .ed-card { min-width: 100%; max-width: 16rem; }
  .ed-word-content { flex-direction: column; gap: 0.75rem; }
  .ed-word-divider { width: 100%; height: 1px; }
  .ed-word-term { font-size: 1.5rem; }
  .active-clue-banner .clue-text { font-size: 1.125rem; }
}

/* ====================== SCROLLBAR ====================== */

.clue-list::-webkit-scrollbar { width: 4px; }
.clue-list::-webkit-scrollbar-track { background: transparent; }
.clue-list::-webkit-scrollbar-thumb { background: var(--border); }
.clue-list::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }



/* ====================== GLOBAL TRANSITIONS ====================== */

/* ensure ALL interactive elements have base transitions */
a, button, select, input, .clue-tab, .clue-item, .preset-card, .welcome-preset,
.disambiguation-btn, .header-streak, .active-clue-banner {
  transition: all 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* SVG cell rect transitions for selection highlight changes */
svg rect {
  transition: fill 150ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* SVG text color transitions for validation state changes */
svg text {
  transition: fill 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* header streak badge entrance */
.header-streak {
  animation: badgeIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}
@keyframes badgeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

/* clue tab underline transition */
.clue-tab::after {
  transition: opacity 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* error banner entrance */
.error-banner {
  animation: bannerIn 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* solved banner - more dramatic entrance */
.solved-banner {
  animation: solvedIn 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
}
@keyframes solvedIn {
  0% { opacity: 0; transform: scaleX(0.3); }
  60% { opacity: 1; transform: scaleX(1.02); }
  100% { opacity: 1; transform: scaleX(1); }
}

/* zoom strip cell transitions */
.zoom-cell {
  transition: all 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* info bar border transition */
.info-bar {
  transition: border-color 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* focus ring: visible on keyboard nav, hidden on mouse clicks */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transition: outline-color 150ms;
}

/* settings section controls */
.settings-section select,
.settings-section input[type="range"] {
  transition: all 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* clue panel border transition */
.clue-panel {
  transition: border-color 200ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* ====================== CUSTOM SELECT ====================== */

.cv-select { position: relative; display: inline-block; }
.cv-select-trigger {
  display: flex; align-items: center; gap: 6px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border-light);
  color: var(--text); cursor: pointer; min-width: 6rem;
  font-family: var(--font-mono); font-size: 0.688rem;
  padding: 0.375rem 0.625rem;
  transition: border-color 150ms var(--ease);
}
.cv-select-trigger:hover { border-color: var(--text-secondary); }
.cv-select-dropdown {
  position: fixed; z-index: 10000;
  background: var(--surface); border: 1px solid var(--border);
  max-height: 12rem; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.cv-select-option {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.688rem;
  color: var(--text-secondary); padding: 0.375rem 0.625rem;
  transition: all 100ms var(--ease);
}
.cv-select-option:hover { background: var(--bg-alt); color: var(--text); }
.cv-select-option-active { color: var(--text); font-weight: 500; }

/* ====================== CUSTOM NUMBER INPUT ====================== */

.cv-number {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-light);
}
.cv-number-btn {
  background: var(--surface); border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.875rem; font-weight: 500;
  color: var(--text-secondary); padding: 0.25rem 0.5rem;
  transition: all 100ms var(--ease);
  line-height: 1;
}
.cv-number-btn:hover:not(:disabled) { background: var(--bg-alt); color: var(--text); }
.cv-number-btn:disabled { opacity: 0.3; cursor: default; }
.cv-number-value {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text); padding: 0.25rem 0.5rem; min-width: 2rem;
  text-align: center; border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ====================== CUSTOM DATE PICKER ====================== */

.cv-datepicker { position: relative; display: inline-block; }
.cv-calendar {
  position: fixed; z-index: 10000;
  background: var(--surface); border: 1px solid var(--border);
  padding: 0.75rem; min-width: 14rem;
  box-shadow: var(--shadow-lg);
}
.cv-cal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.5rem;
}
.cv-cal-title {
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 500; color: var(--text);
}
.cv-cal-nav {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.875rem;
  color: var(--text-secondary); padding: 0.125rem 0.375rem;
  min-width: 2.75rem; min-height: 2.75rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 100ms var(--ease);
}
.cv-cal-nav:hover { color: var(--text); }
.cv-cal-days {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 0.25rem;
}
.cv-cal-dayname {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); text-align: center;
  padding: 0.125rem 0;
}
.cv-cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
}
.cv-cal-day {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.688rem;
  color: var(--text-secondary); padding: 0.25rem;
  min-width: 2.75rem; min-height: 2.75rem;
  display: flex; align-items: center; justify-content: center;
  text-align: center; transition: all 100ms var(--ease);
}
.cv-cal-day:hover { background: var(--bg-alt); color: var(--text); }
.cv-cal-day-today { color: var(--accent); font-weight: 500; }
.cv-cal-day-selected {
  background: var(--text); color: var(--bg); font-weight: 500;
}
.cv-cal-day-selected:hover { background: var(--text-secondary); }

/* ====================== TOOLTIP ====================== */

.cv-tooltip-wrap { display: inline-flex; max-width: 100%; }
.cv-tooltip-wrap:has(> .active-clue-banner) { display: flex; width: 100%; justify-content: center; }
.cv-tooltip {
  position: fixed; z-index: 99999;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-family: var(--font-mono); font-size: 0.563rem;
  letter-spacing: 0.03em;
  padding: 0.325rem 0.5rem;
  white-space: nowrap; pointer-events: auto;
  animation: tooltipIn 0.1s var(--ease);
}
.cv-tooltip::after {
  content: ''; position: absolute;
  left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
}
.cv-tooltip-down::after {
  bottom: -10px;
  border-top-color: var(--text);
}
.cv-tooltip-up::after {
  top: -10px;
  border-bottom-color: var(--text);
}
@keyframes tooltipIn {
  from { opacity: 0; transform: translateX(-50%) translateY(3px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

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

.share-embed-toggle {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); padding: 4px 0;
  transition: color 150ms var(--ease);
}
.share-embed-toggle:hover { color: var(--text); }

/* ====================== EMBED WIDGET ====================== */

.embed-player {
  max-width: 100%; height: 100vh;
  display: flex; flex-direction: column;
  font-family: var(--font-body);
  background: var(--bg);
}
.embed-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
}
.embed-brand {
  font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700; font-style: italic; color: var(--text);
}
.embed-timer {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-secondary);
}
.embed-game {
  flex: 1; display: flex; flex-direction: column;
  overflow: auto; padding: 0.5rem;
}
.embed-grid { display: flex; justify-content: center; }
.embed-solved {
  text-align: center; padding: 0.5rem;
  font-family: var(--font-display); font-size: 1rem;
  font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; background: var(--surface);
  border-bottom: 1px solid var(--border); color: var(--text);
}
.embed-hints {
  display: flex; gap: 0.5rem; justify-content: center;
  padding: 0.5rem; border-top: 1px solid var(--border);
}
.embed-loading, .embed-error {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-family: var(--font-body);
  color: var(--text-secondary); font-size: 0.875rem;
}
.embed-error { color: var(--incorrect); }

/* ====================== ANALYTICS DASHBOARD ====================== */

.analytics-modal {
  background: var(--bg); border: 1px solid var(--border);
  width: 95%; max-width: 42rem; max-height: 90vh;
  overflow-y: auto; padding: 0; scroll-padding-top: 3rem;
}
.analytics-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.analytics-title-row {
  display: flex; justify-content: space-between; align-items: center;
}
.analytics-title {
  font-family: var(--font-display); font-size: 1.125rem;
  font-weight: 700; font-style: italic;
  margin: 0; color: var(--text);
}
.analytics-empty {
  text-align: center; padding: 3rem 2rem;
  color: var(--text-tertiary); font-family: var(--font-body);
  font-size: 0.875rem; display: flex; flex-direction: column;
  align-items: center; gap: 0.25rem;
}
.analytics-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.analytics-section-last { border-bottom: none; }
.analytics-section-title {
  font-family: var(--font-display); font-size: 0.875rem;
  font-weight: 700; font-style: italic;
  margin-bottom: 0.75rem; color: var(--text);
}
.analytics-cards {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
}
.analytics-card {
  flex: 1; min-width: 5rem; text-align: center;
  padding: 0.75rem; border: 1px solid var(--border);
}
.analytics-card-value {
  font-family: var(--font-mono); font-size: 1.5rem;
  font-weight: 500; color: var(--text);
}
.analytics-card-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-top: 0.25rem;
}

/* heatmap */
.analytics-heatmap-total {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: 0.375rem;
}

/* charts */
.analytics-chart-svg {
  display: block;
}
.analytics-chart-tick {
  font-family: var(--font-mono); font-size: 6.5px;
  fill: var(--text-tertiary);
}
.analytics-chart-label {
  font-family: var(--font-mono); font-size: 6px;
  fill: var(--text-tertiary); text-transform: uppercase;
}

/* preset breakdown */
.analytics-presets {
  display: flex; flex-direction: column; gap: 0.5rem;
}
.analytics-preset-row {
  display: flex; align-items: center; gap: 0.75rem;
}
.analytics-preset-name {
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  width: 5rem; flex-shrink: 0; color: var(--text-secondary);
}
.analytics-preset-bar-wrap {
  flex: 1; height: 14px; background: var(--surface);
  border: 1px solid var(--border); position: relative;
}
.analytics-preset-bar {
  height: 100%; background: var(--accent);
  transition: width 0.5s var(--ease);
}
.analytics-preset-count {
  font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 500; width: 2rem; text-align: right;
  color: var(--text);
}
.analytics-preset-best {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); width: 5rem;
}

/* recent solves */
.analytics-recent {
  max-height: 16rem; overflow-y: auto;
  display: flex; flex-direction: column;
}
.analytics-recent-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-secondary);
}
.analytics-recent-row:last-child { border-bottom: none; }
.analytics-recent-date {
  width: 4rem; flex-shrink: 0; color: var(--text-tertiary);
}
.analytics-recent-preset {
  width: 4.5rem; flex-shrink: 0; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text);
}
.analytics-recent-time {
  display: flex; align-items: center; gap: 0.25rem;
  color: var(--text-secondary);
}
.analytics-recent-hints {
  display: flex; align-items: center; gap: 0.25rem;
  color: var(--text-tertiary);
}

/* improvement indicator */
.analytics-improvement {
  text-align: center; padding: 0.75rem 0;
}
.analytics-improvement-value {
  font-family: var(--font-mono); font-size: 2rem;
  font-weight: 600; display: flex; align-items: center;
  justify-content: center; gap: 0;
}
.analytics-improvement-value.positive { color: #22c55e; }
.analytics-improvement-value.negative { color: var(--accent); }
.analytics-improvement-label {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text-tertiary); margin-top: 0.25rem;
}

/* histogram */
.analytics-histogram {
  overflow: hidden;
}

/* donut chart */
.analytics-donut {
  display: flex; align-items: center; gap: 1.5rem;
  justify-content: center; padding: 0.5rem 0;
}
.analytics-donut-total {
  font-family: var(--font-mono); font-size: 16px;
  font-weight: 600; fill: var(--text);
}
.analytics-donut-label {
  font-family: var(--font-mono); font-size: 6px;
  fill: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.1em;
}
.analytics-donut-legend {
  display: flex; flex-direction: column; gap: 0.375rem;
}
.analytics-donut-legend-item {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-secondary);
}
.analytics-donut-swatch {
  width: 8px; height: 8px; flex-shrink: 0;
  border: 1px solid var(--border);
}
.analytics-donut-legend-name {
  text-transform: uppercase; letter-spacing: 0.06em;
  width: 4rem;
}
.analytics-donut-legend-val {
  font-weight: 500; color: var(--text);
}

/* gauge chart */
.analytics-gauge {
  display: flex; justify-content: center;
  padding: 0.25rem 0;
}
.analytics-gauge-value {
  font-family: var(--font-mono); font-size: 18px;
  font-weight: 600; fill: var(--text);
}
.analytics-gauge-label {
  font-family: var(--font-mono); font-size: 6px;
  fill: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* record cards */
.analytics-record-cards {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
}
.analytics-record-card {
  flex: 1; min-width: 5.5rem; text-align: center;
  padding: 0.75rem 0.5rem; border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  gap: 0.25rem;
}
.analytics-record-icon {
  color: var(--accent); margin-bottom: 0.125rem;
}
.analytics-record-preset {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}
.analytics-record-time {
  font-family: var(--font-mono); font-size: 1.125rem;
  font-weight: 500; color: var(--text);
}
.analytics-record-date {
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary);
}

/* peak performance hint */
.analytics-peak-hint {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text-secondary); margin-bottom: 0.5rem;
}
.analytics-stacked {
  display: flex; flex-direction: column;
}
.analytics-section-compact {
  padding: 0.875rem 1.25rem;
}
.analytics-stacked > .analytics-section-compact {
  border-bottom: 1px solid var(--border);
}
.analytics-stacked > .analytics-section-compact:last-child {
  border-bottom: none; flex: 1;
}
.analytics-mini-stat {
  display: flex; align-items: baseline; gap: 0.5rem;
}
.analytics-mini-val {
  font-family: var(--font-mono); font-size: 1.5rem;
  font-weight: 500; color: var(--text);
}
.analytics-mini-label {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* streak visualization */
.analytics-streak-bar {
  padding: 0.25rem 0;
}
.analytics-streak-track {
  height: 16px; background: var(--surface);
  border: 1px solid var(--border); position: relative;
  overflow: hidden;
}
.analytics-streak-fill {
  height: 100%; background: var(--accent);
  transition: width 0.6s var(--ease); opacity: 0.8;
}
.analytics-streak-labels {
  display: flex; justify-content: space-between;
  margin-top: 0.375rem;
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.analytics-streak-record {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--accent); margin-top: 0.375rem;
  text-align: center;
}

/* 2-column grid for paired sections */
.analytics-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.analytics-grid-2 > .analytics-section {
  border-bottom: 1px solid var(--border);
}
.analytics-grid-2 > .analytics-section:nth-child(odd) {
  border-right: 1px solid var(--border);
}

@media (max-width: 640px) {
  .analytics-modal { max-height: 92vh; }
  .analytics-cards { gap: 0.375rem; }
  .analytics-card { min-width: 4rem; padding: 0.5rem; }
  .analytics-card-value { font-size: 1.125rem; }
  .analytics-preset-best { display: none; }
  .analytics-donut { flex-direction: column; gap: 0.75rem; }
  .analytics-record-cards { gap: 0.375rem; }
  .analytics-record-card { min-width: 4rem; padding: 0.5rem; }
  .analytics-record-time { font-size: 0.875rem; }
  .analytics-improvement-value { font-size: 1.5rem; }
  .analytics-grid-2 {
    grid-template-columns: 1fr;
  }
  .analytics-grid-2 > .analytics-section:nth-child(odd) {
    border-right: none;
  }
}

/* ====================== MULTIPLAYER ====================== */

.mp-panel {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); min-width: 20rem; max-width: 24rem;
  width: 92%; max-height: 90vh; overflow-y: auto;
}

.mp-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.mp-header h3 {
  font-family: var(--font-display); font-style: italic;
  font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; gap: 0.5rem;
}

.mp-error {
  padding: 0.5rem 1.5rem;
  font-size: 0.688rem; color: var(--color-error);
  background: rgba(239, 68, 68, 0.06);
  border-bottom: 1px solid var(--border-light);
}

.mp-lobby, .mp-room {
  padding: 1.25rem 1.5rem;
}

.mp-section {
  margin-bottom: 1.25rem;
}
.mp-section:last-child { margin-bottom: 0; }

.mp-section-title {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); margin-bottom: 0.625rem;
}

.mp-mode-picker {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 0.375rem; margin-bottom: 0.625rem;
}
.mp-mode-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.5rem; border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-family: var(--font-body); font-size: 0.688rem;
  color: var(--text-secondary);
  transition: all 150ms var(--ease);
}
.mp-mode-btn:hover { border-color: var(--text-tertiary); }
.mp-mode-active {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
}

.mp-join-row {
  display: flex; gap: 0.375rem;
}
.mp-code-input {
  flex: 1; padding: 0.5rem 0.625rem;
  border: 1px solid var(--border); background: var(--surface);
  font-family: var(--font-mono); font-size: 0.813rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text); outline: none;
  transition: border-color 150ms var(--ease);
}
.mp-code-input::placeholder {
  color: var(--text-tertiary); letter-spacing: 0.05em;
  text-transform: none;
}
.mp-code-input:focus { border-color: var(--accent); }

.mp-recent {
  display: flex; flex-direction: column; gap: 0.25rem;
}
.mp-recent-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.625rem; border: 1px solid var(--border-light);
  background: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.688rem;
  color: var(--text-secondary);
  transition: all 150ms var(--ease);
}
.mp-recent-item:hover { background: var(--bg-alt); }
.mp-recent-code {
  font-family: var(--font-mono); font-weight: 500;
  letter-spacing: 0.1em; color: var(--text);
}
.mp-recent-mode {
  font-size: 0.563rem; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-tertiary);
  flex: 1;
}

.mp-code-display {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; border: 1px solid var(--border);
  margin-bottom: 0.75rem; cursor: pointer;
  transition: background 150ms var(--ease);
}
.mp-code-display:hover { background: var(--bg-alt); }
.mp-code-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}
.mp-code-value {
  font-family: var(--font-mono); font-size: 1.375rem;
  font-weight: 500; letter-spacing: 0.2em;
  color: var(--text); flex: 1;
}
.mp-code-copy {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary);
}

.mp-room-mode {
  display: flex; align-items: center; gap: 0.375rem;
  font-family: var(--font-body); font-size: 0.688rem;
  color: var(--text-secondary); margin-bottom: 0.625rem;
}

.mp-status {
  display: flex; align-items: center; gap: 0.375rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); margin-bottom: 1rem;
}
.mp-status-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.mp-connected { background: var(--color-success); }
.mp-disconnected { background: var(--color-error); }

.mp-player-list {
  display: flex; flex-direction: column; gap: 0.25rem;
  margin-bottom: 1rem;
}
.mp-player {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0.5rem;
}
.mp-player-name {
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text);
}
.mp-empty {
  font-size: 0.688rem; color: var(--text-tertiary);
  font-style: italic; padding: 0.375rem 0;
}

.mp-turn-label {
  font-size: 0.563rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.mp-turn-indicator {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 600; color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.mp-your-turn {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-soft);
}
.mp-player-active { background: var(--bg-alt); }
.mp-player-you {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-tertiary); margin-left: auto;
}
.mp-player-turn {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent);
}
.mp-actions {
  display: flex; flex-direction: column; gap: 0.375rem;
  margin-top: 0.5rem;
}
.mp-leave {
  width: 100%; justify-content: center;
  color: var(--color-error); border-color: var(--color-error);
}
.mp-leave:hover {
  background: var(--color-error); color: #fff;
}

.header-room-tag {
  display: inline-flex; align-items: center; gap: 0.375rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  letter-spacing: 0.06em; color: var(--text-secondary);
  padding: 0.125rem 0.5rem;
  border: 1px solid var(--border-light);
  cursor: pointer;
  transition: all 150ms var(--ease);
}
.header-room-tag:hover { border-color: var(--border); }

.header-narrator-tag {
  display: inline-flex; align-items: center; gap: 0.25rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  letter-spacing: 0.06em; color: var(--accent);
  padding: 0.125rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  opacity: 0.8;
}

/* welcome join room */
.welcome-join-room {
  display: flex; align-items: center; gap: 0.375rem;
  margin-top: 2rem; justify-content: center;
  flex-wrap: wrap;
}
.welcome-join-icon { color: var(--text-tertiary); margin-right: 0.125rem; }
.welcome-join-room .mp-code-input { max-width: 8rem; }
.welcome-join-err {
  width: 100%; text-align: center;
  font-size: 0.688rem; color: var(--color-error);
  margin-top: 0.25rem;
}

@media (max-width: 640px) {
  .mp-panel { min-width: 0; width: 95%; max-width: none; }
  .mp-code-value { font-size: 1.125rem; }
}

/* ====================== RECEIPT NOTIFICATION ====================== */

.receipt-notification {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 1.25rem;
  max-width: 20rem; z-index: 400;
}
.receipt-title {
  font-family: var(--font-display); font-size: 0.875rem; font-weight: 700;
  margin-bottom: 0.625rem;
}
.receipt-info { margin-bottom: 0.75rem; }
.receipt-info p {
  font-family: var(--font-body); font-size: 0.688rem;
  color: var(--text); line-height: 1.5;
}
.receipt-detail {
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-secondary);
}
.receipt-qr {
  display: flex; justify-content: center;
  padding: 0.75rem 0; color: var(--text);
}
.receipt-url-row {
  display: flex; align-items: center; gap: 0.25rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border-light);
  background: var(--bg-alt); padding: 0.25rem 0.5rem;
}
.receipt-url {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-secondary);
}
.receipt-copy-btn { flex-shrink: 0; padding: 0.125rem; }
.receipt-actions { display: flex; gap: 0.375rem; }

/* receipt claim section in settings */
.receipt-claim-section { margin-top: 0.5rem; }
.receipt-claim-input {
  display: flex; gap: 0.375rem; margin-bottom: 0.5rem;
}
.receipt-claim-input input {
  flex: 1; padding: 0.375rem 0.5rem;
  border: 1px solid var(--border); background: var(--bg-alt);
  color: var(--text); font-family: var(--font-mono); font-size: 0.688rem;
}
.receipt-claim-msg {
  font-family: var(--font-mono); font-size: 0.625rem;
  margin-top: 0.25rem;
}
.receipt-claim-msg-ok { color: var(--color-success); }
.receipt-claim-msg-err { color: var(--color-error); }

@media (max-width: 640px) {
  .receipt-notification { left: 1rem; right: 1rem; max-width: none; bottom: 1rem; }
}

/* ====================== PARTY MODE ====================== */

.mp-mode-picker-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.party-room-bar {
  display: flex; align-items: stretch; gap: 0.5rem;
  margin-bottom: 1rem;
}
.party-room-bar .mp-code-display { flex: 1; }
.party-room-bar .mp-leave { height: auto; }

.party-game {
  display: flex; flex-direction: column; gap: 1rem;
  width: 100%; max-width: 36rem;
}

.party-main {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; width: 100%;
}

.party-round {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-tertiary); margin-bottom: 0.25rem;
}

.party-mode-title {
  font-family: 'Abril Fatface', serif;
  font-size: 2.25rem; font-weight: 400; letter-spacing: 0.02em;
  text-transform: uppercase; margin: 0 0 0.25rem;
}

.party-timer {
  font-family: var(--font-mono); font-size: 1.75rem;
  font-weight: 700; color: var(--text);
  line-height: 1; margin-bottom: 0.75rem;
  transition: color 200ms var(--ease);
}
.party-timer-urgent {
  color: var(--color-error);
  animation: partyPulse 0.6s ease-in-out infinite;
}
@keyframes partyPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.party-phase-content {
  width: 100%; display: flex; flex-direction: column;
  align-items: center; gap: 0.75rem;
}

.party-phase-label {
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--accent); font-weight: 600;
}

.party-clue {
  font-family: var(--font-display); font-size: 1.25rem;
  font-style: italic; font-weight: 500;
  color: var(--text); line-height: 1.35;
  max-width: 100%; padding: 0.75rem 0;
}
.party-clue-sm {
  font-size: 0.938rem; padding: 0.375rem 0;
}

.party-submit-area {
  width: 100%; display: flex; flex-direction: column; gap: 0.5rem;
}

.party-input-wrap {
  position: relative; width: 100%;
}
.party-input {
  width: 100%; padding: 0.625rem 3rem 0.625rem 0.75rem;
  border: 1px solid var(--border); background: var(--surface);
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text); outline: none;
  transition: border-color 150ms var(--ease);
}
.party-input:focus { border-color: var(--accent); }
.party-input::placeholder { color: var(--text-tertiary); }
.party-char-count {
  position: absolute; right: 0.625rem; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 0.5rem;
  color: var(--text-tertiary); letter-spacing: 0.05em;
}

.party-submit-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 0.375rem; width: 100%;
}

.party-submitted {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.75rem 1rem; border: 1px solid var(--correct);
  color: var(--correct);
  font-family: var(--font-mono); font-size: 0.688rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}

.party-answers {
  width: 100%; display: flex; flex-direction: column; gap: 0.375rem;
}

.party-answer-card {
  width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text); position: relative;
  transition: all 150ms var(--ease);
  display: flex; align-items: center; justify-content: space-between;
}
.party-answer-card:hover:not(:disabled) {
  border-color: var(--accent); background: var(--accent-soft);
}
.party-answer-card:active:not(:disabled) {
  transform: scale(0.98);
}
.party-answer-card:disabled {
  cursor: default;
}
.party-answer-selected {
  border-color: var(--accent); background: var(--accent-soft);
}
.party-answer-text { flex: 1; }
.party-answer-check { color: var(--accent); flex-shrink: 0; }

.party-voted {
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.party-real-answer {
  font-family: var(--font-mono); font-size: 0.688rem;
  color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 0.75rem;
}
.party-real-answer-word {
  font-size: 1rem; font-weight: 700;
  color: var(--correct); letter-spacing: 0.12em;
}

.party-results-list {
  width: 100%; display: flex; flex-direction: column; gap: 0.5rem;
}

.party-result {
  width: 100%; padding: 0.625rem 0.75rem;
  border: 1px solid var(--border); background: var(--surface);
  text-align: left;
}
.party-result-real {
  border-color: var(--correct);
  background: rgba(45, 122, 79, 0.06);
}
.party-result-top {
  border-color: var(--accent);
}

.party-result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.25rem;
}
.party-result-author {
  display: flex; align-items: center; gap: 0.375rem;
  font-family: var(--font-mono); font-size: 0.563rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 600;
}
.party-result-votes {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--text-tertiary); letter-spacing: 0.06em;
}
.party-result-text {
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text); margin-bottom: 0.375rem;
}

.party-result-bar-track {
  width: 100%; height: 3px; background: var(--border-light);
}
.party-result-bar-fill {
  height: 100%;
}

.party-scoreboard {
  border: 1px solid var(--border); padding: 0.75rem;
}
.party-scoreboard-title {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin-bottom: 0.5rem;
}
.party-score-row {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.25rem 0;
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text);
}
.party-score-you { font-weight: 600; }
.party-score-name { flex: 1; }
.party-score-pts {
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 600; color: var(--accent);
}

.party-final {
  display: flex; flex-direction: column; align-items: center;
  padding: 1rem 0;
}
.party-final-header {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; margin-bottom: 1.25rem;
}
.party-final-header h2 {
  font-family: var(--font-display); font-style: italic;
  font-size: 1.5rem; font-weight: 700;
  color: var(--text);
}
.party-final-list {
  width: 100%; display: flex; flex-direction: column; gap: 0.375rem;
}
.party-final-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.625rem 0.75rem; border: 1px solid var(--border);
  background: var(--surface);
}
.party-final-winner {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.06);
}
.party-final-rank {
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 600; color: var(--text-tertiary);
  min-width: 1.5rem; text-align: center;
}
.party-final-name {
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text); flex: 1;
}
.party-final-pts {
  font-family: var(--font-mono); font-size: 1rem;
  font-weight: 700; color: var(--accent);
}

.mp-party-sub-selected {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.625rem; margin-top: 0.25rem; margin-bottom: 0.5rem;
  text-align: left;
  border: 1px solid var(--border); cursor: pointer;
  font-family: var(--font-body); font-size: 0.75rem;
  font-weight: 600; color: var(--text);
  transition: border-color 150ms var(--ease);
}
.mp-party-sub-selected:hover { border-color: var(--accent); }
.mp-party-dropdown {
  position: fixed; z-index: 9998;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow-y: auto;
}
.mp-party-drop-item {
  display: flex; flex-direction: column; gap: 0.25rem;
  width: 100%; padding: 0.625rem 0.75rem;
  border: none; border-bottom: 1px solid var(--border-light);
  background: transparent; cursor: pointer;
  text-align: left; transition: background 150ms var(--ease);
}
.mp-party-drop-item:last-child { border-bottom: none; }
.mp-party-drop-item:hover { background: var(--bg-alt); }
.mp-party-drop-active { background: var(--accent-soft); }
.mp-party-drop-active:hover { background: var(--accent-soft); }
.mp-party-drop-name {
  font-family: var(--font-body); font-size: 0.75rem;
  font-weight: 600; color: var(--text);
}
.mp-party-drop-active .mp-party-drop-name { color: var(--accent); }
.mp-party-drop-desc {
  font-family: var(--font-body); font-size: 0.625rem;
  color: var(--text-tertiary); line-height: 1.4;
}

.party-speed-feed {
  width: 100%; display: flex; flex-direction: column; gap: 0.25rem;
  margin-top: 0.5rem;
}
.party-speed-correct {
  display: flex; align-items: center; gap: 0.375rem;
  padding: 0.375rem 0.625rem; border: 1px solid var(--correct);
  background: rgba(45, 122, 79, 0.06);
  font-family: var(--font-body); font-size: 0.75rem;
  color: var(--text);
}
.party-speed-pts {
  font-family: var(--font-mono); font-size: 0.688rem;
  font-weight: 600; color: var(--correct);
  margin-left: auto;
}

.party-roulette-options {
  width: 100%; display: flex; flex-direction: column; gap: 0.375rem;
}
.party-roulette-option {
  width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; text-align: left;
  font-family: var(--font-body); font-size: 0.813rem;
  color: var(--text); position: relative;
  transition: all 150ms var(--ease);
  display: flex; align-items: center; gap: 0.625rem;
}
.party-roulette-option:hover:not(:disabled) {
  border-color: var(--accent); background: var(--accent-soft);
}
.party-roulette-option:disabled { cursor: default; }
.party-roulette-picked {
  border-color: var(--accent); background: var(--accent-soft);
}
.party-roulette-label {
  font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 700; color: var(--accent);
  flex-shrink: 0; min-width: 1.25rem;
}
.party-roulette-text { flex: 1; }

/* party full page */
.party-page {
  display: flex; flex-direction: column; align-items: center;
  min-height: calc(100vh - 3rem); padding: 1rem;
}
.party-page-bar {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; max-width: 36rem; margin-bottom: 1.5rem;
  padding: 0.5rem 0.75rem; border: 1px solid var(--border);
  background: var(--surface);
}
.party-page-room {
  display: flex; align-items: center; gap: 0.375rem;
  cursor: pointer; flex: 1;
}
.party-page-code {
  font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 600; letter-spacing: 0.1em;
}
.party-page-sub {
  font-size: 0.625rem; color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.party-page-copied {
  font-family: var(--font-mono); font-size: 0.563rem;
  color: var(--accent); text-transform: uppercase;
}
.party-page-players-compact {
  display: flex; align-items: center; gap: 0.25rem;
  font-family: var(--font-mono); font-size: 0.625rem;
  color: var(--text-tertiary);
}
.party-page-leave {
  color: var(--text-tertiary); border-color: var(--border);
}
.party-page-leave:hover {
  color: var(--color-error); border-color: var(--color-error);
}
.party-lobby {
  display: flex; flex-direction: column; align-items: center;
  max-width: 22rem; width: 100%; margin-top: 4rem;
}
.party-lobby-icon { color: var(--accent); margin-bottom: 0.75rem; }
.party-lobby-title {
  font-family: var(--font-display); font-style: italic;
  font-size: 1.5rem; font-weight: 700; margin: 0 0 0.25rem;
}
.party-lobby-sub {
  font-family: var(--font-mono); font-size: 0.625rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary); margin: 0 0 2rem;
}
.party-lobby-code {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; padding: 0.75rem 1rem; margin-bottom: 1.5rem;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color 150ms var(--ease);
}
.party-lobby-code:hover { border-color: var(--text); }
.party-lobby-code-label {
  font-family: var(--font-mono); font-size: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-tertiary);
}
.party-lobby-code-value {
  font-family: var(--font-mono); font-size: 1.5rem;
  font-weight: 700; letter-spacing: 0.2em; flex: 1;
}
.party-lobby-code-copy {
  font-size: 0.563rem; color: var(--text-tertiary);
}
.party-lobby-players {
  width: 100%; margin-bottom: 1.5rem;
}
.party-lobby-player {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.375rem 0; font-size: 0.8125rem;
}
.party-lobby-hint {
  font-size: 0.688rem; color: var(--text-tertiary);
  font-style: italic; margin: 0.5rem 0 0;
}
.party-lobby-actions {
  width: 100%; display: flex; flex-direction: column; gap: 0.375rem;
}
.party-confirm {
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 1.5rem;
  max-width: 20rem; width: 90%; text-align: center;
}
.party-confirm-text {
  font-size: 0.8125rem; color: var(--text); margin: 0 0 1rem;
}
.party-confirm-actions {
  display: flex; gap: 0.5rem; justify-content: center;
}
.party-confirm-leave {
  color: var(--color-error); border-color: var(--color-error);
}
.party-confirm-leave:hover {
  background: var(--color-error); color: #fff;
}

@media (max-width: 24rem) {
  .settings-panel-tabs { min-width: 0; max-width: 100%; }
  .achievements-panel, .community-panel, .mp-panel, .share-modal { min-width: 0; width: 100%; }
  .analytics-modal { max-width: 100%; }
  .settings-body { flex-direction: column; }
  .settings-sidebar { flex-direction: row; overflow-x: auto; }
}

/* focus-visible contracts for composite controls */
.cv-number-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cv-select-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cv-select-option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
