/* style.css — Klaverjas Toernooi @ Kafé van Zanten
 * Aesthetiek: bruine kroeg. Donker warm bruin, crème papier,
 * amber en bordeaux-accenten. Klassiek display-font.
 */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,900&family=Spectral:wght@400;500;600&display=swap');

:root {
  --bg:        #1d1a15;   /* donker warm bruin — achtergrond */
  --bg-mid:    #151210;   /* donkerder bruin — tabs */
  --bg-light:  #2b2520;   /* iets lichter bruin — vergrendeld */
  --cream:     #f3ead6;   /* warm crème — papier */
  --ink:       #221d14;   /* bijna-zwart inkt */
  --amber:     #c48840;   /* amber/houtkleur — hoofdaccent */
  --amber-lt:  #daa560;   /* licht amber */
  --wine:      #7a1f2e;   /* diep bordeaux — primaire actie */
  --wine-lt:   #9e2840;   /* lichter bordeaux */
  --line:      rgba(0,0,0,.16);
  --shadow:    0 8px 24px rgba(0,0,0,.45);
}

/* Aliassen zodat bestaande verwijzingen naar de "groene" namen
   automatisch de nieuwe bruine kleuren krijgen. */
:root {
  --felt:        var(--bg);
  --felt-dark:   var(--bg-mid);
  --felt-light:  var(--bg-light);
  --paper:       var(--cream);
  --copper:      var(--amber);
  --copper-lt:   var(--amber-lt);
  --card-red:    var(--wine);
  --card-red-lt: var(--wine-lt);
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Spectral', Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 30% 0%, var(--bg-light), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

/* ---- Koptekst ---- */
header {
  text-align: center;
  padding: 1.4rem 1rem .9rem;
  color: var(--cream);
}

/* Van Zanten logo */
.header-logo {
  display: block;
  margin: 0 auto .55rem;
  width: 120px;
  height: auto;
}

header h1 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.9rem;
  letter-spacing: .01em;
  line-height: 1.05;
}

header h1 .suit {
  color: var(--amber-lt);
  font-size: 1.1em;
}

header p {
  font-size: .82rem;
  opacity: .7;
  margin-top: .25rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ---- Tabbladen ---- */
.tabs {
  display: flex;
  gap: .35rem;
  max-width: 540px;
  margin: 0 auto;
  padding: .75rem 1rem 0;
}

.tab {
  flex: 1;
  background: var(--bg-mid);
  color: var(--cream);
  border: 1px solid rgba(255,255,255,.08);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: .7rem .4rem;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .84rem;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, background .15s;
}

.tab.active {
  opacity: 1;
  background: var(--cream);
  color: var(--ink);
}

/* ---- Schermen ---- */
main {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.screen {
  display: none;
  background: var(--cream);
  border-radius: 0 0 14px 14px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.2rem 1.8rem;
}

.screen.active { display: block; }

.screen h2 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.3rem;
  margin-bottom: .2rem;
}

.screen .sub {
  font-size: .85rem;
  opacity: .6;
  margin-bottom: 1.1rem;
}

/* ---- Formulier-elementen ---- */
label {
  display: block;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  opacity: .65;
  margin-bottom: .3rem;
}

input[type="text"],
input[type="number"] {
  width: 100%;
  font-family: 'Spectral', serif;
  font-size: 1rem;
  padding: .65rem .7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf6ea;
  color: var(--ink);
  transition: border-color .15s, outline-color .15s;
}

input:focus {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

/* Rode rand bij fout */
input.input-error {
  border-color: var(--wine);
  outline-color: var(--wine);
}

.field { margin-bottom: 1.2rem; }

/* ---- Keuzekaarten (aantal rondes) ---- */
.radio-group {
  display: flex;
  gap: .6rem;
}

.radio-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .15rem;
  padding: .7rem .65rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #faf6ea;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card:has(input:checked) {
  border-color: var(--wine);
  background: #f5e8ec;
  box-shadow: inset 0 0 0 1px var(--wine);
}

.radio-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .95rem;
}

