/* Hradiště – dark, flat, modern. Original styles (T12).
   Tokens first; components below. Atmosphere (ridges, grain, vignette) sits behind content only. */
:root {
  color-scheme: dark;
  /* surfaces: deep blue-grey, lighter = higher */
  --bg-0: #090c11; --bg-1: #0e1218; --bg-2: #131922; --bg-3: #19212b; --bg-4: #212b37; --bg-5: #2a3544;
  /* hairlines */
  --hair: #ffffff12; --hair-2: #ffffff1f; --hair-3: #ffffff33;
  /* text */
  --text: #d3d9e2; --text-hi: #eef1f6; --text-2: #929eaf; --text-3: #647080;
  /* one accent: muted brass */
  --accent: #c4a768; --accent-hi: #dcc58d; --accent-lo: #8d7a4b; --accent-bg: #c4a76818; --accent-bg2: #c4a76830; --accent-ink: #15110a;
  /* signal colours (muted) */
  --ok: #78b794; --bad: #dc7463; --warn: #d9a64d; --info: #84a9d2;
  --ok-bg: #78b79418; --bad-bg: #dc746318; --warn-bg: #d9a64d18; --info-bg: #84a9d218;
  /* shape, space, depth, motion */
  --r-sm: 4px; --r: 6px; --r-lg: 10px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --sh-1: 0 1px 2px #0007; --sh-2: 0 14px 34px -12px #000d, 0 2px 8px #0006;
  --ease: cubic-bezier(.2, .7, .2, 1); --t: .14s;
  --sans: ui-sans-serif, system-ui, "Segoe UI Variable Text", "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Segoe UI Variable Display", ui-sans-serif, system-ui, "Segoe UI", -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  /* film grain: feTurbulence, white speckle (used by body::after) */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1.1 -.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* legacy aliases (kept so older rules/inline code keep working) */
  --ink: var(--text); --muted: var(--text-2); --link: var(--accent-hi); --line: var(--hair-2); --line-soft: var(--hair);
}
* { box-sizing: border-box; }
html { background: linear-gradient(180deg, #0c1219 0%, #090c11 70%) fixed, var(--bg-0); scrollbar-color: #2b3646 transparent; scrollbar-width: thin; }
body {
  margin: 0; color: var(--text); font: 13.5px/1.5 var(--sans); letter-spacing: .005em; min-height: 100vh; display: flow-root;
  background: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a, .link { color: var(--accent-hi); cursor: pointer; text-decoration: none; font-weight: 500; transition: color var(--t); }
a:hover, .link:hover { color: var(--text-hi); text-decoration: underline; text-decoration-color: var(--accent-lo); text-underline-offset: 3px; }
.ic { width: 18px; height: 18px; vertical-align: -4px; flex: none; }
::selection { background: #c4a76850; color: var(--text-hi); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::-webkit-scrollbar { width: 10px; height: 10px; } ::-webkit-scrollbar-thumb { background: #2b3646; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #3a4659; background-clip: content-box; border: 2px solid transparent; } ::-webkit-scrollbar-track { background: transparent; }

#app { max-width: 1340px; margin: 0 auto; padding: 0 var(--s4) 56px; }

/* ---- Atmosphere (behind content only): ridges from icons.js (--art-ridge), light falloff + vignette, grain ---- */
html::before { content: ''; position: fixed; left: 0; right: 0; bottom: 0; height: 78vh; z-index: -3; pointer-events: none;
  background: var(--art-ridge) center bottom / cover no-repeat; opacity: .55; }
body::before { content: ''; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(1200px 560px at 82% -10%, #3d5f8a2e, transparent 70%), radial-gradient(900px 520px at 6% 108%, #c4a7680f, transparent 70%),
    radial-gradient(ellipse 125% 95% at 50% 42%, transparent 52%, #000000b0 100%); }
body::after { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: var(--grain); background-size: 240px; opacity: .06; }
body:has(.login)::before { background: radial-gradient(1000px 600px at 50% 18%, #3d5f8a38, transparent 70%), radial-gradient(ellipse 120% 90% at 50% 45%, transparent 45%, #000000c0 100%); }
html:has(.login)::before { height: 100vh; opacity: .85; }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 12px;
  background: #0d1219e6; -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--hair); border-top: none; border-radius: 0 0 var(--r-lg) var(--r-lg); box-shadow: 0 16px 30px -18px #000;
}
.topbar .title { display: inline-flex; align-items: center; gap: 9px; font: 600 12px/1 var(--display); letter-spacing: .22em; text-transform: uppercase; color: var(--accent-hi); }
.topbar .title::before { content: ''; width: 7px; height: 7px; background: var(--accent); transform: rotate(45deg); box-shadow: 0 0 10px var(--accent-lo); }
.topbar .res { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; align-items: center; }
.topbar .res > span {
  position: relative; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 4px 10px 6px;
  background: var(--bg-3); border: 1px solid var(--hair); border-radius: var(--r); font-variant-numeric: tabular-nums; font-size: 13px;
}
.topbar .res b { font-weight: 600; color: var(--text-hi); letter-spacing: .01em; }
.topbar .res .fill { position: absolute; left: 8px; right: 8px; bottom: 2px; height: 2px; border-radius: 2px; background: #ffffff14; overflow: hidden; }
.topbar .res .fill i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-lo), var(--accent)); transition: width .4s var(--ease); }
.topbar .res .fill i.hi { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.topbar .res > span:empty { display: none; }
.full { color: var(--bad) !important; }
.vswitch { display: inline-flex; gap: 4px; align-items: center; }
.vswitch select { max-width: 240px; font-weight: 500; }
.topbar .mini { background: transparent; }
.topbar #logout { margin-left: 2px; }

/* ---- Main navigation ---- */
.nav { display: flex; flex-wrap: wrap; gap: 2px; margin: var(--s3) 0 var(--s2); padding: 3px; align-items: center; background: #11171fcc; border: 1px solid var(--hair); border-radius: var(--r-lg); }
/* Each item is a split button (.ni): label = default page, caret (.nc) = menu of sub-pages. The pair shares hover/active state. */
.nav .ni { display: inline-flex; align-items: stretch; border: 1px solid transparent; border-radius: 7px; transition: background var(--t); }
.nav button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; font: 500 13px/1.2 var(--sans); color: var(--text-2); cursor: pointer;
  background: transparent; border: 0; border-radius: 7px; transition: background var(--t), color var(--t);
}
.nav .ni:has(.nc) > [data-tab] { padding-right: 6px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.nav .nc { padding: 6px 7px 6px 4px; border-top-left-radius: 0; border-bottom-left-radius: 0; opacity: .7; }
.nav .nc svg { display: block; transition: transform var(--t); }
.nav .nc[aria-expanded="true"] { background: #ffffff10; color: var(--accent-hi); opacity: 1; }
.nav .nc[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav button .ic { width: 16px; height: 16px; }
.nav button:hover { background: #ffffff0b; color: var(--text-hi); }
.nav .nc:hover { opacity: 1; }
.nav .ni.on { background: var(--bg-4); border-color: var(--hair); box-shadow: inset 0 -2px 0 var(--accent); }
.nav .ni.on > button { color: var(--text-hi); }
.nav .ni.on > button:hover { background: #ffffff0b; }
.nav .right { margin-left: auto; }
.nav .badge { margin-left: 2px; }
/* The menu is a child of <body> (positioned in px by app.js), so it survives page re-renders. */
#navmenu {
  position: absolute; z-index: 60; min-width: 190px; max-width: calc(100vw - 16px); max-height: min(70vh, 520px); overflow-y: auto; padding: 4px;
  background: var(--bg-3); border: 1px solid var(--hair-2); border-radius: var(--r-lg); box-shadow: var(--sh-2); display: flex; flex-direction: column; gap: 1px;
  animation: navmenu-in var(--t) var(--ease);
}
@keyframes navmenu-in { from { opacity: 0; transform: translateY(-3px); } }
#navmenu button {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 6px 10px; text-align: left; font: 500 13px/1.3 var(--sans);
  color: var(--text); background: transparent; border: 0; border-radius: var(--r); cursor: pointer; white-space: nowrap; transition: background var(--t), color var(--t);
}
#navmenu button:hover, #navmenu button:focus-visible { background: #ffffff0d; color: var(--text-hi); outline: none; }
#navmenu button:focus-visible { box-shadow: inset 0 0 0 1px var(--accent-lo); }
#navmenu button.on { color: var(--text-hi); background: var(--accent-bg); box-shadow: inset 2px 0 0 var(--accent); }
#navmenu .cnt { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.quickbar { display: flex; flex-wrap: wrap; gap: 2px 14px; background: transparent; border: 1px dashed var(--hair-2); border-radius: var(--r); padding: 5px 12px; margin: 0 0 var(--s2); font-size: 12.5px; }
.quickbar .link { color: var(--accent-hi); }
.notice {
  background: var(--warn-bg); border: 1px solid #d9a64d3d; color: #e4c386; padding: 7px 12px; margin: 0 0 var(--s3); border-radius: var(--r); font-size: 13px;
}
.sitbar { background: var(--info-bg); border-bottom: 1px solid #84a9d240; color: #bcd3ee; padding: 8px 14px; border-radius: 0 0 var(--r-lg) var(--r-lg); display: flex; gap: 12px; align-items: center; }

/* ---- Panels & boxes ---- */
.panel {
  background: #121821ed; border: 1px solid var(--hair); border-radius: var(--r-lg); padding: var(--s4) var(--s5); box-shadow: var(--sh-2);
}
.panel.wide { overflow-x: auto; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s4); align-items: start; }
.cols > div:not(.panel) > .box:first-child { margin-top: 0; }
@media (max-width: 820px) { .cols, .cols.rep { grid-template-columns: minmax(0, 1fr) !important; } }
h2 { margin: 0 0 var(--s3); font: 600 20px/1.25 var(--display); letter-spacing: -.01em; color: var(--text-hi); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
h2 .muted { font: 400 13px var(--sans); letter-spacing: 0; }
h2 > .ic { width: 24px; height: 24px; color: var(--accent); }
h3 {
  margin: 0; padding: 9px 12px; font: 600 11px/1.25 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--text-2);
  background: transparent; border-bottom: 1px solid var(--hair); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center;
}
h3 .muted { color: var(--text-3); font: 400 12px var(--sans); letter-spacing: 0; text-transform: none; }
h3 .link { color: var(--accent-hi); text-transform: none; letter-spacing: 0; font-size: 12px; }
.box {
  background: var(--bg-2); border: 1px solid var(--hair); border-radius: var(--r-lg); margin-bottom: var(--s3); overflow: hidden; box-shadow: var(--sh-1);
}
.box .in { padding: 10px 12px; }
.box > table.vis { border-radius: 0; }
details.box > summary { list-style: none; cursor: pointer; } details.box > summary::-webkit-details-marker { display: none; }
details > summary { cursor: pointer; }
fieldset { border: 1px solid var(--hair); border-radius: var(--r); margin: 0 0 var(--s3); padding: 8px 12px; background: #ffffff05; }
legend { font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); padding: 0 6px; }

/* ---- Sub navigation (tabs inside a page) ---- */
.subnav { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 var(--s4); border-bottom: 1px solid var(--hair-2); }
.subnav button {
  background: transparent; border: none; border-bottom: 2px solid transparent; padding: 7px 12px; margin-bottom: -1px;
  font: 500 13px var(--sans); color: var(--text-2); cursor: pointer; border-radius: var(--r) var(--r) 0 0; transition: color var(--t), background var(--t), border-color var(--t);
}
.subnav button:hover { background: #ffffff09; color: var(--text-hi); }
.subnav button.on { color: var(--text-hi); border-bottom-color: var(--accent); background: linear-gradient(180deg, transparent, var(--accent-bg)); }

/* ---- Tables ---- */
table.vis { width: 100%; border-collapse: separate; border-spacing: 0; background: transparent; font-variant-numeric: tabular-nums; }
table.vis th {
  text-align: left; padding: 7px 10px; font: 600 10.5px var(--sans); color: var(--text-3); letter-spacing: .08em; text-transform: uppercase;
  border-bottom: 1px solid var(--hair-2); white-space: nowrap; background: #ffffff04;
}
table.vis td { padding: 5px 10px; border-top: 1px solid var(--hair); vertical-align: middle; }
table.vis tr:first-child td { border-top: none; }
table.vis tr:hover td { background: #ffffff08; }
tr.unread td { font-weight: 600; color: var(--text-hi); }
tr.me td { background: var(--accent-bg) !important; color: var(--text-hi); font-weight: 600; }
tr.tot td { border-top: 1px solid var(--hair-3); background: #ffffff08 !important; font-weight: 600; }
tr.past td { opacity: .45; }
table.hq td:nth-child(2), table.hq td:nth-child(3), table.hq td:nth-child(4) { white-space: nowrap; }
@media (max-width: 760px) { table.hq td:nth-child(2) { white-space: normal; } }
table.rec td:nth-child(2) { white-space: normal; }
table.ut th, table.ut td { text-align: center; padding: 4px 5px; }
table.ut td:first-child, table.ut th:first-child { text-align: left; white-space: nowrap; }
table.ut td.zero { color: var(--text-3); opacity: .55; }
table.ut th .ic { width: 16px; height: 16px; }
@media (max-width: 760px) { table.ut .ic { width: 14px; height: 14px; } table.ut { font-size: 11px; } }
table.mail td { vertical-align: top; }
.cost { display: inline-flex; flex-wrap: wrap; gap: 2px 12px; }
.cost span { white-space: nowrap; }
.short { color: var(--bad); }
.ok { color: var(--ok); }
.muted { color: var(--text-2); font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { float: right; }
.pre { white-space: pre-wrap; word-break: break-word; }
b, strong { font-weight: 600; color: var(--text-hi); }

/* ---- Buttons & fields ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 13px; font: 600 12.5px/1.3 var(--sans); letter-spacing: .01em; color: var(--accent-hi); cursor: pointer; white-space: nowrap;
  background: var(--accent-bg); border: 1px solid #c4a76852; border-radius: var(--r);
  transition: background var(--t), border-color var(--t), color var(--t), transform .06s;
}
.btn:hover { background: var(--accent-bg2); border-color: var(--accent); color: #f1e1b8; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .38; cursor: default; background: #ffffff08; border-color: var(--hair); color: var(--text-2); transform: none; }
.btn.danger { color: #f0a698; background: var(--bad-bg); border-color: #dc746352; }
.btn.danger:hover { background: #dc746330; border-color: var(--bad); color: #ffcfc6; }
.btn .ic { width: 15px; height: 15px; }
.mini {
  display: inline-flex; align-items: center; gap: 4px; background: var(--bg-3); border: 1px solid var(--hair-2); border-radius: var(--r-sm);
  padding: 2px 8px; font: 500 12px var(--sans); cursor: pointer; color: var(--text); transition: background var(--t), border-color var(--t), color var(--t);
}
.mini:hover { background: var(--bg-5); border-color: var(--hair-3); color: var(--text-hi); }
.mini.danger { color: var(--bad); }
input, textarea, select {
  font: 13px var(--sans); padding: 5px 8px; border: 1px solid var(--hair-2); background: #0a0e14; color: var(--text); border-radius: var(--r);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
input:hover, textarea:hover, select:hover { border-color: var(--hair-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg2); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 14px; height: 14px; vertical-align: -2px; padding: 0; }
input[type=number], input[type=text], input:not([type]) { font-variant-numeric: tabular-nums; }
input[type=color] { padding: 1px 2px; background: #0a0e14; cursor: pointer; }
textarea { line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 14px; align-items: center; }
.form-grid > label { font-weight: 500; color: var(--text-2); }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.inline { display: inline-flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 0; }
.send-row { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.blk { display: block; margin: 4px 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--bg-3); border: 1px solid var(--hair-2); border-radius: 999px; padding: 2px 10px; margin: 2px; font-size: 12.5px; cursor: pointer; transition: background var(--t), border-color var(--t); }
.pill:hover { background: var(--bg-4); }
.pill:has(input:checked) { background: var(--accent-bg2); border-color: var(--accent-lo); color: var(--text-hi); }
.vpick { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0; font-size: 12.5px; }
.tag { display: inline-block; background: #ffffff0d; border: 1px solid var(--hair); border-radius: var(--r-sm); padding: 0 6px; font-size: 10.5px; font-weight: 600; letter-spacing: .04em; color: var(--text-2); margin-left: 4px; }
.badge { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 10.5px; font-weight: 700; line-height: 16px; display: inline-block; min-width: 17px; text-align: center; }

/* ---- Units ---- */
.un { white-space: nowrap; margin-right: 8px; display: inline-flex; align-items: center; gap: 4px; }
.units-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px 12px; }
.uin { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.uin input { width: 70px; }
.tpls { margin: 0 0 var(--s2); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ---- Village grid (list view) ---- */
.village-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: var(--s2); }
.bld {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; cursor: pointer; border-radius: var(--r-lg); position: relative;
  background: var(--bg-3); border: 1px solid var(--hair); transition: border-color var(--t), background var(--t), transform var(--t);
}
.bld:hover { background: var(--bg-4); border-color: var(--accent-lo); transform: translateY(-1px); }
.bld.zero { background: transparent; border-style: dashed; border-color: var(--hair-2); }
.bld.zero .ic.big { opacity: .4; }
.ic.big { width: 40px; height: 40px; padding: 8px; border-radius: 9px; background: var(--bg-5); border: 1px solid var(--hair); color: var(--text); }
.bld b { font-weight: 600; font-size: 13px; }
.bld .lvl { font-size: 12px; color: var(--text-2); }
.bld .lvl b { color: var(--accent-hi); font-size: 12px; }

/* ---- Village plan (abstract terrain-contour backdrop from village.js ground()) ---- */
.scene { position: relative; width: 100%; aspect-ratio: 16 / 10; min-height: 340px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--hair-2);
  box-shadow: inset 0 0 90px #000c, var(--sh-1); background: radial-gradient(ellipse 70% 60% at 50% 42%, #1a2634, #0c1118 78%); user-select: none; }
.scene > svg.ground { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene .cl { fill: none; stroke: #8fa7c4; stroke-width: 1px; opacity: .1; vector-effect: non-scaling-stroke; }
.scene .cl.ix { opacity: .2; }
.scene .path { fill: none; stroke: var(--accent); stroke-width: 1px; stroke-dasharray: 2 5; stroke-linecap: round; opacity: .32; vector-effect: non-scaling-stroke; }
.scene .road { stroke-dasharray: none; opacity: .24; }
.scene .rng { fill: none; stroke: #9fb4cf; stroke-width: 1px; stroke-dasharray: 1 6; opacity: .16; vector-effect: non-scaling-stroke; }
.scene .wall { fill: none; stroke: var(--accent); opacity: .55; vector-effect: non-scaling-stroke; }
.scene .stakes { fill: none; stroke: var(--accent-hi); stroke-dasharray: 2 7; opacity: .5; vector-effect: non-scaling-stroke; }
.scene .spot { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; cursor: pointer; z-index: 2; }
.scene .spot .medal { width: 54px; height: 54px; border-radius: 13px; display: grid; place-items: center; position: relative; color: var(--text);
  background: linear-gradient(180deg, #202a37, #151c26); border: 1px solid var(--hair-2); box-shadow: 0 10px 18px -8px #000, inset 0 1px 0 #ffffff12;
  transition: transform .14s var(--ease), box-shadow .14s var(--ease), border-color .14s; }
.scene .spot .medal .ic { width: 28px; height: 28px; }
.scene .spot:hover .medal { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg2), 0 14px 22px -8px #000; }
.scene .spot.zero .medal { background: #0f151cb0; border-style: dashed; box-shadow: none; }
.scene .spot.zero .medal .ic { opacity: .38; }
.scene .spot .lv { position: absolute; right: -7px; top: -7px; min-width: 21px; height: 21px; padding: 0 5px; border-radius: 11px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 700 11px var(--sans); border: 2px solid #0e1319; font-variant-numeric: tabular-nums; }
.scene .spot .lv.up { background: var(--ok); }
.scene .spot .nm { margin-top: 6px; padding: 1px 8px; border-radius: var(--r-sm); background: #0a0e14c4; color: var(--text-2); font: 500 11px var(--sans); white-space: nowrap; border: 1px solid var(--hair); }
.scene .spot:hover .nm { color: var(--text-hi); }
.scene .spot.zero .nm { opacity: .6; }
.scene-tools { display: flex; justify-content: space-between; align-items: center; margin: 0 0 var(--s2); gap: var(--s2); flex-wrap: wrap; }
@media (max-width: 600px) { .scene .spot .medal { width: 42px; height: 42px; border-radius: 10px; } .scene .spot .medal .ic { width: 22px; height: 22px; } .scene .spot .nm { display: none; } }

/* ---- Login ---- */
.login { max-width: 380px; margin: 13vh auto 0; }
.login .topbar { position: static; border-radius: 14px 14px 0 0; border: 1px solid var(--hair-2); border-bottom: none; justify-content: center; padding: 26px 18px 20px; background: #111720f0; flex-direction: column; gap: 8px; box-shadow: none; }
.login .topbar .title { font-size: 20px; letter-spacing: .34em; padding-left: .34em; color: var(--text-hi); flex-direction: column; gap: 14px; }
.login .topbar .title::before { width: 9px; height: 9px; }
.login .topbar .res { margin: 0; }
.login .topbar .res.muted { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.login .panel { border-radius: 0 0 14px 14px; border: 1px solid var(--hair-2); border-top: 1px solid var(--hair); background: #111720f0; box-shadow: 0 30px 70px -20px #000; }
.login label { display: block; margin: 12px 0 5px; font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.login input { width: 100%; padding: 9px 11px; }
.login .row { display: flex; gap: 8px; margin-top: 18px; }
.login .row .btn { flex: 1; padding: 9px; }
.login .row .btn[name=register] { color: var(--text); background: transparent; border-color: var(--hair-2); }
.login .row .btn[name=register]:hover { background: #ffffff0b; border-color: var(--hair-3); }
.err { color: var(--bad); min-height: 1.4em; margin-top: 8px; }

/* ---- Admin console ---- */
.console {
  background: #070a0e; color: #c9d1dc; font: 12px/1.5 var(--mono); padding: 10px 12px; height: 360px;
  overflow: auto; white-space: pre-wrap; border-radius: var(--r); border: 1px solid var(--hair); box-shadow: inset 0 2px 10px #000;
}
.console .prompt { color: var(--accent-hi); } .console .tool { color: var(--info); } .console .done { color: var(--ok); } .console .error { color: var(--bad); }

/* ---- Reports ---- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: 0; box-shadow: 0 0 0 3px #ffffff0d; }
.dot.win { background: var(--ok); } .dot.win_loss { background: var(--warn); } .dot.loss { background: var(--bad); }
.dot.scout, .dot.support { background: var(--info); } .dot.trade { background: #b58d62; } .dot.info { background: #7e8a99; } .dot.event { background: var(--accent); }
.outcome { padding: 10px 14px !important; font: 600 14px var(--display) !important; letter-spacing: 0 !important; text-transform: none !important; color: var(--text-hi) !important; border-left: 3px solid transparent; }
.outcome.win { background: var(--ok-bg) !important; border-left-color: var(--ok); } .outcome.win_loss { background: var(--warn-bg) !important; border-left-color: var(--warn); }
.outcome.loss { background: var(--bad-bg) !important; border-left-color: var(--bad); }
.outcome.scout, .outcome.support { background: var(--info-bg) !important; border-left-color: var(--info); }
.outcome.trade, .outcome.info, .outcome.event { background: #ffffff08 !important; border-left-color: var(--hair-3); }
.mods { background: #ffffff06; border: 1px solid var(--hair); padding: 5px 10px; border-radius: var(--r); font-size: 12.5px; }
.conquered { font: 600 16px var(--display); color: var(--ok); }
.cols.rep { grid-template-columns: minmax(0, 1fr) 260px; }
@media (max-width: 820px) { .cols.rep { grid-template-columns: 1fr; } }
.star { color: var(--text-3); font-size: 16px; } .star.on { color: var(--accent); text-shadow: 0 0 8px var(--accent-lo); }
.note { background: var(--warn-bg); }

/* ---- Mail, forum, BB-codes ---- */
.post h3 { justify-content: flex-start; } .post h3 .right { margin-left: auto; float: none; }
.post.new { border-color: var(--accent-lo); box-shadow: 0 0 0 3px var(--accent-bg); }
.preview { font-weight: normal; max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
blockquote { margin: 6px 0; padding: 5px 12px; border-left: 2px solid var(--accent-lo); background: #ffffff06; border-radius: 0 var(--r) var(--r) 0; color: var(--text-2); }
.bb { word-break: break-word; line-height: 1.6; } .bb-small { font-size: 11px; } .bb-large, .bb-big { font-size: 18px; }
.bb details { background: #ffffff06; border-radius: var(--r); padding: 3px 8px; }
.bbbar { display: flex; flex-wrap: wrap; gap: 3px; margin-bottom: 4px; }
.fh { background: none; color: var(--text-hi); padding: 0; font: 600 17px var(--display); letter-spacing: -.005em; text-transform: none; margin: 4px 0 var(--s3); border: none; }
.pager { margin: var(--s2) 0; display: flex; gap: 6px; }
.news > div { padding: 5px 0; border-bottom: 1px solid var(--hair); font-size: 13px; }
.online { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.online.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.rel3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin-bottom: var(--s3); }
.rel3 .col { background: #ffffff06; border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 10px; }
@media (max-width: 760px) { .rel3 { grid-template-columns: 1fr; } }
code { background: #ffffff0f; padding: 1px 5px; border-radius: var(--r-sm); font: 12px var(--mono); word-break: break-all; color: var(--accent-hi); }

/* ---- Progress bits ---- */
.bar { display: inline-block; width: 100px; height: 6px; background: #ffffff14; border-radius: 4px; vertical-align: middle; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-lo), var(--accent)); border-radius: 4px; transition: width .4s var(--ease); }
.tierdot { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #ffffff0d; border: 1px solid var(--hair-2); font-size: 11px; margin-right: 2px; color: var(--text-3); }
.tierdot.on { background: var(--accent-bg2); border-color: var(--accent); color: var(--accent-hi); font-weight: 700; }
.full-cell { color: var(--bad); font-weight: 600; }
.quest { border-bottom: 1px solid var(--hair); padding: 10px 12px; }
.quest:last-child { border-bottom: none; }
.quest.done { background: linear-gradient(90deg, var(--ok-bg), transparent); }
.qhead { display: flex; gap: 10px; align-items: center; margin-bottom: 3px; font: 600 14px var(--sans); color: var(--text-hi); }
.qhead .btn { margin-left: auto; }
.reward { font-size: 12.5px; margin-top: 4px; color: var(--text-2); }
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2); }
@media (max-width: 760px) { .calendar { grid-template-columns: repeat(3, 1fr); } }
.day { background: #ffffff05; border: 1px solid var(--hair); border-radius: var(--r-lg); padding: 8px; font-size: 12px; min-height: 100px; opacity: .5; }
.day.reached { opacity: 1; background: var(--bg-3); } .day.claimed { background: var(--ok-bg); border-color: #78b79440; }
.day.reached:not(.claimed) { border-color: var(--accent-lo); box-shadow: 0 0 0 3px var(--accent-bg); }
.day .dn { font: 600 13px var(--display); color: var(--text-hi); margin-bottom: 3px; }
.day .locked { margin-top: 5px; padding-top: 5px; border-top: 1px dashed var(--hair-2); color: var(--text-2); }
.chart { margin: 0 0 var(--s3); } .chart figcaption { font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); margin-bottom: 4px; }
.chart svg { width: 100%; max-width: 580px; height: auto; background: #0a0e14; border: 1px solid var(--hair); border-radius: var(--r); }
.chart .axis { stroke: var(--hair-3); } .chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart .dotp { fill: var(--accent-hi); } .chart .lbl { font-size: 10px; fill: var(--text-2); }
.emblem { width: 44px; height: 44px; vertical-align: middle; }
h2 .emblem { width: 32px; height: 32px; }
.emblems { display: flex; flex-wrap: wrap; gap: 4px; }
.emblems .em { border: 1px solid transparent; border-radius: var(--r); cursor: pointer; padding: 3px; transition: border-color var(--t), background var(--t); }
.emblems .em:hover { background: #ffffff0a; }
.emblems .em.on { border-color: var(--accent); background: var(--accent-bg); }
.emblems input { display: none; }
.ach-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.ach { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-bg); border: 1px solid #c4a7683d; color: var(--accent-hi); border-radius: 999px; padding: 2px 10px 2px 5px; font-size: 11.5px; white-space: nowrap; }
.coins { background: #ffffff06; border-bottom: 1px solid var(--hair); }
.tier .in { min-height: 44px; }
.sim-opts { margin-top: var(--s3); max-width: 540px; }
.farmtpl { margin: 3px 0; }
.box select, .box input:not([type=checkbox]):not([type=radio]) { max-width: 100%; }
.box td .inline { margin-top: 4px; }

/* empty states: a quiet ring + muted text (no illustration) */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 14px !important; text-align: center; color: var(--text-3) !important; font-size: 12.5px; }
.empty::before { content: ''; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--hair-3); background: radial-gradient(circle, var(--hair-3) 0 2px, transparent 2.5px); }

/* ---- Map ---- */
.panel.mappanel { background: #0d1218f0; }
.mappanel h2 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-2); font-weight: 600; }
/* Map canvas (T13): one pan/zoom canvas drawn by public/views/map.js; the page only supplies the frame and overlays */
.mapwrap { position: relative; }
.mapstage { position: relative; height: clamp(400px, 66vh, 720px); border: 1px solid var(--hair-2); border-radius: var(--r); overflow: hidden; background: #0a0d12; box-shadow: 0 18px 40px -16px #000; }
.mapstage::after { content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; box-shadow: inset 0 0 70px 6px #05070b9c; }
#mapcv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; outline: none; }
#mapcv:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-lo); }
.maphud { position: absolute; left: 40px; bottom: 10px; z-index: 2; max-width: calc(100% - 100px); padding: 4px 10px; pointer-events: none; font: 500 11px/1.45 var(--sans); letter-spacing: .02em; font-variant-numeric: tabular-nums;
  color: var(--text); background: #0a0e14d6; border: 1px solid var(--hair-2); border-radius: var(--r-sm); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapzoom { position: absolute; right: 10px; bottom: 10px; z-index: 2; display: flex; flex-direction: column; overflow: hidden; background: #0a0e14e6; border: 1px solid var(--hair-2); border-radius: var(--r); box-shadow: var(--sh-1); }
.mz { width: 32px; height: 30px; padding: 0; display: grid; place-items: center; font: 500 17px/1 var(--sans); color: var(--text); background: none; border: 0; cursor: pointer; transition: background var(--t), color var(--t); }
.mz + .mz { border-top: 1px solid var(--hair); }
.mz:hover { background: var(--accent-bg2); color: var(--accent-hi); }
.mz .ic { width: 15px; height: 15px; vertical-align: 0; }
.hlrow { margin: 4px 0; } .hlrow input[type=color] { width: 26px; height: 20px; padding: 0; vertical-align: middle; }
.map-nav { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.map-nav form { display: flex; gap: 4px; align-items: center; }
.legend { font-size: 11px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 4px 2px; align-items: center; letter-spacing: .02em; }
.sw { display: inline-block; width: 9px; height: 9px; margin: 0 4px 0 10px; border: 1px solid #0008; border-radius: 50%; vertical-align: -1px; }
.lgi { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.gb { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; border-radius: 50%; background: rgba(10,12,16,.82); border: 1px solid rgba(255,255,255,.18); font-size: 10px; font-weight: 600; line-height: 1; }
.gb i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
#mappop .pgroups { display: flex; flex-wrap: wrap; gap: 2px 10px; }
#mappop .pg { display: inline-flex; align-items: center; gap: 4px; }
#mappop .pg i { width: 8px; height: 8px; border-radius: 50%; }
#minimap { display: block; width: 100%; max-width: 260px; aspect-ratio: 1; border: 1px solid var(--hair-2); border-radius: var(--r); cursor: crosshair; touch-action: none; background: #0a0d12; }

/* Map hover popup, click ring, quick commands */
#mappop { position: fixed; z-index: 50; max-width: 320px; padding: 8px 11px; font-size: 12px; line-height: 1.5; background: #10161ef5; color: var(--text);
  border: 1px solid var(--hair-2); border-radius: var(--r); box-shadow: var(--sh-2); pointer-events: none; font-family: var(--sans); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
#mappop .vis { margin: 2px 0; } #mappop[hidden] { display: none; }
#mappop b { color: var(--text-hi); } #mappop .muted { color: var(--text-2); }
.ring { position: absolute; width: 0; height: 0; z-index: 20; }
.ring .rb { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--hair-3); background: #121821f5; color: var(--text);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0; box-shadow: var(--sh-2); transform: rotate(var(--a)) translate(46px) rotate(calc(-1 * var(--a)));
  transition: background var(--t), border-color var(--t); }
.ring .rb:hover { background: var(--bg-5); border-color: var(--accent); color: var(--text-hi); }
.ring .rb.rc { transform: none; width: 20px; height: 20px; left: -10px; top: -10px; font-size: 10px; background: #2b1c1a; }
.popset { display: flex; flex-wrap: wrap; gap: 2px 10px; margin: 2px 0 var(--s2); font-size: 12px; }

/* ---- Toast ---- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; max-width: min(560px, calc(100% - 32px));
  background: #151c26f5; color: var(--text-hi); padding: 10px 18px; border-radius: var(--r-lg); border: 1px solid var(--hair-2); border-left: 3px solid var(--accent);
  box-shadow: var(--sh-2); animation: toastIn .2s var(--ease); font-weight: 500;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---- Small screens ---- */
@media (max-width: 600px) {
  #app { padding: 0 6px 40px; }
  .panel { padding: 12px 10px; }
  .topbar { position: static; gap: 6px 10px; }
  .topbar .res { margin-left: 0; }
  .nav button { padding: 5px 8px; font-size: 12px; } .nav .ni:has(.nc) > [data-tab] { padding-right: 4px; } .nav .nc { padding: 5px 7px 5px 3px; }
  .village-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 7px; }
  .bld { padding: 7px; gap: 7px; } .bld .ic.big { width: 34px; height: 34px; padding: 6px; } .bld b { font-size: 12.5px; }
  h2 { font-size: 17px; }
  .subnav button { padding: 5px 9px; font-size: 12px; }
}
@media (max-width: 760px) { table.vis { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; } .panel { overflow-x: hidden; } }

/* ---- Icon tints (icons.js sets data-i; everything else follows the text colour) ---- */
.ic[data-i=wood] { color: #c39a66; } .ic[data-i=clay] { color: #c9825f; } .ic[data-i=iron] { color: #a3b4c8; }
.ic[data-i=pop] { color: #96b9a0; } .ic[data-i=storage] { color: #aab4c2; } .ic[data-i=pp] { color: var(--accent-hi); }
.ic[data-i=attack] { color: var(--bad); } .ic[data-i=support] { color: var(--info); } .ic[data-i=return] { color: var(--ok); }
.ic[data-i=star], .ic[data-i=trophy], .ic[data-i=crown] { color: var(--accent); } .ic[data-i=clock], .ic[data-i=moon] { color: var(--text-2); }
.nav button .ic, .ic.big { color: inherit; }

/* ---- Side panels on the map page (box colours come from the base theme) ---- */
.mapside .box:first-child { min-height: 120px; }
.mapside input[type=color] { padding: 0; background: none; }
