/* Stijl: Zonan Late Show. Het spel als nachtelijke spelshow: een paarse zaal met spotlichtstralen,
   witte kaarten met dikke inkt en een harde schaduw, en koppen die geel oplichten. */
:root {
  --zaal: #2A1150;          /* achtergrond van de zaal */
  --zaal-licht: #4B1F86;    /* het spotlicht bovenin */
  --inkt: #12062A;          /* randen, schaduwen en tekst op wit */
  --wit: #FFFFFF;
  --geel: #FFE14D;          /* spotgeel: knoppen, koppen, munt */
  --roze: #FF4FA3;          /* showroze: schaduw onder koppen */
  --mint: #3EE6A8;
  --oranje: #FF8A1F;        /* Kans */
  --blauw: #3BB4F2;         /* Algemeen Fonds */
  --rood: #F2384A;
  --paars: #B44BFF;         /* drankspellen */
  --groen: #1F9D57;
  --bord: #EFE8FF;          /* lichte tint binnen witte vlakken */
  /* Tekst op de zaal. Binnen witte vlakken worden deze twee overschreven, zie "Papier" hieronder. */
  --grijs: rgba(255, 255, 255, .72);
  --lijn: rgba(255, 255, 255, .2);
  --grijs-papier: rgba(18, 6, 42, .62);
  --lijn-papier: rgba(18, 6, 42, .14);
  --kop: Nunito, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --show: "Titan One", "Arial Black", Impact, sans-serif;
  --cijfer: "Titan One", "Arial Black", Impact, sans-serif;
  --schaduw: 0 5px 0 var(--inkt);
  --vloeiend: cubic-bezier(.22, .9, .24, 1);
  --veer: cubic-bezier(.3, 1.5, .5, 1);
}
* { box-sizing: border-box; }
html { background: var(--zaal); }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--wit);
  background: transparent;   /* de zaal zelf staat op html en body::after */
  font-family: var(--kop);
  font-weight: 700;
  font-size: 17px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* Het spotlicht met stralen. Vast in beeld, ook op telefoons die background-attachment negeren. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    repeating-conic-gradient(from 0deg at 50% -12%, rgba(255, 255, 255, .055) 0 6deg, transparent 6deg 14deg),
    radial-gradient(130% 70% at 50% 0%, var(--zaal-licht) 0%, var(--zaal) 62%);
}
/* De rand van het podium: een rij lampjes */
body::before {
  content: "";
  position: fixed;
  inset: 7px;
  border: 4px dotted var(--geel);
  border-radius: 18px;
  opacity: .55;
  pointer-events: none;
  z-index: 5;
}
h1, h2, p, ul, ol, dl, dd { margin: 0; }
h1, h2 { font-family: var(--show); font-weight: 400; letter-spacing: .01em; }
ul, ol { padding: 0; list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--geel); outline-offset: 3px; }

/* Papier: witte vlakken op de zaal. Daarbinnen is de tekst donker. */
.blok, .blad, .chat, .tegel, .feiten, .rang, .toegang, .beurt, .mijnvak, .akte, .kaart, .tabs,
.laatstefoto, .tvfoto, .tvzij .lijst, .tvzij .log, .terug, .icoon, .filter, .middenkaart, .veld input, .veld select, .knop.stil {
  color: var(--inkt);
  --grijs: var(--grijs-papier);
  --lijn: var(--lijn-papier);
}

#app {
  max-width: 560px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px calc(28px + env(safe-area-inset-bottom, 0px));
}
.scherm { flex: 1; display: flex; flex-direction: column; gap: 18px; }
.laden { text-align: center; padding: 38vh 12px 0; color: var(--grijs); }

/* ---------- Kop van elk scherm ---------- */
/* Bovenin terug en je chip, de titel groot op een eigen regel eronder: zo past ook "Spelmeester" op een smalle telefoon. */
.balk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-height: 46px; }
.balk .chip { margin-left: auto; }
.balk h1 {
  order: 3; flex: 1 0 100%; min-width: 0; font-size: clamp(1.7rem, 9vw, 2.2rem); line-height: 1.05; padding: 6px 0 4px;
  overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto;
  color: var(--geel); text-shadow: 0 3px 0 var(--roze), 0 6px 0 var(--inkt);
  rotate: -2deg; transform-origin: left center;
}
.terug {
  width: 44px; height: 44px; flex: none;
  border: 3px solid var(--inkt); border-radius: 50%; background: var(--wit);
  box-shadow: 0 4px 0 var(--inkt);
  font-size: 1.7rem; font-weight: 900; line-height: 1; padding: 0 2px 4px 0;
}
.terug:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--inkt); }
.chip {
  display: flex; align-items: center; gap: 8px; flex: none; max-width: 52%;
  padding: 4px 14px 4px 4px;
  border: 3px solid var(--wit); border-radius: 999px; background: var(--inkt); color: var(--wit);
  font-weight: 800; font-size: .92rem;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-top: 1px; }