.radio-desc {
  font-size: .72rem;
  opacity: .6;
}

/* ---- Knoppen ---- */
.btn {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .95rem;
  padding: .7rem 1.1rem;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: transform .08s, filter .15s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--wine);
  color: var(--cream);
  width: 100%;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }

.btn-copper {
  background: var(--amber);
  color: #fff;
  width: 100%;
}
.btn-copper:hover:not(:disabled) { filter: brightness(1.07); }

.btn-ghost {
  background: transparent;
  color: var(--wine);
  border: 1px solid var(--wine);
  width: 100%;
}

.btn-row { display: flex; gap: .6rem; margin-top: 1rem; }
.btn-row .btn { flex: 1; }

/* ---- Label-rij met spelersteller ---- */
.players-label-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .3rem;
}

.players-label-row label {
  margin-bottom: 0;
}

/* Badge-pilletje met aantal spelers */
.player-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 .42rem;
  background: var(--wine);
  color: #fff;
  font-family: 'Fraunces', serif;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 999px;
  line-height: 1;
}

/* ---- Foutmelding dubbele naam ---- */
.player-name-error {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .82rem;
  color: var(--wine);
  background: #f5e0e4;
  border-radius: 6px;
  padding: .35rem .55rem;
  margin-top: .4rem;
  margin-bottom: .4rem;
}

.player-name-error::before {
  content: "⚠";
  flex-shrink: 0;
}

/* ---- Deelnemerslijst ---- */
#player-add-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 0;
}
#player-add-form input { flex: 1; }
#player-add-form .btn {
  background: var(--bg);
  color: var(--cream);
  padding: .65rem .9rem;
}

#player-list { list-style: none; margin-top: 1rem; }

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem .2rem;
  border-bottom: 1px dashed var(--line);
}
.player-row:last-child { border-bottom: none; }

.player-name { font-size: 1.02rem; }

.btn-icon {
  background: none;
  border: none;
  color: var(--wine);
  font-size: .9rem;
  cursor: pointer;
  padding: .25rem .45rem;
}

#player-count {
  font-size: .85rem;
  font-style: italic;
  opacity: .7;
  margin: .8rem 0 1rem;
}

#setup-locked {
  background: var(--bg-light);
  color: var(--cream);
  border-radius: 8px;
  padding: .8rem;
  font-size: .85rem;
  margin-bottom: 1rem;
}

#setup-locked p { margin-bottom: .6rem; }

#setup-locked .btn-ghost {
  color: var(--amber-lt);
  border-color: var(--amber-lt);
}

#storage-notice {
  background: #fbe9c8;
  border: 1px solid var(--amber);
  color: #5c3a10;
  border-radius: 8px;
  padding: .65rem .8rem;
  font-size: .8rem;
  margin-bottom: 1rem;
}

/* ---- Rondes ---- */
.round-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .9rem .85rem;
  margin-bottom: 1rem;
  background: #faf6ea;
}

.round-card h3 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.05rem;
  color: var(--wine);
  margin-bottom: .15rem;
}

.round-note {
  font-size: .74rem;
  opacity: .6;
  margin-bottom: .6rem;
}

.table-block {
  border-top: 1px solid var(--line);
  padding: .65rem 0 .35rem;
}
.table-block:first-of-type { border-top: none; }

.table-title {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  opacity: .55;
  margin-bottom: .4rem;
}

.score-row {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
}

.score-cell { flex: 1; }

.team-line {
  font-size: .92rem;
  font-weight: 500;
  margin-bottom: .35rem;
  min-height: 2.4em;
}

.score-input {
  text-align: center;
  font-weight: 600;
}

.score-mini-label {
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .6;
  margin: .45rem 0 .15rem;
}

.roem-input {
  background: #f5edd8;
}

.score-input.input-warn {
  border-color: var(--wine);
  background: #f5e0e4;
  outline-color: var(--wine);
}

.table-info {
  margin-top: .55rem;
  min-height: 1.1em;
}

