:root {
  --oranje: #f26522;
  --oranje-donker: #d9531a;
  --blauw: #1a3e72;
  --blauw-licht: #2a5ca8;
  --blauw-zeer-licht: #e8f0fb;
  --wit: #ffffff;
  --groen: #2e9e5b;
  --grijs: #6b7280;
  --rand: #d8e2f0;
  --schaduw: none;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #eef3fa;
  color: var(--blauw);
  min-height: 100vh;
}

.hidden { display: none !important; }

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1000;
}

/* ---------- Logo ---------- */
.logo { display: inline-block; line-height: 0; }
.logo img { max-width: 100%; height: auto; }
.logo-small img { width: 90px; height: auto; }

/* ---------- Login ---------- */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: var(--wit);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 40px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  border-top: 6px solid var(--oranje);
}
.login-card h1 { margin: 18px 0 6px; font-size: 1.5rem; }
.tagline { color: var(--grijs); margin-bottom: 24px; }
.login-card form { text-align: left; }
.login-card label { display: block; font-weight: 600; margin: 14px 0 4px; font-size: 0.9rem; }
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--blauw-zeer-licht);
  border-radius: 10px;
  font-size: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--oranje); }

/* ---------- Knoppen ---------- */
.btn-primary {
  background: var(--oranje);
  color: var(--wit);
  border: none;
  border-radius: 8px;
  padding: 14px 24px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 20px;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--oranje-donker); }
.btn-primary:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-big { font-size: 1.15rem; }
.btn-link { background: none; border: none; color: var(--blauw-licht); cursor: pointer; margin-top: 16px; font-size: 0.95rem; text-decoration: underline; }
.btn-ghost {
  background: var(--wit);
  border: 1.5px solid var(--blauw-zeer-licht);
  color: var(--blauw);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--oranje); }

.error { color: #d33; margin-top: 12px; font-size: 0.9rem; }

/* ---------- Game header ---------- */
#game-screen header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--wit);
  border-bottom: 1px solid var(--rand);
  flex-wrap: wrap;
}
#game-screen header h1 { font-size: 1.25rem; flex: 1; }
.header-right { display: flex; align-items: center; gap: 10px; }
.player-chip {
  background: var(--blauw);
  color: var(--wit);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
}

.test-panel {
  background: #fff7e0;
  border-bottom: 1px solid #f0dfa0;
  padding: 8px 24px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.test-panel input { padding: 4px 8px; border: 1px solid #ddd; border-radius: 6px; }

.status-bar {
  padding: 12px 24px;
  font-weight: 600;
  color: var(--blauw-licht);
}

/* ---------- Layout ---------- */
main {
  display: flex;
  gap: 24px;
  padding: 0 24px 40px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.board-wrap { flex: 1 1 640px; min-width: 320px; }
.side { flex: 0 1 340px; min-width: 280px; display: flex; flex-direction: column; gap: 20px; }

/* ---------- Bord ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  background: var(--blauw);
  border: 4px solid var(--oranje);
  border-radius: 12px;
  padding: 14px;
  position: relative;
}

.tile {
  aspect-ratio: 1 / 1;
  background: var(--wit);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  border: 3px solid transparent;
  overflow: hidden;
}
/* Groot dagnummer, centraal in het vakje */
.tile .num {
  font-size: clamp(1.3rem, 3.4vw, 2.4rem);
  font-weight: 800;
  line-height: 1;
  color: var(--blauw);
}
.tile .kleding { font-size: clamp(0.9rem, 1.9vw, 1.4rem); line-height: 1; }
/* Vakje met eigen dag-afbeelding als achtergrond: de hele foto past in het
   vakje (niets wordt afgeknipt); de randen blijven wit zoals de fotoachtergrond. */
.tile.has-img {
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: var(--wit);
}
.tile.has-img.done { background-color: var(--wit); }
/* Nog niet gehaald: afbeelding bijna onzichtbaar achter een witte waas.
   Gehaald: de waas vervaagt en de afbeelding komt tevoorschijn. */
.tile.has-img::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.93);
  transition: opacity 0.8s ease;
  pointer-events: none;
}
.tile.has-img.done::before { opacity: 0; }
.tile .num { position: relative; z-index: 1; }
.tile .kleding { position: relative; z-index: 1; }
.tile .names { z-index: 1; }
.tile.done::after { z-index: 1; }
.tile.has-img .num {
  color: var(--wit);
  background: rgba(26, 62, 114, 0.7);
  padding: 2px 10px;
  border-radius: 6px;
}
.tile.done { background-color: var(--blauw-zeer-licht); border-color: var(--groen); }
.tile.done::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 3px;
  color: var(--wit);
  background: var(--groen);
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 800;
}
.tile.extra { background: #ffe9d9; border-color: var(--oranje); }
.tile.extra .num {
  position: absolute;
  top: 3px;
  left: 6px;
  font-size: 0.6rem;
  color: var(--oranje-donker);
  background: none;
  padding: 0;
}
.tile { cursor: pointer; }
.tile.next {
  border-color: var(--oranje);
  animation: pulse 1.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 101, 34, 0.55); }
  50% { box-shadow: 0 0 0 8px rgba(242, 101, 34, 0); }
}

