:root {
  --ink: #2B1810;
  --linen: #F5F5DC;
  --panel: rgba(245, 245, 220, 0.94);
  --accent: #8B5A2B;
  --accent-light: #C89B5C;
  --blue: #1A3A8F;
  --red: #C81E2B;
  --grey: #6B6B6B;
  --font-display: 'UnifrakturMaguntia', serif;
  --font-body: 'IM Fell English', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: var(--font-body); color: var(--ink); }
body { background: #4a3320; }
canvas#board { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hidden { display: none !important; }

.panel { position: fixed; background: var(--panel); border: 1px solid var(--accent-light); border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); backdrop-filter: blur(3px); }
.side { top: 12px; right: 12px; width: 272px; max-height: calc(100vh - 24px); padding: 14px 16px; overflow-y: auto; font-size: 15px; }
.logo-lockup-hud { display: block; width: 160px; max-width: 100%; height: auto; margin: 0 auto 10px; }
.muted { color: var(--grey); }
.small { font-size: 13px; margin-top: 3px; }

.score { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; margin-bottom: 4px; }
.score.active { background: rgba(26,58,143,.12); font-weight: 600; }
.score .dot { width: 12px; height: 12px; border-radius: 50%; }
.score .nm { flex: 1; font-family: var(--font-display); font-size: 19px; }

/* Spelernamen in kleine letters tonen: de sierlijke blackletter-hoofdletters zijn bij
   korte namen (2-3 tekens) slecht leesbaar; kleine letters lezen veel prettiger. */
.score .nm, #turn .pname, .result-head .nm, .local-label,
.lobby-player span, .lobby-name-input { text-transform: lowercase; }

/* AI-niveau tussen haakjes ("(Moeilijk)") niet in het sierlijke blackletter-lettertype
   en niet lowercase: dat las juist minder goed dan gewone platte tekst. */
.ai-lvl { font-family: var(--font-body); font-size: 13px; color: var(--grey); text-transform: none; }
.score .pts { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px; color: var(--blue); }
.score .mp { font-size: 14px; color: var(--grey); }