.mededeling { color: var(--grijs); font-weight: 700; }

/* ---------- Geld ---------- */
.munt { font-family: var(--cijfer); font-weight: 400; font-size: 1.05em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.munt::before {
  content: "Z";
  display: inline-grid; place-items: center;
  width: 1.3em; height: 1.3em; margin-right: .3em;
  border-radius: 50%; background: var(--geel); color: var(--inkt); border: .12em solid var(--inkt);
  font-family: var(--show); font-size: .66em; line-height: 1; padding-top: .06em;
  vertical-align: .14em;
}

/* Slokken in de drankmodus: zelfde letter als geld, met een biertje ervoor */
.slok { font-family: var(--cijfer); font-weight: 400; font-size: 1.05em; white-space: nowrap; }
.slok::before { content: "🍺"; margin-right: .25em; }

/* ---------- Pion (avatar) ---------- */
.av {
  position: relative; flex: none;
  display: inline-grid; place-items: center;
  border-radius: 50%; border: 2.5px solid var(--wit);
  background-size: cover; background-position: center;
  color: var(--wit); font-weight: 900; text-transform: uppercase; line-height: 1;
}
.av-s { width: 34px; height: 34px; font-size: .78rem; }
.av-m { width: 50px; height: 50px; font-size: 1.05rem; }
.av-l { width: 132px; height: 132px; font-size: 2.6rem; border-width: 5px; box-shadow: 0 7px 0 var(--inkt); }
.av.aan::after {
  content: ""; position: absolute; right: -2px; bottom: -2px;
  width: 28%; height: 28%; min-width: 11px; min-height: 11px;
  border-radius: 50%; background: var(--mint); border: 2px solid var(--inkt);
}

/* ---------- Knoppen en velden ---------- */
.knop {
  appearance: none;
  border: 3px solid var(--inkt); border-radius: 999px;
  background: var(--geel); color: var(--inkt);
  font-family: var(--show); font-weight: 400; font-size: 1.08rem; letter-spacing: .02em;
  padding: 12px 22px 10px;
  box-shadow: var(--schaduw);
  transition: transform .12s var(--vloeiend), box-shadow .12s var(--vloeiend);
}
.knop:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--inkt); }
.knop.stil { background: var(--wit); }
.knop.rood { background: var(--rood); color: var(--wit); }
.knop.vol { width: 100%; }
.knoppen { display: flex; flex-wrap: wrap; gap: 12px 10px; }
.knoppen:empty { display: none; }
.knoppen .knop { flex: 1 1 auto; }
.tekstknop {
  appearance: none; align-self: center; justify-self: center;
  background: none; border: 0; border-bottom: 3px solid currentColor;
  font-weight: 900; padding: 6px 0 1px; margin-top: 6px;
}
.icoon {
  width: 42px; height: 42px; flex: none;
  border: 3px solid var(--inkt); border-radius: 50%; background: var(--wit);
  box-shadow: 0 3px 0 var(--inkt);
  font-size: 1.4rem; line-height: 1; padding: 0 0 3px;
}
.icoon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--inkt); }
.veld { display: grid; gap: 6px; font-weight: 900; }
.veld input {
  width: 100%;
  border: 3px solid var(--inkt); border-radius: 14px; background: var(--wit);
  padding: 13px 14px 11px; font-weight: 700; font-size: 1.05rem;
}
.fout { color: var(--rood); font-weight: 900; min-height: 1.4em; }
.klein { color: var(--grijs); font-size: .92rem; text-align: center; }
.leeg { color: var(--grijs); padding: 10px 0; }

/* ---------- Inloggen ---------- */
.s-login { justify-content: center; }
.toegang {
  display: grid; gap: 16px;
  background: var(--wit); border: 4px solid var(--inkt); border-radius: 22px;
  box-shadow: 0 9px 0 var(--inkt);
  padding: 26px 22px 24px;
  rotate: -1deg;
}
.toegang h1 {
  font-size: clamp(2rem, 10vw, 2.7rem); line-height: 1;
  color: var(--geel); -webkit-text-stroke: 2px var(--inkt); paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--roze), 0 8px 0 var(--inkt);
  rotate: -3deg; padding-bottom: 6px;
}
.toegang form { display: grid; gap: 14px; }
.toegang { position: relative; z-index: 1; animation: opkomst .7s var(--veer) backwards .25s; }
@keyframes opkomst { from { transform: translateY(60px) scale(.85); opacity: 0; } }

