:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #e8e4db;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --accent: #8b0000;
  --accent-2: #5c0000;
  --success: #1e4d2b;
  --danger: #8b0000;
  --warning: #8b6914;
  --radius: 0px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --border: 1px solid #1a1a1a;
  --font-display: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-serif: Georgia, 'Times New Roman', serif;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface-2: #2c2c2c;
  --text: #e0e0e0;
  --muted: #999;
  --accent: #c0392b;
  --accent-2: #8b0000;
  --success: #2ecc71;
  --border: 1px solid #444;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.015) 2px,
      rgba(0,0,0,0.015) 3px
    ),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.02'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: auto, 200px 200px;
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 24px 24px;
}

.layout {
  width: 100%;
  max-width: 960px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 28px;
  align-items: start;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 32px;
}
.sidebar-header { display:flex; flex-direction:column; gap:4px; }
h1 { margin: 0; font-size: 32px; letter-spacing: 1px; font-family: var(--font-serif); font-weight: 900; text-transform: uppercase; }
.sub { color: var(--muted); font-size: 13px; font-style: italic; }
.stats {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.stat-chip {
  background: var(--surface);
  border: var(--border);
  border-radius: 0px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-display);
  width: 100%;
}
.stat-chip .num { color: var(--text); }

.stat-sep {
  color: var(--surface-2);
  margin: 0 4px;
  font-weight: 400;
  font-size: 0.9em;
}

.game-board {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.instructions {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.instructions strong { color: var(--text); font-weight: 600; }

.slots-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 200px;
}

.event-slot {
  min-height: 80px;
  border: 2px dashed transparent;
  border-radius: var(--radius);
  transition: border-color .2s ease, background .2s ease;
}
.event-slot.locked {
  border-color: rgba(30,77,43,0.3);
}
.event-slot.drag-over {
  border-color: var(--accent);
  background: rgba(139,0,0,0.04);
}
.event-slot.drag-over.locked {
  border-color: rgba(30,77,43,0.3);
  background: transparent;
}

.event-item {
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: grab;
  transition: transform .15s ease, box-shadow .15s ease, border-color .2s ease, background .2s ease;
  user-select: none;
  touch-action: none;
  position: relative;
  min-height: 80px;
}
.event-item.sortable-ghost { opacity: .25; }
.event-item.sortable-drag { opacity: 1; background: var(--surface-2); box-shadow: var(--shadow); transform: scale(1.01); }
.event-item:active { cursor: grabbing; }

.event-item.correct {
  border-color: var(--success);
  background: rgba(30,77,43,0.06);
}
.event-item.correct::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 4px;
  background: var(--success);
}
.event-item.wrong {
  border-color: var(--danger);
  background: rgba(139,0,0,0.04);
}
.event-item.locked {
  cursor: default;
}
.event-item.locked .drag-handle {
  opacity: 0.35;
  cursor: default;
}
.event-item.correct .drag-handle {
  display: none;
}
.event-item.dragging {
  opacity: 0.5;
  transform: scale(1.02);
}

.event-thumb {
  width: 96px;
  height: 60px;
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
  color: var(--text);
  flex-shrink: 0;
  user-select: none;
  overflow: hidden;
  order: -1;
  cursor: pointer;
  border: var(--border);
}
.event-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.event-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  justify-content: center;
}

.event-text {
  font-size: 15px;
  line-height: 1.4;
  font-family: var(--font-serif);
}

.event-source {
  font-size: 12px;
  color: var(--muted);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height .3s ease, opacity .3s ease, margin-top .3s ease;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  text-overflow: ellipsis;
  margin-top: 0;
}
.event-source.visible {
  max-height: 40px;
  opacity: 1;
  margin-top: 4px;
}
.event-source:hover { color: var(--accent); }

.event-year {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  min-width: 0;
  text-align: right;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity .3s ease, transform .3s ease;
  font-family: var(--font-serif);
}
.event-year.revealed { opacity: 1; transform: translateX(0); }

/* Postgame: revealed dates in accent color */
.layout.game-over .event-year.revealed {
  color: var(--accent);
}

.correct-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--success);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 0px;
  display: none;
  z-index: 2;
  line-height: 1;
  border: 2px solid var(--success);
}
.event-item.correct .correct-badge { display: block; }

.check-mark {
  display: none;
}