.controls { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
button { font: inherit; padding: 11px 14px; min-height: 44px; font-size: 15px; border: 1px solid var(--accent); background: #efe3c8; color: var(--ink); border-radius: 8px; cursor: pointer; touch-action: manipulation; }
button:hover { background: var(--accent-light); }
.btn-icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 2px; }

#turn { text-align: center; margin-bottom: 4px; }
#turn b { color: var(--blue); font-family: var(--font-display); font-weight: 400; font-size: 21px; }
#turn .display-accent { font-size: 21px; }
#deck { text-align: center; margin-bottom: 10px; font-size: 15px; }

.menurow { display: flex; gap: 6px; margin-top: 10px; }
.menurow button { flex: 1; padding: 8px 6px; font-size: 14px; }

.lighthouse-choice { text-align: left; border: 1px dashed var(--accent-light); border-radius: 8px; padding: 8px; margin: 10px 0; }
.lighthouse-choice p { margin: 0 0 6px; }
.lighthouse-choice button { text-align: left; font-size: 14px; }

.log { margin-top: 8px; font-size: 14px; color: var(--accent); max-height: 220px; overflow-y: scroll; border-top: 1px dashed var(--accent-light); padding-top: 8px; padding-right: 4px; scrollbar-width: thin; scrollbar-color: var(--accent-light) transparent; }
.log div { padding: 2px 0; border-bottom: 1px solid rgba(139,90,43,0.08); }
.log::-webkit-scrollbar { width: 7px; }
.log::-webkit-scrollbar-track { background: transparent; }
.log::-webkit-scrollbar-thumb { background: var(--accent-light); border-radius: 4px; }

.chat-block { margin-top: 10px; border-top: 1px dashed var(--accent-light); padding-top: 8px; }
.chat-log { max-height: 130px; overflow-y: auto; font-size: 12px; text-align: left; margin-bottom: 6px; scrollbar-width: thin; scrollbar-color: var(--accent-light) transparent; }
.chat-log .msg { padding: 3px 0; }
.chat-log .msg .who { font-weight: 600; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input { padding: 7px 10px; font-size: 13px; }
.chat-input-row button { flex-shrink: 0; padding: 7px 12px; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(40,30,20,.55); padding: 16px; }
#setup {
  background-image: linear-gradient(rgba(30,20,10,.35), rgba(30,20,10,.6)), url('../assets/brand/menu-background.jpg');
  background-size: cover;
  background-position: center;
}
.card { position: relative; background: #FBFAF3; border-radius: 16px; padding: clamp(22px, 5vw, 34px) clamp(20px, 6vw, 40px); width: 100%; max-width: 440px; text-align: center; box-shadow: 0 12px 48px rgba(0,0,0,.4); }
.logo-lockup { width: min(70vw, 340px); height: auto; margin: 0 0 6px; }
.lead { margin: 0 0 14px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; font-size: 13px; color: var(--accent); }
.playerbtns { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.playerbtns button { width: 56px; height: 56px; font-size: 20px; font-weight: 700; }

input[type="text"] { font: inherit; padding: 9px 12px; border: 1px solid var(--accent-light); background: #fff; color: var(--ink); border-radius: 8px; width: 100%; }
input[type="text"]:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
button.wide { width: 100%; margin-top: 8px; }
.coffee-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; margin-top: 8px; padding: 11px 14px; min-height: 44px; font-size: 15px;
  font: inherit; border: 1px solid var(--accent); border-radius: 8px; box-sizing: border-box;
  background: #efe3c8; color: var(--ink); text-decoration: none; cursor: pointer;
}
.coffee-btn:hover { background: var(--accent-light); }

.mp-divider { margin: 18px 0 10px; font-size: 12px; letter-spacing: .5px; text-transform: uppercase; color: var(--grey); text-align: center; }
#mpNameInput, #joinNameInput { margin-bottom: 8px; }

.setup-footer { margin-top: 22px; padding-top: 14px; border-top: 1px dashed var(--accent-light); text-align: center; }
.footer-link { display: inline-flex; align-items: center; gap: 7px; text-decoration: none; color: var(--accent); font-size: 12px; }
.footer-link:hover { color: var(--blue); }

/* Inhoudelijke tekstlinks (credits, disclaimers, privacy) in de neutrale huisstijl-bruin
   i.p.v. de standaard browser-blauw, die te fel afsteekt tegen het perkament. */
.rules-body a, .credits-list a, .version-badge a {
  color: var(--accent);
  text-decoration: underline;
}
.rules-body a:hover, .credits-list a:hover, .version-badge a:hover {
  color: var(--ink);
}

/* Taalschakelaar als nette segmented pill i.p.v. een platte tekstlink. */
.lang-switch {
  display: inline-flex; margin: 10px auto 0; gap: 0;
  border: 1px solid var(--accent-light); border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,0.4);
}
.lang-switch button {
  font: inherit; font-size: 12px; letter-spacing: .3px;
  padding: 5px 14px; min-height: 0; border: none; border-radius: 0;
  background: transparent; color: var(--accent); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.lang-switch button:hover { background: rgba(139,90,43,0.12); }
.lang-switch button.active { background: var(--accent); color: var(--linen); font-weight: 600; }
.lang-switch button.active:hover { background: var(--accent); }
/* Lokaal-spelen: deelnemerslijst met mens/AI en moeilijkheidskeuze. */
.local-players { margin: 8px 0; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.local-player { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: #fff; border: 1px solid #E8E4D5; border-radius: 8px; }
.local-player .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.local-label { font-family: var(--font-display); font-size: 16px; flex-shrink: 0; }
.ai-diff { display: inline-flex; margin-left: auto; border: 1px solid var(--accent-light); border-radius: 999px; overflow: hidden; }
.ai-diff button { font: inherit; font-size: 11px; padding: 4px 9px; min-height: 0; border: none; border-radius: 0; background: transparent; color: var(--accent); cursor: pointer; }
.ai-diff button.active { background: var(--accent); color: var(--linen); font-weight: 600; }
.local-remove { margin-left: auto; width: 30px; height: 30px; min-height: 30px; min-width: 30px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1; }
.ai-diff + .local-remove { margin-left: 6px; }
.local-add-row { display: flex; gap: 8px; margin-bottom: 8px; }
.local-add-row button { flex: 1; }
.local-add-row button:disabled { opacity: .45; cursor: not-allowed; }

.footer-logo { height: 16px; width: auto; opacity: .85; }
.version-badge { margin: 8px 0 0; font-size: 11px; color: var(--grey); }
.linklike { display: inline; padding: 0; margin: 0; min-height: 0; border: none; background: none; color: var(--grey); text-decoration: underline; font-size: 11px; cursor: pointer; }
.linklike:hover { color: var(--blue); background: none; }
.credits-disclaimer { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--accent-light); line-height: 1.5; }

.sharelink-row { display: flex; gap: 8px; margin: 10px 0 16px; }
.sharelink-row input { text-align: center; font-size: 13px; }
.sharelink-row button { flex-shrink: 0; }

.lobby-players { margin: 14px 0; text-align: left; }
.lobby-player { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #fff; border: 1px solid #E8E4D5; border-radius: 8px; margin-bottom: 6px; font-family: var(--font-display); font-size: 16px; }
.lobby-player .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.lobby-name-input { flex: 1; padding: 4px 8px; font-size: 15px; font-family: var(--font-display); }

.popup-card { position: relative; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; text-align: left; }
.closeX { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; min-height: 40px; min-width: 40px; padding: 0; line-height: 1; font-size: 20px; border-radius: 50%; }
.setup-settings-btn { position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; min-height: 40px; min-width: 40px; padding: 0; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.setup-settings-btn .btn-icon { width: 18px; height: 18px; margin: 0; }
.popup-title { font-family: var(--font-display); font-weight: 400; font-size: 32px; color: var(--blue); text-align: center; margin: 0 0 16px; }
.popup-subtitle { font-family: var(--font-display); font-weight: 400; font-size: 20px; color: var(--blue); margin: 20px 0 8px; }
.rules-body h2 { font-family: var(--font-display); font-weight: 400; font-size: 20px; color: var(--blue); margin: 18px 0 6px; }
.rules-body h2:first-child { margin-top: 0; }
.rules-body p, .rules-body li { line-height: 1.5; }
.rules-body ol, .rules-body ul { padding-left: 22px; }

.rule-illustrated::after { content: ""; display: table; clear: both; }
.rule-tile-img { float: right; width: 72px; height: 72px; margin: 2px 0 8px 14px; border-radius: 8px; border: 2px solid var(--accent-light); box-shadow: 0 2px 6px rgba(0,0,0,.15); }

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; }
.volume-row { gap: 10px; }
.volume-row span { flex: 1; text-align: left; }
.volume-slider { width: 120px; accent-color: var(--accent); cursor: pointer; }
.settings-section { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 4px; }
.credits-list { padding-left: 20px; font-size: 13px; color: var(--grey); line-height: 1.7; }

.jukebox { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.jukebox-track { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--accent-light); background: #fff; border-radius: 8px; cursor: pointer; touch-action: manipulation; }
.jukebox-track.playing { background: rgba(26,58,143,.08); border-color: var(--blue); }
.jukebox-track .ico { width: 18px; text-align: center; flex-shrink: 0; }

.result-player { border: 1px solid #E8E4D5; border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; background: #fff; }
.result-player.winner { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(26,58,143,.18); }
.result-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.result-head .dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.result-head .nm { font-family: var(--font-display); font-size: 20px; flex: 1; }
.result-head .total { font-weight: 700; font-size: 20px; color: var(--blue); font-variant-numeric: tabular-nums; }
.result-cat { display: grid; grid-template-columns: 110px 1fr 30px; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 4px; }
.result-cat .bar-track { background: #EEE7D6; border-radius: 4px; height: 8px; overflow: hidden; }
.result-cat .bar-fill { display: block; height: 100%; border-radius: 4px; }
.result-cat .val { text-align: right; font-variant-numeric: tabular-nums; }

.event-toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%) translateY(-12px);
  max-width: min(480px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--accent-light); border-radius: 10px;
  padding: 12px 18px; box-shadow: 0 8px 28px rgba(0,0,0,.3);
  font-family: var(--font-body); font-size: 15px; text-align: center; color: var(--ink);
  z-index: 20; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.event-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.zoom-controls { position: fixed; right: 12px; bottom: 12px; z-index: 5; display: flex; flex-direction: column; gap: 6px; }
.zoom-controls button { width: 44px; height: 44px; min-height: 44px; min-width: 44px; padding: 0; font-size: 22px; line-height: 1; border-radius: 8px; }

.mobile-only-btn { display: none; }
.scores-toggle { display: none; }

/* ============================================================
   Mobiel + tablet in-game menu (herzien): board maximaal vrij.
   - Bovenaan een slank, half-doorzichtig statusstrookje: wiens beurt +
     fase + stapel + ingeklapte spelerbolletjes (tik = uitklappen).
   - Onderaan een vaste icon-toolbar (duim-bereik) met de acties;
     draai/skip bruin (primaire spelacties), menu-knoppen linnen.
   - Logboek/chat klapt uit binnen het bovenstrookje (scrollbaar).
   Geldt tot en met tablet-breedte (≤1024px).
   ============================================================ */
@media (max-width: 1024px) {
  /* Noch transform, noch (backdrop-)filter hier: die maken van .side/.panel het
     bevattingsblok voor position:fixed-kinderen, waardoor de onderste toolbar niet
     meer aan het scherm hangt maar aan het paneel. Daarom transform/filter uit en
     centreren via margin. */
  .side {
    top: 6px; left: 0; right: 0; margin: 0 auto; transform: none;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    width: fit-content; max-width: calc(100vw - 12px);
    padding: 7px 12px; font-size: 13px;
    background: rgba(245, 245, 220, 0.9);
  }
  .logo-lockup-hud { display: none; }
  #turn { margin-bottom: 1px; text-align: center; }
  #turn b, #turn .display-accent { font-size: 15px; }
  #deck { font-size: 12px; margin-bottom: 5px; }

  /* Ingeklapt: horizontale rij chips met alleen bolletje + frilingen/boten. */
  #scores { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 4px 8px; }
  .score { margin: 0; padding: 2px 6px; gap: 5px; }
  .score .nm, .score .pts, .score .ai-lvl { display: none; }
  .score .mp { font-size: 12px; }
  .scores-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 22px; min-height: 22px; margin-top: 4px;
    padding: 0; font-size: 12px; border-radius: 7px;
  }
  #scoresWrap.scores-open #scores { flex-direction: column; gap: 3px; }
  #scoresWrap.scores-open .score { padding: 4px 8px; }
  #scoresWrap.scores-open .score .nm { display: block; flex: 1; }
  #scoresWrap.scores-open .score .pts { display: inline; }
  #scoresWrap.scores-open .score .ai-lvl { display: inline; }

  /* Vaste onderste actie-toolbar. De twee rijen worden via display:contents
     samengevoegd tot één horizontale rij iconknoppen. */
  #actionBar {
    position: fixed; left: 50%; bottom: 8px; transform: translateX(-50%);
    display: flex; flex-direction: row; gap: 7px; z-index: 6;
    background: rgba(245, 245, 220, 0.94); border: 1px solid var(--accent-light);
    border-radius: 14px; padding: 6px; box-shadow: 0 4px 18px rgba(0,0,0,.28);
  }
  .action-row { display: contents; }
  #actionBar button {
    flex: 0 0 auto; width: 44px; height: 44px; min-width: 44px; min-height: 44px;
    margin: 0; border-radius: 10px; padding: 0;
    display: flex; align-items: center; justify-content: center;
  }
  #actionBar button .btn-icon { width: 22px; height: 22px; margin: 0; }
  #actionBar button .btn-label { display: none; }
  .mobile-only-btn { display: flex; }

  /* Primaire spelacties (draai/skip) bruin met wit icoon, om ze te onderscheiden
     van de linnenkleurige menu-knoppen (regels/instellingen/logboek). */
  #actionBar #rotateBtn, #actionBar #skipBtn {
    background: var(--accent); border-color: var(--accent);
  }
  #actionBar #rotateBtn:hover, #actionBar #skipBtn:hover { background: var(--accent-light); border-color: var(--accent-light); }
  #actionBar #rotateBtn .btn-icon, #actionBar #skipBtn .btn-icon { filter: brightness(0) invert(1); }

  #logChatWrap { display: none; }
  #logChatWrap.mobile-log-open { display: block; max-height: 42vh; overflow-y: auto; margin-top: 4px; }

  /* Gebeurtenis-toast net boven de onderste toolbar. */
  .event-toast { top: auto; bottom: 62px; }
}

@media (max-width: 420px) {
  .logo-lockup { width: min(80vw, 340px); }
}
