/* ======================================= */
/* VIER OP EEN RIJ - TOOLIFY STIJL         */
/* ======================================= */

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

  --player-color: #ef4444;
  --ai-color:     #eab308;
  --cell-size: 68px;

  --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(239,68,68,0.07) 0%, transparent 50%),
    radial-gradient(circle at 85% 80%, rgba(234,179,8,0.07) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(139,92,246,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(--player-color), var(--purple), var(--ai-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(239,68,68,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.moves-pill { border-color: #fca5a5; }
.stat-pill.moves-pill .stat-val { color: var(--hard); }
.stat-pill.timer-pill  { border-color: #c4b5fd; }
.stat-pill.timer-pill .stat-val  { color: var(--purple); }
.stat-pill.turn-pill   { border-color: #93c5fd; }
.stat-pill.turn-pill .stat-val   { color: var(--blue); }

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

/* ======================================= */
/* BOARD                                   */
/* ======================================= */
.board-outer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* Column hover indicators */
.col-indicators {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  gap: 4px;
  padding: 0 16px;
  margin-bottom: 4px;
}

.col-ind {
  width: var(--cell-size);
  text-align: center;
  font-size: 1.1rem;
  color: var(--border);
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
  user-select: none;
  line-height: 1.4;
  border-radius: var(--radius-sm);
  padding: 2px 0;
}

.col-ind:hover { color: var(--player-color); transform: translateY(2px); }
.col-ind.ai-hover { color: var(--ai-color); }
.col-ind.active { color: var(--player-color); }
.col-ind.blocked { color: var(--text-muted); cursor: not-allowed; }

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

.connect-board {
  display: grid;
  grid-template-columns: repeat(7, var(--cell-size));
  grid-template-rows: repeat(6, var(--cell-size));
  gap: 6px;
  background: linear-gradient(135deg, #3b5bdb, #4c6ef5);
  border-radius: var(--radius-md);
  padding: 10px;
}

/* ======================================= */
/* CELLS                                   */
/* ======================================= */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 50%;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell:hover.empty-cell {
  background: rgba(239, 68, 68, 0.15);
  transform: scale(1.05);
}

.cell.player {
  background: radial-gradient(circle at 35% 35%, #f87171, var(--player-color) 60%, #b91c1c);
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.2), 0 2px 8px rgba(239,68,68,0.4);
  cursor: default;
}

.cell.ai {
  background: radial-gradient(circle at 35% 35%, #fde047, var(--ai-color) 60%, #a16207);
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.2), 0 2px 8px rgba(234,179,8,0.4);
  cursor: default;
}

.cell.win-cell {
  animation: winPulse 0.6s ease infinite alternate;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.2), 0 0 0 4px #fff, 0 0 0 7px rgba(255,255,255,0.5);
  z-index: 2;
}

.cell.drop-anim {
  animation: dropIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

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

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

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

.score-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  flex: 1;
}

.score-disc { font-size: 1.4rem; }
.score-name { font-size: 0.72rem; font-weight: 800; color: var(--text-muted); }
.score-num  {
  font-family: 'Fredoka One', cursive;
  font-size: 1.8rem;
  color: var(--text);
  line-height: 1;
}

.player-score .score-num { color: var(--player-color); }
.ai-score .score-num     { color: #a16207; }

.score-sep {
  font-size: 1.2rem;
  color: var(--border);
  font-weight: 900;
  padding-bottom: 1rem;
}

/* 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.new-btn   { border-color: #86efac; color: var(--easy); }
.action-btn.undo-btn  { border-color: #93c5fd; color: var(--blue); }
.action-btn:disabled  { opacity: 0.4; pointer-events: none; }

/* Legend */
.legend-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  border: 2px solid var(--border);
}

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

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.legend-disc {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.legend-disc.red    { background: radial-gradient(circle at 35% 35%, #f87171, var(--player-color) 60%, #b91c1c); }
.legend-disc.yellow { background: radial-gradient(circle at 35% 35%, #fde047, var(--ai-color) 60%, #a16207); }

/* ======================================= */
/* AI THINKING INDICATOR                   */
/* ======================================= */
.ai-thinking {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.ai-thinking.visible { display: flex; }

.think-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ai-color);
  animation: bounce 0.6s ease infinite;
}

.think-dot:nth-child(2) { animation-delay: 0.15s; }
.think-dot:nth-child(3) { animation-delay: 0.30s; }

/* ======================================= */
/* 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: 580px;
  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-result { font-size: 0.78rem; font-weight: 800; }
.hs-result.win  { color: var(--easy); }
.hs-result.loss { 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(--player-color), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}

.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(--player-color), var(--purple));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(239,68,68,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(239,68,68,0.45);
}

/* ======================================= */
/* ANIMATIONS                              */
/* ======================================= */
@keyframes dropIn {
  0%   { transform: translateY(-320px); opacity: 0.3; }
  80%  { transform: translateY(6px); }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes winPulse {
  0%   { box-shadow: inset 0 3px 8px rgba(0,0,0,0.2), 0 0 0 3px #fff, 0 0 12px 4px rgba(255,255,255,0.6); }
  100% { box-shadow: inset 0 3px 8px rgba(0,0,0,0.2), 0 0 0 5px #fff, 0 0 20px 8px rgba(255,255,255,0.9); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

@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: 640px) {
  :root { --cell-size: 44px; }

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

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

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

  .score-card, .legend-card { flex: 1; min-width: 140px; }
  .action-btns { flex-direction: row; flex: 100%; }
  .action-btn  { flex: 1; }
}

@media (max-width: 400px) {
  :root { --cell-size: 38px; }
}