/* Het poppetje: één los speelstuk dat over het bord loopt */
.goose-piece {
  position: absolute;
  z-index: 6;
  font-size: clamp(1.4rem, 3.2vw, 2.1rem);
  transform: translate(-50%, -62%);
  transition: left 0.34s ease, top 0.34s ease;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}
.goose-piece.hop { animation: goosehop 0.36s ease; }
@keyframes goosehop {
  0%, 100% { margin-top: 0; }
  50% { margin-top: -16px; }
}

/* Vakje waar jij nu staat */
.tile.here {
  border-color: var(--blauw-licht);
  box-shadow: 0 0 0 3px rgba(42, 92, 168, 0.45);
}

.tile .names {
  position: absolute;
  bottom: 2px;
  left: 3px;
  max-width: calc(100% - 6px);
  background: rgba(255, 255, 255, 0.85);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 0.5rem;
  line-height: 1.15;
  color: var(--blauw-licht);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.tile .badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--blauw);
  color: var(--wit);
  font-size: 0.45rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-bottom-left-radius: 8px;
  z-index: 2;
}
.badge-finish { background: var(--oranje); }

.tile.start-tile, .tile.finish-tile {
  background: var(--oranje);
  color: var(--wit);
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: 1px;
}

.extra-icon { width: 72%; height: 60%; }

/* ---------- Acties ---------- */
.board-actions { margin-top: 18px; text-align: center; }
.board-actions .btn-primary { max-width: 480px; }
.btn-yesterday { display: block; margin: 10px auto 0; font-size: 0.9rem; padding: 8px 16px; }
.action-msg { margin-top: 10px; font-weight: 600; min-height: 1.4em; }
.action-msg.ok { color: var(--groen); }
.action-msg.fout { color: #d33; }

/* ---------- Panelen ---------- */
.panel {
  background: var(--wit);
  border: 1px solid var(--rand);
  border-radius: 12px;
  padding: 20px;
  border-top: 4px solid var(--oranje);
}
.panel h2 { font-size: 1.05rem; margin-bottom: 10px; }
.participant-count { font-size: 0.8rem; color: var(--grijs); margin-bottom: 8px; }

.leaderboard-scroll { max-height: 440px; overflow-y: auto; }
.leaderboard { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.leaderboard th { text-align: left; color: var(--grijs); font-size: 0.72rem; text-transform: uppercase; padding: 4px 6px; position: sticky; top: 0; background: var(--wit); }
.leaderboard td { padding: 5px 6px; border-top: 1px solid var(--blauw-zeer-licht); }
.leaderboard tr.me { background: #fff4ec; font-weight: 700; }
.leaderboard .trofee { margin-left: 4px; }

.extra-list { list-style: none; }
.extra-list li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--blauw-zeer-licht);
  font-size: 0.85rem;
}
.extra-list li:first-child { border-top: none; }
.extra-list .extra-status { font-size: 1.1rem; flex-shrink: 0; }
.extra-list .extra-date { display: block; color: var(--grijs); font-size: 0.75rem; }
.extra-list button { margin-top: 6px; }

/* ---------- Modals ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 62, 114, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal-card {
  background: var(--wit);
  border-radius: 12px;
  padding: 32px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  border-top: 8px solid var(--oranje);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--grijs);
}
.rules { margin-top: 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; }

/* Vakje-info popup */
.tile-card { max-width: 420px; text-align: center; }
.tile-modal-img {
  display: block;
  width: 200px;
  height: 200px;
  object-fit: contain;
  margin: 14px auto 4px;
  background: var(--wit);
  border: 1px solid var(--rand);
  border-radius: 8px;
}
.tile-modal-extra { width: 160px; margin: 14px auto 4px; }
.tile-modal-extra .extra-icon { width: 100%; height: auto; }
.tile-modal-sub { margin: 10px 0; font-size: 0.92rem; }
.tile-modal-wie { margin-top: 18px; font-size: 1rem; text-align: left; }
.tile-modal-spelers {
  list-style: none;
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  text-align: left;
  font-size: 0.9rem;
}
.tile-modal-spelers li { padding: 5px 8px; border-top: 1px solid var(--blauw-zeer-licht); }
.tile-modal-spelers li:first-child { border-top: none; }
.tile-modal-spelers li.me { background: #fff4ec; font-weight: 700; border-radius: 6px; }
.tile-card .btn-primary { margin-top: 12px; }
.winner-card { text-align: center; }
.winner-text { margin: 16px 0; font-size: 1.05rem; }

@media (max-width: 700px) {
  main { padding: 0 10px 30px; }
  .board { gap: 4px; padding: 8px; }
  #game-screen header { padding: 10px 12px; }
}
