/* 1. CONFIGURATION & VARIABLES */
:root {
  --grid-n: 8; /* Updated by JS */
  --cell-size: min(60px, 85vw / var(--grid-n));
  --line-thin: 1px solid #ccc;

  /* Brand */
  --primary-blue: #1976d2;
  --primary-blue-hover-bg: #f0f6ff;
  --primary-blue-active-bg: #e3f0ff;

  /* Semantic */
  --color-solved: #2e7d32;
  --color-solved-dark: #1b5e20;
  --color-error: #c62828;
  --color-win: #6a1b9a;

  /* Neutral palette */
  --bg-light: #f8f9fa;
  --bg-card: #fafafa;
  --bg-white: #fff;
  --border-subtle: #eee;
  --border-light: #e0e0e0;
  --border-input: #ddd;
  --border-strong: #bbb;
  --text-primary: #111;
  --text-secondary: #666;
  --text-muted: #888;
  --text-subtle: #777;

  /* Cell */
  --cell-bg: #fff;
  --cell-border: #ccc;

  /* Highlight overlays */
  --highlight-error-bg:       rgba(255, 0,   0,   0.10);
  --highlight-drag-bg:        rgba(255, 165, 0,   0.18);
  --highlight-hint-blue-bg:   rgba(0,   123, 255, 0.25);
  --highlight-hint-red-bg:    rgba(255, 0,   0,   0.22);
  --highlight-hint-red-out:   rgba(200, 0,   0,   0.55);
  --highlight-hint-green-bg:  rgba(0,   200, 0,   0.25);
  --highlight-hint-yellow:    rgba(255, 255, 0,   0.65);
  --highlight-error-star:     #d00;

  /* Cross-board hover sync — desktop only */
  --highlight-hover-sync-bg:  rgba(0, 180, 160, 0.13);
}

[data-theme="dark"] {
  --primary-blue: #64b5f6;
  --primary-blue-hover-bg: #1a2a3a;
  --primary-blue-active-bg: #1e3248;

  --color-solved: #66bb6a;
  --color-solved-dark: #388e3c;
  --color-error: #ef5350;
  --color-win: #ce93d8;

  --bg-light: #1e1e1e;
  --bg-card: #252525;
  --bg-white: #1a1a1a;
  --border-subtle: #333;
  --border-light: #3a3a3a;
  --border-input: #444;
  --border-strong: #555;
  --text-primary: #e8e8e8;
  --text-secondary: #aaa;
  --text-muted: #888;
  --text-subtle: #999;

  --cell-bg: #2a2a2a;
  --cell-border: #444;
  --line-thin: 1px solid #444;

  /* Highlight overlays — higher opacity so they read on dark cell backgrounds */
  --highlight-error-bg:       rgba(255, 80,  80,  0.28);
  --highlight-drag-bg:        rgba(255, 180, 0,   0.32);
  --highlight-hint-blue-bg:   rgba(80,  160, 255, 0.35);
  --highlight-hint-red-bg:    rgba(255, 80,  80,  0.35);
  --highlight-hint-red-out:   rgba(255, 100, 100, 0.70);
  --highlight-hint-green-bg:  rgba(80,  220, 80,  0.30);
  --highlight-hint-yellow:    rgba(255, 255, 80,  0.50);
  --highlight-error-star:     #ff6b6b;

  /* Cross-board hover sync — desktop only */
  --highlight-hover-sync-bg:  rgba(0, 210, 190, 0.18);
}

/* 2. RESET & BASE STYLES */
* { box-sizing: border-box; }

body {
  font-family: sans-serif;
  margin: 0;
  background-color: var(--bg-white);
  color: var(--text-primary);
}

button {
  padding: 8px 16px;
  cursor: pointer;
  background: var(--border-light);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  color: var(--text-primary);
  transition: background 0.2s;
  --btn-font-size: 1rem;
  font-size: var(--btn-font-size);
}

/* Scoped to enabled buttons only — removes need for button:disabled:hover override */
button:not(:disabled):hover { background: var(--border-input); }

button:disabled {
  background: var(--bg-light);
  color: var(--text-muted);
  border-color: var(--border-light);
  cursor: not-allowed;
  opacity: 0.6;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* 3. LAYOUT CONTAINERS */
#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 20px 160px;
  min-height: 100vh;
}

.menu-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
  padding: 15px;
  background: var(--bg-light);
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

#boards-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  min-height: 400px;
}

/* 4. MENU & INPUT COMPONENTS */
.menu-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Only needs to override gap — flex/align inherited from .menu-group context */
.puzzle-nav { gap: 8px; }

.input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  margin-right: 25px;
}

.input-relative-box {
  position: relative;
  display: inline-block;
}