/* Feestelijke deur: een lichtbord, een sticker en confetti achter de kaart */
.lichtbord {
  position: relative; z-index: 1; justify-self: center; align-self: center;
  margin-bottom: -6px; padding: 9px 22px 7px;
  background: var(--inkt); border-radius: 16px; rotate: 2deg;
  box-shadow: 0 0 0 4px var(--geel), 0 0 0 8px var(--inkt), 0 0 36px 6px rgba(255, 225, 77, .45);
  animation: zwaai 3s ease-in-out infinite alternate;
}
.lichtbord::before {   /* een rij lampjes rondom die achter elkaar aan lopen */
  content: ""; position: absolute; inset: -4px; border-radius: 18px; pointer-events: none;
  border: 4px dashed var(--wit); opacity: .9;
  mask: linear-gradient(90deg, #000 0 40%, transparent 40% 60%, #000 60%) 0 0 / 200% 100%;
  animation: lampjes 1.2s linear infinite;
}
.lichtbord span {
  display: block; font-family: var(--show); font-size: 1.15rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--roze); text-shadow: 0 0 8px var(--roze), 0 0 18px rgba(255, 79, 163, .7);
  animation: neon 2.4s steps(1) infinite;
}
@keyframes zwaai { from { rotate: 2deg; } to { rotate: -2deg; } }
@keyframes lampjes { to { mask-position: -200% 0; } }
@keyframes neon { 0%, 46%, 50%, 100% { opacity: 1; } 48% { opacity: .35; } }

