:root {
  --bg: #f4f7fb;
  --text: #0f172a;
  --muted: #475569;
  --card: #ffffff;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-2: #7c3aed;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #e9f0ff 0%, var(--bg) 45%, #f8fafc 100%);
}

.container {
  max-width: 1040px;
  margin: 2rem auto 3rem;
  padding: 0 1rem;
}

h1 {
  margin: 0 0 0.3rem;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: 1.2rem;
}

h3 {
  margin: 1rem 0 0.55rem;
  font-size: 1rem;
}

.subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
}

.card {
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.hero {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  align-items: end;
  background:
    linear-gradient(120deg, rgba(15, 23, 42, 0.82) 0%, rgba(30, 41, 59, 0.6) 42%, rgba(37, 99, 235, 0.36) 100%),
    url("boerenbridge-spelregels-2560x1100_1499_644-1524565064.png") center 28% / cover no-repeat;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 42%;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0) 0%, rgba(15, 23, 42, 0.55) 100%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.hero h1 {
  color: #f8fafc;
  text-shadow: 0 2px 10px rgba(2, 6, 23, 0.4);
}

.hero .subtitle {
  color: #dbeafe;
  margin-bottom: 0;
}

.hidden {
  display: none;
}

.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.7rem;
}

.variant-btn {
  border: 1px solid #dbe4f1;
  background: #f8fbff;
  color: #1e293b;
  border-radius: 12px;
  padding: 0.8rem;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.variant-btn:hover {
  transform: translateY(-1px);
  border-color: #bcd1f6;
  background: #f2f7ff;
}

.variant-btn.active {
  border-color: #5b8def;
  background: linear-gradient(180deg, #e8f0ff 0%, #dbeafe 100%);
  box-shadow: inset 0 0 0 1px #bfdbfe;
}

.setup-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.setup-submit {
  margin-top: 1rem;
}

.names-wrap {
  margin-top: 0.9rem;
}

.names-wrap h3 {
  margin: 0.2rem 0 0.6rem;
  font-size: 1rem;
}

.names-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.6rem;
}

label {
  display: grid;
  gap: 0.3rem;
  color: #334155;
  font-size: 0.93rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: #fff;
  color: #0f172a;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

button {
  border: 1px solid #1d4ed8;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
}

button.secondary {
  border-color: #64748b;
  background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
}

.actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.hint {
  color: #64748b;
  margin-top: 0.45rem;
  font-size: 0.92rem;
}

.round-row {
  margin-bottom: 0.45rem;
}

.player-row {
  display: grid;
  grid-template-columns: 1.8fr 1fr 1fr;
  gap: 0.65rem;
  margin: 0.5rem 0;
  align-items: center;
  padding: 0.4rem 0.45rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5edf7;
}

#scoreTable,
#breakdownTable {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5edf7;
  border-radius: 12px;
  overflow: hidden;
}

#scoreTable th,
#scoreTable td,
#breakdownTable th,
#breakdownTable td {
  border-bottom: 1px solid #eef2f7;
  padding: 0.6rem 0.65rem;
  text-align: left;
}

#scoreTable th,
#breakdownTable th {
  background: #f8fafd;
  color: #334155;
  font-size: 0.9rem;
}

.score-breakdown-wrap {
  overflow-x: auto;
  margin-top: 0.6rem;
}

.chart-wrap {
  margin-top: 0.55rem;
  border: 1px solid #e5edf7;
  border-radius: 12px;
  padding: 0.55rem;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

#flowChart,
#totalScoreChart {
  width: 100%;
  display: block;
}

.breakdown-points {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.variation-pill {
  display: inline-block;
  padding: 0.16rem 0.45rem;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 700;
}

.variation-positive {
  background: #ffedd5;
  color: #9a3412;
}

.variation-negative {
  background: #fee2e2;
  color: #991b1b;
}

.error {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.6rem;
  min-height: 2.2rem;
  display: flex;
  align-items: center;
}

.winner {
  font-weight: 800;
  color: #166534;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.95rem;
}

.site-footer {
  margin-top: 1.2rem;
}

.site-footer p {
  margin: 0.25rem 0 0.8rem;
  color: #475569;
}

.sponsor-row {
  margin: 0.2rem 0 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.8rem;
  font-size: 0.92rem;
  color: #334155;
}

.site-footer a {
  color: #1d4ed8;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer code {
  background: #eef2ff;
  color: #312e81;
  padding: 0.1rem 0.3rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.sponsor-dialog {
  border: 1px solid #dbe4f1;
  border-radius: 14px;
  padding: 1rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.22);
}

.sponsor-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.sponsor-intro {
  margin: 0 0 0.75rem;
  color: #334155;
  line-height: 1.45;
}

.sponsor-qr {
  margin: 0.75rem auto 1rem;
  text-align: center;
}

.sponsor-qr img {
  max-width: 100%;
  width: min(240px, 100%);
  height: auto;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

@media (max-width: 760px) {
  .container {
    margin: 1rem auto 1.8rem;
    padding: 0 0.7rem;
  }

  .card {
    padding: 0.9rem;
    border-radius: 14px;
  }

  .hero {
    min-height: 180px;
    background-position: center 40%;
  }

  h2 {
    font-size: 1.05rem;
  }

  h3 {
    font-size: 0.95rem;
  }

  .setup-form,
  .names-grid,
  .variant-grid {
    grid-template-columns: 1fr;
  }

  .player-row {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    padding: 0.55rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions button,
  #setupForm button {
    flex: 1 1 auto;
    width: 100%;
  }

  #scoreTable th,
  #scoreTable td,
  #breakdownTable th,
  #breakdownTable td {
    padding: 0.5rem;
    font-size: 0.86rem;
  }

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

@media (max-width: 420px) {
  .subtitle,
  .hint {
    font-size: 0.86rem;
  }

  input,
  select,
  button {
    font-size: 0.95rem;
  }
}
