/* ======================================= */
/* SUDOKU GAME - FRIS & KLEURRIJK          */
/* ======================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

:root {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --surface2: #f8faff;
  --border: #dde3f5;
  --text: #2d3561;
  --text-muted: #7b84b0;

  --easy:   #22c55e;
  --medium: #f59e0b;
  --hard:   #ef4444;

  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --pink:   #ec4899;
  --teal:   #14b8a6;
  --orange: #f97316;

  --cell-size: 56px;
  --cell-font: 1.4rem;
  --grid-gap: 2px;
  --block-gap: 4px;

  --shadow-sm: 0 2px 8px rgba(59,82,246,0.08);
  --shadow-md: 0 6px 24px rgba(59,82,246,0.13);
  --shadow-lg: 0 12px 40px rgba(59,82,246,0.18);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(139,92,246,0.08) 0%, transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(59,130,246,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(236,72,153,0.04) 0%, transparent 60%);
}

/* ======================================= */
/* HEADER                                  */
/* ======================================= */
.game-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.game-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2.8rem;
  line-height: 1;
  background: linear-gradient(135deg, var(--blue), var(--purple), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(139,92,246,0.2));
  margin-bottom: 0.3rem;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ======================================= */
/* DIFFICULTY PICKER                       */
/* ======================================= */
.difficulty-row {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.4rem;
  flex-wrap: wrap;
}

.diff-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.5rem 1.3rem;
  border-radius: 999px;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.03em;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.diff-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.diff-btn[data-diff="easy"]   { border-color: var(--easy);   }
.diff-btn[data-diff="medium"] { border-color: var(--medium); }
.diff-btn[data-diff="hard"]   { border-color: var(--hard);   }

