:root {
  /* Tosch huisstijl */
  --orange: #FF6F00;
  --orange-soft: #fff3e0;
  --blue: #1E4962;
  --blue-700: #163749;
  --grey: #F5F1E9;
  --green: #397F57;
  --yellow: #FFDD53;

  --ink: #1b2b34;
  --muted: #6b7c85;
  --line: #e6e2d8;
  --card: #ffffff;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(30, 73, 98, .08), 0 6px 16px rgba(30, 73, 98, .06);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--grey);
  color: var(--ink);
  font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 640px;
  margin: 0 auto;
  padding-bottom: calc(64px + var(--safe-bottom));
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--blue);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 38px; height: 38px; flex: none; cursor: pointer; transition: transform .15s; }
.brand-logo:active { transform: scale(.9) rotate(-20deg); }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 900; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { font-size: .72rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  flex: none;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 1.3rem;
  cursor: pointer; transition: transform .2s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.spin { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Tabs ---------- */
.tabs {
  position: sticky;
  top: calc(62px + var(--safe-top));
  z-index: 19;
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: var(--grey);
}
.tab {
  flex: 1;
  border: none;
  padding: 10px 0;
  border-radius: 999px;
  background: #fff;
  color: var(--blue);
  font: inherit; font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.tab.is-active { background: var(--orange); color: #fff; }

/* ---------- Rangschikking-schakelaar (in instellingen-paneel) ---------- */
.seg { display: inline-flex; background: var(--card); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); }
.seg-wide { display: flex; width: 100%; }
.seg-wide .seg-btn { flex: 1; }
.seg-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 9px 14px; border-radius: 999px; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer;
}
.seg-btn.is-active { background: var(--blue); color: #fff; }

/* ---------- Landen-paneel (bottom sheet) ---------- */
.sheet-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 34, 43, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
.sheet-overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 640px;
  max-height: 85vh;
  background: var(--grey);
  border-radius: 20px 20px 0 0;
  padding: 14px 16px calc(16px + var(--safe-bottom));
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .25);
  animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(100%); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sheet-head strong { font-size: 1.05rem; color: var(--blue); }
.sheet-head .icon-btn { background: rgba(30, 73, 98, .1); color: var(--blue); }

.sheet-scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-section { margin-bottom: 18px; }
.sheet-section + .sheet-section { border-top: 1px solid var(--line); padding-top: 14px; }
.sheet-label {
  display: block; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em;
  color: var(--blue); margin: 0 2px 4px;
}
.section-hint { font-size: .78rem; color: var(--muted); margin: 0 2px 8px; line-height: 1.45; }
.info-section .section-hint b { color: var(--ink); }
.version { font-size: .72rem; color: var(--muted); margin: 8px 2px 0; font-weight: 700; }
.info-dot { cursor: help; font-size: .85rem; }
.ios-note { background: var(--orange-soft); border-radius: 8px; padding: 7px 10px; color: #7a4a00; }
.list-note { font-size: .74rem; color: var(--muted); text-align: center; padding: 8px 2px 2px; }

.country-search {
  width: 100%; box-sizing: border-box;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: .95rem; background: #fff; color: var(--ink);
  margin-bottom: 10px;
}
.country-search:focus { outline: 2px solid var(--orange); border-color: transparent; }

.sheet-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.mini-btn {
  flex: 1; padding: 9px 0; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--blue); font: inherit; font-weight: 700; font-size: .85rem;
  cursor: pointer;
}
.mini-btn:active { transform: scale(.97); }
.mini-btn.wide { width: 100%; flex: none; margin-top: 4px; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 13px; background: var(--card); border-radius: 12px; margin-bottom: 8px;
  font-weight: 700; cursor: pointer;
}
.switch-row.sub { font-weight: 400; }
.switch-row input { width: 22px; height: 22px; accent-color: var(--orange); flex: none; }
#notif-opts { margin-top: 2px; }

.country-list { border-radius: 12px; }
.country {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; background: #fff; border-radius: 12px;
  margin-bottom: 6px; cursor: pointer;
}
.country input { width: 20px; height: 20px; accent-color: var(--orange); flex: none; }
.country .crest { width: 22px; height: 22px; object-fit: contain; flex: none; }
.country-name { flex: 1; min-width: 0; }
.country.is-oranje { border: 1px solid var(--orange); background: var(--orange-soft); margin-bottom: 10px; }
.country .pin {
  font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: #fff; background: var(--orange); padding: 2px 8px; border-radius: 999px;
}
body.sheet-open { overflow: hidden; }

.sheet-agenda { padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.agenda-btn {
  width: 100%; padding: 13px 0; border: none; border-radius: 14px;
  background: var(--orange); color: #fff; font: inherit; font-weight: 800; font-size: .95rem; cursor: pointer;
}
.agenda-btn:active { transform: scale(.98); }
.agenda-hint { margin: 8px 2px 0; font-size: .72rem; color: var(--muted); text-align: center; }

/* ---------- Wedstrijddetail ---------- */
.match { cursor: pointer; }
.detail-sheet { max-height: 80vh; }
.d-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; padding: 8px 0 16px; }
.d-team { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-weight: 800; color: var(--ink); }
.d-crest { width: 48px; height: 48px; object-fit: contain; }
.d-center { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 84px; }
.d-score { font-size: 2rem; font-weight: 900; color: var(--blue); font-variant-numeric: tabular-nums; }
.d-score span { color: var(--muted); margin: 0 6px; font-weight: 700; }
.d-kick { font-size: 1.5rem; font-weight: 900; color: var(--ink); }
.d-sub { font-size: .78rem; color: var(--muted); text-transform: capitalize; }
.d-muted { color: var(--muted); font-weight: 400; text-align: center; padding: 10px 0; }
.d-block { border-top: 1px solid var(--line); padding: 12px 0 4px; }
.d-block-h { text-align: center; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: .9rem; }
.d-grid .r { text-align: right; }
.d-grid b { color: var(--blue); }
.d-line { text-align: center; color: var(--muted); font-weight: 700; font-size: .85rem; padding: 8px 0; border-top: 1px solid var(--line); }
.d-min-row { text-align: center; color: var(--green); font-weight: 800; padding: 6px 0; }
.d-stadium { display: flex; align-items: center; gap: 12px; border-top: none; padding-top: 4px; }
.d-stadium-img { width: 96px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.d-stadium-info { min-width: 0; }
.d-stadium-name { font-weight: 800; color: var(--ink); }
.d-stadium-cap { color: var(--muted); font-weight: 700; font-size: .85rem; margin-top: 3px; }
.d-out { color: var(--muted); font-weight: 400; }
.d-form { font-weight: 900; color: var(--orange); margin-bottom: 4px; }
.d-stat { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 5px 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.d-stat-l { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Views ---------- */
main { padding: 8px 16px 0; }

.banner {
  background: var(--orange-soft);
  border: 1px solid #ffd9a8;
  color: #7a4a00;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: .85rem;
  margin-bottom: 12px;
}

.stage-group { margin-top: 18px; }
.stage-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.1rem; font-weight: 900;
  color: var(--blue);
  margin: 0 2px 8px;
}
.stage-title .dots { color: var(--orange); letter-spacing: -2px; }

.subgroup-title {
  font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
  margin: 14px 2px 6px;
}

.day-head {
  font-size: 1rem; font-weight: 900; color: var(--blue);
  margin: 2px 2px 8px; text-transform: capitalize;
  border-bottom: 2px solid var(--orange); padding-bottom: 4px; display: inline-block;
}
.match-ctx {
  font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 4px;
}
.day-label {
  font-size: .8rem; font-weight: 700; color: var(--muted);
  margin: 14px 2px 6px;
  text-transform: capitalize;
}

/* ---------- Match card ---------- */
.match {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius);
  border-left: 4px solid transparent;
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
}
.match.is-oranje { border-left-color: var(--orange); background: linear-gradient(90deg, var(--orange-soft), #fff 55%); }

.teams { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.team .tla {
  font-size: .68rem; font-weight: 900; color: var(--muted);
  width: 34px; flex: none;
}
.team.win .name { font-weight: 900; }
.team .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crest { width: 18px; height: 18px; object-fit: contain; flex: none; }

.result { text-align: right; flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.score { font-weight: 900; font-size: 1.15rem; color: var(--blue); font-variant-numeric: tabular-nums; }
.score .x { color: var(--muted); margin: 0 3px; font-weight: 700; }
.kick { font-size: .9rem; font-weight: 700; color: var(--ink); }
.kick small { display: block; font-size: .7rem; font-weight: 400; color: var(--muted); }

.badge { font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; }
.badge.done { background: var(--grey); color: var(--muted); }
.badge.live { background: var(--green); color: #fff; }
.badge.live::before { content: "● "; }

/* ---------- Standings ---------- */
.standing { margin-top: 18px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.standing h3 { margin: 0; padding: 12px 14px; background: var(--blue); color: #fff; font-size: .95rem; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { padding: 8px 6px; text-align: center; }
th { color: var(--muted); font-size: .68rem; text-transform: uppercase; font-weight: 700; }
td.team-cell, th.team-cell { text-align: left; padding-left: 14px; }
tbody tr { border-top: 1px solid var(--line); }
tbody tr.qualify { background: var(--orange-soft); }
tbody tr.oranje td { font-weight: 900; }
.pos { width: 22px; color: var(--muted); font-weight: 700; }
td.pts { font-weight: 900; color: var(--blue); }
.team-cell .flag { width: 18px; height: 18px; object-fit: contain; vertical-align: -4px; margin-right: 7px; }

/* ---------- States ---------- */
.empty, .loading { text-align: center; color: var(--muted); padding: 48px 16px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--orange); border-radius: 50%; margin: 0 auto 12px; animation: spin .8s linear infinite; }

.app-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 640px; margin: 0 auto;
  padding: 8px 16px calc(8px + var(--safe-bottom));
  background: rgba(245, 241, 233, .92);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--line);
  font-size: .72rem; color: var(--muted); text-align: center;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef3f6; --muted: #9fb2bc; --line: #2a3f4c;
    --card: #1b2b34; --grey: #12222b; --orange-soft: #2a2418;
  }
  .tab { background: #1b2b34; color: #cfe0e8; }
  .match.is-oranje { background: linear-gradient(90deg, #2a2418, #1b2b34 55%); }
  .app-footer { background: rgba(18, 34, 43, .92); }
  .country, .mini-btn, .country-search { background: #1b2b34; color: var(--ink); }
  .sheet-head .icon-btn { background: rgba(255, 255, 255, .12); color: #fff; }
  .ios-note { color: #f0c98a; }
}
