/* ======================================= */
/* WOORDZOEKER – TOOLIFY STIJL             */
/* Passend bij Sudoku kleurig/fris thema   */
/* ======================================= */

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

  --blue:   #3b82f6;
  --purple: #8b5cf6;
  --pink:   #ec4899;
  --teal:   #14b8a6;
  --orange: #f97316;
  --easy:   #22c55e;
  --hard:   #ef4444;

  --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: 38px;
}

* { 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%);
}

.hidden { display: none !important; }

/* ── Top bar met terug knop ── */
.top-bar {
  display: flex;
  justify-content: flex-start;
  max-width: 900px;
  margin: 0 auto 0.75rem;
  padding: 0 0.25rem;
}

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

.back-btn:hover {
  border-color: var(--purple);
  color: var(--purple);
  transform: translateX(-2px);
  box-shadow: var(--shadow-md);
}

/* ======================================= */
/* HEADER                                  */
/* ======================================= */
.game-header {
  text-align: center;
  margin-bottom: 1.5rem;
  animation: fadeSlideIn 0.4s ease both;
}

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

/* ======================================= */
/* STATS BAR                               */
/* ======================================= */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
  animation: fadeSlideIn 0.4s 0.1s ease both;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 1.1rem;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  color: var(--text);
  min-width: 110px;
  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.found-pill { border-color: #86efac; }
.stat-pill.found-pill .stat-val { color: var(--easy); }

/* ======================================= */
/* SETUP CARD                              */
/* ======================================= */
.setup-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  max-width: 580px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  animation: fadeSlideIn 0.4s 0.05s ease both;
}

.setup-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.setup-label {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.clear-all-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  border: 2px solid #fca5a5;
  background: rgba(239,68,68,0.07);
  color: var(--hard);
  cursor: pointer;
  transition: all 0.18s ease;
  text-transform: none;
  letter-spacing: 0;
  margin-left: auto;
}

.clear-all-btn:hover {
  background: rgba(239,68,68,0.15);
  border-color: var(--hard);
  transform: scale(1.05);
}
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.78rem;
}

.word-count-badge {
  font-size: 0.72rem;
  background: rgba(59,130,246,0.1);
  color: var(--blue);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}

/* Inputs */
input[type="text"],
input[type="number"] {
  font-family: 'Nunito', sans-serif;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

input[type="number"] {
  width: 80px;
  text-align: center;
  font-family: 'Fredoka One', cursive;
}

.size-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.size-label {
  font-family: 'Fredoka One', cursive;
  font-size: 1.1rem;
  color: var(--text-muted);
}

/* Richtingen */
.direction-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface2);
  transition: border-color 0.2s ease, background 0.2s ease;
  user-select: none;
}

.checkbox-label:hover { border-color: var(--blue); }

.checkbox-label input {
  width: auto;
  accent-color: var(--blue);
}

/* Word input row */
.word-input-row {
  display: flex;
  gap: 0.5rem;
}

.word-input-row input { flex: 1; }

/* ── Thema woordenbank ── */
.theme-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.theme-btn {
  font-family: 'Nunito', sans-serif;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 0.38rem 0.85rem;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

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

.theme-btn.selected {
  border-color: var(--purple);
  background: rgba(139,92,246,0.1);
  color: var(--purple);
}

.theme-count-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.ai-count-btns {
  display: flex;
  gap: 0.35rem;
}

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

.ai-count-btn:hover { border-color: var(--purple); color: var(--purple); }

.ai-count-btn.active {
  background: var(--purple);
  border-color: var(--purple);
  color: #fff;
}

/* ── Thema woordenbank einde ── */


.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  border: 2.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: var(--surface2);
  position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--purple);
  background: rgba(139,92,246,0.05);
}

.drop-zone.drag-over {
  box-shadow: 0 0 0 3px rgba(139,92,246,0.2);
}

.drop-icon { font-size: 1.8rem; }

.drop-text {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
}

.drop-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.drop-browse {
  color: var(--blue);
  cursor: pointer;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* Word tags */
.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.word-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text);
  font-family: 'Fredoka One', cursive;
  animation: tagIn 0.15s ease;
  letter-spacing: 0.03em;
}

@keyframes tagIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.word-tag button {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.word-tag button:hover { color: var(--hard); }

/* Setup error */
.setup-error {
  text-align: center;
  color: var(--hard);
  font-size: 0.87rem;
  font-weight: 700;
  background: rgba(239,68,68,0.08);
  border: 2px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
}

/* Generate button */
.generate-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 1.15rem;
  padding: 0.8rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  color: #fff;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 4px 20px rgba(99,102,241,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  letter-spacing: 0.02em;
}

.generate-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.4);
}

.generate-btn:active { transform: translateY(0); }

/* ======================================= */
/* GAME LAYOUT                             */
/* ======================================= */
.game-layout {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  animation: fadeSlideIn 0.4s 0.15s ease both;
}

/* ── Grid ── */
.grid-wrap {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-lg);
  border: 3px solid var(--border);
  display: inline-block;
}