.sticker {
  position: absolute; right: -12px; top: -30px;
  display: grid; place-items: center; width: 86px; height: 86px; border-radius: 50%;
  background: var(--roze); color: var(--wit); border: 4px solid var(--inkt); box-shadow: 0 5px 0 var(--inkt);
  font-family: var(--show); font-size: .6rem; line-height: 1.1; padding: 0 6px; text-align: center; letter-spacing: .02em;
  rotate: 14deg; animation: stempel .5s var(--veer) backwards .8s, wiebel 2.8s ease-in-out infinite 1.3s;
}
@keyframes stempel { from { transform: scale(2.4); opacity: 0; } }
@keyframes wiebel { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.deurgrap { font-size: .9rem; color: var(--grijs); text-align: center; font-style: italic; }
.deurgrap::before { content: "🎤 "; font-style: normal; }

.confetti { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.confetti i {
  position: absolute; top: -20px; left: var(--x); width: 10px; height: 16px;
  background: var(--k); border: 2px solid var(--inkt); border-radius: var(--r, 3px);
  animation: dwarrel var(--v) linear infinite var(--d);
}
@keyframes dwarrel {
  0% { transform: translate(0, 0) rotate(0); }
  50% { transform: translate(24px, 55vh) rotate(260deg); }
  100% { transform: translate(-12px, 110vh) rotate(540deg); }
}

/* ---------- Wachtkamer ---------- */
.spelersrij { display: flex; gap: 14px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; }
.spelersrij::-webkit-scrollbar { display: none; }
.pion { display: grid; justify-items: center; gap: 5px; flex: none; width: 64px; }
.pion .av { animation: binnen .5s var(--veer) backwards; }
.pion span:last-child { font-size: .8rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes binnen { from { transform: scale(.3) rotate(-20deg); } }

/* ---------- Chat ---------- */
.chat {
  flex: 1; min-height: 300px;
  display: flex; flex-direction: column;
  background: var(--wit); border: 4px solid var(--inkt); border-radius: 20px; overflow: hidden;
  box-shadow: 0 7px 0 var(--inkt);
}
.chatlijst { flex: 1; min-height: 0; max-height: 58dvh; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.s-chat .chatlijst { max-height: none; }
.bericht { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.bericht .av { border-color: var(--inkt); }
.bericht.eigen { align-self: flex-end; }
.ballon { background: var(--bord); border-radius: 16px 16px 16px 4px; padding: 9px 12px 7px; overflow-wrap: anywhere; }
.ballon b { display: block; font-size: .78rem; font-weight: 900; }
.eigen .ballon { background: var(--inkt); color: var(--wit); border-radius: 16px 16px 4px 16px; }
.bericht.systeem { align-self: center; max-width: 100%; text-align: center; font-size: .85rem; color: var(--grijs); }
.chatform { display: flex; gap: 8px; padding: 10px; border-top: 3px solid var(--inkt); }
.chatform input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 6px 5px; font-size: 1.02rem; }
.chatform input:focus { outline: none; }
.chatform .knop { padding: 9px 18px 7px; box-shadow: 0 3px 0 var(--inkt); }

/* ---------- Menu: tegels als eigendomsbewijzen ---------- */
.beurt {
  display: flex; align-items: center; gap: 10px;
  background: var(--wit); border: 3px solid var(--inkt); border-radius: 999px;
  box-shadow: 0 4px 0 var(--inkt);
  padding: 5px 16px 5px 5px; font-weight: 900;
}
.beurt .av { border-color: var(--inkt); }
.beurt > span:not(.av) { flex: 1; padding-top: 1px; }
.beurt > span:only-child { padding: 9px 0 6px 12px; }
.beurt em { font-style: normal; font-weight: 700; color: var(--grijs); padding-top: 1px; white-space: nowrap; }
.tegels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.tegel {
  appearance: none; text-align: left;
  display: grid; align-content: end; gap: 3px; min-height: 124px;
  background: var(--wit);
  border: 3px solid var(--inkt); border-top: 24px solid var(--band, var(--inkt)); border-radius: 12px;
  padding: 14px 14px 12px;
  box-shadow: 0 6px 0 var(--inkt);
  transition: transform .12s var(--vloeiend), box-shadow .12s var(--vloeiend);
}
.tegel:nth-child(4n + 1), .tegel:nth-child(4n + 4) { rotate: -1.2deg; }
.tegel:nth-child(4n + 2), .tegel:nth-child(4n + 3) { rotate: 1deg; }
.tegel:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--inkt); }
.tegel b { font-family: var(--show); font-weight: 400; font-size: clamp(.95rem, 4.6vw, 1.2rem); line-height: 1.1; overflow-wrap: anywhere; }
.tegel small { font-size: .82rem; color: var(--grijs); }
.tegel:disabled { cursor: default; box-shadow: none; rotate: none; background: rgba(255, 255, 255, .55); border-color: rgba(18, 6, 42, .35); border-top-color: color-mix(in srgb, var(--band) 45%, var(--zaal)); }
.tegel:disabled b { opacity: .55; }

/* ---------- Blokken en lijsten (spelmeester, bank, profiel) ---------- */
.blok { display: grid; gap: 12px; background: var(--wit); border: 3px solid var(--inkt); border-radius: 18px; padding: 18px 16px 16px; box-shadow: 0 6px 0 var(--inkt); }
.blok + .blok { margin-top: 18px; }
.blok h2 { font-size: 1.25rem; }
.blok > p { color: var(--grijs); }
.blok.gevaar { border-color: var(--rood); box-shadow: 0 6px 0 var(--rood); }
.blok .av, .blad .av, .rang .av, .feiten .av, .tvzij .av { border-color: var(--inkt); }
.lijst { display: grid; }
.rij { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 2px solid var(--lijn); }
.lijst > li:first-child, .lijst > li:first-child .rij, .blad > .rij { border-top: 0; }
.wie { flex: 1; min-width: 0; display: grid; }
.wie b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 900; }
.wie small { color: var(--grijs); font-size: .85rem; }
.knoprij { width: 100%; appearance: none; background: none; border-width: 2px 0 0; border-style: solid; border-color: var(--lijn); text-align: left; }
.schakel { display: flex; align-items: center; gap: 6px; font-size: .8rem; flex: none; }
.schakel input { width: 22px; height: 22px; accent-color: var(--inkt); margin: 0; }
.rang { background: var(--wit); border: 3px solid var(--inkt); border-radius: 18px; padding: 6px 16px; counter-reset: plek; box-shadow: 0 6px 0 var(--inkt); }
.rang .rij::before { counter-increment: plek; content: counter(plek); font-family: var(--cijfer); font-size: 1.3rem; width: 1.2em; text-align: center; }
.rang li:first-child .rij::before { color: var(--roze); font-size: 1.6rem; }
.log { display: grid; }
.log li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 2px solid var(--lijn); font-size: .93rem; }
.log li:first-child { border-top: 0; }
.log b { font-family: var(--cijfer); font-weight: 400; white-space: nowrap; }
.min { color: var(--rood); }
.plus { color: var(--groen); }