.check-warn {
  font-size: .78rem;
  color: var(--wine);
  background: #f5e0e4;
  border-radius: 6px;
  padding: .35rem .5rem;
  margin-bottom: .35rem;
}

.totals-line {
  font-size: .85rem;
  text-align: center;
  opacity: .85;
}

.totals-line strong {
  font-family: 'Fraunces', serif;
  font-size: 1rem;
}

.winmark {
  color: var(--amber);
  font-size: .8rem;
}

.vs {
  align-self: center;
  font-family: 'Fraunces', serif;
  color: var(--amber);
  padding-top: 1.4rem;
}

.bye-line {
  font-size: .82rem;
  font-style: italic;
  opacity: .7;
  margin-top: .6rem;
}

.empty-hint {
  text-align: center;
  font-style: italic;
  opacity: .6;
  padding: 1.5rem 0;
}

/* ---- Klassement ---- */
#winner-banner {
  background: var(--amber);
  color: #fff;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  text-align: center;
  padding: .7rem;
  border-radius: 9px;
  margin-bottom: 1rem;
  font-size: 1.05rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

thead th {
  text-align: left;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .5rem .4rem;
  border-bottom: 2px solid var(--bg);
}

thead th.num { text-align: right; }

tbody td {
  padding: .55rem .4rem;
  border-bottom: 1px solid var(--line);
}

tbody td.num, tbody td.rank { text-align: right; }
tbody td.rank { font-weight: 600; color: var(--amber); }

tbody tr.leader {
  background: rgba(196,136,64,.12);
}
tbody tr.leader td.rank { color: var(--wine); }

/* ---- Firebase-foutbanner ---- */
.firebase-error-banner {
  max-width: 540px;
  margin: .6rem auto 0;
  padding: .65rem .9rem;
  background: #fff3cd;
  border: 1px solid #e6a817;
  border-radius: 9px;
  color: #6b4a00;
  font-size: .8rem;
  line-height: 1.5;
}

/* ---- Toernooinavigatie ---- */
#tournament-nav {
  max-width: 540px;
  margin: 0 auto;
}

.tournament-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .55rem 1rem .1rem;
}

.btn-back {
  background: none;
  border: none;
  color: var(--cream);
  font-family: 'Fraunces', serif;
  font-size: .82rem;
  font-weight: 600;
  opacity: .75;
  cursor: pointer;
  padding: .2rem .1rem;
  transition: opacity .15s;
}
.btn-back:hover { opacity: 1; }

.topbar-id {
  font-size: .75rem;
  font-family: 'Spectral', serif;
  color: var(--cream);
  opacity: .55;
  letter-spacing: .08em;
}

/* ---- Startscherm: afgeronde hoeken ---- */
#screen-home {
  border-radius: 14px;
  margin-top: .75rem;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: .76rem;
  opacity: .75;
}

.open-error {
  font-size: .82rem;
  color: var(--wine);
  background: #f5e0e4;
  border-radius: 6px;
  padding: .35rem .55rem;
  margin-bottom: .5rem;
}

/* Recente toernooien */
#recent-tournaments { margin-top: 1.6rem; }

.recent-heading {
  font-family: 'Fraunces', serif;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .5;
  margin-bottom: .55rem;
}

.recent-list { list-style: none; }

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem 0;
  border-bottom: 1px dashed var(--line);
}
.recent-item:last-child { border-bottom: none; }

.recent-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}