.diff-btn[data-diff="easy"].active   { background: var(--easy);   color: #fff; }
.diff-btn[data-diff="medium"].active { background: var(--medium); color: #fff; }
.diff-btn[data-diff="hard"].active   { background: var(--hard);   color: #fff; }

/* ======================================= */
/* STATS BAR                               */
/* ======================================= */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  min-width: 90px;
  justify-content: center;
}

.stat-pill .stat-icon { font-size: 1rem; }
.stat-pill .stat-val  { font-size: 1rem; font-weight: 900; }

.stat-pill.errors-pill { border-color: #fca5a5; }
.stat-pill.errors-pill .stat-val { color: var(--hard); }
.stat-pill.hints-pill  { border-color: #93c5fd; }
.stat-pill.hints-pill .stat-val  { color: var(--blue); }
.stat-pill.timer-pill  { border-color: #c4b5fd; }
.stat-pill.timer-pill .stat-val  { color: var(--purple); }

/* ======================================= */
/* GAME LAYOUT                             */
/* ======================================= */
.game-layout {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

/* ======================================= */
/* SUDOKU GRID                             */
/* ======================================= */
.grid-wrap {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-lg);
  border: 3px solid var(--border);
  display: inline-block;
}

.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, var(--cell-size));
  grid-template-rows:    repeat(9, var(--cell-size));
  gap: var(--grid-gap);
  position: relative;
}

/* Block borders via box-shadow on cells */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: var(--cell-font);
  cursor: pointer;
  border-radius: 6px;
  border: 1.5px solid #c5cef5;
  background: #b8c4f8;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  user-select: none;
  position: relative;
  color: var(--text);
}

/* Block separators — right border after col 3, 6 */
.cell[data-col="2"], .cell[data-col="5"] {
  border-right: 3px solid #b0bcdf;
  margin-right: 3px;
}
/* Block separators — bottom border after row 3, 6 */
.cell[data-row="2"], .cell[data-row="5"] {
  border-bottom: 3px solid #b0bcdf;
  margin-bottom: 3px;
}

.cell:hover:not(.given):not(.wrong) {
  background: #9aaaf5;
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(99,102,241,0.2);
  z-index: 2;
}

.cell.selected {
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
  z-index: 3;
  transform: scale(1.06);
}

.cell.highlight {
  background: #d8e2fc;
}

.cell.same-number {
  background: #d0dafc;
}

.cell.given {
  color: var(--text);
  font-weight: 900;
  cursor: default;
  background: #f1f5ff;
}

.cell.wrong {
  background: #fee2e2;
  color: var(--hard);
  animation: shake 0.35s ease;
}

.cell.correct-anim {
  animation: pop 0.3s ease;
}

.cell.complete {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: var(--easy);
}

/* Notes grid inside cell */
.cell-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 2px;
}

.cell-notes span {
  font-family: 'Nunito', sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ======================================= */
/* SIDE PANEL                              */
/* ======================================= */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 160px;
}

/* Number pad */
.numpad {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
}

.numpad-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
  text-align: center;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.num-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.3rem;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.num-btn:hover {
  transform: translateY(-2px) scale(1.08);
  box-shadow: var(--shadow-md);
}

.num-btn:nth-child(1)  { border-color: #fca5a5; }
.num-btn:nth-child(2)  { border-color: #fdba74; }
.num-btn:nth-child(3)  { border-color: #fde68a; }
.num-btn:nth-child(4)  { border-color: #86efac; }
.num-btn:nth-child(5)  { border-color: #67e8f9; }
.num-btn:nth-child(6)  { border-color: #93c5fd; }
.num-btn:nth-child(7)  { border-color: #c4b5fd; }
.num-btn:nth-child(8)  { border-color: #f9a8d4; }
.num-btn:nth-child(9)  { border-color: #6ee7b7; }

.num-btn:nth-child(1):hover  { background: #fee2e2; }
.num-btn:nth-child(2):hover  { background: #ffedd5; }
.num-btn:nth-child(3):hover  { background: #fefce8; }
.num-btn:nth-child(4):hover  { background: #dcfce7; }
.num-btn:nth-child(5):hover  { background: #ecfeff; }
.num-btn:nth-child(6):hover  { background: #dbeafe; }
.num-btn:nth-child(7):hover  { background: #ede9fe; }
.num-btn:nth-child(8):hover  { background: #fdf2f8; }
.num-btn:nth-child(9):hover  { background: #d1fae5; }

.num-btn.used {
  opacity: 0.35;
  pointer-events: none;
}

/* Action buttons */
.action-btns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.action-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.action-btn.hint-btn  { border-color: #93c5fd; color: var(--blue); }
.action-btn.erase-btn { border-color: #fca5a5; color: var(--hard); }
.action-btn.note-btn  { border-color: #c4b5fd; color: var(--purple); }
.action-btn.note-btn.active { background: #ede9fe; border-color: var(--purple); }
.action-btn.new-btn   { border-color: #86efac; color: var(--easy); }

.action-btn:disabled { opacity: 0.4; pointer-events: none; }

/* ======================================= */
/* HIGHSCORES                              */
/* ======================================= */
.highscores-wrap {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-md);
  border: 2px solid var(--border);
  max-width: 520px;
  margin: 1.5rem auto 0;
}

.hs-title {
  font-family: 'Fredoka One', cursive;
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 0.8rem;
  background: linear-gradient(135deg, var(--orange), var(--pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hs-tabs {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.8rem;
}

.hs-tab {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 0.3rem 0.9rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.hs-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.hs-list { list-style: none; }

.hs-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  transition: background 0.1s;
}

.hs-list li:hover { background: var(--surface2); }

.hs-rank {
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  width: 24px;
  text-align: center;
  color: var(--text-muted);
}

.hs-rank.gold   { color: #f59e0b; }
.hs-rank.silver { color: #94a3b8; }
.hs-rank.bronze { color: #b45309; }

.hs-time { margin-left: auto; font-family: 'Fredoka One', cursive; color: var(--purple); }
.hs-errors { font-size: 0.78rem; color: var(--hard); }
.hs-empty { text-align: center; color: var(--text-muted); font-size: 0.88rem; padding: 0.8rem 0; }

/* ======================================= */
/* WIN OVERLAY                             */
/* ======================================= */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 80, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.win-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.win-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 340px;
  width: 90%;
  animation: popIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.win-emoji { font-size: 3.5rem; display: block; margin-bottom: 0.5rem; }

.win-title {
  font-family: 'Fredoka One', cursive;
  font-size: 2rem;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.win-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1rem 0 1.5rem;
}

.win-stat { text-align: center; }
.win-stat-val {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  display: block;
  color: var(--purple);
}
.win-stat-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.win-play-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  padding: 0.75rem 2rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.win-play-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 24px rgba(99,102,241,0.45);
}

/* ======================================= */
/* ANIMATIONS                              */
/* ======================================= */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  40%      { transform: translateX(5px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

@keyframes pop {
  0%   { transform: scale(0.85); }
  60%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes popIn {
  0%   { transform: scale(0.7) translateY(30px); opacity: 0; }
  100% { transform: scale(1) translateY(0);      opacity: 1; }
}

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

.game-header, .difficulty-row, .stats-bar, .game-layout, .highscores-wrap {
  animation: fadeSlideIn 0.4s ease both;
}
.difficulty-row  { animation-delay: 0.05s; }
.stats-bar       { animation-delay: 0.10s; }
.game-layout     { animation-delay: 0.15s; }
.highscores-wrap { animation-delay: 0.20s; }

/* ======================================= */
/* RESPONSIVE                              */
/* ======================================= */
@media (max-width: 620px) {
  :root {
    --cell-size: 36px;
    --cell-font: 1rem;
  }

  .game-title { font-size: 2rem; }

  .cell-notes span { font-size: 0.42rem; }

  .game-layout { flex-direction: column; align-items: center; }

  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: unset;
    width: 100%;
  }

  .numpad, .action-btns { flex: 1; min-width: 150px; }

  .action-btns { flex-direction: row; flex-wrap: wrap; }
  .action-btn  { flex: 1; min-width: 80px; }
}

@media (max-width: 380px) {
  :root { --cell-size: 32px; --cell-font: 0.9rem; }
}