.drag-handle {
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  cursor: grab;
}

/* Postgame: hide drag handles and flush-right dates */
.layout.game-over .event-item .drag-handle {
  display: none;
}

.layout.game-over .event-item .event-year.revealed {
  text-align: right;
  margin-left: auto;
  min-width: auto;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
  flex-wrap: wrap;
  width: 100%;
}
#submit-btn { flex: 1; }
#sidebar-share-btn {
  width: 100%;
  margin-top: 8px;
}
.sidebar-disclaimer {
  margin-top: auto;
  padding-top: 8px;
  font-size: 11px;
}
.sidebar-disclaimer a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.sidebar-disclaimer a:hover {
  color: var(--accent);
}
button {
  appearance: none;
  border: var(--border);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .1s ease, background .2s ease;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
button:hover { background: var(--accent-2); }
button:active { transform: scale(0.98); }
button.secondary {
  background: var(--surface);
  color: var(--text);
  border: var(--border);
  box-shadow: none;
}
button.secondary:hover { background: var(--surface-2); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; filter: none !important; }

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 100;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-bg {
  position: absolute;
  inset: 0;
  background: rgba(26,26,26,0.7);
}
.modal {
  position: relative;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transform: translateY(12px);
  transition: transform .3s ease;
}
.overlay.show .modal { transform: translateY(0); }
.modal h2 { margin: 0 0 8px; font-size: 22px; font-family: var(--font-serif); }
.modal p { margin: 6px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.modal .big { font-size: 32px; margin: 8px 0 2px; }
.settings-item + .settings-item,
.mobile-settings-item + .mobile-settings-item {
  margin-top: 12px;
}
.countdown { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }

.share-row { display:flex; gap:10px; margin-top: 14px; }
.share-row button { flex: 1; }

.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--danger);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 200;
}
.error-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden { display: none !important; }

/* Reading mode toggle */
.reading-mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: -8px;
}
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}
.toggle-switch input {
  display: none;
}
.toggle-slider {
  width: 36px;
  height: 20px;
  background: var(--surface-2);
  border-radius: 0px;
  position: relative;
  transition: background .2s ease;
  flex-shrink: 0;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  background: var(--text);
  border-radius: 0px;
  transition: transform .2s ease;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}
.toggle-hint {
  font-size: 11px;
  color: var(--muted);
  margin-left: 46px;
  line-height: 1.3;
}

/* Auth section in header */
.auth-section {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.auth-section button {
  padding: 8px 14px;
  font-size: 13px;
  box-shadow: none;
  width: 100%;
}
.auth-section .user-name {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* Auth modal */
.auth-modal .input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.auth-modal label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.auth-modal input {
  background: var(--bg);
  border: var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  font-family: var(--font-body);
}
.auth-modal input:focus {
  border-color: var(--accent);
}
.auth-modal .auth-toggle {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  margin-top: 10px;
  text-align: center;
}
.auth-modal .auth-toggle:hover {
  text-decoration: underline;
}
.auth-modal .auth-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: -8px;
  margin-bottom: 10px;
}

/* Image Lightbox */
.lightbox-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 90vh;
  z-index: 101;
}
.lightbox-card {
  position: relative;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}
.lightbox-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: var(--radius);
}
.lightbox-caption {
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  max-width: 100%;
}
.lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(244,241,234,0.9);
  border: var(--border);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 10px;
  box-shadow: none;
  z-index: 102;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0px;
}
.lightbox-close:hover {
  color: var(--accent);
}

.view-toggle {
  display: flex;
  justify-content: center;
  margin: 2px 0 0;
}

.view-toggle-track {
  display: inline-flex;
  background: var(--surface);
  border: var(--border);
  border-radius: 0px;
  padding: 2px;
  gap: 0;
}

.view-toggle-label {
  padding: 6px 18px;
  font-size: 13px;
  font-family: var(--font-display);
  color: var(--muted);
  cursor: pointer;
  transition: background 0.25s, color 0.25s;
  white-space: nowrap;
  user-select: none;
  border-radius: 0px;
}

.view-toggle-label.active {
  background: var(--accent);
  color: #fff;
}