.recent-name {
  font-size: .98rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-meta {
  font-size: .74rem;
  opacity: .55;
  font-style: italic;
}

.recent-open-btn {
  width: auto !important;
  flex-shrink: 0;
  padding: .4rem .75rem;
  font-size: .82rem;
}

/* Knoppen-groep per toernooi-rij (Openen + Verwijderen naast elkaar) */
.recent-btns {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
  align-items: center;
}

/* Gevaarlijke actie — bordeaux outline */
.btn-danger {
  background: transparent;
  color: var(--wine);
  border: 1px solid rgba(122,31,46,.45);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(122,31,46,.1);
  border-color: var(--wine);
}

/* Cloud-toernooien (andere apparaten) */
.btn-cloud {
  background: transparent;
  color: var(--bg);
  border: 1px solid rgba(29,26,21,.3);
}
.btn-cloud:hover:not(:disabled) { background: #ede5cf; }

.recent-item--cloud .recent-name { opacity: .75; }

.recent-loading {
  list-style: none;
  font-size: .8rem;
  font-style: italic;
  opacity: .5;
  padding: .5rem 0;
}

/* ---- Aangemaakt-scherm ---- */
.created-badge {
  display: inline-block;
  background: var(--bg);
  color: var(--cream);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
  padding: .25rem .65rem;
  border-radius: 999px;
  margin-bottom: .75rem;
}

.code-block {
  display: flex;
  align-items: center;
  gap: .6rem;
  border-radius: 10px;
  padding: .75rem 1rem;
  margin-bottom: .85rem;
}

.code-block-primary {
  background: #ede5cf;
  border: 1px solid rgba(29,26,21,.18);
}

.code-block-admin {
  background: #fdf2e2;
  border: 1px solid rgba(196,136,64,.3);
}

.code-block > div:first-child {
  flex: 1;
  min-width: 0;
}

.code-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
  opacity: .6;
  margin-bottom: .2rem;
}

.code-label-sub {
  font-size: .68rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: .8;
}

.code-value {
  font-family: 'Fraunces', serif;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--ink);
}

.btn-copy {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  opacity: .5;
  font-size: 1.1rem;
  padding: .3rem .5rem;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-copy:hover { opacity: 1; }

.admin-warning {
  background: #fef9ec;
  border: 1px solid #e6c94a;
  border-radius: 8px;
  padding: .7rem .85rem;
  font-size: .82rem;
  line-height: 1.5;
  color: #6b5a10;
  margin-bottom: 1.2rem;
}

/* ---- Viewer-banner (toeschouwer-modus) ---- */
.viewer-banner {
  background: #f5edda;
  border: 1px solid rgba(196,136,64,.4);
  border-radius: 8px;
  padding: .6rem .85rem;
  font-size: .84rem;
  color: #5a3a10;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.btn-inline-link {
  background: none;
  border: none;
  color: var(--amber);
  font-family: 'Spectral', serif;
  font-size: .84rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}
.btn-inline-link:hover { color: var(--amber-lt); }

/* ---- Modal (beheercode invoeren) ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-box {
  background: var(--cream);
  border-radius: 14px;
  padding: 1.5rem 1.4rem 1.3rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

.modal-box h3 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1.1rem;
  margin-bottom: .45rem;
}

.modal-box p {
  font-size: .85rem;
  opacity: .7;
  margin-bottom: .9rem;
  line-height: 1.5;
}

.modal-box input {
  margin-bottom: .6rem;
  font-size: 1.1rem;
  letter-spacing: .1em;
  text-align: center;
}

.modal-btns {
  display: flex;
  gap: .5rem;
  margin-top: .6rem;
}

.modal-btns .btn { flex: 1; }

/* ---- Help-modal ---- */
.modal-box--help {
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
}

.help-section {
  margin-top: 1.1rem;
}

.help-section h4 {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: .95rem;
  color: var(--ink);
  margin-bottom: .45rem;
  padding-bottom: .2rem;
  border-bottom: 1px solid rgba(0,0,0,.1);
}

.help-section ol,
.help-section ul {
  padding-left: 1.3rem;
  margin: 0;
}

.help-section li {
  font-size: .86rem;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: .35rem;
  opacity: .85;
}

.help-section li:last-child { margin-bottom: 0; }

.help-section li strong { opacity: 1; }

/* Help-knop onderaan het startscherm */
.btn-help-link {
  display: block;
  width: 100%;
  margin-top: 1.4rem;
  background: none;
  border: 1px solid rgba(34,29,20,.35);
  border-radius: 8px;
  color: var(--ink);
  font-family: 'Spectral', serif;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  padding: .6rem 1rem;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-help-link:hover {
  background: rgba(34,29,20,.07);
  border-color: rgba(34,29,20,.6);
}

/* ---- Aanmaakformulier nieuw toernooi ---- */
#new-tournament-form {
  background: #ede8d4;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1rem .8rem;
  margin: .75rem 0 1rem;
}

.new-form-header {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: .95rem;
  margin-bottom: .85rem;
  color: var(--bg);
}

.field-hint {
  font-size: .74rem;
  opacity: .58;
  margin-top: .3rem;
  font-style: italic;
  line-height: 1.4;
}

/* ---- Persoonlijke tafelbanner (rondes-scherm, na QR-aanmelding) ---- */
.my-table-card {
  background: var(--amber);
  color: #fff;
  border-radius: 13px;
  padding: 1rem 1rem 1.1rem;
  margin-bottom: 1.3rem;
  box-shadow: 0 4px 16px rgba(196,136,64,.35);
}

.my-table-heading {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .75;
  margin-bottom: .7rem;
}

.my-table-teams {
  display: flex;
  align-items: stretch;
  gap: .6rem;
  margin-bottom: .75rem;
}

.my-team {
  flex: 1;
  min-width: 0;
}

.my-team-mine {
  background: rgba(255,255,255,.18);
  border-radius: 8px;
  padding: .45rem .6rem;
}

.my-team-label {
  display: block;
  font-size: .62rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 600;
  opacity: .65;
  margin-bottom: .2rem;
}

.my-team-names {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
}

.my-vs {
  align-self: center;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  opacity: .5;
  flex-shrink: 0;
  font-size: .9rem;
}

.my-table-prog {
  font-size: .8rem;
  opacity: .7;
  margin-bottom: .8rem;
}
.my-table-prog--done {
  font-weight: 700;
  opacity: .9;
}

.my-table-bye {
  font-size: .9rem;
  opacity: .8;
  margin-top: .25rem;
}

/* Knop in de banner: wit op amber */
.my-table-btn {
  background: rgba(255,255,255,.22) !important;
  color: #fff !important;
  border: 1px solid rgba(255,255,255,.4);
}
.my-table-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.32) !important;
}

