/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f13;
  --surface: #1a1a24;
  --surface2: #23232f;
  --accent: #6c63ff;
  --accent2: #ff6584;
  --text: #e8e8f0;
  --text-muted: #888899;
  --border: #2e2e3e;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}

.logo span {
  color: var(--accent);
}

nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  transition: all 0.2s;
}

nav a:hover, nav a.active {
  background: var(--accent);
  color: #fff;
}

/* ===== Main ===== */
main {
  flex: 1;
  padding: 3rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* ===== Home ===== */
.home h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.home > p {
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  display: block;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(108,99,255,0.2);
}

.game-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.game-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.4rem;
}

.game-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ===== Sudoku Page ===== */
.sudoku-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 700px) {
  .sudoku-layout { grid-template-columns: 1fr; }
}

.sudoku-panel h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.sudoku-panel > p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

/* Difficulty buttons */
.difficulty-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.diff-btn {
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover { border-color: var(--accent); color: var(--text); }
.diff-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Timer */
.timer-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--accent);
}

/* Board */
#sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2px solid var(--text-muted);
  border-radius: 8px;
  overflow: hidden;
  width: 100%;
  max-width: 504px;
  aspect-ratio: 1;
  background: var(--border);
  gap: 1px;
}

.cell {
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  user-select: none;
  border: none;
  outline: none;
  color: var(--text);
}

/* Bold borders for 3x3 boxes */
.cell[data-col="2"], .cell[data-col="5"] { border-right: 2px solid var(--text-muted); }
.cell[data-row="2"], .cell[data-row="5"] { border-bottom: 2px solid var(--text-muted); }

.cell.given { color: var(--text); font-weight: 700; }
.cell.user-input { color: var(--accent); }
.cell.error { color: var(--accent2) !important; }
.cell.selected { background: rgba(108,99,255,0.25) !important; }
.cell.highlight { background: rgba(108,99,255,0.1); }
.cell.same-number { background: rgba(108,99,255,0.18); }

/* Numpad */
.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.num-btn {
  padding: 0.8rem;
  font-size: 1.15rem;
  font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.num-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.num-btn.erase {
  grid-column: 1 / -1;
  color: var(--accent2);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem;
}

/* Action buttons */
.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.55rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { opacity: 0.85; }

/* Status message */
.status-msg {
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.5rem;
}

.status-msg.win { color: #4ade80; }
.status-msg.error { color: var(--accent2); }

/* Sidebar info */
.sudoku-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  min-width: 220px;
  position: sticky;
  top: 80px;
  align-self: start;
}

.sudoku-sidebar h3 {
  font-size: 0.8rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span:last-child { color: var(--accent); font-weight: 700; }

/* ===== Modal ===== */
.modal-overlay[hidden] { display: none !important; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-win  .modal-box { border-color: #4ade80; }
.modal-lose .modal-box { border-color: var(--accent2); }

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.modal-box h2 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.modal-box p {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

/* ===== Snake ===== */
.snake-layout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 700px) {
  .snake-layout { grid-template-columns: 1fr; }
}

.snake-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #1a1a24;
}

#snake-canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* Start / pause overlay on canvas */
.snake-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15,15,19,0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.snake-overlay[hidden] { display: none !important; }

.snake-overlay-box {
  text-align: center;
  padding: 2rem;
}

.overlay-icon {
  font-size: 3.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.snake-overlay-box h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.snake-overlay-box p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Sidebar score block */
.snake-sidebar { min-width: 200px; }

.snake-score-block {
  text-align: center;
  padding: 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.snake-score-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.snake-score-value {
  font-size: 2.8rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* D-Pad mobile controls */
.snake-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  margin: 1.25rem 0;
}

.dpad-mid {
  display: flex;
  gap: 0.3rem;
}

.dpad-btn {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dpad-btn:hover { background: var(--accent); border-color: var(--accent); }