/* Mobile game view — hidden on desktop */
.mobile-game-view {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop layout */
  .layout {
    display: none !important;
  }

  body {
    padding: 0;
    margin: 0;
    display: block;
    background: var(--bg);
  }

  .mobile-game-view {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .mobile-top-bar {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    align-items: center;
    padding: 12px 16px;
    flex-shrink: 0;
  }

  .mobile-logo-block {
    display: flex;
    flex-direction: column;
    gap: 0;
    justify-self: start;
  }

  .mobile-logo {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 1.5px;
    color: var(--text);
    font-family: var(--font-serif);
    text-transform: uppercase;
    line-height: 1.2;
  }

  .mobile-date {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    line-height: 1;
  }

  .mobile-top-actions {
    justify-self: end;
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .mobile-stats-pill {
    justify-self: center;
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: 0px;
    padding: 8px 16px;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
  }

  .mobile-stats-pill span span {
    color: var(--text);
  }

  .mobile-settings-btn {
    background: none;
    border: none;
    font-size: 22px;
    padding: 4px;
    cursor: pointer;
    box-shadow: none;
    color: var(--text);
    line-height: 1;
  }
  .mobile-settings-btn:active {
    transform: scale(0.92);
  }

  .mobile-big-card-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    flex: 1;
    min-height: 0;
    gap: 4px;
  }

  .mobile-big-card {
    flex: 1;
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 8px;
    max-height: 100%;
    overflow-y: auto;
    transition: transform 0.15s ease;
    position: relative;
    min-height: 0;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-big-card .mobile-big-thumb {
    width: 100%;
    border-radius: var(--radius);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    border: var(--border);
  }

  .mobile-big-card .mobile-big-thumb img {
    width: 100%;
    object-fit: contain;
    border-radius: inherit;
    display: block;
  }

  .mobile-big-card .mobile-big-thumb span {
    font-size: 48px;
    font-weight: 700;
    color: var(--text);
  }

  .mobile-big-card .mobile-big-text {
    font-size: 17px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--text);
    font-family: var(--font-serif);
  }

  .mobile-big-card .event-source {
    max-height: none;
    opacity: 1;
    margin-top: 2px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
    white-space: normal;
    overflow-wrap: break-word;
    display: none;
  }
  .mobile-big-card .event-source.visible {
    display: block;
  }

  .mobile-big-date-inline {
    color: var(--accent);
    font-weight: 700;
    white-space: nowrap;
  }

  .mobile-reorder-bar {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 8px 0;
  }

  .mobile-reorder-btn {
    background: var(--surface);
    border: var(--border);
    border-radius: 0px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: background .15s ease, transform .1s ease, border-color .2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    font-family: var(--font-display);
    min-width: 120px;
  }
  .mobile-reorder-btn:active {
    transform: scale(0.97);
    background: var(--surface);
  }
  .mobile-reorder-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
  }

  .mobile-locked-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--success);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 0px;
  }

  .mobile-placeholder {
    font-size: 16px;
    color: var(--muted);
    font-style: italic;
  }

  .view-toggle {
    padding: 8px 16px;
    margin-bottom: 8px;
    flex-shrink: 0;
    max-width: 480px;
    width: 100%;
    align-self: center;
  }

  .mobile-slot-strip {
    display: flex;
    gap: 0;
    justify-content: center;
    align-items: flex-end;
    padding: 6px 12px 4px;
    margin-top: 16px;
    flex-shrink: 0;
    min-height: 85px;
    --card-width: 60px;
    --card-overlap: 18px;
  }

  .mobile-slot {
    width: var(--card-width);
    height: calc(var(--card-width) * 1.35);
    background: var(--surface);
    border: 2px solid var(--surface-2);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform .2s ease, border-color .2s ease, background .2s ease, box-shadow .2s ease, opacity .2s ease;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    margin-left: calc(-1 * var(--card-overlap));
    padding: 2px;
    z-index: 1;
  }

  .mobile-slot:first-child {
    margin-left: 0;
  }

  .mobile-slot-thumb {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 0px;
    background: var(--surface-2);
    font-size: calc(var(--card-width) * 0.35);
    font-weight: 700;
    color: var(--text);
  }

  .mobile-slot-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    pointer-events: none;
  }

  .mobile-slot-num {
    position: absolute;
    top: 2px;
    left: 2px;
    background: var(--surface);
    border: 1px solid var(--surface-2);
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0px;
    z-index: 3;
    line-height: 1;
  }

  .mobile-slot.active {
    transform: translateY(-8px) scale(1.05);
    border-color: var(--accent);
    background: var(--surface-2);
    box-shadow: 0 6px 20px rgba(139,0,0,0.2);
    z-index: 10;
  }

  .mobile-slot.locked {
    border-color: var(--success);
    background: rgba(30,77,43,0.06);
  }

  .mobile-slot.locked.active {
    border-color: var(--success);
    box-shadow: 0 6px 20px rgba(30,77,43,0.2);
    z-index: 10;
  }

  .mobile-slot.locked .mobile-slot-num {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    font-size: 11px;
  }

  .mobile-slot.correct {
    border-color: var(--success);
  }

  .mobile-slot.wrong {
    border-color: rgba(139,0,0,0.3);
  }

  /* Dim inactive neighbors when one is active */
  .mobile-slot-strip:has(.mobile-slot.active) .mobile-slot:not(.active) {
    opacity: 0.82;
  }

  .mobile-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px 20px;
    gap: 12px;
    flex-shrink: 0;
  }

  #mobile-submit-btn {
    flex: 1;
    max-width: 480px;
    font-size: 16px;
    padding: 14px 24px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(139,0,0,0.15);
  }

  #mobile-share-btn {
    margin: 0 16px 16px;
    padding: 14px 24px;
    font-size: 16px;
    width: calc(100% - 32px);
    max-width: 480px;
    align-self: center;
    flex-shrink: 0;
  }

  .mobile-disclaimer {
    text-align: center;
    padding: 4px 16px 16px;
    font-size: 11px;
    flex-shrink: 0;
    max-width: 480px;
    width: 100%;
    align-self: center;
  }
  .mobile-disclaimer a {
    color: var(--muted);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .mobile-disclaimer a:hover {
    color: var(--accent);
  }

  .settings-modal {
    max-width: 320px;
    border: var(--border);
    border-radius: var(--radius);
  }

  /* Mobile settings overlay adjustments */
  .mobile-settings-modal {
    max-width: 320px;
    border: var(--border);
    border-radius: var(--radius);
  }

  .mobile-instructions {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
  }

  .lightbox-close { top: 8px; right: 8px; font-size: 20px; width: 32px; height: 32px; }
}