/* Wachtkader na het voltooien van een partij — zichtbaar totdat de volgende ronde geloot is */
.my-table-waiting-card {
  margin-bottom: 1.3rem;
}

/* ---- Tournament-over banner (toernooi beëindigd) ---- */
.tournament-over-banner {
  background: linear-gradient(135deg, rgba(196,136,64,.22), rgba(196,136,64,.1));
  border: 1.5px solid var(--copper);
  border-radius: 10px;
  padding: .9rem 1.1rem;
  margin: 0 0 1rem;
  text-align: center;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .4rem;
}

/* Flex-rij voor Nieuwe-ronde en Einde-toernooi knoppen */
.round-action-row {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
}

/* ---- Naamkieslijst (terugkeren naar portaal als toernooi al gestart is) ---- */
.join-picker-list {
  list-style: none;
  margin: .75rem 0 .5rem;
  padding: 0;
}
.join-picker-list li {
  margin-bottom: .4rem;
}
.join-picker-list li button {
  width: 100%;
  text-align: left;
  padding: .65rem .9rem;
  background: #fff8f0;
  border: 1px solid rgba(196,136,64,.4);
  border-radius: 8px;
  font-family: 'Spectral', serif;
  font-size: 1rem;
  cursor: pointer;
  color: var(--ink);
  transition: background .15s, border-color .15s;
}
.join-picker-list li button:hover {
  background: rgba(196,136,64,.18);
  border-color: var(--copper);
}

/* ---- Aanmeld-scherm (QR-code flow voor deelnemers) ---- */
.screen-join {
  border-radius: 14px;
  margin-top: .75rem;
  max-width: 400px;
}

.join-success-banner {
  background: #e9f4ee;
  border: 1px solid #5cb87a;
  border-radius: 10px;
  padding: 1.1rem 1rem;
  text-align: center;
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: #1a5c2a;
  margin-bottom: .5rem;
  transition: background .4s, color .4s, border-color .4s;
}

