:root {
  --wood: #2a2015;
  --wood2: #3a2c1c;
  --wood3: #4b3922;
  --parch: #f4e8cc;
  --parch2: #ead9b3;
  --parch3: #dcc596;
  --ink: #3a2a18;
  --ink2: #6b5535;
  --muted: #8a7558;
  --gold: #d9a43a;
  --gold2: #f2c95a;
  --red: #b2372a;
  --green: #3f8f3c;
  --blue: #2f6fb5;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --r: 10px;
  --topbar: 58px;
  --nav: 74px;
  --panel: 360px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--wood);
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
h1, h2, h3, .cinzel { font-family: 'Cinzel', Georgia, serif; }

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

/* ---------- knoppen ---------- */
.btn {
  border: 1px solid #8b6a3a;
  background: linear-gradient(#f7ecd3, #e3cd9e);
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 12px;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset, 0 2px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.06s, filter 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(#e7b54c, #c58a24); border-color: #8d5f16; color: #2b1a05; }
.btn.danger { background: linear-gradient(#d0553f, #a5321f); border-color: #6e1e12; color: #fff3e6; }
.btn.green { background: linear-gradient(#6db35a, #3f8a36); border-color: #2a5e22; color: #f2ffe9; }
.btn.small { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn.big { padding: 11px 16px; font-size: 16px; width: 100%; }
.btn.ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink2); }

/* ---------- aanmelden ---------- */
#auth { display: grid; place-items: center; background: #2a649c; }
#authCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: linear-gradient(170deg, #fbf3df, #ecdcb6);
  border: 2px solid #8b6a3a;
  border-radius: 16px;
  padding: 26px 26px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), 0 0 0 6px rgba(42, 32, 21, 0.35);
}
.logo { text-align: center; margin-bottom: 10px; }
.logo h1 { margin: 2px 0 0; font-size: 28px; letter-spacing: 0.5px; color: #4a2f12; }
.logo-crown { font-size: 34px; color: var(--red); text-shadow: 0 2px 0 #f2c95a; }
.logo-crown.sm { font-size: 22px; }
.tagline { margin: 4px 0 0; color: var(--ink2); font-style: italic; }
.auth-info { text-align: center; font-size: 13px; color: var(--ink2); background: rgba(139, 106, 58, 0.12); border-radius: 8px; padding: 8px; margin: 10px 0 14px; }
.auth-info b { color: var(--ink); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; border: 1px solid #b89a66; background: transparent; padding: 8px; border-radius: 8px; color: var(--ink2); font-weight: 600; }
.tab.active { background: #8b6a3a; color: #fff5e1; border-color: #6e5228; }
.auth-form { display: grid; gap: 10px; }
.auth-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink2); }
.auth-form input, .field {
  border: 1px solid #b89a66; background: #fffaf0; border-radius: 8px; padding: 9px 10px; color: var(--ink); width: 100%;
}
.auth-form input:focus, .field:focus { outline: 2px solid var(--gold); border-color: transparent; }
.opt { font-weight: 400; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--ink2); margin: 0; }
.error { color: var(--red); font-weight: 600; min-height: 1.2em; margin: 10px 0 0; text-align: center; }

/* ---------- spellay-out ---------- */
#game {
  display: grid;
  grid-template-columns: var(--nav) 1fr var(--panel);
  grid-template-rows: var(--topbar) 1fr;
  grid-template-areas: 'top top top' 'nav stage panel';
}
#topbar {
  grid-area: top;
  display: flex; align-items: center; gap: 12px;
  padding: 0 14px;
  background: linear-gradient(#45341f, #2f2416);
  border-bottom: 2px solid #1a130b;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  color: #f6ead0;
  z-index: 5;
  min-width: 0;
}
.brand { display: flex; align-items: center; gap: 6px; font-family: 'Cinzel', serif; font-weight: 700; font-size: 18px; color: var(--gold2); }
.resbar { display: flex; gap: 6px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.resbar::-webkit-scrollbar { display: none; }
.res {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px; padding: 3px 10px 3px 4px; white-space: nowrap;
}
.res .ico { width: 24px; height: 24px; flex: none; }
.res .amt { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.res .sub { font-size: 10.5px; color: #cdb88f; line-height: 1.05; display: grid; }
.res.full .amt { color: #ff9a7a; }
.phase {
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 13px; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(255, 255, 255, 0.1);
}
.phase .timer { color: inherit; font-family: 'Inter', sans-serif; font-weight: 700; }
.phase.prep { color: #bfe6a8; }
.phase.war { color: #ffb4a0; background: rgba(150, 30, 20, 0.45); animation: warglow 2s infinite; }
.phase.lobby { color: #cfe0ff; }
.phase.ended { color: var(--gold2); }
@keyframes warglow { 50% { box-shadow: 0 0 12px rgba(255, 80, 50, 0.6); } }
.alert {
  background: #a5281b; color: #fff; font-weight: 700; font-size: 12.5px; padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; animation: pulse 1.2s infinite; cursor: pointer; border: 1px solid #ff8a70;
}
@keyframes pulse { 50% { filter: brightness(1.25); } }

#nav {
  grid-area: nav;
  display: flex; flex-direction: column; gap: 4px; padding: 8px 6px;
  background: linear-gradient(90deg, #3a2c1c, #2d2215);
  border-right: 2px solid #1a130b;
  z-index: 4;
}
.navbtn {
  position: relative;
  display: grid; justify-items: center; gap: 2px;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: #e7d6b2; padding: 8px 2px; font-size: 11px; font-weight: 600;
}
.navbtn .ni { font-size: 22px; line-height: 1; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.4)); }
.navbtn:hover { background: rgba(255, 255, 255, 0.06); }
.navbtn.active { background: linear-gradient(#6b5130, #4a3720); border-color: #8b6a3a; color: #fff3d6; }
.navbtn.bottom { margin-top: auto; }
.badge {
  position: absolute; top: 4px; right: 8px; min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--red); color: #fff; font-size: 11px; line-height: 18px; border: 1px solid #ffb19f;
}
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 7px; right: 16px; }

#stage { grid-area: stage; position: relative; overflow: hidden; background: #4f7d33; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; cursor: grab; }
#stage canvas:active { cursor: grabbing; }
.view-title {
  position: absolute; left: 12px; top: 10px; pointer-events: none; z-index: 2;
  padding: 6px 12px 7px; border-radius: 10px; background: rgba(30, 22, 12, 0.55); backdrop-filter: blur(3px);
  font-family: 'Cinzel', serif; font-weight: 700; font-size: 20px; color: #fff8e6;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 0, 0, 0.3);
}
.view-title small { display: block; font-family: 'Inter', sans-serif; font-weight: 600; font-size: 12px; color: #f2e2bf; }
.hud { position: absolute; right: 12px; top: 12px; display: grid; gap: 6px; }
.hudbtn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid #8b6a3a;
  background: rgba(244, 232, 204, 0.92); color: var(--ink); font-size: 20px; font-weight: 700; box-shadow: var(--shadow);
}
.place-hint {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(30, 22, 12, 0.85); color: #fff3d6; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
}
.place-hint button { margin-left: 8px; }

.buildbar {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; gap: 8px; overflow-x: auto; padding: 8px; scrollbar-width: thin;
  background: rgba(42, 32, 21, 0.82); border: 1px solid #6e5228; border-radius: 14px; box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
}
.bcard {
  flex: none; width: 92px; display: grid; justify-items: center; gap: 2px;
  background: linear-gradient(#f7ecd3, #e3cd9e); border: 1px solid #8b6a3a; border-radius: 10px; padding: 4px 4px 5px;
  color: var(--ink); position: relative;
}
.bcard img { width: 64px; height: 56px; object-fit: contain; }
.bcard .bn { font-size: 11px; font-weight: 700; line-height: 1.1; text-align: center; }
.bcard .bc { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 5px; font-size: 10.5px; font-variant-numeric: tabular-nums; }
.bcard .bc span { display: inline-flex; align-items: center; gap: 1px; }
.bcard .bc img, .cost img, .chip img { width: 14px; height: 14px; }
.bcard.locked { filter: grayscale(0.8); opacity: 0.55; }
.bcard.poor .bc { color: var(--red); }
.bcard.active { outline: 3px solid var(--gold2); }
.bcard .cnt { position: absolute; top: 3px; right: 5px; font-size: 10px; color: var(--muted); font-weight: 700; }

/* ---------- zijpaneel ---------- */
.panel {
  grid-area: panel;
  background: linear-gradient(170deg, #f8eed7, #ecdcb6);
  border-left: 2px solid #1a130b;
  overflow-y: auto;
  padding: 14px 14px 30px;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.25) inset;
}
.panel-toggle { display: none; }
.ph { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.ph img.thumb { width: 64px; height: 58px; object-fit: contain; background: rgba(139, 106, 58, 0.12); border-radius: 10px; padding: 2px; }
.ph h2 { margin: 0; font-size: 19px; color: #4a2f12; line-height: 1.15; }
.ph .lvl { font-size: 12.5px; color: var(--ink2); font-weight: 600; }
.desc { font-size: 13px; color: var(--ink2); margin: 4px 0 10px; line-height: 1.4; }
.card {
  background: rgba(255, 252, 242, 0.7); border: 1px solid #d3bb8a; border-radius: var(--r); padding: 10px 11px; margin: 10px 0;
}
.card h3 { margin: 0 0 8px; font-size: 14px; color: #4a2f12; display: flex; align-items: center; gap: 6px; }
.card h3 .right { margin-left: auto; font-family: 'Inter'; font-size: 12px; color: var(--ink2); font-weight: 600; }
.row { display: flex; align-items: center; gap: 8px; }
.row + .row { margin-top: 6px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.cost { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cost span { display: inline-flex; align-items: center; gap: 3px; }
.cost .no { color: var(--red); }
.req { font-size: 12px; color: var(--red); font-weight: 600; margin-top: 6px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: #6b4c12; }
.bar { height: 8px; background: rgba(0, 0, 0, 0.12); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #d9a43a, #f2c95a); border-radius: 4px; }
.vrow { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 6px; align-items: center; }
.vrow + .vrow { margin-top: 6px; }
.vrow img { width: 24px; height: 24px; }
.vrow .nm { font-size: 13px; font-weight: 600; line-height: 1.1; }
.vrow .nm small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid #b89a66; border-radius: 8px; overflow: hidden; background: #fffaf0; }
.stepper button { border: 0; background: #ead9b3; width: 26px; height: 26px; font-weight: 800; color: var(--ink); }
.stepper button:disabled { opacity: 0.4; }
.stepper b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; font-size: 13px; }
.qitem { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-top: 1px dashed #d3bb8a; }
.qitem:first-of-type { border-top: 0; }
.qitem img { width: 32px; height: 32px; object-fit: contain; }
.qitem .nm { font-size: 13px; font-weight: 600; }
.unitgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.ucell { display: grid; justify-items: center; background: rgba(139, 106, 58, 0.1); border-radius: 8px; padding: 4px; font-size: 11px; font-weight: 600; }
.ucell img { width: 36px; height: 36px; }
.ucell b { font-size: 14px; font-variant-numeric: tabular-nums; }
.urow { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 8px 0; border-top: 1px dashed #d3bb8a; }
.urow:first-of-type { border-top: 0; }
.urow img { width: 44px; height: 44px; }
.urow .nm { font-weight: 700; font-size: 14px; }
.stats { display: flex; gap: 8px; font-size: 11.5px; color: var(--ink2); margin: 2px 0 4px; flex-wrap: wrap; }
.trainrow { display: flex; gap: 6px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.num { width: 70px; border: 1px solid #b89a66; border-radius: 8px; padding: 5px 6px; background: #fffaf0; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.actions .btn { flex: 1; }
.empty { font-size: 13px; color: var(--muted); font-style: italic; }
.sep { border: 0; border-top: 1px solid #d3bb8a; margin: 10px 0; }
select.field { padding: 6px 8px; }

/* ---------- modaal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20, 14, 8, 0.6); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card {
  position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: linear-gradient(170deg, #fbf3df, #ecdcb6); border: 2px solid #8b6a3a; border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal-card h2 { margin: 0 0 12px; color: #4a2f12; }
.modal-close { position: absolute; right: 10px; top: 8px; border: 0; background: transparent; font-size: 28px; color: var(--ink2); line-height: 1; }
.split { display: grid; grid-template-columns: 260px 1fr; gap: 14px; min-height: 300px; }
.rlist { display: grid; gap: 4px; align-content: start; max-height: 60vh; overflow: auto; }
.ritem { text-align: left; border: 1px solid #d3bb8a; background: rgba(255, 252, 242, 0.7); border-radius: 8px; padding: 7px 9px; font-size: 13px; }
.ritem.unseen { border-color: var(--gold); background: #fff6dc; font-weight: 700; }
.ritem.active { outline: 2px solid var(--gold); }
.ritem small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; }
.ricon { margin-right: 4px; }
table.bt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.bt th, table.bt td { padding: 4px 6px; text-align: right; border-bottom: 1px dashed #d3bb8a; font-variant-numeric: tabular-nums; }
table.bt th:first-child, table.bt td:first-child { text-align: left; }
table.bt td img { width: 24px; height: 24px; vertical-align: middle; margin-right: 4px; }
.lost { color: var(--red); font-weight: 700; }
.outcome { font-family: 'Cinzel', serif; font-size: 20px; font-weight: 800; margin: 0 0 6px; }
.outcome.win { color: var(--green); }
.outcome.lose { color: var(--red); }
.chat { display: grid; grid-template-rows: auto 1fr auto; height: 360px; border: 1px solid #d3bb8a; border-radius: 10px; background: rgba(255, 252, 242, 0.6); }
.chat .msgs { overflow-y: auto; padding: 8px 10px; display: grid; gap: 6px; align-content: start; }
.msg { font-size: 13px; line-height: 1.35; }
.msg b { color: #4a2f12; }
.msg time { color: var(--muted); font-size: 11px; margin-left: 4px; }
.chat form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #d3bb8a; }
.chat .tabs { padding: 8px 8px 0; margin: 0; }
.members { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb td, .lb th { padding: 6px 8px; border-bottom: 1px dashed #d3bb8a; text-align: left; }
.lb td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.lb tr.me td { background: rgba(217, 164, 58, 0.18); }
.teambar { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; margin: 6px 0; }
.teambar .tb { height: 22px; border-radius: 6px; position: relative; overflow: hidden; background: rgba(0, 0, 0, 0.08); }
.teambar .tb i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.teambar .tb span { position: relative; padding-left: 8px; font-size: 12.5px; font-weight: 700; line-height: 22px; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.help h3 { margin: 16px 0 6px; color: #4a2f12; }
.help p, .help li { font-size: 14px; line-height: 1.5; }
.timeline { display: grid; grid-template-columns: 3fr 1fr; border-radius: 10px; overflow: hidden; margin: 10px 0; font-size: 13px; font-weight: 700; color: #fff; text-align: center; }
.timeline div { padding: 10px 6px; }
.timeline .tp { background: linear-gradient(#5fa04e, #3f7f35); }
.timeline .tw { background: linear-gradient(#c24a33, #8f2a1b); }
.sendrow { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px dashed #d3bb8a; }
.sendrow img { width: 38px; height: 38px; }
.summary { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; margin: 12px 0; padding: 10px; border-radius: 8px; background: rgba(139, 106, 58, 0.12); }
.summary b { font-variant-numeric: tabular-nums; }

/* ---------- meldingen ---------- */
.toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; pointer-events: none; width: min(420px, calc(100vw - 24px)); }
.toast {
  background: rgba(30, 22, 12, 0.94); color: #fff3d6; border: 1px solid #8b6a3a; border-left: 5px solid var(--gold);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  animation: tin 0.25s ease-out;
}
.toast.err { border-left-color: #e0553f; }
.toast.ok { border-left-color: #6db35a; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- mobiel ---------- */
@media (max-width: 900px) {
  :root { --topbar: auto; }
  #game {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 'top' 'stage' 'nav';
  }
  #topbar { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .brand { display: none; }
  .resbar { order: 2; flex-basis: 100%; }
  .phase { font-size: 11px; padding: 4px 8px; }
  .res { padding: 2px 8px 2px 3px; }
  .res .ico { width: 20px; height: 20px; }
  .res .amt { font-size: 13px; }
  #nav { flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 2px solid #1a130b; position: relative; z-index: 30; }
  .navbtn { padding: 4px 2px; font-size: 10px; flex: 1; }
  .navbtn .ni { font-size: 20px; }
  .navbtn.bottom { margin-top: 0; }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-height: 66vh;
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
    border-left: 0; border-top: 2px solid #8b6a3a; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.4);
    transform: translateY(100%); transition: transform 0.25s;
  }
  .panel.open { transform: none; }
  .panel-toggle {
    display: block; position: absolute; right: 10px; top: 10px; z-index: 3;
    border: 1px solid #8b6a3a; background: #f4e8cc; border-radius: 999px; padding: 7px 14px; font-weight: 700; box-shadow: var(--shadow);
  }
  .hud { top: 58px; }
  .buildbar { bottom: 6px; left: 6px; right: 6px; padding: 5px; gap: 5px; border-radius: 12px; }
  .bcard { width: 66px; padding: 2px 2px 4px; border-radius: 8px; }
  .bcard img { width: 44px; height: 36px; }
  .bcard .bn { font-size: 9.5px; max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bcard .bc { font-size: 9px; gap: 1px 3px; }
  .bcard .cnt { font-size: 8.5px; top: 1px; right: 3px; }
  .split { grid-template-columns: 1fr; }
  .rlist { max-height: 30vh; }
  .modal-card { padding: 16px; }
  .view-title { font-size: 16px; }
}
@media (max-width: 520px) {
  .res .sub { display: none; }
  .res { gap: 4px; padding: 2px 8px 2px 3px; }
  .view-title { max-width: calc(100% - 140px); }
}

/* =====================================================================
   Grafische afwerking: texturen, iconen, animaties
   ===================================================================== */
:root {
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .3 0 0 0 0 .14 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='60'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .35' numOctaves='2' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='300' height='60' filter='url(%23g)'/%3E%3C/svg%3E");
  --parchment: var(--noise), radial-gradient(ellipse at 20% 0%, rgba(255, 252, 240, 0.9), transparent 60%),
    radial-gradient(ellipse at 100% 100%, rgba(170, 120, 50, 0.18), transparent 55%), linear-gradient(170deg, #fbf2dc, #ead6ad);
  --wood-bg: var(--grain), linear-gradient(#4d3a22, #33261a);
}

/* iconen */
.ic { width: 1.3em; height: 1.3em; vertical-align: -0.28em; flex: none; display: inline-block; }
.navbtn .ni { display: grid; place-items: center; }
.navbtn .ni .ic { width: 30px; height: 30px; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45)); transition: transform 0.15s; }
.navbtn:hover .ni .ic { transform: translateY(-2px) scale(1.06); }
.navbtn.active .ni .ic { transform: scale(1.08); }
.card h3 .ic { width: 22px; height: 22px; }
.ph h2 .ic, .modal-card h2 .ic { width: 28px; height: 28px; vertical-align: -0.3em; }
.hudbtn { display: grid; place-items: center; padding: 0; }
.hudbtn .ic { width: 22px; height: 22px; }
.btn .ic { width: 1.25em; height: 1.25em; margin-right: 3px; }
.qicon { display: grid; place-items: center; }
.qicon .ic { width: 28px; height: 28px; }
.ricon .ic { width: 18px; height: 18px; }
.stats .ic { width: 14px; height: 14px; vertical-align: -0.2em; }
.phase .ic { width: 18px; height: 18px; margin-right: 2px; }
.alert .ic { width: 16px; height: 16px; }
.logo-crest { display: inline-block; }
.logo-crest .ic { width: 58px; height: 58px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.3)); }
.logo-crest.sm .ic { width: 28px; height: 28px; }
.panel-toggle .ic { width: 16px; height: 16px; }
.modal-close .ic { width: 22px; height: 22px; }

/* perkament en hout */
.panel, .modal-card, .auth-card { background: var(--parchment); }
.panel { box-shadow: inset 6px 0 18px rgba(80, 50, 15, 0.22), inset 0 0 0 1px rgba(255, 250, 230, 0.5); }
.modal-card, .auth-card {
  border: 2px solid #8b6a3a;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 0 0 4px rgba(255, 248, 225, 0.55), inset 0 0 0 5px rgba(139, 106, 58, 0.45), inset 0 0 40px rgba(150, 100, 40, 0.18);
}
#topbar { background: var(--wood-bg); box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45), inset 0 -1px 0 rgba(255, 220, 160, 0.12); }
#nav { background: var(--grain), linear-gradient(90deg, #3e2f1d, #2c2115); }
.card {
  background: linear-gradient(180deg, rgba(255, 253, 245, 0.82), rgba(255, 248, 230, 0.66));
  border: 1px solid #cdb37f;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset, 0 2px 6px rgba(90, 60, 20, 0.12);
}
.card h3 { padding-bottom: 6px; border-bottom: 1px solid transparent; border-image: linear-gradient(90deg, rgba(139, 106, 58, 0.55), rgba(139, 106, 58, 0.05)) 1; }
.res {
  background: linear-gradient(rgba(0, 0, 0, 0.42), rgba(0, 0, 0, 0.25));
  border: 1px solid rgba(255, 220, 160, 0.16);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.res .ico { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.res.bump .amt { animation: bump 0.6s ease-out; }
@keyframes bump { 30% { color: #ffe28a; transform: scale(1.12); } }
.res .amt { display: inline-block; }
.phase { display: inline-flex; align-items: center; gap: 4px; }
.alert { display: inline-flex; align-items: center; gap: 5px; }
.view-title { border: 1px solid rgba(255, 220, 160, 0.18); }

/* knoppen */
.btn { position: relative; overflow: hidden; }
.btn.primary::after, .btn.danger::after, .btn.green::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-120%);
  background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
}
.btn.primary:hover:not(:disabled)::after, .btn.danger:hover:not(:disabled)::after, .btn.green:hover:not(:disabled)::after { animation: shine 0.8s ease-out; }
@keyframes shine { to { transform: translateX(120%); } }
.bcard { transition: transform 0.15s, box-shadow 0.15s; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); background: var(--noise), linear-gradient(#f8eed6, #e1c994); }
.bcard:not(.locked):hover { transform: translateY(-4px); box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35); }
.bcard:not(.locked):not(.poor) { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 220, 120, 0.4); }
.bcard img { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.25)); }
.hudbtn { background: var(--noise), linear-gradient(#fbf2dc, #e6d0a2); transition: transform 0.12s; }
.hudbtn:hover { transform: scale(1.06); }

/* vensters en meldingen */
.modal { backdrop-filter: blur(3px); animation: fadein 0.18s ease-out; }
.modal-card { animation: pop 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.25); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.96); } }
@keyframes fadein { from { opacity: 0; } }
.modal-card h2 { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 2px solid transparent; border-image: linear-gradient(90deg, #b48a45, rgba(180, 138, 69, 0)) 1; }
.toast { display: flex; align-items: center; gap: 10px; background: var(--grain), rgba(34, 25, 14, 0.95); }
.toast .ic { width: 24px; height: 24px; }
.toasts .toast { animation: tin 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
.panel.enter > * { animation: slidein 0.24s ease-out both; }
@keyframes slidein { from { opacity: 0; transform: translateX(10px); } }

/* laadscherm */
.splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #5a4328, #1e160d 75%);
  transition: opacity 0.5s, visibility 0.5s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-inner { text-align: center; color: #f2c95a; }
.splash-crest .ic { width: 96px; height: 96px; animation: crest 1.6s ease-in-out infinite; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.5)); }
@keyframes crest { 50% { transform: translateY(-8px); } }
.splash-title { font-family: 'Cinzel', Georgia, serif; font-weight: 800; font-size: 26px; margin: 12px 0 16px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); }
.splash-bar { width: 200px; height: 6px; margin: auto; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, #d9a43a, #ffe28a); border-radius: 3px; animation: load 1.1s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* aanmeldscherm */
.logo h1 { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7); }
.auth-card { animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }

@media (max-width: 900px) {
  .panel::before {
    content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; margin: -4px auto 10px;
    background: rgba(90, 60, 25, 0.35);
  }
  .navbtn .ni .ic { width: 26px; height: 26px; }
  .panel-toggle { display: inline-flex; align-items: center; gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
