:root {
  --concrete: #2a3033;
  --panel: #333b3f;
  --panel-2: #3b4449;
  --line: #4d575c;
  --text: #e7e3d4;
  --muted: #a8a390;
  --sand: #cdb67f;
  --sand-deep: #9d8a5a;
  --rust: #b86a45;
  --moss: #90a063;
  --cond: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Barlow", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--concrete); color: var(--text); font: 16px/1.55 var(--body); }
body { margin: 0; min-height: 100vh; }
a { color: var(--sand); text-underline-offset: 3px; }
a:hover { color: #e6d3a0; }
:focus-visible { outline: 2px solid var(--sand); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); font-size: .92em; }

/* Barra superiore */
.top {
  display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem;
  background: var(--panel); border-bottom: 3px solid var(--sand-deep);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font: 700 1.5rem/1 var(--cond); letter-spacing: .02em; color: var(--text);
  text-decoration: none; display: flex; align-items: center; gap: .6rem; white-space: nowrap;
}
.brand-mark {
  width: 22px; height: 22px; border: 2px solid var(--sand); border-radius: 50%;
  background: radial-gradient(circle, var(--sand) 0 3px, transparent 4px),
    linear-gradient(var(--sand), var(--sand)) center/2px 100% no-repeat,
    linear-gradient(var(--sand), var(--sand)) center/100% 2px no-repeat;
}
.search { flex: 1; max-width: 520px; }
.search input {
  width: 100%; padding: .55rem .8rem; font: inherit; color: var(--text);
  background: var(--concrete); border: 1px solid var(--line); border-radius: 3px;
}
.who { color: var(--muted); font-size: .85rem; margin-left: auto; }

/* Login */
.who { display: flex; align-items: center; gap: 1rem; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--sand); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.loginbody { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login { width: 100%; max-width: 380px; background: var(--panel); border-top: 3px solid var(--sand-deep); padding: 2rem; }
.login .brand { margin: 0 0 1.5rem; }
.login h1 { font-size: 2rem; }
.login .btn { justify-self: start; }
.error { color: #f0c2ab; background: rgba(184,106,69,.18); border-left: 3px solid var(--rust); padding: .6rem .8rem; }

/* Struttura */
.shell { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 60px); }
.side { padding: 1.2rem 0; border-right: 1px solid var(--line); background: #2e3538; }
.side a {
  display: block; padding: .45rem 1.5rem; color: var(--text); text-decoration: none;
  font: 500 1.1rem/1.3 var(--cond); border-left: 3px solid transparent;
}
.side a:hover { background: var(--panel); }
.side a[aria-current="page"] { border-left-color: var(--sand); background: var(--panel); color: var(--sand); }
.side .warn { color: #e8a888; }
.side .sync { margin: 1.5rem 1.5rem 0; font-size: .8rem; color: var(--muted); line-height: 1.4; }
main { padding: 2rem 2.5rem 4rem; max-width: 1200px; min-width: 0; }

h1, h2, h3 { font-family: var(--cond); font-weight: 600; line-height: 1.15; margin: 0 0 .6rem; }
h1 { font-size: 2.4rem; font-weight: 700; }
h2 { font-size: 1.55rem; margin-top: 2.2rem; color: var(--sand); }
h3 { font-size: 1.2rem; }
.lead { color: var(--muted); max-width: 68ch; margin-top: 0; }
.empty { padding: 1.2rem 1.4rem; border: 1px dashed var(--line); color: var(--muted); max-width: 68ch; }
.crumbs { color: var(--muted); margin: 0 0 .3rem; font-size: .9rem; }
.facts .sep { display: inline-block; width: 1.2rem; }

/* Home */
.hero h1 { font-size: clamp(2.2rem, 4.5vw, 3.4rem); max-width: 18ch; }
.more { font-family: var(--cond); font-size: 1.1rem; }
.changes { list-style: none; padding: 0; margin: 1.2rem 0; max-width: 820px; }
.changes li { padding: .45rem 0; border-bottom: 1px solid var(--line); }
.changes li.day { border: 0; padding-top: 1.2rem; color: var(--muted); font: 600 1rem var(--cond); }
.cat {
  display: inline-block; min-width: 6.5rem; font: 600 .95rem var(--cond);
  color: var(--concrete); background: var(--muted); padding: 0 .45rem; border-radius: 2px; text-align: center;
}
.cat-munizioni { background: var(--rust); color: #fff4ea; }
.cat-boss { background: var(--sand); }
.cat-missioni { background: var(--moss); }
.changes details { margin-top: .3rem; }
.changes summary { cursor: pointer; color: var(--sand); font-size: .9rem; }

.bosses th { width: 1%; text-align: left; padding: .5rem 1.5rem .5rem 0; border-bottom: 1px solid var(--line); font: 600 1.1rem var(--cond); white-space: nowrap; }
.bosses td { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.bosses a { color: var(--text); }
.chip {
  display: inline-flex; align-items: center; gap: .4rem; margin: .15rem .3rem .15rem 0;
  padding: .15rem .55rem .15rem .35rem; background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
}
.chip .bar { width: 34px; height: 6px; background: linear-gradient(90deg, var(--sand) var(--p), var(--line) var(--p)); }
.chip b { color: var(--sand); font-weight: 600; }

/* Tabelle */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
.data { font-size: .94rem; }
.data th {
  text-align: left; font: 600 1rem var(--cond); padding: .5rem .7rem; background: var(--panel-2);
  border-bottom: 2px solid var(--sand-deep); position: sticky; top: 0; white-space: nowrap;
}
.sortable th { cursor: pointer; user-select: none; }
.sortable th[aria-sort="ascending"]::after { content: " ▲"; color: var(--sand); }
.sortable th[aria-sort="descending"]::after { content: " ▼"; color: var(--sand); }
.data td { padding: .4rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.data tbody tr:hover { background: var(--panel); }
.ac { display: inline-block; width: 1.7rem; text-align: center; font-weight: 600; border-radius: 2px; }
.ac0, .ac1, .ac2 { background: var(--line); }
.ac3 { background: #6e7446; }
.ac4 { background: var(--moss); color: var(--concrete); }
.ac5 { background: var(--sand); color: var(--concrete); }
.ac6 { background: var(--rust); color: #fff4ea; }

/* Filtri e bottoni */
.filterform { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin: 1rem 0; }
.filterform label, .editor label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.filterform label.check { flex-direction: row; align-items: center; color: var(--text); font-size: .95rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 3px; padding: .45rem .6rem;
}
textarea { font-family: ui-monospace, Consolas, monospace; font-size: .92rem; line-height: 1.5; width: 100%; }
.btn {
  display: inline-block; font: 600 1.05rem var(--cond); padding: .45rem 1rem; cursor: pointer;
  background: var(--sand); color: var(--concrete); border: 0; border-radius: 3px; text-decoration: none;
}
.btn:hover { background: #e0cb95; color: var(--concrete); }
.btn.danger { background: transparent; color: var(--rust); border: 1px solid var(--rust); margin-left: auto; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1rem 0; }
.filters a { padding: .2rem .7rem; border: 1px solid var(--line); border-radius: 2px; text-decoration: none; color: var(--text); }
.filters a[aria-current] { border-color: var(--sand); color: var(--sand); }
.titlebar { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* Mappe */
.bossgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.boss { background: var(--panel); border-top: 3px solid var(--sand-deep); padding: 1rem 1.1rem; }
.boss-head { display: flex; justify-content: space-between; align-items: baseline; }
.boss .big { font: 700 2rem/1 var(--cond); color: var(--sand); }
.meter { height: 6px; background: var(--line); margin: .5rem 0 .8rem; }
.meter span { display: block; height: 100%; background: var(--sand); }
.spawns { list-style: none; padding: 0; margin: 0; font-size: .92rem; }
.spawns li { display: flex; justify-content: space-between; padding: .15rem 0; }
.excols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; }
.excols ul { padding-left: 1.1rem; margin: 0; }

/* Missioni, hideout */
.tasks { list-style: none; padding: 0; margin: 0; }
.tasks > li, .station { border-bottom: 1px solid var(--line); }
.tasks summary, .station summary { cursor: pointer; padding: .55rem 0; }
.lvl {
  display: inline-block; min-width: 2rem; text-align: center; font: 600 .95rem var(--cond);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 2px; margin-right: .3rem;
}
.tag { font: 600 .85rem var(--cond); color: var(--sand); border: 1px solid var(--sand-deep); padding: 0 .35rem; border-radius: 2px; }
.taskbody { padding: 0 0 1rem 2.6rem; max-width: 75ch; }
.lvlblock { padding: .3rem 0 .8rem 1rem; border-left: 2px solid var(--line); margin: 0 0 .6rem .4rem; }
.lvlblock ul { margin: .2rem 0; padding-left: 1.1rem; }

/* Mercato */
.movers { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.movers li { background: var(--panel); padding: .3rem .7rem; border-radius: 2px; }
.up { color: var(--moss); } .down { color: var(--rust); }

/* Tips */
.tiplist { list-style: none; padding: 0; margin: 0; max-width: 760px; }
.tiplist li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.tiplist a { font: 500 1.2rem var(--cond); }
.tip { max-width: 72ch; }
.prose { font-size: 1.04rem; }
.prose h2 { font-size: 1.45rem; }
.prose li { margin: .25rem 0; }
.prose blockquote { margin: 1rem 0; padding: .6rem 1rem; border-left: 3px solid var(--rust); background: var(--panel); }
.prose code { background: var(--panel); padding: .1rem .3rem; border-radius: 2px; }
.tipfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.editor { display: grid; gap: 1rem; max-width: 820px; }
.actions { display: flex; gap: 1rem; align-items: center; }
.results { padding-left: 1.1rem; }

@media (max-width: 820px) {
  .top { flex-wrap: wrap; gap: .7rem; padding: .7rem 1rem; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { align-self: start; }
  .side { display: flex; overflow-x: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .side a { white-space: nowrap; padding: .6rem .9rem; border-left: 0; border-bottom: 3px solid transparent; }
  .side a[aria-current="page"] { border-bottom-color: var(--sand); }
  .side .warn { color: #e8a888; }
.side .sync { display: none; }
  main { padding: 1.4rem 1rem 3rem; }
  .taskbody { padding-left: 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* Immagini */
.ico { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: .45rem; background: #1f2427; border-radius: 2px; }
.ico-round { border-radius: 50%; object-fit: cover; }
.chip .ico { width: 22px; height: 22px; margin-right: .1rem; }
.data td .ico { width: 32px; height: 32px; }
.movers li { display: inline-flex; align-items: center; gap: .1rem; }
.portrait { width: 56px; height: 56px; object-fit: cover; border-radius: 50%; border: 2px solid var(--sand-deep); margin-right: .7rem; flex: none; }
.boss-head { align-items: center; }
.boss-head h3 { flex: 1; margin: 0; }
.mapimg { display: block; max-width: 100%; max-height: 360px; object-fit: cover; margin: .5rem 0 1rem; border: 1px solid var(--line); }
.taskimg { float: right; width: 160px; max-width: 40%; margin: 0 0 .8rem 1rem; border: 1px solid var(--line); }
.req { list-style: none; padding-left: 0; }
.req li { display: flex; align-items: center; padding: .15rem 0; }
.line { display: flex; align-items: center; padding: .1rem 0; }
.results li { list-style: none; display: flex; align-items: center; padding: .15rem 0; }
.results { padding-left: 0; }
.station summary .ico { width: 36px; height: 36px; }

/* Visualizzatore mappe */
.mapview { margin: 1rem 0 2rem; }
.mapview-stage {
  position: relative; height: min(70vh, 720px); overflow: hidden; background: #1c2023;
}
.mapview-stage[style*="aspect-ratio"] { height: auto; max-height: 78vh; min-height: 320px; width: 100%;
  border: 1px solid var(--line); cursor: grab; touch-action: none;
}
.mapview-stage.dragging { cursor: grabbing; }
.mapview-layer { position: absolute; left: 0; top: 0; transform-origin: 0 0; --s: 1; will-change: transform; }
.mapview-layer img { display: block; max-width: none; user-select: none; pointer-events: none; }
.mk {
  position: absolute; width: 14px; height: 14px; margin: 0; padding: 0; border-radius: 50%;
  background: var(--mc); border: 2px solid #111a; box-shadow: 0 0 0 1px #fff6;
  transform: translate(-50%, -50%) scale(calc(1 / var(--s))); cursor: pointer;
}
.mk[hidden] { display: none; }
.mk-pop {
  position: absolute; z-index: 5; max-width: 270px; padding: .6rem .75rem; background: var(--panel);
  border: 1px solid var(--sand-deep); box-shadow: 0 6px 20px #0008; font-size: .9rem;
}
.mk-pop p { margin: .3rem 0 0; color: var(--muted); }
.legend { border: 1px solid var(--line); margin: .8rem 0 0; padding: .5rem .8rem .7rem; display: flex; flex-wrap: wrap; gap: .35rem 1.2rem; }
.legend legend { font: 600 1rem var(--cond); color: var(--sand); padding: 0 .3rem; }
.legend label { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; cursor: pointer; }
.legend-actions { flex-basis: 100%; display: flex; gap: 1rem; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.mapview-tools { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.mapview-tools button { font: 600 1rem var(--cond); background: var(--panel-2); color: var(--text); border: 1px solid var(--line); padding: .3rem .8rem; border-radius: 3px; cursor: pointer; }
.mapview-tools button:hover { border-color: var(--sand); }
.mapview figcaption { color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.mapview:fullscreen { background: #1c2023; padding: 1rem; margin: 0; }
.mapview:fullscreen .mapview-stage { height: calc(100vh - 7rem); max-height: none; aspect-ratio: auto !important; }
.mapthumb { width: 44px; height: 32px; object-fit: cover; }

/* Missioni con spunta */
.tasks > li { display: flex; gap: .6rem; align-items: flex-start; }
.tasks > li details { flex: 1; min-width: 0; }
.tick { margin: .45rem 0 0; }
.tickbtn {
  width: 26px; height: 26px; border: 2px solid var(--line); background: var(--concrete); color: var(--concrete);
  border-radius: 3px; cursor: pointer; font-weight: 700; line-height: 1; padding: 0;
}
.tickbtn:hover { border-color: var(--sand); }
.tickbtn[aria-pressed="true"] { background: var(--moss); border-color: var(--moss); }
.st-fatta summary b { text-decoration: line-through; color: var(--muted); }
.st-bloccata summary, .st-livello summary { opacity: .75; }
.small { font-size: .82rem; }
.taskactions { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; clear: both; }
.taskactions form { margin: 0; }

/* Hideout */
form.inline { display: flex; gap: .8rem; align-items: flex-end; margin: .2rem 0 1rem; }
form.inline label { display: flex; gap: .5rem; align-items: center; color: var(--muted); font-size: .9rem; }
.btn.small { font-size: .95rem; padding: .3rem .8rem; }
.lvlblock.built { opacity: .55; }
.lvlblock.nextlvl { border-left-color: var(--sand); }

/* Progressi */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1rem 0; }
.stats > div { background: var(--panel); padding: 1rem 1.1rem; border-top: 3px solid var(--sand-deep); }
.stats h3 { color: var(--muted); font-weight: 500; }
.bignum { font: 700 2.2rem/1 var(--cond); color: var(--sand); margin: .2rem 0 .6rem; }
.bignum .muted { font-size: 1rem; font-weight: 400; }
.pbar { display: block; height: 6px; background: var(--line); }
.pbar span { display: block; height: 100%; background: var(--moss); }
.traders { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .6rem; }
.trader { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .2rem .4rem; padding: .6rem .7rem; background: var(--panel); color: var(--text); text-decoration: none; border-radius: 2px; }
.trader:hover { background: var(--panel-2); }
.trader .pbar { grid-column: 1 / -1; }

/* Utenti */
.notice { color: #d8e4c0; background: rgba(144,160,99,.18); border-left: 3px solid var(--moss); padding: .6rem .8rem; }
.secret { display: inline-block; margin-left: .4rem; padding: .2rem .5rem; background: var(--concrete); color: var(--sand); font-size: 1.05rem; user-select: all; }
.users .actions { display: flex; flex-wrap: wrap; gap: .3rem 1rem; }
.users .actions form { margin: 0; }
.users tr.off td { color: var(--muted); }
.linkbtn.danger { color: var(--rust); }
.editor.narrow { max-width: 420px; }
.who a { color: var(--muted); text-decoration: none; }
.who a:hover { color: var(--sand); }

/* Marcatori con icona e nome */
.mk.ico-mk { width: 26px; height: 26px; background: none; border: 0; box-shadow: none; border-radius: 0; filter: drop-shadow(0 1px 2px #000c); }
.mk.ico-mk img { width: 100%; height: 100%; display: block; pointer-events: none; }
.mk-l {
  display: none; position: absolute; left: calc(100% + 3px); top: 50%; transform: translateY(-50%);
  white-space: nowrap; font: 600 12px/1.2 var(--body); color: #fff; pointer-events: none;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 1px 2px #000;
}
.labels .mk-l { display: block; }
.mk-pop small { display: block; color: var(--sand); margin-top: .1rem; }
.lg-ico { width: 18px; height: 18px; object-fit: contain; }
.mapview-tools [aria-pressed="true"] { border-color: var(--sand); color: var(--sand); }

/* Pagine lunghe: il browser disegna solo quello che è sullo schermo */
.tasks > li { content-visibility: auto; contain-intrinsic-size: auto 46px; }
.stations > .station { content-visibility: auto; contain-intrinsic-size: auto 40px; }
