:root {
  --ink: #2b2523;
  --ink-soft: #4a403b;
  --paper: #f6e9cf;
  --paper-2: #ead8b4;
  --paper-3: #d9c294;
  --liberal: #6aa7c4;
  --liberal-dark: #2e5d74;
  --fascist: #e2603c;
  --fascist-dark: #8e2d20;
  --ok: #4f8a4a;
  --radius: 10px;
  --title: 'Oswald', 'Arial Narrow', sans-serif;
  --type: 'Special Elite', 'Courier New', monospace;
  --fraktur: 'UnifrakturMaguntia', 'Old English Text MT', serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--ink);
  background-image:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 14px),
    radial-gradient(ellipse at top, rgba(226, 96, 60, .14), transparent 60%);
  color: var(--paper);
  font-family: var(--type);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

h1, h2, h3 { font-family: var(--title); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 .5em; line-height: 1.1; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--liberal); }
.muted { opacity: .7; }
.small { font-size: .85rem; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lang-select { display: inline-block; margin: 0; }
.lang-select select { width: auto; min-height: 0; padding: 6px 28px 6px 10px; font-size: .85rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* Titel in de stijl van het spel */
.logo { text-align: center; margin: 12px 0 24px; }
.logo-img { display: block; height: auto; border-radius: var(--radius); box-shadow: 0 6px 18px rgba(0, 0, 0, .45); }
.logo .logo-img { width: 100%; }
.logo .sub { font-family: var(--type); letter-spacing: .3em; text-transform: uppercase; font-size: .8rem; opacity: .75; margin-top: 8px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 16px; }
.topbar .brand { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.topbar .logo-top { width: 120px; max-width: 100%; border-radius: 4px; box-shadow: 0 3px 8px rgba(0, 0, 0, .4); }
.topbar .code { font-family: var(--title); font-size: 1.4rem; letter-spacing: .2em; line-height: 1; }
.topbar .who { font-size: .85rem; text-align: right; opacity: .85; }

/* Papieren kaart */
.card {
  color-scheme: light;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 2px 0 var(--paper-3), 0 8px 20px rgba(0, 0, 0, .35);
  position: relative;
}
.card + .card { margin-top: 16px; }
.card.liberal { background: var(--liberal); }
.card.fascist { background: var(--fascist); }
.card h2 { border-bottom: 2px solid currentColor; padding-bottom: 6px; }

/* Knoppen */
button, .btn {
  font-family: var(--title);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 1rem;
  font-weight: 600;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 48px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform .08s ease, filter .15s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--fascist); border-color: var(--fascist-dark); color: #fff; box-shadow: 0 3px 0 var(--fascist-dark); }
button.blue { background: var(--liberal-dark); border-color: #1e3f50; color: #fff; box-shadow: 0 3px 0 #1e3f50; }
button.ghost { background: transparent; color: inherit; border-color: currentColor; }
button.small { min-height: 34px; padding: 4px 10px; font-size: .8rem; width: auto; }
button.link { background: none; border: none; color: inherit; text-decoration: underline; min-height: 0; padding: 4px; width: auto; text-transform: none; font-family: var(--type); letter-spacing: 0; }

/* Formulieren */
label { display: block; font-family: var(--title); text-transform: uppercase; letter-spacing: .06em; font-size: .85rem; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  font: inherit;
  font-size: 1.05rem;
  padding: 10px 12px;
  min-height: 46px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--ink);
}
input[type=text]:focus, input[type=password]:focus, select:focus { outline: 3px solid var(--liberal); outline-offset: 1px; }
input.code-input { text-transform: uppercase; letter-spacing: .4em; text-align: center; font-family: var(--title); font-size: 1.5rem; }
.field + .field { margin-top: 12px; }
.switch { display: flex; align-items: center; gap: 12px; font-family: var(--type); text-transform: none; letter-spacing: 0; font-size: 1rem; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--fascist); }
fieldset { border: 2px dashed var(--paper-3); border-radius: 8px; padding: 12px; margin: 12px 0 0; }
legend { font-family: var(--title); text-transform: uppercase; padding: 0 6px; letter-spacing: .06em; }
.grid3 { display: grid; grid-template-columns: 1fr; gap: 8px; }

/* Spelerslijst */
.players { list-style: none; padding: 0; margin: 0; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--paper-3); }
.players li:last-child { border-bottom: none; }
.players .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .dead .name { text-decoration: line-through; opacity: .55; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #9a8b77; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(79, 138, 74, .25); }
.tag { font-family: var(--title); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; padding: 2px 6px; border-radius: 4px; background: var(--ink); color: var(--paper); }
.tag.liberal { background: var(--liberal-dark); }
.tag.fascist, .tag.hitler { background: var(--fascist-dark); }
.tag.yes { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); }
.tag.no { background: var(--ink); }

.dist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.dist .pill { padding: 4px 10px; border-radius: 999px; font-family: var(--title); font-size: .8rem; color: #fff; }
.pill.liberal { background: var(--liberal-dark); }
.pill.fascist { background: var(--fascist-dark); }
.pill.hitler { background: #000; }

/* Stembriefjes zoals in het spel */
.ballots { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 8px 0; }
.ballot {
  aspect-ratio: 5 / 7;
  border-radius: 12px;
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-family: var(--fraktur);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: clamp(2rem, 11vw, 3.2rem);
  line-height: 1;
  text-align: center;
  word-break: break-word;
  position: relative;
  min-height: 0;
  box-shadow: 0 6px 0 rgba(0, 0, 0, .35);
}
.ballot::before { content: ''; position: absolute; inset: 7px; border: 2px solid currentColor; border-radius: 7px; opacity: .55; pointer-events: none; }
.ballot.yes { background: var(--paper); color: var(--ink); }
.ballot.no { background: var(--ink); color: var(--paper); border-color: var(--paper-3); }
.ballot.chosen { transform: translateY(-6px) rotate(-2deg); outline: 4px solid var(--fascist); outline-offset: 3px; }
.ballot.dim { opacity: .4; }
.ballot.mini { font-size: 1.6rem; aspect-ratio: auto; height: 90px; box-shadow: none; }

.progress { height: 10px; background: var(--paper-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--ink); }
.progress > div { height: 100%; background: var(--fascist); transition: width .3s ease; }

.result-big { display: flex; justify-content: center; align-items: baseline; gap: 14px; font-family: var(--fraktur); font-size: 2.4rem; }
.result-big b { font-family: var(--title); font-size: 2.8rem; }
.verdict { text-align: center; font-family: var(--title); text-transform: uppercase; letter-spacing: .1em; font-size: 1.2rem; padding: 6px; border-radius: 6px; }
.verdict.passed { background: var(--ok); color: #fff; }
.verdict.failed { background: var(--fascist-dark); color: #fff; }
.verdict.cancelled { background: var(--paper-3); }

.history { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.history li { padding: 4px 0; border-bottom: 1px dashed var(--paper-3); display: flex; justify-content: space-between; gap: 8px; }

/* Rolkaarten */
.role-card {
  border-radius: 14px;
  border: 4px solid var(--ink);
  padding: 22px 16px;
  text-align: center;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  position: relative;
}
.role-card::before { content: ''; position: absolute; inset: 8px; border: 2px solid rgba(255, 255, 255, .55); border-radius: 8px; pointer-events: none; }
.role-card.liberal { background: linear-gradient(160deg, var(--liberal), var(--liberal-dark)); }
.role-card.fascist { background: linear-gradient(160deg, var(--fascist), var(--fascist-dark)); }
.role-card.hitler { background: linear-gradient(160deg, #b8402a, #3a120d); }
.role-card svg { width: 96px; height: 96px; margin: 6px auto 10px; display: block; }
.role-card .role-name { font-family: var(--title); font-weight: 700; font-size: clamp(1.8rem, 9vw, 2.6rem); text-transform: uppercase; letter-spacing: .08em; line-height: 1; }
.role-card .role-sub { font-family: var(--type); margin-top: 6px; opacity: .9; }
.role-card .intel { margin-top: 16px; background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 10px; text-align: left; }
.role-card .intel b { font-family: var(--title); letter-spacing: .05em; }

/* Envelop: vasthouden om te bekijken */
.envelope {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  border-radius: 14px;
  background: var(--paper-2);
  border: 3px solid var(--ink);
  color: var(--ink);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.envelope::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--paper-3);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.envelope .seal {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--fascist-dark);
  color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fraktur);
  font-size: 2rem;
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, .2);
}
.envelope .hint { position: relative; font-family: var(--title); text-transform: uppercase; letter-spacing: .08em; }
.envelope.open { background: transparent; border-color: transparent; padding: 0; align-items: stretch; }
.envelope.open > * { width: 100%; }
.envelope.open::before { display: none; }

/* Overlay / modal */
#overlay:empty { display: none; }
#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(20, 16, 15, .92);
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px 24px;
  animation: fade .2s ease;
}
.modal { width: 100%; max-width: 480px; margin: auto 0; }
.modal .close { margin-top: 16px; }
.qr { background: var(--paper); border-radius: 12px; padding: 12px; }
.qr img { width: 100%; display: block; image-rendering: pixelated; }
.qr-code { font-family: var(--title); font-size: 2.6rem; letter-spacing: .3em; text-align: center; margin: 8px 0 0; }
.url { word-break: break-all; font-size: .8rem; text-align: center; opacity: .8; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(150%);
  background: var(--fascist-dark);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 20;
  transition: transform .25s ease;
  max-width: calc(100% - 32px);
  text-align: center;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.info { background: var(--liberal-dark); }

.banner {
  text-align: center;
  padding: 24px 16px;
  border-radius: 14px;
  border: 4px solid var(--ink);
  color: #fff;
}
.banner.liberal { background: linear-gradient(160deg, var(--liberal), var(--liberal-dark)); }
.banner.fascist { background: linear-gradient(160deg, var(--fascist), var(--fascist-dark)); }
.banner.none { background: var(--ink-soft); }
.banner .big { font-family: var(--title); font-weight: 700; font-size: 2rem; text-transform: uppercase; letter-spacing: .06em; }

.conn { position: fixed; top: 0; left: 0; right: 0; text-align: center; font-size: .8rem; padding: 4px; background: var(--fascist-dark); color: #fff; z-index: 30; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }
.pop { animation: pop .25s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (min-width: 420px) {
  .grid3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Speltype-keuze */
.types { display: grid; gap: 8px; }
.type-option { display: flex; gap: 10px; align-items: flex-start; text-transform: none; letter-spacing: 0; font-family: var(--type); font-size: .95rem; padding: 10px; border: 2px solid var(--paper-3); border-radius: 8px; cursor: pointer; margin: 0; }
.type-option:has(input:checked) { border-color: var(--fascist); background: #fff6e6; }
.type-option input { width: 20px; height: 20px; accent-color: var(--fascist); flex: none; margin-top: 2px; }
.type-option b { font-family: var(--title); text-transform: uppercase; letter-spacing: .05em; display: block; }
.type-option .small { display: block; }

/* Tafelvolgorde */
.players.order li { gap: 8px; }
.players.order .pos { font-family: var(--title); width: 22px; text-align: center; }
.handle { cursor: grab; touch-action: none; user-select: none; font-size: 1.2rem; padding: 4px 6px; border-radius: 6px; background: var(--paper-2); }
.players.order li.dragging { opacity: .5; }
.players.order li.drop-target { box-shadow: inset 0 3px 0 var(--fascist); }
.big-tap { min-height: 72px; font-size: 1.3rem; }

/* Wetskaarten */
.policy {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  border: 3px solid var(--ink);
  color: #fff;
  font-family: var(--title);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: .85rem;
  text-align: center;
  padding: 8px;
  position: relative;
}
.policy::before { content: ''; position: absolute; inset: 5px; border: 1.5px solid rgba(255, 255, 255, .6); border-radius: 6px; pointer-events: none; }
.policy svg { width: 55%; height: auto; }
.policy.liberal { background: linear-gradient(160deg, var(--liberal), var(--liberal-dark)); }
.policy.fascist { background: linear-gradient(160deg, var(--fascist), var(--fascist-dark)); }
.policy.mini { border-width: 2px; padding: 3px; font-size: 0; gap: 0; border-radius: 6px; }
.policy.mini::before { inset: 3px; border-radius: 3px; }
.policy.mini svg { width: 70%; }

.hand { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 10px; }
.hand-card { padding: 0; border: none; background: none; min-height: 0; display: block; box-shadow: none; transition: transform .12s ease; }
.hand-card.picked { transform: translateY(-8px); }
.hand-card.picked .policy { outline: 4px solid var(--ink); outline-offset: 2px; }
button.hand-card .policy::after { content: ''; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choices button { min-height: 44px; }

/* Bord */
.board .track + .track { margin-top: 12px; }
.board h3 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.board h3 small { font-family: var(--title); }
.slots { display: grid; gap: 6px; }


.slot {
  aspect-ratio: 5 / 7;
  border-radius: 6px;
  border: 2px dashed var(--paper-3);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .55rem;
  line-height: 1.1;
  text-align: center;
  padding: 2px;
  font-family: var(--title);
  text-transform: uppercase;
}
.track.liberal .slot { background: rgba(106, 167, 196, .15); }
.track.fascist .slot { background: rgba(226, 96, 60, .12); }
.slot em { font-style: normal; color: var(--fascist-dark); margin-top: 2px; }
.slot.filled { border: none; background: none; padding: 0; }
.slot.filled .policy { height: 100%; }
.board-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 12px; font-size: .85rem; align-items: center; }
.pip { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); margin-left: 3px; vertical-align: middle; }
.pip.on { background: var(--fascist); }

.tag.pres { background: var(--ink); }
.tag.chan { background: var(--fascist-dark); }
.tag.muted-tag { background: var(--paper-3); color: var(--ink); }
.log { list-style: none; padding: 0; margin: 8px 0 0; font-size: .85rem; }
.log li { padding: 4px 0; border-bottom: 1px dashed var(--paper-3); }
details summary { cursor: pointer; }
h2 small { font-size: .7em; text-transform: none; letter-spacing: 0; font-family: var(--type); }

/* Afteller van de bedenktijd */
.countdown { display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.countdown b { font-family: var(--title); font-size: 2.4rem; line-height: 1; min-width: 1.4em; text-align: center; color: var(--fascist); }
.countdown span { font-size: .85rem; }

/* Eigen stemkaart schermvullend (open stemming) */
.fullballot { position: fixed; inset: 0; width: auto; height: auto; aspect-ratio: auto; border-radius: 0; border: none; z-index: 15;
  flex-direction: column; font-size: clamp(5rem, 30vw, 14rem); box-shadow: none; }
.fullballot::before { inset: 16px; border-width: 4px; border-radius: 16px; }
.fullballot .hint { font-family: var(--title); font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; margin-top: 24px; opacity: .7; }
.track.fascist .slot.zone:not(.filled) { border-color: var(--fascist); }

/* Speelbord-modus (tablet / groot scherm) */
body.display-mode main { max-width: 1280px; }
body.display-mode { font-size: 18px; }
.display-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.display-head .code { font-family: var(--title); font-size: 2rem; letter-spacing: .25em; }
.display-head button { width: auto; }
.display-head .logo-display { width: 220px; max-width: 40%; border-radius: 6px; }
.display-grid { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
.display-grid > div > .card + .card { margin-top: 16px; }
@media (min-width: 900px) {
  .display-grid { grid-template-columns: 3fr 2fr; }
}
.display-mode .qr { max-width: 420px; margin: 0 auto; }
.display-mode .players li { padding: 10px 0; }
.big-line { font-size: 1.35rem; line-height: 1.35; }
.card.phase h2 { font-size: 1.6rem; }
.announce { font-size: 1.8rem; line-height: 1.4; padding: 32px 24px; }
.display-mode .countdown b { font-size: 3.4rem; }