#puzzle-input {
  width: 65px;
  padding: 6px;
  border: 2px solid var(--border-input);
  border-radius: 4px;
  text-align: center;
  font-size: 1.125rem; /* was 18px */
  font-weight: bold;
  background: var(--bg-white);
  color: var(--text-primary);
}

#puzzle-input:focus {
  border-color: var(--primary-blue);
  outline: none;
}

.label-top, .label-bottom {
  font-size: 0.6875rem; /* was 11px */
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#solved-badge {
  position: absolute;
  right: -25px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* 5. GRID & GAMEPLAY */
.grid-wrapper {
  position: relative;
}

.star-battle-grid {
  display: grid;
  user-select: none;
  touch-action: none; /* Prevents scrolling while drawing */
}

.cell {
  font-size: calc(var(--cell-size) * 0.55);
  width: var(--cell-size);
  height: var(--cell-size);
  border: var(--line-thin);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  /* box-sizing already set globally */
  background-color: var(--cell-bg);
  position: relative;
  overflow: visible;
  -webkit-tap-highlight-color: transparent;
}

.star { color: var(--text-primary); font-weight: bold; pointer-events: none; }

.dot {
  width: calc(var(--cell-size) * 0.12);
  height: calc(var(--cell-size) * 0.12);
  background: var(--text-secondary);
  border-radius: 50%;
  pointer-events: none; /* also covers .cell .dot — no separate rule needed */
  z-index: 5;
}

.region-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* SVG region borders inherit currentColor so they respect dark mode */
.region-svg path,
.region-svg rect {
  stroke: var(--text-primary);
}

/* Cell state overlays. No !important needed — .cell sets background-color: white
   at the same specificity, and these classes appear later in the cascade. */
.error-cell          { background-color: var(--highlight-error-bg); }

.error-cell .star { color: var(--highlight-error-star); }

/* Hint highlights — same cascade fix as above */
.hint-source-blue  { background-color: var(--highlight-hint-blue-bg); }
.hint-error-red    {
  background-color: var(--highlight-hint-red-bg);
  outline: 2px solid var(--highlight-hint-red-out);
  outline-offset: -2px;
}
.hint-target-green { background-color: var(--highlight-hint-green-bg); }
.hint-target-yellow {
  /* Use background-image so background-color can still show through beneath it */
  background-image: radial-gradient(circle, var(--highlight-hint-yellow) 70%, transparent 71%);
  background-size: 75% 75%;
  background-position: center;
  background-repeat: no-repeat;
}

/* Drag highlight uses background-color only, so hint-target-yellow's
   background-image (the circle) composites on top of it naturally. */
.cell-drag-highlight { background-color: var(--highlight-drag-bg); }

/* Cross-board hover sync — only applied via JS on pointer:fine (desktop) devices */
.cell-hover-sync { background-color: var(--highlight-hover-sync-bg); }

/* Drag takes priority over hover sync when both classes are present */
.cell-drag-highlight.cell-hover-sync { background-color: var(--highlight-drag-bg); }

/* 5b. AXIS LABELS */

/* When labels are on, .grid-wrapper becomes a CSS grid. The grid-template-columns
   and grid-template-rows are set via inline style in JS (where this.n is known).
   Layout: col 1 = row-label gutter, cols 2..N+1 = board columns
            row 1 = col-label gutter, rows 2..N+1 = board rows */
.grid-wrapper--labeled {
  display: grid;
  /* The row-label gutter on the left shifts the board rightward by --cell-size,
     so pull the whole wrapper left by half that amount to re-center visually.
     The col-label gutter on top has no effect on horizontal centering. */
  margin-left: calc(var(--cell-size) * -0.5);
}

/* The inner wrapper carries position:relative so the SVG overlay works correctly */
.axis-board-inner {
  position: relative;
  grid-column: 2;
}

.axis-label {
  font-size: calc(var(--cell-size) * 0.28);
  font-weight: 600;
  color: var(--text-secondary);
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  justify-self: center;
  user-select: none;
  pointer-events: none;
  line-height: 1;
}

/* 6. CONTROLS */
#controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 800px;
  margin-block: 20px;
}

/* 7. TOASTS & FEEDBACK */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);

  /* Critical for mobile wrapping */
  width: 90%;
  max-width: 500px;
  white-space: normal;
  text-align: center;
  line-height: 1.4;

  color: white;
  padding: 12px 20px;
  border-radius: 25px;
  z-index: 3000; /* Above modals */

  transition: opacity 0.3s, transform 0.3s;
}

.toast-hidden {
  opacity: 0;
  transform: translate(-50%, -20px) !important;
  pointer-events: none;
}