.word-grid {
  display: grid;
  gap: 3px;
  user-select: none;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  font-size: 1.05rem;
  cursor: pointer;
  border-radius: 6px;
  border: 1.5px solid #c5cef5;
  background: #b8c4f8;
  transition: background 0.12s, transform 0.1s, border-color 0.12s;
  color: var(--text);
  text-transform: uppercase;
}

.cell:hover:not(.found) {
  background: #9aaaf5;
  transform: scale(1.08);
  z-index: 2;
}

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

/* Color palette for found words — cycles through colors */
.cell.found-0  { background: #bbf7d0; border-color: #4ade80; color: #14532d; }
.cell.found-1  { background: #bfdbfe; border-color: #60a5fa; color: #1e3a8a; }
.cell.found-2  { background: #ddd6fe; border-color: #a78bfa; color: #4c1d95; }
.cell.found-3  { background: #fde68a; border-color: #f59e0b; color: #78350f; }
.cell.found-4  { background: #fbcfe8; border-color: #f472b6; color: #831843; }
.cell.found-5  { background: #a5f3fc; border-color: #22d3ee; color: #164e63; }
.cell.found-6  { background: #fed7aa; border-color: #fb923c; color: #7c2d12; }
.cell.found-7  { background: #d9f99d; border-color: #a3e635; color: #365314; }
.cell.found-8  { background: #fecaca; border-color: #f87171; color: #7f1d1d; }
.cell.found-9  { background: #e9d5ff; border-color: #c084fc; color: #581c87; }

.cell.found-new {
  animation: cellPop 0.3s ease;
}

@keyframes cellPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* ── Side panel ── */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 160px;
  max-width: 400px;
}

.word-panel {
  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;
}

.word-panel-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
}

.word-panel-list.two-cols {
  grid-template-columns: 1fr 1fr;
}

.word-panel-list li {
  font-family: 'Fredoka One', cursive;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 2px solid var(--border);
  transition: all 0.25s ease;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.word-panel-list li::before {
  content: '○';
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

/* ── Gevonden woord: vette gekleurde achtergrond, groot vinkje ── */
.word-panel-list li.found-word {
  opacity: 1;
  text-decoration: none;
  font-weight: 900;
  transform: none;
  animation: wordFound 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.word-panel-list li.found-word::before {
  content: '✔';
  font-size: 0.85rem;
  font-weight: 900;
}

@keyframes wordFound {
  0%   { transform: scale(0.92); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Niet-gevonden kleuren: subtiele rand */
.word-panel-list li.color-0  { border-color: #4ade80; }
.word-panel-list li.color-1  { border-color: #60a5fa; }
.word-panel-list li.color-2  { border-color: #a78bfa; }
.word-panel-list li.color-3  { border-color: #f59e0b; }
.word-panel-list li.color-4  { border-color: #f472b6; }
.word-panel-list li.color-5  { border-color: #22d3ee; }
.word-panel-list li.color-6  { border-color: #fb923c; }
.word-panel-list li.color-7  { border-color: #a3e635; }
.word-panel-list li.color-8  { border-color: #f87171; }
.word-panel-list li.color-9  { border-color: #c084fc; }

/* Gevonden: volle gekleurde achtergrond + passende tekstkleur */
.word-panel-list li.found-word.color-0  { background: #bbf7d0; border-color: #22c55e; color: #14532d; }
.word-panel-list li.found-word.color-1  { background: #bfdbfe; border-color: #3b82f6; color: #1e3a8a; }
.word-panel-list li.found-word.color-2  { background: #ddd6fe; border-color: #8b5cf6; color: #4c1d95; }
.word-panel-list li.found-word.color-3  { background: #fde68a; border-color: #f59e0b; color: #78350f; }
.word-panel-list li.found-word.color-4  { background: #fbcfe8; border-color: #ec4899; color: #831843; }
.word-panel-list li.found-word.color-5  { background: #a5f3fc; border-color: #06b6d4; color: #164e63; }
.word-panel-list li.found-word.color-6  { background: #fed7aa; border-color: #f97316; color: #7c2d12; }
.word-panel-list li.found-word.color-7  { background: #d9f99d; border-color: #84cc16; color: #365314; }
.word-panel-list li.found-word.color-8  { background: #fecaca; border-color: #ef4444; color: #7f1d1d; }
.word-panel-list li.found-word.color-9  { background: #e9d5ff; border-color: #a855f7; color: #581c87; }

/* ── 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.add-btn  { border-color: #86efac; color: var(--easy); }
.action-btn.new-btn  { border-color: #c4b5fd; color: var(--purple); }

/* ======================================= */
/* 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 fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ======================================= */
/* RESPONSIVE                              */
/* ======================================= */
@media (max-width: 680px) {
  :root { --cell-size: 30px; }

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

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

  .side-panel {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 100%;
    width: 100%;
  }

  .word-panel { flex: 1; min-width: 200px; }

  .word-panel-list {
    grid-template-columns: 1fr 1fr;
    max-height: none;
  }

  .word-panel-list.two-cols {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .word-panel-list li { font-size: 0.8rem; padding: 0.28rem 0.6rem; }

  .direction-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  :root { --cell-size: 26px; }
  .cell { font-size: 0.85rem; }
}