.profielkop { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 8px 0 4px; }
.profielkop h2 { font-size: 1.8rem; color: var(--geel); text-shadow: 0 3px 0 var(--roze), 0 6px 0 var(--inkt); }
.feiten { background: var(--wit); border: 3px solid var(--inkt); border-radius: 18px; padding: 4px 16px; margin: 18px 0 16px; box-shadow: 0 6px 0 var(--inkt); }
.feiten div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 0 9px; border-top: 2px solid var(--lijn); }
.feiten div:first-child { border-top: 0; }
.feiten dt { color: var(--grijs); }
.feiten dd { font-weight: 900; text-align: right; }
#profiel { display: grid; }

/* ---------- Vensters ---------- */
.venster {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(18, 6, 42, .74);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  animation: doek .25s ease-out;
}
@keyframes doek { from { background-color: transparent; } }
/* Elk moment zijn eigen kleur: de zaal kleurt mee met wat er gebeurt. */
.venster:has(.soort-kans), .venster:has(.soort-fonds), .venster:has(.radblad), .venster:has(.potblad), .venster:has(.slotblad), .venster:has(.luid), .venster:has(.drankblad) {
  background:
    repeating-conic-gradient(from 0deg at 50% 38%, rgba(255, 255, 255, .1) 0 7deg, transparent 7deg 15deg),
    radial-gradient(circle at 50% 38%, var(--moment) 0%, color-mix(in srgb, var(--moment) 40%, var(--inkt)) 48%, rgba(18, 6, 42, .94) 85%);
}
.venster:has(.soort-kans) { --moment: var(--oranje); }
.venster:has(.soort-fonds) { --moment: var(--blauw); }
.venster:has(.radblad) { --moment: var(--geel); }
.venster:has(.potblad) { --moment: var(--mint); }
.venster:has(.slotblad) { --moment: var(--roze); }
.venster:has(.luid) { --moment: var(--rood); }
.venster:has(.drankblad) { --moment: var(--paars); }
.blad {
  width: min(100%, 480px); display: grid; gap: 14px;
  background: var(--wit); border: 4px solid var(--inkt); border-radius: 22px;
  box-shadow: 0 8px 0 var(--inkt);
  padding: 22px 18px 18px;
  animation: omhoog .42s var(--veer);
}
@keyframes omhoog { from { transform: translateY(40px) scale(.9) rotate(-2deg); opacity: 0; } }
.vraag { font-size: 1.12rem; font-weight: 900; }
.snel { display: flex; gap: 8px; }
.snel button {
  flex: 1; appearance: none; background: var(--bord); border: 3px solid var(--inkt); border-radius: 12px;
  font-family: var(--cijfer); font-size: 1.05rem; padding: 8px 0 7px; color: var(--inkt);
  box-shadow: 0 3px 0 var(--inkt);
}
.snel button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--inkt); }
@media (min-width: 620px) { .venster { align-items: center; } }

/* ---------- Pauze, melding, testmodus ---------- */
.pauze {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center; text-align: center;
  background: rgba(18, 6, 42, .9); color: var(--wit); padding: 32px;
}
.pauze[hidden] { display: none; }
.pauze h2 { font-size: 2.6rem; margin-bottom: 10px; color: var(--geel); text-shadow: 0 4px 0 var(--roze), 0 8px 0 var(--inkt); rotate: -3deg; }
.toast {
  position: fixed; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  transform: translate(-50%, 30px) scale(.8); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100vw - 48px); text-align: center;
  background: var(--geel); color: var(--inkt); font-weight: 900;
  border: 3px solid var(--inkt); border-radius: 999px; box-shadow: var(--schaduw);
  padding: 11px 20px 9px;
  transition: opacity .2s ease, transform .35s var(--veer);
}
.toast.zichtbaar { opacity: 1; transform: translate(-50%, 0) scale(1); }
.testmodus {
  position: fixed; left: 0; right: 0; top: 0; z-index: 6; margin: 0;
  background: var(--geel); color: var(--inkt); text-align: center; font-size: .78rem;
  padding: calc(5px + env(safe-area-inset-top, 0px)) 14px 3px;
}
body:has(.testmodus:not([hidden])) #app { padding-top: calc(46px + env(safe-area-inset-top, 0px)); }

@media (prefers-reduced-motion: reduce) {
  .knop, .tegel, .toast { transition: none; }
  .blad, .venster, .pion .av, .toegang, .lichtbord, .lichtbord::before, .lichtbord span, .sticker { animation: none; }
  .confetti { display: none; }
}