/* Tablet layout */


/* ===== Onboarding ===== */
.onboarding-card {
  position: relative;
  background: var(--surface);
  border: var(--border);
  border-radius: var(--radius);
  padding: 28px 24px 20px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  z-index: 101;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.onboarding-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  box-shadow: none;
  z-index: 102;
}
.onboarding-close:hover { color: var(--accent); }

.settings-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  box-shadow: none;
  z-index: 102;
}
.settings-close:hover { color: var(--accent); }

.onboarding-slide {
  display: none;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.onboarding-slide.active {
  display: flex;
}

.onboarding-slide h2 {
  margin: 0;
  font-size: 22px;
  font-family: var(--font-display);
  color: var(--text);
}

.onboarding-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}
.onboarding-body strong {
  color: var(--text);
}

.onboarding-footer {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}

.onboarding-dots {
  display: flex;
  gap: 8px;
}

.onboarding-dots .dot {
  width: 8px;
  height: 8px;
  border-radius: 0px;
  background: var(--surface-2);
  transition: background .2s ease;
}
.onboarding-dots .dot.active {
  background: var(--accent);
}

.onboarding-next,
.onboarding-got-it {
  width: 100%;
  padding: 12px;
  font-size: 15px;
}

/* Help buttons */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.help-btn,
.settings-btn {
  background: none;
  border: 1px solid var(--surface-2);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 0px;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  font-family: var(--font-display);
}
.help-btn:hover,
.settings-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mobile-help-btn {
  background: none;
  border: 1px solid var(--surface-2);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 0px;
  font-size: 16px;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
  font-family: var(--font-display);
  -webkit-tap-highlight-color: transparent;
}
.mobile-help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.logo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Desktop / mobile slide visibility */
.desktop-only { display: none !important; }
.mobile-only { display: none !important; }

@media (min-width: 769px) {
  .desktop-only.onboarding-slide.active { display: flex !important; }
}
@media (max-width: 768px) {
  .mobile-only.onboarding-slide.active { display: flex !important; }
}