/* Wacht-instructies na aanmelding (verdwijnen als toernooi start) */
.join-waiting-hints {
  background: rgba(196,136,64,.14);
  border: 1px solid rgba(196,136,64,.45);
  border-radius: 10px;
  padding: .9rem 1rem;
  margin-top: .75rem;
}

.join-hint-item {
  margin: 0 0 .55rem;
  font-size: .9rem;
  color: var(--ink);
  line-height: 1.4;
}

.join-hint-item:last-child { margin-bottom: 0; }

#btn-join-watch:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Toestand zodra beheerder het toernooi start */
.join-started-banner {
  background: var(--amber);
  border-color: var(--amber-lt);
  color: #fff;
}

@keyframes join-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(122,31,46,.45); }
  55%       { box-shadow: 0 0 0 10px rgba(122,31,46,0); }
}

.join-watch-highlight {
  background: var(--wine) !important;
  color: #fff !important;
  border-color: transparent !important;
  animation: join-pulse 1.6s ease-out infinite;
}

/* ---- QR-code sectie (in setup-scherm, alleen admin) ---- */
#qr-section {
  background: #ede8d4;
  border: 1px solid rgba(29,26,21,.16);
  border-radius: 12px;
  padding: 1rem 1rem .8rem;
  margin: 1.2rem 0 1.1rem;
}

.qr-section-header { margin-bottom: .7rem; }

.qr-section-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: .92rem;
  color: var(--bg);
}

.qr-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.qr-code {
  width: 110px;
  height: 110px;
  border-radius: 8px;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  flex-shrink: 0;
}

.qr-actions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  min-width: 0;
}

.qr-hint {
  font-size: .8rem;
  line-height: 1.45;
  opacity: .65;
  margin-bottom: .15rem;
}

#btn-copy-join-link,
#btn-share-wa {
  width: auto !important;
  font-size: .82rem;
  padding: .45rem .85rem;
  text-align: center;
  text-decoration: none;
}

.qr-live-hint {
  font-size: .73rem;
  opacity: .5;
  font-style: italic;
  margin-top: .65rem;
  text-align: center;
}

/* ---- Score bijhouden: knop + voortgangsindicator ---- */
.table-score-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}

.btn-score {
  background: var(--bg);
  color: var(--cream);
  border: none;
  border-radius: 7px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .78rem;
  padding: .38rem .75rem;
  cursor: pointer;
  transition: filter .15s;
  flex-shrink: 0;
}
.btn-score:hover { filter: brightness(1.35); }

.table-game-progress {
  font-size: .75rem;
  font-style: italic;
  opacity: .6;
  flex: 1;
}
.table-game-progress.table-game-done {
  color: #7a4e10;
  font-style: normal;
  font-weight: 600;
  opacity: .85;
}

/* ============================================================
   SCORING-MODAL (volledige ronde-registratie per tafel)
   ============================================================ */

.scoring-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background:
    radial-gradient(circle at 30% 0%, var(--bg-light), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scoring-modal-header {
  display: flex;
  align-items: center;
  padding: calc(.65rem + env(safe-area-inset-top, 0px)) 1rem .5rem;
  flex-shrink: 0;
}

.scoring-title {
  color: var(--cream);
  font-size: .8rem;
  font-family: 'Spectral', serif;
  opacity: .65;
  letter-spacing: .06em;
  margin-left: .5rem;
}

.scoring-content {
  overflow-y: auto;
  flex: 1;
  padding: .5rem 1rem 3rem;
  max-width: 540px;
  margin: 0 auto;
  width: 100%;
}

/* Scorebord (legacy, niet meer getoond) */
.scoreboard {
  display: flex;
  align-items: stretch;
  gap: .6rem;
  margin-bottom: .9rem;
  padding: .85rem .75rem;
  background: var(--bg-light);
  border-radius: 12px;
}

.score-panel {
  flex: 1;
  text-align: center;
  padding: .75rem .5rem .6rem;
  border-radius: 9px;
  background: rgba(0,0,0,.18);
  transition: background .25s;
}

.score-panel.panel-leader { background: var(--wine); }

.score-team-name {
  font-family: 'Fraunces', serif;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--cream);
  opacity: .75;
  margin-bottom: .2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-total {
  font-family: 'Fraunces', serif;
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--cream);
  line-height: 1;
}

