/* ======================================= */
/* MEMORY 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;

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

  --card-size: 80px;
}

* { 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.timer-pill  { border-color: #c4b5fd; }
.stat-pill.timer-pill .stat-val  { color: var(--purple); }
.stat-pill.moves-pill  { border-color: #93c5fd; }
.stat-pill.moves-pill .stat-val  { color: var(--blue); }
.stat-pill.pairs-pill  { border-color: #86efac; }
.stat-pill.pairs-pill .stat-val  { color: var(--easy); }

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

/* ======================================= */
/* BOARD                                   */
/* ======================================= */
.board-wrap {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  border: 3px solid var(--border);
  display: inline-block;
}

.memory-board {
  display: grid;
  gap: 10px;
}

/* ======================================= */
/* CARDS                                   */
/* ======================================= */
.memory-card {
  width: var(--card-size);
  height: var(--card-size);
  cursor: pointer;
  perspective: 600px;
  position: relative;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-sm);
}

.memory-card.flipped .card-inner,
.memory-card.matched .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 2.5px solid transparent;
}

/* Back = gezicht naar voren (de kaart die je ziet als hij dicht is) */
.card-back {
  background: linear-gradient(135deg, #b8c4f8, #9aaaf5);
  border-color: #c5cef5;
  font-size: 2rem;
  color: rgba(255,255,255,0.5);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, box-shadow 0.15s;
}

.memory-card:not(.flipped):not(.matched):hover .card-back {
  background: linear-gradient(135deg, #9aaaf5, #7c8fef);
  box-shadow: 0 4px 14px rgba(99,102,241,0.3);
  transform: scale(1.06);
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}

/* Front = de emoji kant */
.card-front {
  background: var(--surface2);
  border-color: var(--border);
  font-size: 2.4rem;
  transform: rotateY(180deg);
  box-shadow: var(--shadow-sm);
}

/* Matched styling */
.memory-card.matched .card-front {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  border-color: var(--easy);
  animation: matchPop 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

/* Wrong pair flash */
.memory-card.wrong .card-front {
  background: #fee2e2;
  border-color: var(--hard);
  animation: shake 0.35s ease;
}

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

.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.new-btn { border-color: #86efac; color: var(--easy); }

/* Legend */
.legend-card {
  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;
}

.legend-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.legend-list li {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ======================================= */
/* 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-moves  { font-size: 0.78rem; color: var(--blue); }
.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: rotateY(180deg) translateX(0); }
  20%      { transform: rotateY(180deg) translateX(-5px); }
  40%      { transform: rotateY(180deg) translateX(5px); }
  60%      { transform: rotateY(180deg) translateX(-4px); }
  80%      { transform: rotateY(180deg) translateX(4px); }
}

@keyframes matchPop {
  0%   { transform: rotateY(180deg) scale(0.85); }
  60%  { transform: rotateY(180deg) scale(1.12); }
  100% { transform: rotateY(180deg) 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-area, .highscores-wrap {
  animation: fadeSlideIn 0.4s ease both;
}
.difficulty-row  { animation-delay: 0.05s; }
.stats-bar       { animation-delay: 0.10s; }
.game-area       { animation-delay: 0.15s; }
.highscores-wrap { animation-delay: 0.20s; }

/* ======================================= */
/* RESPONSIVE                              */
/* ======================================= */
@media (max-width: 600px) {
  :root { --card-size: 62px; }

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

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

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

  .legend-card { flex: 1; min-width: 160px; }
  .action-btns { flex: 1; min-width: 140px; }
}

@media (max-width: 400px) {
  :root { --card-size: 52px; }
  .card-front { font-size: 1.6rem; }
}