/* toast-info and toast-hint are identical — combined into one rule */
.toast-info,
.toast-hint    { background-color: var(--primary-blue); }
.toast-success { background-color: var(--color-solved); }
.toast-error   { background-color: var(--color-error); }

.toast-win {
  background-color: var(--color-win);
  border: 2px solid #ffd700;
  /* Only transition opacity — animation handles transform */
  transition: opacity 0.3s;
  animation: win-pulse 2s infinite;
}

@keyframes win-pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50%       { transform: translateX(-50%) scale(1.05); }
}

/* 8. RESPONSIVE DESIGN */
@media (min-width: 900px) {
  :root {
    --cell-size: min(55px, 42vw / var(--grid-n));
  }
  #boards-wrapper {
    flex-direction: row;
    justify-content: center;
    gap: 40px;
  }
}

@media (min-width: 601px) {
  #help-btn { margin-left: auto; }
}

@media (max-width: 600px) {
  :root {
    --cell-size: clamp(30px, 85vw / var(--grid-n), 65px);
  }
  .menu-container {
    flex-direction: column;
    gap: 15px;
  }
  .step-btn {
    padding: 12px 20px; /* Larger hit targets for mobile */
  }
  #controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Row 1: board state actions */
  #undo-btn, #redo-btn, #reset-btn { flex: 1 1 30%; }

  /* Row 2: help and checking tools */
  #check-btn, #hint-btn, #help-btn { flex: 1 1 30%; }

  /* Shorter label on mobile */
  #check-btn { font-size: 0; }
  #check-btn::after {
    content: attr(data-mobile-label);
    font-size: var(--btn-font-size);
  }
}

.step-btn:active { background: #ddd; }

/* 9. MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  transition: opacity 0.2s;
}

.modal-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Base modal. Use .modal-box--wide for browse/book-picker modals. */
.modal-box {
  background: var(--bg-white);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-box--wide {
  max-width: 560px;
  width: 94%;
  max-height: 85vh;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-header button {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--text-secondary);
}

.modal-header button:not(:disabled):hover {
  color: #000;
  background: #f0f0f0;
  border-radius: 4px;
}

.modal-body {
  padding: 16px 20px;
  line-height: 1.6;
}

.modal-body h3 { margin: 16px 0 8px; }
.modal-body ul { margin: 8px 0; padding-left: 20px; }
.modal-body li { margin-bottom: 6px; }

.modal-action-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-footer-note {
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 10. BROWSE MODAL */
.browse-modal-body { padding: 12px 16px 20px; }

.browse-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 10px;
  flex-wrap: wrap;
}

.browse-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 2px;
}

.legend-solved   { background: var(--color-solved); }
.legend-current  { background: var(--primary-blue); }
.legend-unsolved { background: var(--border-light); border: 1px solid var(--border-strong); }

.browse-jump-btn {
  font-size: 0.82rem;
  padding: 5px 10px;
  white-space: nowrap;
}

.browse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 6px;
  max-height: 55vh;
  overflow-y: auto;
  padding: 2px; /* room for focus rings */
}

.browse-tile {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s, box-shadow 0.1s;
  background: var(--border-light);
  color: var(--text-primary);
  padding: 0;
  min-width: 0;
}

.browse-tile:not(:disabled):hover {
  transform: scale(1.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  background: var(--border-strong);
}

.browse-tile.bt-solved { background: var(--color-solved); color: white; }
.browse-tile.bt-solved:not(:disabled):hover { background: var(--color-solved-dark); }

.browse-tile.bt-current {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 2px var(--primary-blue);
}

.browse-tier-header {
  grid-column: 1 / -1;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  padding: 8px 2px 2px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2px;
}

/* 11. BOOK PICKER */
#category-select { display: none; } /* Hidden; kept for JS compatibility */

#book-picker-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 2px solid var(--border-input);
  border-radius: 6px;
  color: var(--text-primary);
  /* cursor: pointer already set globally on button */
  transition: border-color 0.15s, background 0.15s;
  max-width: 180px;
}
#book-picker-btn:not(:disabled):hover {
  border-color: var(--primary-blue);
  background: var(--primary-blue-hover-bg);
}

#book-picker-btn .bpb-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow: hidden;
}
#book-picker-btn .bpb-eyebrow {
  font-size: 0.5625rem; /* was 9px */
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  line-height: 1;
}
#book-picker-btn .bpb-name {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
#book-picker-btn .bpb-chevron { color: #aaa; font-size: 0.7rem; flex-shrink: 0; }

#bp-modal-body { padding-bottom: 24px; }