.score-vs {
  align-self: center;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--cream);
  opacity: .45;
  font-size: .9rem;
  padding: 0 .1rem;
}

.game-status {
  font-size: .8rem;
  text-align: center;
  opacity: .6;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 1rem;
  color: var(--cream);
}

/* Afgerond-banner */
.winner-banner {
  background: var(--amber);
  color: #fff;
  font-family: 'Fraunces', serif;
  font-weight: 900;
  text-align: center;
  padding: .85rem;
  border-radius: 10px;
  margin-bottom: 1.2rem;
  font-size: 1.05rem;
}

/* Invoerkaart */
.entry-card {
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1rem 1.2rem;
  margin-bottom: 1.2rem;
}

.entry-card h3 {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: 1rem;
  color: var(--wine);
  margin-bottom: .9rem;
}

.entry-cols {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  margin-bottom: .9rem;
}

.entry-col { flex: 1; min-width: 0; }

.entry-col-sub {
  font-size: .72rem;
  color: var(--ink);
  opacity: .6;
  text-align: center;
  margin: -.3rem 0 .45rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

.entry-col-sep {
  align-self: center;
  margin-top: 1.4rem;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  color: var(--amber);
  font-size: 1rem;
  padding: 0 .1rem;
}

.entry-col-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  opacity: .65;
  margin-bottom: .45rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-field { margin-bottom: .55rem; }

.mini-label {
  display: block;
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  opacity: .55;
  margin-bottom: .2rem;
}

/* Automatisch berekende waarde */
.auto-value {
  width: 100%;
  font-family: 'Spectral', serif;
  font-size: 1.05rem;
  font-weight: 600;
  padding: .6rem .4rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #e8e0ca;
  color: var(--ink);
  text-align: center;
  min-height: 2.5rem;
  box-sizing: border-box;
}

.auto-value.auto-empty { opacity: .4; font-style: italic; }

/* Nat / Pit opties */
.option-row {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
  margin-bottom: .65rem;
}

.option-row-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  opacity: .55;
  flex-shrink: 0;
  min-width: 2.2rem;
}

.option-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .3rem .6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #faf6ea;
  cursor: pointer;
  font-size: .8rem;
  font-family: 'Spectral', serif;
  transition: border-color .12s, background .12s;
  user-select: none;
}

.option-chip input {
  width: auto;
  accent-color: var(--wine);
  margin: 0;
  cursor: pointer;
  padding: 0;
}

.option-chip:has(input:checked) {
  border-color: var(--wine);
  background: #f5e8ec;
  color: var(--wine);
  font-weight: 600;
}

/* Foutmelding in invoerkaart */
.round-error {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .82rem;
  color: var(--wine);
  background: #f5e0e4;
  border-radius: 6px;
  padding: .35rem .55rem;
  margin-top: .75rem;
}

.round-error::before { content: "⚠"; flex-shrink: 0; }

/* Sectielabel boven recente rondes */
.section-label {
  font-family: 'Fraunces', serif;
  font-weight: 900;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .55;
  margin-bottom: .65rem;
  margin-top: .3rem;
  color: var(--cream);
}

/* Recente rondes */
.recent-round {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .2rem;
  border-bottom: 1px dashed rgba(255,255,255,.2);
  color: var(--cream);
}
.recent-round:last-child { border-bottom: none; }

.rr-num { font-size: .82rem; opacity: .6; flex-shrink: 0; min-width: 5rem; }

.rr-scores {
  flex: 1;
  font-size: .95rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
}

.rr-badge {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .1rem .4rem;
  border-radius: 999px;
}

