body.light-mode .pad-btn {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}
:root {
  --sudoku-bg: #10131a;
  --sudoku-panel: rgba(255, 255, 255, 0.05);
  --sudoku-border: rgba(255, 255, 255, 0.2);
  --sudoku-accent: #4fc3f7;
  --sudoku-danger: #ff8a80;
  --sudoku-success: #81c784;
}

body.light-mode {
  --sudoku-bg: #f8fafc;
  --sudoku-panel: rgba(255, 255, 255, 0.96);
  --sudoku-border: rgba(15, 23, 42, 0.12);
  --sudoku-accent: #1d4ed8;
  --sudoku-danger: #c62828;
  --sudoku-success: #1b5e20;
}

.sudoku-body {
  display: block;
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: var(--sudoku-bg);
  color: #fff;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  transition: background 0.3s ease, color 0.3s ease;
}

body.light-mode .sudoku-body {
  color: #0f172a;
}

.sudoku-shell,
.intro-shell {
  width: min(1200px, 100vw);
  margin: 0 auto;
  padding: 40px 0 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.shell-heading {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shell-heading h1 {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  margin: 0;
}

body.light-mode .shell-heading h1 {
  color: #0f172a;
}

.shell-heading .subtitle {
  color: rgba(255, 255, 255, 0.72);
}

body.light-mode .shell-heading .subtitle {
  color: rgba(15, 23, 42, 0.72);
}

.intro-link {
  align-self: center;
  color: var(--sudoku-accent);
  text-decoration: none;
  font-weight: 500;
}

body.light-mode .intro-link {
  color: #1d4ed8;
}

.game-surface {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.board-panel {
  flex: 2;
  background: var(--sudoku-panel);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid var(--sudoku-border);
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

body.light-mode .board-panel,
body.light-mode .control-card,
body.light-mode .saved-progress {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.status-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.status-item {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--sudoku-border);
  font-size: 0.95rem;
}

body.light-mode .status-item {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.15);
  color: #0f172a;
}

body.light-mode .status-item {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.15);
}

select {
  background: transparent;
  color: inherit;
  border: 1px solid var(--sudoku-border);
  border-radius: 12px;
  padding: 6px 12px;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(28px, 1fr));
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid var(--sudoku-border);
  width: min(520px, 100%);
  max-width: 100%;
  align-self: center;
  margin: 0 auto;
}

body.light-mode .sudoku-board {
  background: #e8eef8;
  border-color: rgba(15, 23, 42, 0.2);
}

.cell {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: clamp(1.1rem, 2vw, 1.8rem);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
  padding: 0;
}

.cell[data-row="0"] {
  border-top-width: 2px;
}
.cell[data-row="8"] {
  border-bottom-width: 2px;
}
.cell[data-col="0"] {
  border-left-width: 2px;
}
.cell[data-col="8"] {
  border-right-width: 2px;
}
.cell[data-row="2"],
.cell[data-row="5"] {
  border-bottom-width: 3px;
}
.cell[data-row="3"],
.cell[data-row="6"] {
  border-top-width: 3px;
}
.cell[data-col="2"],
.cell[data-col="5"] {
  border-right-width: 3px;
}
.cell[data-col="3"],
.cell[data-col="6"] {
  border-left-width: 3px;
}

.cell:focus-visible {
  outline: 3px solid var(--sudoku-accent);
  outline-offset: -3px;
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid transparent;
  pointer-events: none;
}

.cell-value {
  font-weight: 600;
  color: #ffffff;
}

.cell-notes {
  position: absolute;
  inset: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  font-size: 0.55rem;
  opacity: 0.7;
  color: rgba(255, 255, 255, 0.8);
}

.cell-notes span {
  display: block;
  text-align: center;
}

body.light-mode .cell-notes {
  color: rgba(15, 23, 42, 0.7);
  opacity: 0.9;
}

body.light-mode .cell-notes span {
  color: rgba(15, 23, 42, 0.8);
}

.cell.given {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 700;
  color: #ffd54f;
}

.cell.given .cell-value {
  color: #ffd54f;
}

body.light-mode .cell {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(15, 23, 42, 0.12);
}

body.light-mode .cell-value {
  color: #0f172a;
}

body.light-mode .cell.given {
  background: #e3f2fd;
  color: #0d47a1;
}

body.light-mode .cell.given .cell-value {
  color: #0d47a1;
}

.cell.selected,
.cell:hover {
  background: rgba(79, 195, 247, 0.18);
}

body.light-mode .cell.selected,
body.light-mode .cell:hover {
  background: rgba(25, 118, 210, 0.15);
}

.cell.highlight {
  background: rgba(79, 195, 247, 0.1);
}

body.light-mode .cell.highlight {
  background: rgba(25, 118, 210, 0.12);
}

.cell.value-match {
  background: rgba(255, 214, 79, 0.22);
  box-shadow: inset 0 0 0 1px rgba(255, 214, 79, 0.5);
}

.cell.highlight.value-match {
  background: rgba(255, 214, 79, 0.28);
}

.cell.selected.value-match {
  background: rgba(255, 214, 79, 0.4);
}

body.light-mode .cell.value-match {
  background: rgba(255, 215, 64, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255, 215, 64, 0.5);
}

body.light-mode .cell.highlight.value-match {
  background: rgba(255, 215, 64, 0.32);
}

body.light-mode .cell.selected.value-match {
  background: rgba(255, 215, 64, 0.45);
}

.cell.conflict {
  background: rgba(255, 138, 128, 0.2);
}

body.light-mode .cell.conflict {
  background: rgba(211, 47, 47, 0.22);
  box-shadow: inset 0 0 0 1px rgba(211, 47, 47, 0.4);
}

.cell.error {
  animation: pulseError 0.4s;
}

@keyframes pulseError {
  from {
    box-shadow: 0 0 0 0 rgba(255, 138, 128, 0.6);
  }
  to {
    box-shadow: 0 0 0 12px rgba(255, 138, 128, 0);
  }
}

.cell.note-visible .cell-value {
  opacity: 0;
}

.cell.note-visible .cell-notes {
  opacity: 1;
}

body.light-mode .cell.note-visible .cell-notes {
  opacity: 1;
  color: rgba(15, 23, 42, 0.95);
}

body.light-mode .cell.note-visible .cell-notes span {
  color: rgba(15, 23, 42, 1);
}

/* Hide notes when cell has a value */
.cell.has-value .cell-notes {
  display: none;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
}

.pad-btn {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--sudoku-border);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.pad-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

body.light-mode .pad-btn:hover {
  background: rgba(15, 23, 42, 0.08);
}

.pad-btn.utility {
  font-size: 0.9rem;
}

.pad-btn.active {
  background: rgba(79, 195, 247, 0.2);
  border-color: var(--sudoku-accent);
}

.control-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.control-card {
  background: var(--sudoku-panel);
  border: 1px solid var(--sudoku-border);
  border-radius: 20px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body.light-mode .control-card {
  color: #0f172a;
}

.control-card ul {
  margin: 0;
  padding-left: 20px;
}

.control-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.control-buttons button,
#resetProgress,
.modal-actions button {
  border-radius: 12px;
  border: 1px solid var(--sudoku-border);
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}

body.light-mode .control-buttons button,
body.light-mode #resetProgress,
body.light-mode .modal-actions button {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.08);
}

.control-buttons button:hover,
#resetProgress:hover,
.modal-actions button:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.light-mode .control-buttons button:hover,
body.light-mode #resetProgress:hover,
body.light-mode .modal-actions button:hover {
  background: rgba(15, 23, 42, 0.08);
}

.saved-progress {
  background: var(--sudoku-panel);
  border-radius: 20px;
  border: 1px solid var(--sudoku-border);
  padding: 24px;
}

body.light-mode .saved-progress {
  color: #0f172a;
}

.modal {
  border: none;
  background: rgba(0, 0, 0, 0.5);
}

.modal-card {
  background: #151a24;
  border-radius: 20px;
  padding: 30px;
  width: min(400px, 90vw);
}

body.light-mode .modal-card {
  background: #fff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

/* Intro page */
.intro-shell {
  gap: 32px;
}

.intro-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.85rem;
  color: var(--sudoku-accent);
}

.hero-copy {
  max-width: 600px;
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.8);
}

body.light-mode .hero-copy {
  color: rgba(0, 0, 0, 0.7);
}

.hero-cta {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.primary-cta,
.secondary-cta {
  border-radius: 999px;
  padding: 12px 24px;
  text-decoration: none;
  font-weight: 600;
}

.primary-cta {
  background: var(--sudoku-accent);
  color: #0b1020;
}

.secondary-cta {
  border: 1px solid var(--sudoku-border);
  color: inherit;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.intro-card,
.intro-faq {
  background: var(--sudoku-panel);
  border: 1px solid var(--sudoku-border);
  border-radius: 20px;
  padding: 20px;
}

.intro-card h2,
.intro-faq h2 {
  margin-top: 0;
}

.intro-faq ol {
  padding-left: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 960px) {
  .game-surface {
    flex-direction: column;
    width: 100%;
    gap: 20px;
  }

  .control-buttons {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .status-bar {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .sudoku-shell {
    padding: 16px 12px 40px;
    width: 100%;
  }

  .sudoku-board {
    width: 100%;
    max-width: 100%;
  }

  .board-panel,
  .control-panel,
  .game-surface {
    width: 100%;
  }
}
