/* ======================================= */
/* MIJNENVEGER – ZELFDE STIJL ALS SUDOKU   */
/* ======================================= */

@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: #b8c4f8;
  --border:   #dde3f5;
  --text:     #2d3561;
  --text-muted: #7b84b0;

  --easy:   #22c55e;
  --medium: #f59e0b;
  --hard:   #ef4444;
  --expert: #7c3aed;

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

  --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;

  /* cell size — overridden per difficulty */
  --cell-size: 40px;
  --cell-font: 0.95rem;
}

* { 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                              */
/* ======================================= */
.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="expert"] { border-color: var(--expert); }

.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; }
.diff-btn[data-diff="expert"].active { background: var(--expert); 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.timer-pill { border-color: #c4b5fd; }
.stat-pill.timer-pill .stat-val { color: var(--purple); }
.stat-pill.mines-pill { border-color: #fca5a5; }
.stat-pill.mines-pill .stat-val { color: var(--hard); }
.stat-pill.flags-pill { border-color: #86efac; }
.stat-pill.flags-pill .stat-val { color: var(--easy); }

/* ======================================= */
/* GRID                                    */
/* ======================================= */
.grid-outer {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding: 0 0.5rem;
}

.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;
}

.ms-grid {
  display: grid;
  gap: 3px;
}

/* difficulty-driven cell size on grid-wrap */
.grid-wrap.diff-easy   { --cell-size: 46px; --cell-font: 1rem; }
.grid-wrap.diff-medium { --cell-size: 40px; --cell-font: 0.9rem; }
.grid-wrap.diff-hard   { --cell-size: 34px; --cell-font: 0.82rem; }
.grid-wrap.diff-expert { --cell-size: 28px; --cell-font: 0.72rem; }

.ms-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 #e2e8f8;
  background: var(--surface2);
  transition: background 0.12s, transform 0.1s, box-shadow 0.12s;
  user-select: none;
  position: relative;
  color: var(--text);
  font-weight: 900;
}

.ms-cell:hover:not(.revealed):not(.flagged) {
  background: #35427a;
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(99,102,241,0.22);
  z-index: 2;
}

.ms-cell.revealed {
  background: #f1f5ff;
  border-color: #d0d9f0;
  cursor: default;
}

.ms-cell.revealed.mine {
  background: #fee2e2;
  border-color: #fca5a5;
  animation: pop 0.3s ease;
}

.ms-cell.revealed.mine-trigger {
  background: #ef4444;
  border-color: #b91c1c;
}

.ms-cell.flagged {
  background: #fef9c3;
  border-color: #fde68a;
  animation: pop 0.25s ease;
}

/* Number colours — same rainbow feel as Sudoku numpad */
.ms-cell[data-val="1"] { color: #3b82f6; }
.ms-cell[data-val="2"] { color: #22c55e; }
.ms-cell[data-val="3"] { color: #ef4444; }
.ms-cell[data-val="4"] { color: #7c3aed; }
.ms-cell[data-val="5"] { color: #dc2626; }
.ms-cell[data-val="6"] { color: #0891b2; }
.ms-cell[data-val="7"] { color: #1e293b; }
.ms-cell[data-val="8"] { color: #475569; }

.ms-cell.complete {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-color: #86efac;
}

/* ======================================= */
/* ACTION ROW                              */
/* ======================================= */
.action-row {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.action-btn {
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.6rem 1.4rem;
  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.4rem;
  box-shadow: var(--shadow-sm);
}

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

.action-btn.flag-toggle-btn               { border-color: #fde68a; color: #b45309; }
.action-btn.flag-toggle-btn.active        { background: #fef9c3; border-color: #f59e0b; }
.action-btn.new-btn                       { border-color: #86efac; color: var(--easy); }

/* ======================================= */
/* HINTS                                   */
/* ======================================= */
.ms-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 1rem;
}

.hint-mobile  { display: none; }

@media (hover: none) and (pointer: coarse) {
  .hint-desktop { display: none; }
  .hint-mobile  { display: block; }
}

/* ======================================= */
/* 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: 560px;
  margin: 0.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;
  flex-wrap: wrap;
}

.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-flags  { font-size: 0.78rem; color: #b45309; }
.hs-empty  { text-align: center; color: var(--text-muted); font-size: 0.88rem; padding: 0.8rem 0; }

/* ======================================= */
/* WIN / LOSS 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.3rem;
}

.win-title.loss {
  background: linear-gradient(135deg, var(--hard), var(--orange));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.win-sub {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.9rem;
  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, .grid-outer, .action-row, .highscores-wrap {
  animation: fadeSlideIn 0.4s ease both;
}
.difficulty-row { animation-delay: 0.05s; }
.stats-bar      { animation-delay: 0.10s; }
.grid-outer     { animation-delay: 0.15s; }
.action-row     { animation-delay: 0.18s; }
.highscores-wrap{ animation-delay: 0.22s; }

/* reveal wave animation */
@keyframes revealCell {
  0%   { transform: scale(0.6); opacity: 0.4; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

.ms-cell.just-revealed {
  animation: revealCell 0.18s ease both;
}

/* ======================================= */
/* RESPONSIVE                              */
/* ======================================= */
@media (max-width: 500px) {
  .game-title { font-size: 2rem; }
  .grid-wrap.diff-easy   { --cell-size: 38px; }
  .grid-wrap.diff-medium { --cell-size: 32px; }
  .grid-wrap.diff-hard   { --cell-size: 26px; }
  .grid-wrap.diff-expert { --cell-size: 22px; }
}

@media (max-width: 380px) {
  .grid-wrap.diff-easy   { --cell-size: 34px; }
  .grid-wrap.diff-medium { --cell-size: 28px; }
  .grid-wrap.diff-hard   { --cell-size: 22px; }
  .grid-wrap.diff-expert { --cell-size: 18px; }
}