.nat-badge { background: #f5e0e4; color: var(--wine); }
.pit-badge { background: #fef3e0; color: #7a5200; }

/* ---- Scoring-modal: per-ronde tabel ---- */
.sc-rounds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  color: var(--cream);
}

/* Override globale thead/tbody stijlen voor deze tabel */
.sc-rounds-table thead th {
  font-family: 'Spectral', serif;
  font-weight: 600;
  font-size: .7rem;
  text-transform: none;
  letter-spacing: 0;
  padding: .2rem .3rem .3rem;
  border-bottom: 1px solid rgba(255,255,255,.18);
  text-align: right;
  color: var(--cream);
  opacity: .75;
}

.sc-th-sub {
  display: block;
  font-size: .62rem;
  font-weight: 400;
  font-style: italic;
  opacity: .65;
  margin-top: .1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sc-th-n { text-align: left !important; width: 2.8rem; }
.sc-th-team {
  text-align: center !important;
  font-family: 'Fraunces', serif !important;
  font-weight: 600 !important;
  font-size: .75rem !important;
  opacity: 1 !important;
  border-bottom: none !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sc-rounds-table .sc-subhead-row th {
  font-size: .65rem;
  opacity: .55;
  font-weight: 400;
  padding-top: .05rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sc-th-v { width: 2.6rem; }
.sc-th-r { width: 2.6rem; }
.sc-th-t { width: 3rem; }
.sc-rounds-table thead th:last-child { width: 1.8rem; border-bottom: none; }

.sc-rounds-table tbody td {
  padding: .32rem .3rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  text-align: right;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

.sc-td-n {
  text-align: left;
  font-size: .78rem;
  opacity: .7;
  white-space: nowrap;
}

.sc-td-r { opacity: .8; }

/* Gecombineerde totaal-kolom */
.sc-td-t { opacity: .4; }

/* Verticale scheidingslijn na Tot-kolom van team A */
.sc-rounds-table thead tr:first-child th:nth-child(2),
.sc-rounds-table .sc-subhead-row th:nth-child(4),
.sc-rounds-table tbody td:nth-child(4) {
  border-right: 1px solid rgba(255,255,255,.2);
}

/* Gecombineerd getal in subtotaal- en totaalrijen */
.sc-td-tot {
  opacity: 1;
  font-weight: 700;
  color: var(--amber-lt);
}

.sc-td-del {
  padding: 0;
  border-bottom: none !important;
  text-align: center;
}

/* Verwijder-knop in de tabel */
.sc-del-btn {
  color: rgba(255,255,255,.35) !important;
  font-size: .8rem;
  padding: .15rem .3rem;
}
.sc-del-btn:hover { color: var(--amber-lt) !important; }

/* Subtotaalrij */
.sc-sub-row td {
  font-weight: 600;
  border-top: 1px solid rgba(255,255,255,.2);
  border-bottom: 1px solid rgba(255,255,255,.06) !important;
  background: rgba(255,255,255,.05);
}

/* Totaalrij */
.sc-total-row td {
  font-weight: 700;
  border-top: 2px solid rgba(255,255,255,.3);
  border-bottom: 2px solid rgba(255,255,255,.18) !important;
  background: rgba(255,255,255,.1);
}

/* Label-cel in subtotaal- en totaalrij */
.sc-sum-lbl {
  font-family: 'Fraunces', serif;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  opacity: 1;
}

/* Kleine nat/pit-badges in de #-kolom */
.sc-np-badge {
  display: inline-block;
  font-size: .58rem;
  font-weight: 700;
  padding: .05rem .22rem;
  border-radius: 3px;
  margin-left: .2rem;
  vertical-align: middle;
  line-height: 1.5;
}
.sc-nat-badge { background: var(--wine); color: #fff; }
.sc-pit-badge { background: var(--amber); color: #fff; }

/* disabled inputs in scoring modal */
.scoring-modal input:disabled {
  background: #e2dbc8;
  opacity: .7;
  cursor: not-allowed;
}

/* ---- Responsief ---- */
@media (max-width: 380px) {
  header h1 { font-size: 1.6rem; }
  .header-logo { width: 96px; }
  .tab { font-size: .76rem; }
  .team-line { font-size: .86rem; }
  .code-value { font-size: 1.3rem; }
}
