/* Territorial 2.0 — dark theme, glaspanelen, responsive */

:root {
  --bg: #0d1117;
  --panel: rgba(13, 17, 23, 0.86);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #e6edf3;
  --muted: #8b949e;
  --gold: #ffd728;
  --accent: #3478f6;
  --danger: #e64a3c;
  --radius: 6px;
}

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

html, body {
  height: 100%;
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Achtergrondkleur alleen op html: als body óók een dekkende achtergrond
   heeft, schildert die OVER elementen met negatieve z-index heen en is het
   achtergrond-potje (#bg-canvas, z-index -2) onzichtbaar. */
html { background: var(--bg); }
body { background: transparent; }

.hidden { display: none !important; }

.noscript-seo {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  background: #0d1117;
  color: #e6edf3;
  text-align: center;
}
.noscript-seo h1 {
  color: var(--gold);
  letter-spacing: 4px;
}
.noscript-seo p {
  max-width: 680px;
  line-height: 1.55;
}

.screen {
  position: fixed;
  inset: 0;
  overflow: auto;
}

/* ---------------- panelen & knoppen ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.btn {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 18px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  touch-action: manipulation;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: #4587ff; }
.btn-danger { background: var(--danger); border-color: transparent; font-weight: 600; }
.btn-target { background: rgba(210, 153, 34, 0.2); border-color: rgba(255, 215, 40, 0.45); color: #ffe67a; }
.btn-target:hover { background: rgba(210, 153, 34, 0.34); }
.btn-ghost { background: transparent; }
.btn-big { font-size: 18px; padding: 14px 24px; width: 100%; }

input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 4px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
input:focus { border-color: var(--accent); }
input[readonly].disabled-name {
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  border-color: rgba(255, 255, 255, 0.06);
}
input[readonly].disabled-name:hover {
  border-color: var(--panel-border);
}

.error { color: #ff6b6b; font-size: 14px; min-height: 18px; margin-top: 6px; }

/* ---------------- menu ---------------- */

.menu-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 6vh 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.logo {
  text-align: center;
  font-size: clamp(34px, 8vw, 52px);
  letter-spacing: 4px;
  font-weight: 800;
}
.logo span { color: var(--gold); }
.logo-small { font-size: clamp(24px, 5vw, 32px); }

.tagline { text-align: center; color: var(--muted); margin-top: -10px; }

.menu-panel {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 14px;
}

.admin-link, .privacy-link { color: var(--muted); text-decoration: none; font-size: 13px; text-align: center; }
.admin-link:hover, .privacy-link:hover { color: var(--text); }

.howto { padding: 16px 20px; font-size: 14px; color: var(--muted); }
.howto b { color: var(--text); }
.howto ul { margin: 10px 0 0 18px; display: flex; flex-direction: column; gap: 6px; }

/* ---------------- lobby ---------------- */

.lobby-panel { padding: 26px; display: flex; flex-direction: column; gap: 16px; text-align: center; }
.lobby-label { color: var(--muted); font-size: 14px; }
.lobby-countdown { font-size: 64px; font-weight: 800; color: var(--gold); line-height: 1.1; }
.lobby-meta { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.lobby-players { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.lobby-chip {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
}

/* ---------------- game ---------------- */

#screen-game { overflow: hidden; }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.spawnhint {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 10px 22px;
  border-radius: 30px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

.syncing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  padding: 14px 26px;
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
}

.hud-top {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}

.leaderboard {
  min-width: 200px;
  padding: 8px;
  font-size: 13px;
  pointer-events: auto;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.lb-row:hover { background: rgba(255, 255, 255, 0.08); }
.lb-row.me { background: rgba(255, 215, 40, 0.12); }
.lb-rank { color: var(--muted); width: 18px; text-align: right; }
.lb-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
.player-type { display: inline-block; font-size: 11px; vertical-align: 1px; }
.player-type.human { color: #79c0ff; }
.player-type.bot { color: #d2a8ff; }
.lb-pct { color: var(--muted); }

.hud-clock-wrap { padding: 8px 14px; font-weight: 600; }

.rts-hud {
  min-width: 188px;
  padding: 7px 9px;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rts-hud-row {
  display: flex;
  gap: 6px;
  font: 700 11px ui-monospace, 'Cascadia Mono', Consolas, monospace;
  color: #f3f7ff;
  white-space: nowrap;
}
.rts-hud-row span {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 3px;
  padding: 3px 5px;
}
.rts-help-btn {
  border: 1px solid rgba(255, 215, 40, 0.34);
  border-radius: 3px;
  background: rgba(255, 215, 40, 0.1);
  color: #ffe67a;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
}
.rts-help-btn:hover { background: rgba(255, 215, 40, 0.2); }

.feed {
  position: absolute;
  right: 10px;
  top: 10px;
  width: min(280px, 46vw);
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: none;
  font-size: 12.5px;
}
.feed-item {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 6px 10px;
  animation: feedin 0.25s ease;
}
@keyframes feedin { from { opacity: 0; transform: translateY(-6px); } }

.allyreq-wrap {
  position: absolute;
  right: 10px;
  top: 46%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.allyreq {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.allyreq button {
  border: none;
  border-radius: 6px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 15px;
}
.allyreq button:first-of-type { background: #2ea043; color: #fff; }
.allyreq button:last-of-type { background: var(--danger); color: #fff; }

.dead-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--danger);
  padding: 12px 18px 12px 26px;
  border-radius: 30px;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 14px;
}
.dead-actions { display: flex; align-items: center; gap: 8px; }

.hud-bottom {
  position: absolute;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: min(640px, calc(100vw - 16px));
}

.hud-stats {
  padding: 8px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 130px;
}
.hud-balance { font-size: 22px; font-weight: 700; color: var(--gold); }
.hud-balmax { font-size: 12px; color: var(--muted); margin-left: 4px; }
.hud-land { font-size: 12px; color: var(--muted); }
.hud-income { font-size: 11px; color: #7ee787; }
.eco-label { margin-top: 5px; font-size: 10px; color: var(--muted); }

.eco-bar {
  height: 4px;
  margin-top: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
#hud-ecofill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d29922, var(--gold));
  border-radius: 2px;
}

.hud-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
}
.hud-pct { font-weight: 700; width: 48px; text-align: right; }

input[type="range"] {
  flex: 1;
  min-width: 0;
  -webkit-appearance: none;
  appearance: none;
  height: 26px;
  background: transparent;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #2ea043, #d29922, #e64a3c);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg);
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #2ea043, #d29922, #e64a3c);
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--bg);
  cursor: pointer;
}

.btn-surrender { font-size: 18px; padding: 8px 14px; }
.btn-rts-front {
  min-width: 92px;
  padding: 8px 10px;
  border-color: rgba(255, 215, 40, 0.45);
  background: rgba(210, 153, 34, 0.18);
  color: #ffe67a;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}
.btn-rts-front:hover { background: rgba(210, 153, 34, 0.32); }
#btn-game-settings,
#btn-surrender {
  background: var(--panel);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#btn-game-settings:hover,
#btn-surrender:hover {
  background: rgba(35, 42, 52, 0.96);
  border-color: rgba(255, 255, 255, 0.28);
}
.btn-boat {
  min-width: 132px;
  padding: 8px 12px;
  border: 1px solid rgba(88, 166, 255, 0.55);
  background: rgba(31, 111, 235, 0.22);
  color: #c9e5ff;
}
.btn-boat:hover { background: #1f6feb; color: #fff; }
.boat-context {
  position: fixed;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: boat-pop 0.14s ease-out;
}
@keyframes boat-pop { from { opacity: 0; transform: scale(0.85); } }

/* ---------------- modals ---------------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100; /* boven de tutorial-overlay (1000), anders opent een dialoog erachter */
  padding: 16px;
  overflow-y: auto; /* Scrollen toestaan als de modal te hoog is */
}
@media (max-height: 650px) {
  .modal {
    align-items: flex-start; /* Uitlijnen naar boven om cut-off te voorkomen */
  }
}
.modal-panel {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 32px); /* Beperk hoogte tot viewport minus padding */
  overflow-y: auto; /* Scrollen binnen het paneel zelf toestaan */
  box-sizing: border-box;
}
@media (max-width: 480px) {
  .modal-panel {
    padding: 16px;
  }
}
.modal-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.rts-note {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
}
.rts-perks-list .rts-perk-row {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 4px;
  padding: 8px;
}
.rts-perks-list .rts-perk-row + .rts-perk-row { margin-top: 8px; }
.rts-perk-row .btn {
  min-width: 34px;
  padding: 5px 9px !important;
  border-radius: 3px !important;
}
#perk-gold-val,
#perk-troop-val,
#perk-def-val {
  display: inline-block;
  min-width: 18px;
  text-align: center;
  font-weight: 800;
}
.rts-build-buttons .btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.app-dialog-panel { max-width: 420px; }
.app-dialog-heading { display: flex; align-items: center; gap: 12px; }
.app-dialog-heading h2 { font-size: 21px; line-height: 1.25; }
.app-dialog-icon { font-size: 28px; line-height: 1; }
.app-dialog-message { color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.app-dialog-actions { flex-direction: row; justify-content: flex-end; margin-top: 10px; }
.app-dialog-actions .btn { min-width: 110px; }

@media (max-width: 440px) {
  .app-dialog-actions { flex-direction: column-reverse; }
  .app-dialog-actions .btn { width: 100%; }
}

.auth-tabs { display: flex; gap: 6px; }
.tab {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

#form-login, #form-register { display: flex; flex-direction: column; gap: 10px; }
.setup-form { display: flex; flex-direction: column; gap: 10px; }
.setup-wrap code { color: var(--gold); }
.setup-wrap a { text-decoration: none; text-align: center; display: block; }

.social-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.social-divider::before, .social-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--panel-border);
}
.social-buttons { display: flex; flex-direction: column; gap: 8px; }
.btn-social { text-align: center; text-decoration: none; display: block; font-weight: 600; }
.btn-google { background: #fff; color: #1a1a1a; }
.btn-googleplay { background: #0f9d58; color: #fff; }
.btn-discord { background: #5865f2; color: #fff; }
.btn-github { background: #24292f; color: #fff; }
.social-hint { color: var(--muted); font-size: 13px; text-align: center; }

/* ---------------- wachtwoord vergeten ---------------- */
.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px;
  text-decoration: underline;
  align-self: center;
}
.link-btn:hover { color: var(--text); }
.forgot-intro { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
.auth-success {
  color: #7ee787;
  font-size: 14px;
  text-align: center;
  line-height: 1.5;
  padding: 8px 0;
}

/* ---------------- gast-modus ---------------- */
.guest-warning {
  background: rgba(255, 155, 0, 0.1);
  border: 1px solid rgba(255, 155, 0, 0.35);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #ffd9a0;
}
.guest-stats { font-size: 13px; color: var(--muted); flex: 1; }
.end-earned { color: var(--gold); font-weight: 700; margin-top: 4px; }
.end-guestnote {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #ffd9a0;
  background: rgba(255, 155, 0, 0.1);
  border: 1px solid rgba(255, 155, 0, 0.3);
  border-radius: 8px;
  padding: 8px 10px;
}

/* ---------------- eindscherm ---------------- */

.end-panel { padding: 30px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.end-panel h2 { font-size: 30px; }
.end-winner { color: var(--gold); font-size: 18px; font-weight: 600; }
.end-stats { display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.end-stats b { color: var(--text); }

.fatal {
  position: fixed;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background: var(--danger);
  color: #fff;
  padding: 12px;
  border-radius: 8px;
  z-index: 99;
}

/* ---------------- mobiel ---------------- */

@media (max-width: 640px) {
  .hud-top {
    top: max(6px, env(safe-area-inset-top));
    left: 6px;
    right: 6px;
    justify-content: space-between;
  }
  .leaderboard {
    min-width: 0;
    width: 174px;
    padding: 5px;
    font-size: 10.5px;
  }
  .lb-row { min-height: 34px; gap: 5px; padding: 6px 4px; }
  .lb-rank { width: 14px; }
  .lb-dot { width: 8px; height: 8px; }
  .lb-name { max-width: 92px; }
  .hud-clock-wrap { padding: 6px 9px; font-size: 12px; }

  /* Alleen de nieuwste melding blijft zichtbaar en zit boven de bediening. */
  .feed {
    top: auto;
    right: auto;
    left: 50%;
    bottom: calc(max(8px, env(safe-area-inset-bottom)) + 94px);
    transform: translateX(-50%);
    width: min(330px, calc(100vw - 24px));
    font-size: 11.5px;
  }
  .feed-item { display: none; padding: 6px 9px; text-align: center; }
  .feed-item:last-child { display: block; }

  .dead-banner {
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    padding: 10px;
    border-radius: 12px;
    gap: 8px;
    justify-content: space-between;
    font-size: 13px;
    z-index: 20;
  }
  .dead-banner .btn { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
  .dead-banner { flex-direction: column; align-items: stretch; text-align: center; }
  .dead-actions { width: 100%; }
  .dead-actions .btn { flex: 1; }

  .hud-bottom {
    bottom: max(8px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr) 42px 42px;
    align-items: stretch;
    gap: 5px;
    width: calc(100vw - 12px);
    height: 88px;
  }
  .hud-stats { min-width: 0; padding: 6px 8px; }
  .hud-balance { font-size: 17px; }
  .hud-balmax, .hud-land { font-size: 10px; }
  .eco-label { display: none; }
  .eco-bar { margin-top: 4px; }
  .hud-income { font-size: 10px; margin-top: 2px; }
  .hud-slider-wrap { min-width: 0; gap: 5px; padding: 8px 7px; overflow: hidden; }
  .hud-slider-wrap input[type="range"] { width: 100%; min-width: 0; }
  .hud-pct { flex: 0 0 34px; width: 34px; font-size: 13px; text-align: center; }
  .btn-surrender { min-width: 0; padding: 0; font-size: 17px; }
  .btn-rts-front {
    min-width: 0;
    padding: 0 6px;
    font-size: 10.5px;
  }
  .hud-bottom:has(.btn-rts-front:not(.hidden)) {
    grid-template-columns: 88px minmax(0, 1fr) 56px 38px 38px;
  }
  .rts-hud {
    position: absolute;
    top: 42px;
    left: 0;
    min-width: 0;
    max-width: calc(100vw - 12px);
    padding: 5px;
  }
  .rts-hud-row { font-size: 9.5px; gap: 3px; }
  .rts-hud-row span { padding: 2px 3px; }
  .rts-help-btn { padding: 3px 5px; font-size: 10px; }
  .spawnhint {
    top: max(64px, calc(env(safe-area-inset-top) + 52px));
    width: calc(100vw - 20px);
    max-width: 430px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    z-index: 12;
  }
  .allyreq-wrap { right: 6px; left: 6px; top: auto; bottom: 104px; }
  .allyreq { justify-content: center; font-size: 12px; }
  .lobby-countdown { font-size: 48px; }

  /* Na uitschakeling zijn de gewone spelcontrols niet meer bruikbaar. */
  body.player-dead .hud-bottom,
  body.player-dead .zoom-controls { display: none; }
}

/* ---------------- admin ---------------- */

.admin-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.admin-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-section { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .admin-grid { grid-template-columns: 1fr; } }

.gen-controls { display: flex; flex-direction: column; gap: 10px; }
.gen-controls label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.gen-controls select, .gen-controls input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-size: 15px;
}
.gen-row { display: flex; gap: 8px; flex-wrap: wrap; }

#map-preview { width: 100%; border-radius: 8px; border: 1px solid var(--panel-border); image-rendering: pixelated; background: #0e2a3f; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--panel-border); }
.admin-table th { color: var(--muted); font-weight: 500; }
.admin-table .small-btn { padding: 4px 10px; font-size: 12.5px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat-card { padding: 16px; text-align: center; }
.stat-card .num { font-size: 28px; font-weight: 700; color: var(--gold); }
.stat-card .lbl { font-size: 12.5px; color: var(--muted); }

/* ---------------- game mode selection & lobby chat ---------------- */
.mode-select-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.mode-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
}
.mode-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.btn-mode {
  padding: 8px 12px;
  font-size: 13.5px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  transition: all 0.2s ease;
}
.btn-mode:hover {
  background: rgba(255, 255, 255, 0.08);
}
.btn-mode.active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(52, 120, 246, 0.4);
}

.lobby-chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  padding: 10px;
  margin-top: 10px;
  height: 200px;
}
.lobby-chat-messages {
  flex: 1;
  overflow-y: auto;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  padding-right: 5px;
}
.lobby-chat-msg {
  word-break: break-word;
  line-height: 1.4;
}
.lobby-chat-msg b {
  color: var(--gold);
}
.lobby-chat-input-row {
  display: flex;
  gap: 8px;
}
#lobby-chat-input {
  flex: 1;
  font-size: 14px;
  padding: 8px 12px;
}
#lobby-chat-send {
  padding: 8px 16px;
  font-size: 14px;
}

/* ---------------- general menu chat & game chat box ---------------- */
.menu-chat-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 280px;
}
.menu-chat-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}
.menu-chat-messages {
  flex: 1;
  height: 150px;
  overflow-y: auto;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  padding-right: 5px;
}
.menu-chat-msg {
  word-break: break-word;
  line-height: 1.4;
}
.menu-chat-msg b {
  color: var(--gold);
}
.menu-chat-input-row {
  display: flex;
  gap: 8px;
}
#menu-chat-input {
  flex: 1;
  font-size: 14px;
  padding: 8px 12px;
}
#menu-chat-send {
  padding: 8px 16px;
  font-size: 14px;
}

.game-chat-box {
  position: absolute;
  left: 16px;
  bottom: 120px; /* Boven de HUD slider */
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 8px;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#game-chat-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13.5px;
  border-radius: 6px;
  border: 1px solid var(--panel-border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

/* ---------------- animated background ---------------- */
.bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -2;
  filter: blur(1.5px) saturate(1.15);
  opacity: 0.6;
  pointer-events: auto; /* Zorgt dat klikken erdoorheen kan worden opgevangen */
}
.bg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  background: radial-gradient(circle, rgba(13, 17, 23, 0.4) 0%, rgba(13, 17, 23, 0.8) 100%);
  pointer-events: none;
}

/* ---------------- instellingen ---------------- */

.settings-panel {
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
}

.settings-body { display: flex; flex-direction: column; gap: 18px; }

.set-section { display: flex; flex-direction: column; gap: 8px; }
.set-section h3 {
  font-size: 15px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 6px;
}
.set-infotext { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.set-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.set-langs { max-height: 180px; overflow-y: auto; }

.set-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 20px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.set-pill.active { border-color: var(--accent); background: rgba(52, 120, 246, 0.15); }
.set-pill .set-dot { font-size: 10px; }

.set-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  padding: 3px 0;
}

.set-toggle, .set-key {
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  min-width: 90px;
  text-align: center;
}
.set-toggle.on { border-color: #2ea043; background: rgba(46, 160, 67, 0.15); }
.set-key { min-width: 110px; font-family: ui-monospace, monospace; }
.set-resetkeys { margin-top: 6px; font-size: 13px; }

/* ---------------- zoomknoppen ---------------- */

.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 110px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}
.zoom-btn {
  width: 44px;
  height: 44px;
  font-size: 22px;
  font-weight: 700;
  padding: 0;
  background: var(--panel);
}
body.hide-zoom .zoom-controls { display: none; }

/* ---------------- instelbare UI-modi ---------------- */

/* Grote gebruikersinterface */
body.big-ui .leaderboard { font-size: 15.5px; min-width: 240px; }
body.big-ui .hud-balance { font-size: 28px; }
body.big-ui .hud-land, body.big-ui .hud-income { font-size: 14px; }
body.big-ui .feed { font-size: 15px; }
body.big-ui .hud-pct { font-size: 18px; }
body.big-ui .hud-clock-wrap { font-size: 18px; }
body.big-ui .eco-label { font-size: 13px; }

/* Saldo bovenaan */
body.balance-top .hud-stats {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--panel);
  border-radius: 12px;
  padding: 8px 18px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  min-width: auto;
  white-space: nowrap;
  pointer-events: auto;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
body.balance-top .hud-stats .eco-label { display: none; }
body.balance-top .hud-stats .eco-bar { display: none; }

/* hud-bottom herstellen: slider neemt de volle breedte als stats weg zijn */
body.balance-top .hud-bottom {
  display: flex;
}
body.balance-top .hud-bottom .hud-stats {
  /* Bewaar dezelfde fixed-positie; neem geen ruimte in de flex-parent */
}

@media (max-width: 640px) {
  body.balance-top .hud-stats {
    top: max(6px, env(safe-area-inset-top));
    padding: 5px 12px;
    font-size: 12px;
    max-width: calc(100vw - 140px); /* ruimte voor leaderboard + klok */
  }
  body.balance-top .hud-stats .hud-land { display: none; }
  body.balance-top .hud-stats .hud-income { display: none; }
  body.balance-top .hud-bottom {
    grid-template-columns: minmax(0, 1fr) 42px 42px;
  }
  body.balance-top .hud-bottom:has(.btn-rts-front:not(.hidden)) {
    grid-template-columns: minmax(0, 1fr) 56px 38px 38px;
  }
}

/* Berichtenbox gesloten houden */
body.feed-closed #hud-feed { display: none; }

/* Lettertype */
body.font-serif { font-family: Georgia, 'Times New Roman', serif; }
body.font-mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }

/* UI verbergen (sneltoets) */
body.ui-hidden .hud-top,
body.ui-hidden .hud-bottom,
body.ui-hidden .feed,
body.ui-hidden .allyreq-wrap,
body.ui-hidden .zoom-controls { display: none; }

/* Mobiele grenzen moeten ook winnen van de optionele 'grote UI'-modus. */
@media (max-width: 640px) {
  body.big-ui .leaderboard {
    min-width: 0;
    width: min(200px, calc(100vw - 68px));
    padding: 5px;
    font-size: 11.5px;
  }
  body.big-ui .lb-name { max-width: 108px; }
  body.big-ui .hud-balance { font-size: 19px; }
  body.big-ui .hud-land,
  body.big-ui .hud-income { font-size: 10px; }
  body.big-ui .hud-pct { font-size: 14px; }
  body.big-ui .hud-clock-wrap { padding: 6px 9px; font-size: 13px; }
  body.big-ui .eco-label { display: none; }

  .zoom-controls { right: 8px; bottom: 108px; gap: 6px; }
  .zoom-btn { width: 42px; height: 42px; font-size: 20px; }
}

.tutorial-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 1000;
}
.tutorial-card {
  pointer-events: auto;
}

@media (max-width: 480px), (max-height: 650px) {
  #shop-items-list {
    max-height: 180px !important;
  }
}

#shop-items-list {
  flex-shrink: 0;
}
.shop-unlocked-section {
  flex-shrink: 0;
}
