/* Empire of Tribes — middeleeuws perkament, huisstijl "Klei & Koper" (klei, koper, smidsvuur) */
:root {
  /* Huisstijl Empire of Tribes, voorstel I "Klei & Koper" (docs/huisstijl/palet-1.json) */
  --primary: #A3441C;        /* primair: knoppen, links, actieve tab */
  --primary-light: #B8572A;  /* primair licht: bovenkant knopverloop, focus */
  --primary-dark: #6E2C12;   /* primair donker: knoprand, snelbalk */
  --bg: #2B1C13;             /* achtergrond: spel, kopbalk, koppen */
  --bg-2: #3F2A1C;           /* achtergrond 2: verloop kopbalk, toast, chips */
  --night: #1A110B;
  --accent: #E8A93A;         /* accent: badges, aanvalsmelding, Tribes+ (altijd met --on-accent) */
  --accent-dark: #8E4A16;    /* accent op perkament */
  --on-accent: #2A1A0C;
  --gold: #D4A55A;
  --gold-l: #EFD29A;
  --head-text: #D2BCA0;      /* gedempte tekst op de kopbalk */
  --ivory: #F6ECDB;
  --parch: #F4E8D2;
  --parch-2: #E9D6B4;
  --parch-3: #DCC39A;
  --ink: #2A1C12;
  --ink-soft: #694E36;
  --border: #AF8B5C;
  --green: #356E26;
  --yellow: #8F6410;
  --red: #B3261E;
  --wood: #8b5a2b;
  --clay: #c0662f;
  --iron: #6f7a86;
  --radius: 6px;
  --serif: Georgia, 'Times New Roman', serif;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@font-face { font-family: 'Cinzel'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/cinzel-latin-800-normal.woff2') format('woff2'); }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 14px/1.45 var(--sans);
  color: var(--ink);
  background: radial-gradient(ellipse at top, #4A3121 0%, var(--bg) 60%) fixed;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-variant: small-caps; letter-spacing: .03em; margin: 0 0 .5em; color: var(--bg); }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
.loading { color: #fff; padding: 40px; text-align: center; font-family: var(--serif); font-size: 20px; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------------- header ---------------- */
.topbar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 3px solid var(--primary);
  box-shadow: 0 2px 0 var(--accent);
  color: #fff;
}
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 8px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand img { width: 38px; height: 38px; }
.brand .word { font-family: var(--display); font-size: 20px; font-weight: 800; letter-spacing: .06em; line-height: 1; color: var(--ivory); text-transform: uppercase; white-space: nowrap; }
.brand .word b { color: var(--ivory); font-weight: inherit; }
.brand .word i { color: var(--gold-l); font-style: normal; }
.brand .world { font-size: 11px; color: var(--head-text); letter-spacing: .1em; text-transform: uppercase; }
nav.menu { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
nav.menu a {
  color: var(--head-text); padding: 7px 11px; border-radius: var(--radius); font-weight: 600; position: relative;
}
nav.menu a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
nav.menu a.active { background: var(--primary); color: #fff; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; font-size: 11px; line-height: 18px;
  background: var(--accent); color: var(--on-accent); text-align: center; font-weight: bold;
}
.userbox { font-size: 12px; color: var(--head-text); text-align: right; }
.userbox strong { color: var(--ivory); font-size: 13px; }

.subbar { background: var(--parch-3); border-bottom: 1px solid var(--border); }
.subbar-inner { max-width: 1240px; margin: 0 auto; padding: 6px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.vswitch { display: flex; align-items: center; gap: 6px; }
.vswitch select { font-weight: bold; }
.resbar { display: flex; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.res { display: flex; align-items: center; gap: 5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.res.full { color: var(--red); }
.res .cap { color: var(--ink-soft); font-weight: normal; }
/* inkt zacht op perkament 3 haalt net geen 4,5:1; op de subbalk iets donkerder */
.subbar .muted, .subbar .res .cap { color: #5C432D; }
.ico { width: 18px; height: 18px; display: inline-block; vertical-align: -4px; flex: none; }
.alert-incoming {
  background: var(--accent); color: var(--on-accent); padding: 4px 10px; border-radius: var(--radius); font-weight: bold;
  animation: pulse 1.4s infinite;
}
.alert-incoming a { color: var(--on-accent); text-decoration: underline; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(232,169,58,.4); } }
.protect { background: var(--primary); color: #fff; padding: 3px 9px; border-radius: var(--radius); font-size: 12px; }

/* ---------------- content ---------------- */
main { max-width: 1280px; margin: 16px auto 40px; padding: 0 16px; }
.card {
  background: var(--parch);
  background-image: linear-gradient(180deg, rgba(255,255,255,.35), rgba(255,255,255,0) 120px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,.35), inset 0 0 0 3px rgba(255,255,255,.25);
  padding: 16px 18px; margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { border-bottom: 2px solid var(--parch-3); padding-bottom: 6px; }
.card-head { display: flex; align-items: center; gap: 12px; border-bottom: 2px solid var(--parch-3); padding-bottom: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h1, .card-head h2 { margin: 0; }
.card-head .spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--parch-3); vertical-align: middle; }
th { background: var(--parch-2); font-family: var(--serif); font-variant: small-caps; color: var(--bg); font-size: 13px; }
tr:hover td { background: rgba(255,255,255,.25); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.costs { display: inline-flex; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.costs span { display: inline-flex; gap: 3px; align-items: center; }
.costs .lack { color: var(--red); font-weight: bold; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--primary-dark); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--primary-light), var(--primary)); color: #fff; padding: 6px 12px; display: inline-block;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled { background: #b8ad93; border-color: #9c916f; color: #f4efe2; cursor: not-allowed; }
button.secondary { background: var(--parch-2); color: var(--bg); border-color: var(--border); }
button.danger { background: linear-gradient(180deg, #C73A2F, var(--red)); border-color: #7E1A14; }
button.small { padding: 3px 8px; font-size: 12px; }
input, select, textarea {
  font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: #fffaf0; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-light); outline-offset: 0; }
input.n { width: 72px; text-align: right; }
input:disabled { background: var(--parch-2); color: var(--ink-soft); }
input.coord { width: 64px; text-align: center; }
textarea { width: 100%; min-height: 110px; resize: vertical; }
label { font-weight: 600; }
.form-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.maxlink { font-size: 12px; cursor: pointer; color: var(--primary); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: var(--radius) var(--radius) 0 0; background: var(--parch-2); color: var(--bg); font-weight: 600; border: 1px solid var(--border); border-bottom: none; }
.tabs a.active { background: var(--primary); color: #fff; }

.dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.25); }
.dot.green { background: var(--green); } .dot.yellow { background: var(--yellow); } .dot.red { background: var(--red); } .dot.blue { background: var(--primary); }
tr.unread td { font-weight: bold; }

.unit-chip {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 22px; padding: 0 5px; border-radius: 4px;
  font-size: 11px; font-weight: bold; color: #fff; background: var(--bg); margin-right: 6px; letter-spacing: .03em;
}
.unit-chip.cav { background: var(--primary); }
.unit-chip.siege { background: #6b4a2a; }
.unit-chip.noble { background: var(--accent); color: var(--on-accent); }
.lvl { display: inline-block; background: var(--bg); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: bold; margin-left: 4px; }

.progress { height: 6px; background: var(--parch-3); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }

.mov-attack { color: var(--red); font-weight: bold; }
.mov-support { color: var(--green); font-weight: bold; }
.mov-return { color: var(--primary); font-weight: bold; }
.mov-trade, .mov-trade_return { color: var(--wood); font-weight: bold; }

/* ---------------- dorpsweergave ---------------- */
.village-view { position: relative; width: 100%; aspect-ratio: 16 / 11; border-radius: var(--radius); overflow: hidden; border: 2px solid var(--border); }
.village-view svg { width: 100%; height: 100%; display: block; }
.village-view .bld { cursor: pointer; }
.village-view .bld:hover .roof { filter: brightness(1.25); }
.village-view .bld text { font: bold 11px var(--sans); fill: #fff; paint-order: stroke; stroke: rgba(43,28,19,.85); stroke-width: 3px; pointer-events: none; }
.village-view .bld .lvlbadge { fill: var(--bg); stroke: #fff; stroke-width: 1.5; }
.village-view .bld.empty { opacity: .45; }

/* ---------------- TW-panelen (dorp & kaart) ---------------- */
.tw-frame {
  background: #f4e4bc; border: 1px solid #c1a264; border-radius: 4px; padding: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.45), inset 0 0 0 1px #fff3d6;
}
.tw-village { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 12px; align-items: start; }
@media (max-width: 900px) { .tw-village { grid-template-columns: 1fr; } }
.tw-panel { border: 1px solid var(--border); background: var(--parch); margin-bottom: 12px; box-shadow: 0 1px 2px rgba(80,50,10,.2); }
.tw-panel > header {
  display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 7px;
  background: linear-gradient(180deg, #f3dca6 0%, #dcbb79 100%); border-bottom: 1px solid var(--border);
  font-weight: bold; font-style: italic; color: #3b2a12; font-size: 13px;
}
.tw-panel > header > span { flex: 1; }
.tw-min { padding: 0 5px; line-height: 14px; font-size: 13px; background: #fbf1da; color: #3b2a12; border: 1px solid #8c7040; border-radius: 1px; font-style: normal; }
.tw-min:hover { filter: none; background: #fff; }
.tw-panel.collapsed > .tw-body { display: none; }
.tw-panel.scene > .tw-body { padding: 0; line-height: 0; }
.tw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tw-table th { background: var(--parch-2); font-family: var(--sans); font-variant: normal; font-weight: bold; color: #3b2a12; text-align: left; padding: 4px 6px; border-bottom: 1px solid #c9ad72; font-size: 12.5px; }
.tw-table td { padding: 4px 6px; border-bottom: 1px solid #ead9b0; }
.tw-table tr:nth-child(even) td { background: #fbf3df; }
.tw-table tr:hover td { background: #fff7e3; }
.tw-table a { color: var(--primary-dark); font-weight: bold; }
.tw-x { color: #c0272d !important; font-weight: bold; text-decoration: none !important; font-size: 15px; }
.tw-panel .lvl { background: #4b7a24; }

.vscene-wrap { position: relative; }
.vscene { width: 100%; height: auto; display: block; }
.vscene .bld, .vscene .lvlbadge { cursor: pointer; }
.vscene .bld:hover { filter: brightness(1.18) drop-shadow(0 0 4px rgba(255,240,180,.9)); }
.vscene .lvlbadge text { font: bold 12px var(--sans); fill: #fff; pointer-events: none; }
.vscene .lvlbadge:not(.is-building):hover rect:nth-of-type(2) { fill: #5f9a2e; }
.vscene .smoke circle { animation: smoke 3.5s ease-out infinite; transform-box: fill-box; }
.vscene .smoke circle:nth-child(2) { animation-delay: 1.7s; }
@keyframes smoke { 0% { opacity: 0; transform: translate(0, 4px) scale(.6); } 30% { opacity: .9; } 100% { opacity: 0; transform: translate(6px, -14px) scale(1.6); } }
.vscene .mill { animation: mill 9s linear infinite; transform-origin: 0px -36px; }
@keyframes mill { to { transform: rotate(360deg); } }
.vscene .flag { animation: flag 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: left center; }
@keyframes flag { 50% { transform: scaleX(.82) skewY(4deg); } }

.unit-ico { display: inline-block; width: 20px; height: 20px; vertical-align: -5px; margin-right: 5px; }
.unit-ico .uico { width: 20px; height: 20px; display: block; }

/* ---------------- kaart ---------------- */
.mappanel > .tw-body { padding: 0; position: relative; }
.map-toolbar { display: flex; align-items: center; gap: 6px; padding: 6px 8px; flex-wrap: wrap; border-bottom: 1px solid #c9ad72; background: #f3e3bb; }
.map-toolbar .sep { width: 10px; }
.map-toolbar .legend { margin: 0 0 0 10px; }
.wmap { position: relative; height: calc(100vh - 260px); min-height: 460px; background: #6f8f2a; overflow: hidden;
  border: 4px solid #8a6a3a; box-shadow: inset 0 0 0 1px #d9b878; }
.wmap-canvas { display: block; cursor: grab; touch-action: none; outline: none; }
.wmap-tip { position: absolute; pointer-events: none; background: var(--parch); border: 1px solid var(--border); color: #3b2a12; padding: 6px 9px;
  font-size: 12px; line-height: 1.45; box-shadow: 0 4px 12px rgba(0,0,0,.4); min-width: 170px; border-top: 3px solid var(--accent); z-index: 3; }
.map-pop { position: absolute; width: 320px; background: var(--parch); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 4; }
.map-pop header { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px; background: linear-gradient(180deg, #f3dca6, #dcbb79); border-bottom: 1px solid var(--border); color: #3b2a12; }
.map-pop-actions { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.danger-btn { background: linear-gradient(180deg, #C73A2F, var(--red)) !important; border-color: #7E1A14 !important; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 4px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.6); }
.map-tip { position: fixed; pointer-events: none; background: var(--parch); color: #3b2a12; border: 1px solid var(--border); padding: 5px 9px; font-size: 12px; z-index: 50; border-top: 3px solid var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,.35); }

/* ---------------- rapport ---------------- */
.report-units td, .report-units th { text-align: center; }
.report-units td:first-child, .report-units th:first-child { text-align: left; }
.loss { color: var(--red); }
.result-banner { padding: 10px 14px; border-radius: var(--radius); color: #fff; font-family: var(--serif); font-size: 18px; margin-bottom: 12px; }
.result-banner.green { background: var(--green); } .result-banner.yellow { background: var(--yellow); } .result-banner.red { background: var(--red); } .result-banner.blue { background: var(--primary); }

.error { color: var(--red); font-weight: 600; min-height: 20px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bg); color: #fff; padding: 10px 18px; border-radius: var(--radius); border-left: 4px solid var(--primary); box-shadow: 0 6px 20px rgba(0,0,0,.4); z-index: 100; max-width: 90vw; }
.toast.err { border-left-color: var(--red); }

.quest { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--parch-3); }
.quest .q-state { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: bold; background: var(--parch-3); flex: none; }
.quest.done .q-state { background: var(--green); }
.quest.claimed { opacity: .55; }
.quest .q-body { flex: 1; }
.advisor { display: flex; gap: 12px; align-items: flex-start; background: var(--parch-2); border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; }
.advisor img { width: 40px; height: 40px; }
.post { border-bottom: 1px solid var(--parch-3); padding: 8px 0; white-space: pre-wrap; }
.msg-body { white-space: pre-wrap; background: #fffaf0; border: 1px solid var(--parch-3); padding: 12px; border-radius: var(--radius); }
footer { text-align: center; color: var(--head-text); font-size: 12px; padding: 0 0 24px; }

/* ---------------- Tribes+ ---------------- */
.quickbar { background: var(--parch-2); border-bottom: 1px solid #b49a66; }
.quickbar-inner { max-width: 1280px; margin: 0 auto; padding: 3px 16px; display: flex; gap: 2px; flex-wrap: wrap; align-items: center; font-size: 12.5px; }
.quickbar a { color: var(--primary-dark); font-weight: bold; padding: 3px 8px; border-radius: 3px; }
.quickbar a:hover { background: var(--parch); text-decoration: none; }
.qb-sep { width: 1px; height: 16px; background: #b49a66; margin: 0 6px; }
.qb-hint { margin-left: auto; color: var(--ink-soft); font-size: 11px; }
.plus-btn { background: linear-gradient(180deg, var(--gold-l), var(--accent)); border-color: var(--accent-dark); color: var(--on-accent); }
.plus-btn:disabled { background: #D8CBB6; border-color: #B3A58E; color: var(--ink-soft); }
.farm-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 22px; padding: 0; margin: 0 1px; font-weight: bold;
  border-radius: 3px; color: #fff; border: 1px solid rgba(0,0,0,.35); font-size: 12px; }
.farm-A { background: linear-gradient(180deg, #4fa04a, #2e7a2a); }
.farm-B { background: linear-gradient(180deg, var(--primary-light), var(--primary)); }
.farm-C { background: linear-gradient(180deg, #9A5A2A, #6E3A12); }
tr.farm-sent td { background: #e3f1d2 !important; }
.map-pop-farm, .map-pop-marks { padding: 4px 8px 8px; border-top: 1px solid #e0cc9c; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.mark-row { display: flex; align-items: center; gap: 3px; width: 100%; }
.mark-row > span:first-child { width: 48px; }
.swatch { width: 16px; height: 16px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.5); display: inline-block; }
.swatch.on { outline: 2px solid #3b2a12; outline-offset: 1px; }
.plus-hero { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; padding: 16px 18px;
  background: linear-gradient(120deg, var(--bg) 0%, var(--primary-dark) 65%, var(--primary) 120%); color: var(--ivory); border-radius: 4px; }
.plus-hero h1 { color: var(--ivory); font-size: 30px; margin: 0 0 4px; } .plus-hero h1 i { color: var(--accent); font-style: normal; }
.plus-hero p { max-width: 560px; margin: 0; color: var(--ivory); }
.plus-links { display: flex; gap: 6px; flex-wrap: wrap; }
.plus-free { color: var(--green); font-weight: bold; text-transform: uppercase; font-size: 11px; }
.plus-up { color: var(--green); font-weight: bold; margin-left: 1px; }
.table-scroll { overflow-x: auto; }
input.n.tiny { width: 54px; padding: 3px 4px; }

/* "Genoeg grondstoffen om …" */
.ready-at { font-size: 11.5px; color: #2e6b1e; margin-top: 2px; white-space: nowrap; }
.ready-at .timer { font-weight: bold; }
.ready-at.bad { color: var(--red); font-weight: 600; }

/* ---------------- nieuws ---------------- */
.news-item { padding: 10px 0; border-bottom: 1px solid var(--parch-3); }
.news-item:last-child { border-bottom: 0; }
.news-item header { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; justify-content: space-between; }
.news-item h3 { margin: 0; font-size: 17px; }
.news-item.pinned h3 { color: var(--accent-dark); }
.news-body { white-space: pre-wrap; margin: 6px 0; }
.news-wrap { padding: 4px 12px; }

/* ---------------- mobiel ---------------- */
.mobile-tabs, .mobile-sheet { display: none; }
@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  /* header compact */
  .topbar-inner { padding: 6px 10px; gap: 8px; flex-wrap: nowrap; }
  .brand img { width: 30px; height: 30px; }
  .brand .word { font-size: 17px; }
  .brand .world { display: none; }
  nav.menu { display: none; }
  .userbox { margin-left: auto; font-size: 11px; }
  .userbox br, .userbox a[data-act=logout] { display: none; }
  /* grondstoffenbalk: één compacte rij */
  .subbar-inner { padding: 6px 10px; gap: 8px; }
  .vswitch { width: 100%; }
  .vswitch select { flex: 1; min-width: 0; }
  .resbar { margin-left: 0; width: 100%; justify-content: space-between; gap: 6px; font-size: 13px; }
  .resbar .cap { display: none; }
  .alert-incoming, .protect { width: 100%; text-align: center; }
  .quickbar-inner { flex-wrap: nowrap; overflow-x: auto; padding: 4px 10px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  /* flex-shrink: 0 — anders krimpen de knoppen (min-width 44px vervangt min-width:auto) en schuift de tekst over elkaar */
  .quickbar a { white-space: nowrap; flex-shrink: 0; }
  .qb-hint { display: none; }
  main { margin: 10px auto 20px; padding: 0 8px; }
  .card, .tw-frame { padding: 10px; }
  .card { overflow-x: auto; }
  .tw-body { overflow-x: auto; }
  h1 { font-size: 21px; }
  footer { display: none; }
  /* knoppen en invoer groot genoeg voor duimen */
  button, .btn { padding: 9px 14px; }
  button.small, .btn.small { padding: 6px 10px; font-size: 13px; }
  input, select, textarea { font-size: 16px; } /* voorkomt inzoomen op iOS */
  input.n { width: 76px; }
  .tw-table td, .tw-table th, td, th { padding: 6px 5px; }
  /* onderbalk */
  .mobile-tabs { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--bg);
    border-top: 3px solid var(--primary); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-tabs a { flex: 1; color: var(--head-text); text-align: center; font-size: 11px; padding: 6px 0 7px; position: relative; text-decoration: none; }
  .mobile-tabs a.active { color: #fff; background: rgba(163,68,28,.6); }
  .mobile-tabs .mt-ico { display: block; font-size: 20px; line-height: 24px; }
  .mobile-tabs .badge { position: absolute; top: 2px; left: 55%; margin: 0; }
  .mobile-sheet { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 39; background: var(--parch);
    border-top: 3px solid var(--accent); border-radius: 14px 14px 0 0; padding: 8px 0 calc(70px + env(safe-area-inset-bottom));
    transform: translateY(105%); transition: transform .22s ease; box-shadow: 0 -10px 40px rgba(0,0,0,.5); max-height: 80vh; overflow-y: auto; }
  body.menu-open .mobile-sheet { transform: translateY(0); }
  .mobile-sheet a { display: flex; justify-content: space-between; padding: 13px 20px; border-bottom: 1px solid var(--parch-3); color: var(--bg); font-weight: 600; }
  .ms-head { display: flex; justify-content: space-between; padding: 6px 20px 10px; border-bottom: 2px solid var(--parch-3); }
  .mobile-sheet a.ms-close { padding: 0 4px; border: 0; }
  .mobile-sheet a.ms-logout { color: var(--red); }
  /* dorp: scène bovenaan, panelen eronder */
  .tw-village { grid-template-columns: 1fr; gap: 0; }
  /* kaart: bijna het hele scherm, popup als onderblad */
  .map-toolbar .legend, .map-toolbar > .small.muted { display: none; }
  .wmap { height: calc(100vh - 290px); min-height: 360px; border-width: 2px; }
  .map-pop { position: fixed; left: 0 !important; right: 0; top: auto !important; bottom: calc(60px + env(safe-area-inset-bottom)); width: auto;
    border-radius: 12px 12px 0 0; max-height: 62vh; overflow-y: auto; z-index: 45; }
  .wmap-tip { display: none; }
  .grid2 { gap: 0; }
  .plus-hero { padding: 12px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; }
  .tabs a { white-space: nowrap; }
}

/* Rekruteren op mobiel: elke eenheid als gestapelde kaart */
@media (max-width: 760px) {
  .rc-table, .rc-table tbody { display: block; }
  .rc-table tr:first-child { display: none; }
  .rc-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; padding: 10px 4px; border-bottom: 1px solid #d9c79c; }
  .rc-table td { display: block; border: 0; padding: 0; text-align: left; }
  .rc-table td:first-child, .rc-table td:nth-child(2), .rc-table td:last-child { grid-column: 1 / -1; }
  .rc-table td[data-l]::before { content: attr(data-l) ": "; color: #7a6136; font-size: 13px; }
  .rc-table td:last-child .row { flex-wrap: nowrap; }
  .rc-table td:last-child input.n { flex: 1; min-width: 0; }
  .rc-table td:last-child button { padding: 10px 18px; }
}

/* ------------------------------------------------------------ hulpklassen (vervangen inline styles) */
#userbox .ub-name { color: #fff; }
#userbox .ub-tribe { color: var(--gold-l); }
#userbox .ub-logout { color: var(--accent); }
#userbox .ub-admin { color: #ffd27a; }
.txt-red { color: var(--red); }
.txt-green { color: var(--green); }
.gap-s { gap: 6px; }
.unit-inputs { display: flex; flex-wrap: wrap; }
.unit-input { display: flex; align-items: center; gap: 4px; margin: 4px 12px 4px 0; }
tr.row-current { font-weight: bold; background: rgba(163, 68, 28, .08); }
tr.row-me { font-weight: bold; background: rgba(232, 169, 58, .2); }
.mt { margin-top: 12px; }
.mb-s { margin-bottom: 6px; }
.pad { padding: 8px; }
.full { width: 100%; }
.grow { flex: 1; }
.lbl-m { width: 80px; }
.lbl-s { width: 60px; }
.w-tag { width: 100px; }
.notes-area { min-height: 360px; }

/* ------------------------------------------------------------ meldingen bovenaan */
.alerts { max-width: 1180px; margin: 10px auto 0; padding: 0 12px; display: grid; gap: 8px; }
.alerts:empty { display: none; }
.alert { padding: 10px 14px; border-radius: var(--radius); border: 1px solid; font-size: 14px; }
.alert a { font-weight: bold; }
.alert-warn { background: #FBEBD0; border-color: var(--accent); color: #5A3410; }
.alert-season { background: linear-gradient(90deg, #fff3cf, #f6e0a8); border-color: #c9961a; color: #4a3200; }
.alert-info { background: #F7E3D6; border-color: var(--primary); color: #5A2410; }
.alert-ok { background: #e7f5e9; border-color: var(--green); color: #18451f; margin-bottom: 12px; }
.alert-inline { background: #FBEBD0; border-left: 3px solid var(--accent); padding: 6px 10px; margin: 0 0 10px; }
.temp-pw { font-size: 17px; padding: 2px 8px; background: #fff; border: 1px dashed var(--green); user-select: all; }
.mono { font-family: ui-monospace, monospace; }
.rebels { color: var(--red); }

/* ------------------------------------------------------------ wachtwoordformulier */
.pw-form label { display: block; margin-bottom: 8px; font-size: 13px; color: var(--ink-soft); }
.pw-form input { display: block; width: 100%; max-width: 320px; margin-top: 3px; }

/* ------------------------------------------------------------ seizoen en eregalerij */
.season-results { padding: 4px 8px 8px; }
.season-results table { width: 100%; }
.season-results td:first-child { width: 40px; text-align: center; }
.season-results th.num, .season-results td.num { text-align: right; width: 110px; }
.season-honours { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 10px 4px 0; font-size: 14px; }
.hof { border-top: 1px solid var(--parch-3); padding: 6px 8px; }
.hof summary { cursor: pointer; padding: 6px 0; }
.rank-line { display: flex; gap: 8px; padding: 5px 10px; border-bottom: 1px solid var(--parch-3); }
.rank-line .num { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ beheer */
.admin-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 12px; }
.admin-players td { vertical-align: middle; }
.admin-players tr.is-blocked td { opacity: .6; }
.admin-actions { white-space: nowrap; }
.admin-actions button { margin: 2px 2px 2px 0; }
.tag { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; background: var(--parch-3); color: var(--ink); }
.tag-admin { background: var(--primary); color: #fff; }
.tag-blocked { background: var(--red); color: #fff; }
button.danger { background: var(--red); border-color: #8a1a1f; color: #fff; }
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-actions { white-space: normal; }
  .alerts { margin-top: 6px; }
}

/* ------------------------------------------------------------ dorpsscène: in aanbouw */
.vscene .lvlbadge.is-building rect:nth-of-type(2) { animation: badge-glow 2.4s ease-in-out infinite; }
.vscene .lvlbadge.is-building:hover rect:nth-of-type(2) { fill: #d27a1a; }
.vscene .badge-timer rect { fill: rgba(43, 28, 19, .85); stroke: #f2a33a; stroke-width: 1; }
.vscene .badge-timer text { font: bold 10.5px var(--sans); fill: #ffd27a; font-variant-numeric: tabular-nums; }
.vscene .crane-load { animation: hoist 3.2s ease-in-out infinite; }
@keyframes hoist { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes badge-glow { 0%, 100% { filter: none; } 50% { filter: drop-shadow(0 0 4px rgba(255, 190, 90, .95)); } }
@media (prefers-reduced-motion: reduce) {
  .vscene .crane-load, .vscene .lvlbadge.is-building rect:nth-of-type(2) { animation: none; }
}

/* ------------------------------------------------------------ bouwwachtrij verslepen */
.bq-table .q-handle { width: 30px; padding-right: 0; text-align: center; }
.q-grip {
  min-width: 28px; min-height: 28px; padding: 0; border: 1px solid transparent; border-radius: 4px; background: none;
  color: var(--ink-soft); font-size: 18px; line-height: 1; cursor: grab; touch-action: none; user-select: none;
}
.q-grip:hover, .q-grip:focus-visible { background: rgba(163, 68, 28, .1); border-color: rgba(163, 68, 28, .35); color: var(--primary); }
.q-lock { font-size: 13px; opacity: .7; }
.q-sorting { cursor: grabbing; }
.q-sorting .q-grip { cursor: grabbing; }
tr.q-dragging { position: relative; z-index: 2; transform: translateY(var(--dy, 0)); background: #fff8e4;
  box-shadow: 0 8px 20px -6px rgba(43, 33, 21, .45); outline: 2px solid var(--primary); }
tr.q-dragging td { background: #fff8e4; }
.q-hint { margin: 6px 0 0; }
@media (max-width: 760px) { .q-grip { min-width: 40px; min-height: 40px; font-size: 22px; } }

/* ------------------------------------------------------------ tweestapsverificatie */
.tf-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 12px; }
.tf-qr { margin: 10px 0 6px; }
.tf-qr img { display: block; width: 200px; height: 200px; image-rendering: pixelated; border: 6px solid #fff; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.tf-secret { font-family: ui-monospace, Consolas, monospace; background: #fff8e4; padding: 2px 6px; border-radius: 4px; word-break: break-all; }
.code-input { width: 9em; font-size: 1.3rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.tag-2fa { background: #1f6f3a; color: #fff; }
/* ------------------------------------------------------------ beheer: accounts en wereld */
.lbl-block { display: block; font-weight: bold; margin: 8px 0 4px; }
.ad-names { width: 100%; max-width: 420px; font: inherit; }
.ad-status td:first-child { width: 170px; color: var(--ink-soft); }
.creds { margin: 8px 0; max-width: 520px; }
.creds-text { display: block; width: 100%; max-width: 520px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin: 6px 0; }
.wf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 16px; margin: 8px 0; }
.wf-field { display: grid; gap: 3px; font-size: 13px; }
.wf-field input { width: 100%; }
.wf-check { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.wf-new { margin-top: 14px; border-top: 1px solid var(--line, #c9b27f); padding-top: 10px; }
.wf-new summary { cursor: pointer; font-weight: bold; color: var(--danger, #a1261b); }
#ad-world h3 { font-size: 14px; margin: 12px 0 4px; }
.tf-open { display: none; }
@media (max-width: 760px) {
  .tf-open { display: inline-flex; align-items: center; min-height: 44px; margin: 0 0 8px; padding: 8px 12px; background: var(--primary); color: #fff; border-radius: 6px; text-decoration: none; font-weight: bold; }
}

/* ------------------------------------------------------------ interface-iconen (ui-icons.js) */
.ic { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
.mt-ico .ic { width: 22px; height: 22px; vertical-align: middle; }
.tw-x .ic, button .ic:only-child { vertical-align: middle; }
.result-banner .ic { width: 1.3em; height: 1.3em; }
.q-state .ic { width: 18px; height: 18px; }
.medal { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; font-weight: bold; font-size: .85em;
  color: #2b2115; border: 1px solid rgba(0, 0, 0, .3); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.medal-1 { background: linear-gradient(#ffe48a, #d4a017); }
.medal-2 { background: linear-gradient(#f2f2f2, #a9adb3); }
.medal-3 { background: linear-gradient(#f0b98a, #a8642c); color: #fff; }

/* ------------------------------------------------------------ toegankelijkheid: focus en tikvlakken */
/* Zichtbare focusring voor toetsenbordgebruikers (niet bij klikken met de muis). */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.topbar :focus-visible, .mobile-tabs :focus-visible, .mobile-sheet :focus-visible, #userbox :focus-visible { outline-color: #ffd27a; }
button:focus-visible, .btn:focus-visible { box-shadow: 0 0 0 5px rgba(163, 68, 28, .25); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--primary); outline-offset: 0; }
.vscene .bld:focus-visible, .vscene .lvlbadge:focus-visible { outline: none; filter: drop-shadow(0 0 4px var(--primary-light)); }

/* Tikvlakken van minimaal 44×44 px op telefoons en touchschermen (WCAG 2.5.5 / Apple HIG). */
@media (max-width: 760px), (pointer: coarse) {
  button, .btn, a.button, select, textarea, input:not([type="checkbox"]):not([type="radio"]) { min-height: 44px; }
  button.small, .btn.small { min-height: 44px; padding-inline: 12px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 11px 6px 11px 0; vertical-align: middle; }
  label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { display: inline-flex; align-items: center; min-height: 44px; }
  .tabs a { display: inline-flex; align-items: center; min-height: 44px; padding-inline: 14px; }
  .quickbar-inner { gap: 4px; }
  .quickbar a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 10px; }
  .farm-btn { width: 44px; height: 44px; margin: 2px; }
  .card-head a, .tw-body a, .pad a, .rank-line a { display: inline-flex; align-items: center; min-height: 44px; }
  .tw-body td > a, .tw-table td > a, td > a, a.small, a[data-act="switchvillage"] { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }
  .brand { display: inline-flex; align-items: center; min-height: 44px; }
  summary { min-height: 44px; display: flex; align-items: center; }
  .map-toolbar button { min-width: 44px; }
  /* Kleine inline-bediening: groter, onzichtbaar tikvlak zonder dat de layout verschuift. */
  .tw-min, .tw-x, .maxlink, .ms-close, #userbox a, .q-lock { position: relative; }
  .tw-min::before, .tw-x::before, .maxlink::before, .ms-close::before, #userbox a::before {
    content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%);
  }
  .hub-nav a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ------------------------------------------------------------ centrale site (hub): /account en /beheer */
[hidden] { display: none !important; }
.hub-head { background: linear-gradient(180deg, var(--bg-2), var(--bg)); border-bottom: 3px solid var(--primary); box-shadow: 0 2px 0 var(--accent); color: #fff; }
.hub-head-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 8px 16px; flex-wrap: wrap; }
.hub-nav { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; margin-left: auto; }
.hub-nav a { color: var(--head-text); font-weight: bold; padding: 4px 2px; }
.hub-nav a[aria-current="page"] { color: var(--ivory); box-shadow: inset 0 -3px 0 var(--accent); }
.hub-main { max-width: 1240px; margin: 14px auto 40px; padding: 0 12px; }
.hub-main > .tw-frame { margin: 0; }
.world-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.world-card { background: #fffaf0; border: 1px solid #c9ad72; border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; min-width: 0; }
.world-card.is-busy { border-color: var(--primary); }
.world-card.is-error { border-color: var(--red); }
.world-card h3 { margin: 0; overflow-wrap: anywhere; }
.world-card .wc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.world-card .wc-sub { color: var(--ink-soft); font-size: 12.5px; overflow-wrap: anywhere; }
.world-card .wc-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.world-card .wc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; font-size: 12.5px; }
.world-card .wc-stats b { display: block; font-size: 16px; color: var(--bg); }
.world-card details { border-top: 1px solid #ead9b0; padding-top: 6px; }
.world-card summary { cursor: pointer; font-weight: bold; color: var(--bg); }
.world-card .wc-error { color: #8A1A14; background: #FBE3DF; border-radius: 4px; padding: 6px 8px; font-size: 12.5px; overflow-wrap: anywhere; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: bold; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-ok { color: #1f6f3a; background: #e3f3e6; }
.pill-warn { color: #8a5a00; background: #fbefd2; }
.pill-err { color: #8A1A14; background: #FBE3DF; }
.pill-busy { color: var(--primary); background: #F7E3D6; }
.hub-log td { font-size: 12.5px; }
.news-admin .news-item { border-bottom: 1px solid #ead9b0; padding: 6px 0; }
.sso-box { max-width: 460px; margin: 12vh auto 0; padding: 0 12px; }
@media (max-width: 760px) {
  .world-cards { grid-template-columns: 1fr; }
  .world-card .wc-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hub-nav { margin-left: 0; width: 100%; }
  .hub-main { padding: 0 8px; }
  .hub-accounts td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; color: var(--ink-soft); }
  .hub-accounts tr { display: block; border-bottom: 1px solid #c9ad72; padding: 4px 0; }
  .hub-accounts th { display: none; }
  .hub-accounts td { display: block; border: 0; }
}