.bp-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.bp-group-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 10px 14px;
  border: 2px solid var(--border-light);
  border-radius: 10px;
  /* cursor: pointer already set globally on button */
  background: var(--bg-card);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  text-align: center;
}
.bp-group-card:not(:disabled):hover {
  border-color: var(--primary-blue);
  background: var(--primary-blue-hover-bg);
  transform: translateY(-2px);
}
.bp-group-card.bp-active {
  border-color: var(--primary-blue);
  background: var(--primary-blue-active-bg);
}
.bp-group-card .bp-icon       { font-size: 1.6rem; line-height: 1; }
.bp-group-card .bp-group-name { font-weight: 700; font-size: 0.88rem; }
.bp-group-card .bp-group-sub  { font-size: 0.72rem; color: var(--text-subtle); }
.bp-group-card .bp-group-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.3;
  margin-top: 2px;
}

.bp-group-desc-header {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0 0 10px;
}

.bp-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  font-size: 0.85rem;
  color: var(--primary-blue);
  /* cursor: pointer already set globally on button */
  padding: 0 0 12px;
  font-weight: 600;
}
.bp-back-btn:not(:disabled):hover { text-decoration: underline; background: none; }

.bp-drill-title { font-weight: 700; font-size: 1rem; margin-bottom: 12px; }

.bp-diff-list { display: flex; flex-direction: column; gap: 8px; }

.bp-diff-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 2px solid var(--border-light);
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 0.95rem;
  font-weight: 600;
  /* cursor: pointer already set globally on button */
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}
.bp-diff-btn:not(:disabled):hover {
  border-color: var(--primary-blue);
  background: var(--primary-blue-hover-bg);
}
.bp-diff-btn.bp-selected {
  border-color: var(--primary-blue);
  background: var(--primary-blue-active-bg);
  color: var(--primary-blue);
}
.bp-diff-btn .bp-diff-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.bp-diff-btn .bp-diff-name { font-weight: 600; }
.bp-diff-btn .bp-diff-desc {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.3;
}
.bp-diff-btn.bp-selected .bp-diff-desc { color: var(--primary-blue); opacity: 0.8; }
.bp-diff-btn .bp-diff-arrow          { color: var(--border-strong); font-size: 0.8rem; flex-shrink: 0; }
.bp-diff-btn.bp-selected .bp-diff-arrow { color: var(--primary-blue); }

/* 12. SETTINGS BUTTON */
.settings-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  padding: 6px 8px;
  color: var(--text-secondary);
  line-height: 1;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.settings-btn:not(:disabled):hover {
  background: var(--border-light);
  color: var(--text-primary);
}

/* 13. SETTINGS MODAL */
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }

.settings-row-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}
.settings-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* Toggle switch */
.toggle-switch { flex-shrink: 0; position: relative; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle-track {
  display: block;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
}
.toggle-switch input:checked + .toggle-track { background: var(--primary-blue); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--bg-white);
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }

/* Settings danger zone */
.settings-danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.danger-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1.5px solid #d9534f;
  background: transparent;
  color: #d9534f;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.danger-btn:hover {
  background: #d9534f;
  color: #fff;
}
.danger-btn--confirm {
  background: #d9534f;
  color: #fff;
  border-color: #b52b27;
  animation: danger-pulse 0.3s ease;
}
@keyframes danger-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* 14. TAB MODE */
.board-tabs {
  display: none; /* hidden by default, shown via JS when tab mode is on */
  gap: 0;
  margin-bottom: 12px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-input);
  width: fit-content;
}

body.tab-mode .board-tabs { display: flex; }

.board-tab {
  padding: 8px 28px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 0;
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  border-right: 1px solid var(--border-input);
}
.board-tab:last-child { border-right: none; }
.board-tab:not(:disabled):hover { background: var(--primary-blue-hover-bg); color: var(--text-primary); }
.board-tab.board-tab--active {
  background: var(--primary-blue);
  color: #fff;
}
.board-tab.board-tab--active:not(:disabled):hover { background: var(--primary-blue); }

/* In tab mode, boards stack exactly on top of each other.
   Both boards stay in normal flow (position: relative) so the wrapper
   height never collapses. The inactive board is made invisible with
   opacity + visibility — no position switching means no layout jank. */

/* Hide the h2 headings in tab mode — the tabs replace them */
body.tab-mode .board-container > h2 { display: none; }

body.tab-mode #boards-wrapper {
  /* Two-row grid: tabs row, then a stacking cell for both boards */
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: start;
}

body.tab-mode #board-tabs {
  grid-row: 1;
}

body.tab-mode .board-container {
  /* Both boards sit in row 2, column 1 — stacked exactly on top of each other */
  grid-row: 2;
  grid-column: 1;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s, visibility 0.12s;
}

body.tab-mode .board-container.tab-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
