:root {
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #1e293b;
  --primary-hover: #0f172a;
  --category-color: #1e293b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  padding-bottom: 90px;
}

.core-container {
  padding: 20px 16px;
  max-width: 500px;
  margin: 0 auto;
}

/* Breedbeeld-overide voor het resultatenscherm als de tabel getoond wordt */
.core-container.wide {
  max-width: 800px;
}

/* --- HERO HEADER --- */
.hero-header {
  text-align: center;
  margin-bottom: 24px;
}
.hero-icon {
  font-size: 44px;
  display: block;
  margin-bottom: 4px;
}
h1 {
  font-size: 26px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.subtitle {
  color: var(--text-muted);
  margin: 4px 0 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- CARDS & GRIDS --- */
.card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.05);
  margin-bottom: 16px;
}

.section-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.player-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

/* --- INPUTS & BUTTONS --- */
.inputs-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border-radius: 10px;
  padding: 4px 12px;
  border: 1px solid var(--border-color);
}
.input-number {
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 12px;
  width: 16px;
}
.input-group input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}
.input-group input:focus {
  outline: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  /* CRUCIAL: Stopt de iOS double-tap zoom op alle knoppen! */
  touch-action: manipulation;
}

.btn-select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.btn-select.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 16px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.2);
  margin-bottom: 10px;
}
.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  width: 100%;
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  background: white;
}

/* --- GAME SCREEN --- */
.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  background: white;
  padding: 12px;
  border-radius: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.step-title {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.step-title h2 {
  margin: 4px 0 2px 0;
  font-size: 18px;
  font-weight: 800;
}
.cat-badge {
  font-size: 24px;
}
.step-counter {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 2px 8px;
  border-radius: 20px;
}
.btn-back, .btn-next-step {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-back:disabled {
  opacity: 0.3;
}
.btn-next-step {
  background: var(--category-color);
  color: white;
  border: none;
}

/* --- STEPPER CONTROL --- */
.scoring-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player-score-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  border-left: 4px solid var(--category-color);
}
.player-name {
  font-weight: 700;
  font-size: 16px;
}

.stepper-control {
  display: flex;
  align-items: center;
  background: var(--bg-main);
  border-radius: 24px;
  padding: 4px;
  border: 1px solid var(--border-color);
}
.btn-step {
  background: white;
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-step:active {
  transform: scale(0.9);
}
.score-display-wrapper {
  min-width: 60px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 4px;
}
.score-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}
.tap-hint {
  font-size: 9px;
  font-weight: 700;
  color: var(--category-color);
  opacity: 0.7;
  margin-top: -2px;
}

/* --- FOOTER / SCOREBOARD --- */
.game-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  padding: 12px 16px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  backdrop-filter: blur(8px);
  z-index: 10;
}
.mini-scoreboard {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 500px;
  margin: 0 auto;
  white-space: nowrap;
}
.mini-scoreboard::-webkit-scrollbar {
  display: none;
}
.mini-player-pill {
  background: rgba(255,255,255,0.1);
  padding: 6px 14px;
  border-radius: 20px;
  color: white;
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mini-player-pill.leading {
  background: var(--category-color);
  box-shadow: 0 0 10px rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
}
.mini-name {
  font-weight: 500;
  opacity: 0.9;
}
.mini-score {
  font-weight: 800;
}

/* --- RESULT & LEADERBOARD --- */
.leaderboard {
  padding: 8px 0;
}
.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
}
.leaderboard-row:last-child {
  border-bottom: none;
}
.rank-and-name {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rank-badge {
  background: var(--bg-main);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.winner-row {
  background: #fef08a;
  border-radius: 12px;
}
.winner-row .rank-badge {
  background: #facc15;
  color: #713f12;
}
.winner-row .player-name {
  color: #713f12;
}
.final-score {
  font-weight: 800;
  font-size: 18px;
}
.animate-pop {
  animation: pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* --- DETAILS TABLE MATRIX --- */
.table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: white;
}
.matrix-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}
.matrix-table th, .matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}
.matrix-table th {
  background: var(--bg-main);
  font-weight: 700;
}
.matrix-table tr:last-child td {
  border-bottom: none;
}
.matrix-table .row-total {
  background: #f1f5f9;
  font-weight: 800;
}
.matrix-table .row-total td {
  font-size: 15px;
}

/* --- MODAL DIALOG (RULES) --- */
.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open {
  display: flex;
}
.modal-content {
  background: white;
  border-radius: 20px;
  max-width: 450px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}
.modal-header h3 { margin: 0; font-size: 20px; font-weight: 800; }
.btn-close {
  background: var(--bg-main);
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 700;
}
.rules-body h4 {
  margin: 14px 0 6px 0;
  color: var(--primary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rules-body p, .rules-body ul {
  margin: 0 0 10px 0;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
  padding-left: 20px;
}
.rules-body ul { padding-left: 20px; }
.rules-body li { margin-bottom: 4px; }


/* Zwevende tandwiel/info knop op het setup scherm */
.btn-info-floating {
  position: absolute;
  top: 4px;
  right: 16px;
  background: white;
  border: 1px solid var(--border-color);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  z-index: 5;
}
.btn-info-floating:active {
  transform: scale(0.9);
  background: var(--bg-main);
}

/* Prullenbak knop mooi geïntegreerd naast de hoofdaanwijzer */
.btn-reset-inline {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  width: 54px;
  height: 54px; /* Zelfde hoogte als de btn-primary */
  border-radius: 12px;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  touch-action: manipulation;
}
.btn-reset-inline:active {
  transform: scale(0.95);
  background: #fca5a5;
}
