:root {
  --bg: #0e1712;
  --panel: #15231b;
  --panel-2: #1b2d22;
  --line: #27402f;
  --text: #e8efe9;
  --muted: #93a89b;
  --accent: #ffd166;
  --accent-2: #06d6a0;
  --danger: #ef476f;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent-2); }
a.nolink { color: inherit; text-decoration: none; }
h1 { font-size: 24px; margin: 0 0 12px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 0 6px; }

.page { max-width: 920px; margin: 0 auto; padding: 24px 16px 64px; }
.narrow { max-width: 400px; }
.center { margin: 8vh auto 0; }
.brand { font-weight: 800; font-size: 24px; letter-spacing: .01em; margin-bottom: 16px; }
.brand span { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); font-weight: 600; }

header.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
header.bar .brand { margin: 0; }

.box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > input[type=text] { flex: 1 1 220px; }
.inline { display: inline-flex; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
label.check { display: inline-flex; align-items: center; gap: 4px; margin: 0; }

input[type=text], input[type=password], input[type=number] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a120d;
  color: var(--text);
  font: inherit;
}
input.short { width: 80px; flex: 0 0 80px; }
input:focus { outline: 2px solid var(--accent-2); outline-offset: 1px; }
input.copy { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; margin: 8px 0 16px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #1d1600;
  font: 600 14px/1.2 system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.wide { width: 100%; margin-top: 18px; padding: 11px; }
button.ghost, .btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
button.danger { color: var(--danger); }
button.small, .btn.small { padding: 6px 10px; font-size: 13px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tcard {
  background: linear-gradient(160deg, #1f4a33, #173726);
  border: 1px solid #2c5a40;
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tcard .tname { font-weight: 700; font-size: 17px; }

/* ---------------- Speeltafel ---------------- */

body.table-page {
  overflow: hidden;
  overscroll-behavior: none;
  height: 100vh;
  height: 100dvh;
}

#app { display: flex; width: 100vw; height: 100vh; height: 100dvh; }

#tablewrap { position: relative; flex: 0 0 80%; min-width: 0; overflow: hidden; }
#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  padding-top: max(8px, env(safe-area-inset-top));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar > a, #topbar > button { white-space: nowrap; flex-shrink: 0; }
#players { min-width: 0; }
#topbar .tname {
  font-weight: 700;
  background: rgba(8, 16, 11, .75);
  padding: 5px 10px;
  border-radius: 8px;
  max-width: 30vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#topbar .spacer { flex: 1; pointer-events: none; }
#topbar button.ghost, #topbar .btn { background: rgba(8, 16, 11, .75); border-color: var(--line); color: var(--text); }

#players { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(8, 16, 11, .8);
  border: 2px solid var(--c, #888);
  white-space: nowrap;
}
.chip.off { opacity: .5; border-style: dashed; }
.c0 { --c: #ef476f; } .c1 { --c: #4cc9f0; } .c2 { --c: #ffd166; } .c3 { --c: #b388ff; }
.c4 { --c: #fb8500; } .c5 { --c: #06d6a0; } .c6 { --c: #f15bb5; } .c7 { --c: #e9ecef; }

#zoomctl { position: absolute; right: 8px; top: 56px; display: flex; flex-direction: column; gap: 6px; }
#zoomctl button {
  width: 42px; height: 42px; padding: 0;
  font-size: 20px;
  background: rgba(8, 16, 11, .85);
  color: var(--text);
  border: 1px solid var(--line);
}
#zoomctl button.accent { background: var(--accent); color: #1d1600; font-size: 24px; }

/* ---------- Spellenwinkel ---------- */
.shopbtn {
  background: var(--accent);
  color: #1d1600;
  font-weight: 800;
  padding: 8px 14px;
  box-shadow: 0 4px 14px rgba(255, 209, 102, .35);
}
#shop {
  position: absolute;
  right: 8px;
  top: 56px;
  bottom: 132px;
  width: 360px;
  max-width: calc(100% - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(13, 24, 17, .97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
  z-index: 4;
  transition: opacity .15s;
}
#shop.dragging { opacity: .15; pointer-events: none; }
.shop-head {
  position: sticky;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  align-items: center;
  padding: 12px 0 8px;
  background: rgba(13, 24, 17, .98);
  z-index: 1;
}
.shop-head strong { font-size: 16px; }
.shop-head .small { grid-column: 1; grid-row: 2; }
.shop-head button { grid-column: 2; grid-row: 1 / span 2; }
.shelf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 8px;
  background: linear-gradient(180deg, #1f3a2a, #172b20);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  cursor: grab;
  touch-action: pan-y;
  text-align: center;
}
.item:hover { border-color: var(--accent-2); filter: none; transform: translateY(-1px); }
.item.basis { grid-column: span 3; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 8px 14px; border-color: var(--accent); background: linear-gradient(120deg, #3a3214, #1f2a17); }
.item.basis .nm { font-size: 15px; }
.item.basis > span { text-align: left; }
.item .pv { width: 64px; height: 64px; pointer-events: none; }
.item .nm { font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.item .ds { font-size: 11px; color: var(--muted); font-weight: 400; line-height: 1.25; }
.item .ds:empty { display: none; }
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  pointer-events: none;
  background: var(--accent);
  color: #1d1600;
  font-weight: 800;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .45);
}

#toolbar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 132px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: calc(100% - 16px);
  background: rgba(10, 18, 13, .94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
#toolbar button { background: var(--panel-2); color: var(--text); border-color: var(--line); padding: 7px 10px; font-size: 13px; }
#toolbar .tb-title { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--accent); white-space: nowrap; }

#log {
  position: absolute;
  left: 8px;
  bottom: 132px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  max-width: 40%;
}
.logline {
  background: rgba(0, 0, 0, .6);
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 12.5px;
  animation: fade 12s forwards;
}
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .5);
  font-weight: 700;
  font-size: 16px;
  z-index: 5;
}

#video {
  flex: 1 1 20%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #09110c;
  border-left: 1px solid var(--line);
}
#tiles { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; }
.tile { position: relative; flex: 0 0 auto; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: #000; border: 1px solid var(--line); }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile.me video { transform: scaleX(-1); }
.tile .name {
  position: absolute; left: 6px; bottom: 6px;
  font-size: 12px; font-weight: 600;
  background: rgba(0, 0, 0, .6);
  padding: 2px 7px;
  border-radius: 6px;
}
#mediactl { display: flex; gap: 6px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
#mediactl button { flex: 1; background: var(--panel-2); color: var(--text); border-color: var(--line); }
#mediactl button.media { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; font-weight: 600; min-width: 0; }
#mediactl .icon { width: 32px; height: 25px; display: block; }
#mediactl .icon .slash { display: none; }
#mediactl button.off { background: #3b1620; border-color: #6b2333; color: #ffb3c1; }
#mediactl button.off .icon .slash { display: inline; }
#mediactl button.on { background: #0f3d34; border-color: var(--accent-2); color: var(--accent-2); }
#mediactl button[data-act=sound] { flex-basis: 100%; background: var(--accent); color: #1d1600; font-size: 14px; }

/* Telefoon staand: video als smalle strook bovenaan, tafel eronder. */
@media (max-width: 900px) and (orientation: portrait) {
  #app { flex-direction: column-reverse; }
  #tablewrap { flex: 1 1 auto; }
  #video { flex: 0 0 auto; flex-direction: row; border-left: 0; border-bottom: 1px solid var(--line); }
  #tiles { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 6px; }
  .tile { height: 84px; }
  #mediactl { flex-direction: column; flex-wrap: nowrap; border-top: 0; border-left: 1px solid var(--line); padding: 6px; }
  #mediactl button.media { padding: 3px 6px; }
  #mediactl button.media span { display: none; }
  #mediactl .icon { width: 26px; height: 20px; }
  #shop { top: 52px; bottom: 128px; width: auto; left: 8px; }
  .shelf { grid-template-columns: repeat(3, 1fr); }
  #topbar .tname { display: none; }
  #log { max-width: 60%; }
}

/* Telefoon liggend: smallere videokolom. */
@media (max-height: 500px) and (orientation: landscape) {
  #tablewrap { flex-basis: 78%; }
  .tile .name { display: none; }
}

/* ---------- Beheer ---------- */
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 14px; align-items: end; }
.grid-form label { margin: 6px 0 0; }
.grid-form label input, .grid-form label select { margin-top: 4px; }
.grid-form > div { padding-top: 8px; }
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0a120d;
  color: var(--text);
  font: inherit;
}
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.tag.admin { color: #1d1600; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.box.notice { border-color: var(--accent-2); color: var(--accent-2); padding: 12px 16px; }
.box.danger-zone { border-color: #6b2333; }
td.actions a.btn { text-decoration: none; }

/* ---------- Spelregels ---------- */
.shopbtn { font-size: 20px; padding: 6px 12px; line-height: 1; }
#rules {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .55);
  padding: 16px;
}
.rules-card {
  width: min(620px, 100%);
  max-height: calc(100% - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fdfbf3;
  color: #2a2a22;
  border-radius: 16px;
  padding: 0 22px 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .5);
}
.rules-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 10px;
  background: #fdfbf3;
  border-bottom: 2px solid #e9dfbd;
}
.rules-head h2 { margin: 0; font: 800 20px Georgia, serif; color: #1d3b2a; }
.rules-head button { color: #1d3b2a; border-color: #d9d0b2; background: transparent; }
#rules-body h3 { color: #7a5a1e; margin: 16px 0 6px; }
#rules-body ul { margin: 0; padding-left: 20px; }
#rules-body li { margin: 4px 0; line-height: 1.5; font-size: 14.5px; }

/* ---------- Account / 2FA ---------- */
.narrow-box { max-width: 520px; }
.steps { padding-left: 20px; line-height: 1.6; }
.qr { display: flex; justify-content: center; margin: 14px 0 6px; }
.qr svg { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
.center-text { text-align: center; }
code.key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; color: var(--text); }
ul.codes { columns: 2; list-style: none; padding: 12px 16px; background: #0a120d; border: 1px solid var(--line); border-radius: 10px; }
ul.codes li { padding: 3px 0; }
ul.codes code { font: 600 15px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .05em; }

/* ---------- Rollen en meldingen ---------- */
.tag.gm { color: #062a22; background: var(--accent-2); border-color: var(--accent-2); font-weight: 700; }
.box.warn { border-color: var(--accent); background: #2b2612; color: #ffe8a8; padding: 14px 16px; }
