/* The Conquest of Albania — stile. Pergamena, cuoio, oro e inchiostro. */
:root {
  --ink: #2a1c10; --ink2: #5a4128; --ink3: #7d6444;
  --parch: #f0e3c4; --parch2: #e3cfa3; --parch3: #cdb583; --parch4: #b39a68;
  --wood: #1e140c; --wood2: #2f2014; --wood3: #463020;
  --gold: #dcb863; --gold2: #b08a3e; --gold3: #7a5a22;
  --red: #a92a22; --red2: #7c1a16; --green: #3d7a3a; --green2: #2b5a29; --blue: #2d5a8a;
  --light: #f4e8cc; --light2: #cbb893; --shadow: rgba(10, 6, 2, .55);
  --good: #2f7a36; --bad: #a3261f; --warn: #b8801c;
  --f-title: "Cinzel", "Trajan Pro", Georgia, serif;
  --f-body: "EB Garamond", Garamond, Georgia, "Times New Roman", serif;
  --top-h: 46px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #140d07; color: var(--ink); font-family: var(--f-body); font-size: 16px; }
button { font-family: inherit; }
canvas { display: block; }
html, body { overscroll-behavior: none; }
/* la mappa si trascina col dito: niente scorrimento o zoom del browser (che annullava il gesto) */
#map { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#mapvig { position: fixed; inset: 0; pointer-events: none; z-index: 1; background: radial-gradient(ellipse 80% 75% at 50% 50%, transparent 58%, rgba(10,6,2,.38) 100%); }
#map.hidden + #mapvig { display: none; }
.hidden { display: none !important; }
.ico { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(90, 65, 40, .5); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- pulsanti ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; user-select: none;
  font: 600 15px/1.1 var(--f-body); color: var(--ink); padding: 8px 14px; border-radius: 7px;
  background: linear-gradient(#f6ebd0, #dcc595); border: 1.5px solid var(--ink2);
  box-shadow: 0 2px 0 rgba(60, 40, 20, .55), inset 0 1px 0 rgba(255, 255, 255, .6);
  transition: transform .08s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(60, 40, 20, .55); }
.btn:disabled, .btn.off { opacity: .45; cursor: not-allowed; filter: grayscale(.4); }
.btn.primary { color: #fbeed2; background: linear-gradient(#c6412f, #86201a); border-color: #4e100c; text-shadow: 0 1px 1px rgba(0, 0, 0, .5); }
.btn.gold { color: #2a1a08; background: linear-gradient(#f3d98a, #c79a45); border-color: #6a4a18; }
.btn.dark { color: var(--light); background: linear-gradient(#4a3522, #2a1c10); border-color: #140c05; box-shadow: 0 2px 0 #0a0603, inset 0 1px 0 rgba(255, 220, 160, .15); }
.btn.small { font-size: 13px; padding: 5px 9px; border-radius: 6px; }
.btn.tiny { font-size: 12px; padding: 3px 7px; border-radius: 5px; }
.btn.icon { padding: 7px; }
.btn.wide { width: 100%; }
.btn.sel { outline: 2.5px solid var(--gold); outline-offset: 1px; }

/* ---------------- caricamento e titolo ---------------- */
#boot { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(ellipse at 50% 40%, #3a2716, #120b05 70%); color: var(--light); }
#boot h1 { font: 700 clamp(28px, 6vw, 56px)/1 var(--f-title); letter-spacing: .06em; margin: 0; color: var(--gold); text-shadow: 0 3px 18px rgba(0, 0, 0, .8); text-align: center; }
#boot .bar { width: min(360px, 70vw); height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
#boot .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold2), var(--gold)); transition: width .25s; }
#boot .msg { font-style: italic; color: var(--light2); }

.screen { position: fixed; inset: 0; z-index: 40; overflow: auto; }
#title { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 16px 60px;
  background: radial-gradient(ellipse at 50% 42%, rgba(20, 12, 6, .55), rgba(12, 7, 3, .9) 78%); }
#title .logo { text-align: center; margin-bottom: 28px; }
#title h1 { font: 700 clamp(34px, 7.5vw, 84px)/1.02 var(--f-title); margin: 0; letter-spacing: .05em; color: #f7e6b8;
  text-shadow: 0 2px 0 #6a4418, 0 6px 30px rgba(0, 0, 0, .95); }
#title .sub { font: italic 400 clamp(15px, 2.2vw, 21px) var(--f-body); color: #e9d6a8; margin-top: 12px; text-shadow: 0 2px 10px #000; }
#title .eagle { width: 84px; height: 84px; margin: 0 auto 10px; filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .8)); }
#title .menu { display: flex; flex-direction: column; gap: 10px; width: min(320px, 86vw); }
#title .menu .btn { font-size: 18px; padding: 12px 16px; }
#title .foot { position: fixed; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 13px; color: rgba(240, 225, 190, .55); }
#title .foot a { color: inherit; }
.lang-btn { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 45; }

/* scelta della casata */
#newgame { padding: 64px 16px 130px; background: radial-gradient(ellipse at 50% 20%, rgba(46, 30, 16, .75), rgba(12, 7, 3, .95) 80%); color: var(--light); }
#newgame h2 { font: 700 clamp(24px, 4vw, 38px) var(--f-title); text-align: center; margin: 0 0 18px; color: var(--gold); letter-spacing: .05em; }
.houses { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; max-width: 1180px; margin: 0 auto; }
.house { position: relative; cursor: pointer; border-radius: 12px; overflow: hidden; color: var(--ink);
  background: linear-gradient(170deg, var(--parch), var(--parch2)); border: 2px solid var(--gold3);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .55); transition: transform .15s, box-shadow .15s; }
.house:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0, 0, 0, .7); }
.house.sel { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold), 0 10px 30px rgba(0, 0, 0, .75); }
.house .top { display: flex; gap: 12px; padding: 12px; align-items: center; background: linear-gradient(100deg, var(--hc) 10%, #2a1a0c 100%); border-bottom: 1.5px solid var(--gold3); }
.house .portrait { width: 74px; height: 92px; border-radius: 6px; object-fit: cover; border: 2px solid var(--gold2); background: #3a2716; flex: none; }
.house .names h3 { margin: 0; font: 700 21px var(--f-title); color: #fff5dc; text-shadow: 0 1px 3px rgba(0, 0, 0, .8); }
.house .names .ldr { font-size: 14px; color: #fff0cf; text-shadow: 0 1px 2px #000; }
.house .names img { width: 34px; height: 39px; }
.house .body { padding: 8px 12px 12px; font-size: 14px; line-height: 1.35; }
.house .trait { margin-top: 8px; padding: 6px 8px; border-radius: 6px; background: rgba(255, 255, 255, .45); border: 1px solid var(--parch4); font-size: 13px; }
.house .trait b { font-family: var(--f-title); font-size: 13px; }
.house .diff { position: absolute; top: 8px; right: 10px; color: var(--gold); text-shadow: 0 1px 2px #000; font-size: 13px; letter-spacing: 1px; }
.ng-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(10, 6, 2, .95) 30%); }
.seg { display: inline-flex; border: 1.5px solid var(--gold3); border-radius: 8px; overflow: hidden; }
.seg button { background: rgba(30, 20, 10, .8); color: var(--light2); border: 0; padding: 8px 12px; font: 600 14px var(--f-body); cursor: pointer; }
.seg button.on { background: linear-gradient(#e8c877, #b8903f); color: #2a1a08; }
.ng-bar label { color: var(--light2); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; }

/* ---------------- HUD della campagna ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; top: 0; left: 0; right: 0; min-height: var(--top-h); display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: max(5px, env(safe-area-inset-top)) 10px 5px 124px; color: var(--light);
  background: linear-gradient(#352416, #1d130b); border-bottom: 2px solid var(--gold2); box-shadow: 0 3px 12px rgba(0, 0, 0, .6); }
.topbar .fac { display: flex; align-items: center; gap: 7px; font: 700 15px var(--f-title); color: var(--gold); white-space: nowrap; }
.topbar .fac img { width: 26px; height: 30px; }
.stat { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 14px; background: rgba(0, 0, 0, .35); border: 1px solid rgba(220, 184, 99, .28);
  font: 600 15px var(--f-body); white-space: nowrap; cursor: default; }
.stat .ico { color: var(--gold); }
.stat .d { font-size: 12.5px; }
.pos { color: #8fd07e; } .neg { color: #ff8a73; }
.stat.date { font-family: var(--f-title); font-size: 13px; letter-spacing: .04em; }
.topbar .sp { flex: 1; }
.nav { display: flex; gap: 5px; }
.nav .btn { padding: 5px 9px; font-size: 13.5px; }
.nav .btn .lbl { margin-left: 2px; }
.nav .btn.alert { box-shadow: 0 0 0 2px #e0503a, 0 2px 0 #0a0603; }

.feed { position: absolute; top: calc(var(--top-h) + 10px); right: 10px; width: 300px; max-height: 44vh; display: flex; flex-direction: column;
  background: rgba(24, 16, 9, .86); border: 1px solid var(--gold3); border-radius: 10px; color: var(--light); backdrop-filter: blur(3px); }
.feed h4 { margin: 0; padding: 7px 10px; font: 700 13px var(--f-title); letter-spacing: .08em; color: var(--gold); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.feed .list { overflow: auto; padding: 0 6px 6px; }
.feed.collapsed .list { display: none; }
.feed .item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 6px; border-radius: 6px; font-size: 14px; line-height: 1.25; cursor: pointer; }
.feed .item:hover { background: rgba(255, 230, 180, .08); }
.feed .item .ico { color: var(--gold); margin-top: 1px; }
.feed .item.imp2 { color: #ffe3b0; }
.feed .item.imp0 { color: #bfae8a; font-size: 13px; }
.feed .item img { width: 16px; height: 18px; flex: none; margin-top: 1px; }

.endturn { position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); width: 92px; height: 92px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
  background: radial-gradient(circle at 40% 35%, #d9503b, #7a1712 75%); border: 3px solid var(--gold); color: #fff1d6;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .7), inset 0 2px 6px rgba(255, 220, 180, .35); font: 700 12.5px var(--f-title); letter-spacing: .06em; text-align: center; }
.endturn .n { font-size: 11px; opacity: .85; }
.endturn .ico { width: 26px; height: 26px; }
.endturn:hover { filter: brightness(1.1); }
.endturn:active { transform: scale(.97); }
.endturn.busy { pointer-events: none; filter: grayscale(.6) brightness(.8); }
.minimap { position: absolute; right: 12px; bottom: calc(122px + env(safe-area-inset-bottom)); pointer-events: auto; padding: 3px; border-radius: 7px;
  background: rgba(22, 14, 8, .82); border: 1px solid rgba(220, 184, 99, .5); box-shadow: 0 6px 18px rgba(0, 0, 0, .55); touch-action: none; }
.minimap canvas { display: block; border-radius: 4px; cursor: crosshair; }
.minimap.off { display: none; }
@media (max-width: 759px) { .minimap { top: calc(var(--top-h) + 54px); bottom: auto; right: 8px; } }
.mapbtns { position: absolute; right: 118px; bottom: calc(22px + env(safe-area-inset-bottom)); display: flex; gap: 6px; }

/* pannello in basso */
.sheet { position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); width: min(760px, calc(100vw - 132px)); max-height: 52vh; display: flex; flex-direction: column;
  background: linear-gradient(175deg, var(--parch), var(--parch2)); border: 2px solid var(--gold3); border-radius: 12px; box-shadow: 0 8px 30px rgba(0, 0, 0, .65); overflow: hidden; }
.sheet .hd { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; background: linear-gradient(90deg, var(--hc, #5a4128), rgba(90, 65, 40, .15) 80%); border-bottom: 1px solid var(--parch4); }
.sheet .hd .ttl { font: 700 19px var(--f-title); color: #fff6dd; text-shadow: 0 1px 3px rgba(0, 0, 0, .75); line-height: 1.05; }
.sheet .hd .sub { font-size: 13.5px; color: #fff0cf; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); }
.sheet .hd .x { margin-left: auto; }
.sheet .hd img.sh { width: 32px; height: 37px; flex: none; }
.sheet .hd img.pt { width: 46px; height: 56px; border-radius: 5px; object-fit: cover; border: 2px solid var(--gold2); flex: none; background: #3a2716; }
.sheet .bd { overflow: auto; padding: 10px 12px 12px; }
.sheet .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.sheet .kv { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14.5px; }
.sheet .kv .k { color: var(--ink3); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 12px; background: rgba(255, 255, 255, .5); border: 1px solid var(--parch4); font-size: 14px; white-space: nowrap; }
.pill .ico { color: var(--ink2); }
.pill.bad { background: rgba(169, 42, 34, .12); border-color: rgba(169, 42, 34, .45); color: var(--red2); }
.pill.good { background: rgba(61, 122, 58, .12); border-color: rgba(61, 122, 58, .4); color: var(--green2); }
.section { margin-top: 10px; }
.section > h5 { margin: 0 0 6px; font: 700 12.5px var(--f-title); letter-spacing: .1em; color: var(--ink2); text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.section > h5::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--parch4), transparent); }
.hint { font-size: 13px; color: var(--ink3); font-style: italic; }
.warn { color: var(--red2); font-weight: 600; font-size: 14px; }

/* carte delle unita' */
.cards { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.ucard { position: relative; flex: none; width: 70px; height: 100px; border-radius: 7px; cursor: pointer; overflow: hidden;
  background: linear-gradient(#5b4731, #2b2015); border: 1.5px solid #8a6c3a; box-shadow: 0 2px 5px rgba(0, 0, 0, .45); color: var(--light); }
.ucard img { position: absolute; left: 3px; top: 2px; width: 64px; height: 72px; }
.ucard .n { position: absolute; left: 0; right: 0; bottom: 13px; text-align: center; font: 700 12.5px var(--f-body); text-shadow: 0 1px 2px #000; }
.ucard .hp { position: absolute; left: 4px; right: 4px; bottom: 6px; height: 4px; border-radius: 2px; background: rgba(0, 0, 0, .55); overflow: hidden; }
.ucard .hp i { display: block; height: 100%; background: linear-gradient(90deg, #7fcf5f, #3f9a3a); }
.ucard .xp { position: absolute; right: 3px; top: 3px; color: var(--gold); font-size: 10px; letter-spacing: -1px; text-shadow: 0 1px 1px #000; }
.ucard .gen { position: absolute; left: 3px; top: 3px; color: var(--gold); }
.ucard.sel { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.ucard.queued { opacity: .55; }
.ucard.queued::after { content: "⧗"; position: absolute; right: 5px; top: 3px; color: #fff; font-size: 13px; }
.ucard.recruit { width: 84px; }
.ucard.recruit img { left: 10px; }
.ucard.recruit .n { bottom: 4px; font-size: 12px; color: #ffe7a8; }
.ucard.off { filter: grayscale(.85) brightness(.7); cursor: not-allowed; }

/* edifici */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 7px; }
.slot { position: relative; min-height: 76px; border-radius: 8px; padding: 7px 8px; cursor: pointer; background: rgba(255, 255, 255, .45); border: 1.5px solid var(--parch4); display: flex; flex-direction: column; gap: 3px; }
.slot:hover { background: rgba(255, 255, 255, .7); }
.slot .ico { width: 24px; height: 24px; color: var(--ink2); }
.slot .nm { font-weight: 700; font-size: 14px; line-height: 1.1; }
.slot .sq { font-size: 12px; color: var(--ink3); font-style: italic; }
.slot .tier { position: absolute; right: 7px; top: 6px; font: 700 12px var(--f-title); color: var(--gold3); }
.slot.empty { align-items: center; justify-content: center; border-style: dashed; color: var(--ink3); font-size: 13px; background: rgba(255, 255, 255, .2); }
.slot.building { background: repeating-linear-gradient(135deg, rgba(220, 184, 99, .25) 0 8px, rgba(255, 255, 255, .35) 8px 16px); }
.prog { height: 5px; border-radius: 3px; background: rgba(0, 0, 0, .15); overflow: hidden; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.opts { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, .5); border: 1px solid var(--parch4); cursor: pointer; }
.opt:hover { background: rgba(255, 255, 255, .8); }
.opt.off { opacity: .55; cursor: not-allowed; }
.opt .ico { width: 26px; height: 26px; color: var(--ink2); }
.opt .mid { flex: 1; min-width: 0; }
.opt .nm { font-weight: 700; }
.opt .fx { font-size: 13px; color: var(--ink2); }
.opt .why { font-size: 12.5px; color: var(--red2); }
.opt .cost { text-align: right; font-size: 14px; white-space: nowrap; }

/* barre */
.meter { position: relative; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .18); overflow: hidden; min-width: 80px; }
.meter i { position: absolute; top: 0; bottom: 0; }
.meter.bi i { left: 50%; }
.meter .mid { position: absolute; left: 50%; top: -1px; bottom: -1px; width: 1px; background: rgba(0, 0, 0, .4); }

/* ---------------- finestre modali ---------------- */
.backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(10, 6, 2, .62); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal { position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: rise .22s;
  background: linear-gradient(175deg, var(--parch), var(--parch2)); border: 2px solid var(--gold2); border-radius: 12px;
  box-shadow: 0 0 0 5px rgba(30, 20, 10, .85), 0 20px 60px rgba(0, 0, 0, .8); overflow: hidden; }
.modal.wide { width: min(1080px, 100%); }
.modal.narrow { width: min(480px, 100%); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--parch4); background: linear-gradient(#e9d8ad, #dcc594); }
.modal .mh h2 { margin: 0; font: 700 21px var(--f-title); letter-spacing: .04em; color: var(--ink); }
.modal .mh .x { margin-left: auto; }
.modal .mb { overflow: auto; padding: 14px; }
.modal .mf { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--parch4); background: rgba(0, 0, 0, .04); }
.modal .art { width: 100%; aspect-ratio: 16/7; object-fit: cover; display: block; border-bottom: 2px solid var(--gold2); background: linear-gradient(135deg, #4a3522, #1e140c); }
.modal.event .mb p { font-size: 17px; line-height: 1.5; margin: 0 0 8px; }
.choices { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.choice { text-align: left; padding: 10px 12px; border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, .55); border: 1.5px solid var(--parch4); font: 600 16px var(--f-body); color: var(--ink); }
.choice:hover { background: #fffaf0; border-color: var(--gold2); }
.choice .fx { display: block; font-weight: 400; font-size: 13.5px; color: var(--ink2); margin-top: 3px; }
.choice.off { opacity: .5; cursor: not-allowed; }

/* diplomazia */
.dip { display: grid; grid-template-columns: 300px 1fr; gap: 14px; min-height: 420px; }
.dip .list { display: flex; flex-direction: column; gap: 5px; overflow: auto; max-height: 64vh; }
.frow { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; background: rgba(255, 255, 255, .4); border: 1px solid transparent; }
.frow:hover { background: rgba(255, 255, 255, .7); }
.frow.sel { border-color: var(--gold2); background: #fff8e8; }
.frow img { width: 26px; height: 30px; flex: none; }
.frow .nm { font-weight: 700; font-size: 14.5px; line-height: 1.1; }
.frow .st { font-size: 12px; color: var(--ink3); }
.frow .rel { margin-left: auto; font: 700 14px var(--f-body); }
.dip .detail { min-width: 0; }
.parts { font-size: 13.5px; }
.parts div { display: flex; justify-content: space-between; gap: 10px; padding: 1px 0; border-bottom: 1px dotted rgba(90, 65, 40, .25); }
.verdict { font-size: 12.5px; font-weight: 700; padding: 2px 7px; border-radius: 9px; white-space: nowrap; }
.verdict.yes { background: rgba(61, 122, 58, .18); color: var(--green2); }
.verdict.maybe { background: rgba(184, 128, 28, .2); color: #7a5410; }
.verdict.no { background: rgba(169, 42, 34, .15); color: var(--red2); }
.acts { display: flex; flex-direction: column; gap: 6px; }
.act { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: 8px; background: rgba(255, 255, 255, .45); border: 1px solid var(--parch4); }
.act .nm { flex: 1; font-weight: 600; }

/* dinastia */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.person { display: flex; gap: 10px; padding: 9px; border-radius: 9px; background: rgba(255, 255, 255, .5); border: 1.5px solid var(--parch4); position: relative; }
.person.leader { border-color: var(--gold2); background: #fff7e2; }
.person img.pt { width: 60px; height: 74px; border-radius: 6px; object-fit: cover; border: 2px solid var(--gold3); background: #3a2716; flex: none; }
.person .nm { font-weight: 700; font-size: 15px; line-height: 1.1; }
.person .ep { font-style: italic; color: var(--ink2); font-size: 13px; }
.person .meta { font-size: 12.5px; color: var(--ink3); }
.person .tag { position: absolute; right: 7px; top: 6px; color: var(--gold3); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font-size: 11.5px; padding: 1px 7px; border-radius: 9px; background: rgba(90, 65, 40, .12); border: 1px solid rgba(90, 65, 40, .25); cursor: help; }
.chip.bad { background: rgba(169, 42, 34, .1); color: var(--red2); border-color: rgba(169, 42, 34, .3); }
.chip.perk { background: rgba(220, 184, 99, .25); border-color: var(--gold2); }
.stars { color: var(--gold2); letter-spacing: -1px; font-size: 12px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th { text-align: left; font: 700 11.5px var(--f-title); letter-spacing: .08em; color: var(--ink2); padding: 6px 6px; border-bottom: 1.5px solid var(--parch4); white-space: nowrap; }
table.tbl td { padding: 5px 6px; border-bottom: 1px solid rgba(90, 65, 40, .15); white-space: nowrap; }
table.tbl tr:hover td { background: rgba(255, 255, 255, .35); }
table.tbl td.num, table.tbl th.num { text-align: right; }

/* battaglia (finestra della campagna) */
.bside { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: start; }
.bcol { min-width: 0; }
.bcol .who { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bcol .who img.sh { width: 34px; height: 39px; }
.bcol .who img.pt { width: 42px; height: 52px; border-radius: 5px; object-fit: cover; border: 2px solid var(--gold3); }
.bcol .who .nm { font: 700 16px var(--f-title); }
.bcol .cards { flex-wrap: wrap; overflow: visible; }
.bcol .ucard { width: 52px; height: 74px; }
.bcol .ucard img { width: 48px; height: 54px; left: 1px; }
.bcol .ucard .n { font-size: 11px; bottom: 10px; }
.bcol .ucard .hp { bottom: 4px; }
.vs { font: 700 28px var(--f-title); color: var(--red2); align-self: center; }
.pbar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--ink2); margin: 10px 0 4px; }
.pbar i { display: block; height: 100%; }
.result-banner { text-align: center; font: 700 clamp(26px, 5vw, 40px) var(--f-title); letter-spacing: .06em; margin: 4px 0 2px; }
.result-banner.win { color: var(--green2); } .result-banner.lose { color: var(--red2); }

/* tooltip */
#tip { position: fixed; z-index: 90; max-width: 320px; pointer-events: none; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; line-height: 1.35;
  background: rgba(24, 15, 8, .96); color: var(--light); border: 1px solid var(--gold3); box-shadow: 0 6px 20px rgba(0, 0, 0, .6); }
#tip b { color: var(--gold); }
#tip .row { display: flex; justify-content: space-between; gap: 14px; }
#tip .sep { height: 1px; background: rgba(220, 184, 99, .3); margin: 5px 0; }

/* avvisi */
#toasts { position: fixed; top: calc(var(--top-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, 92vw); }
.toast { padding: 8px 14px; border-radius: 9px; font-size: 15px; text-align: center; background: rgba(28, 18, 10, .94); color: var(--light); border: 1px solid var(--gold3); box-shadow: 0 6px 18px rgba(0, 0, 0, .55); animation: rise .2s; }
.toast.bad { border-color: #b8453a; }

/* velo del turno nemico */
#aiveil { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; border-radius: 24px; background: rgba(24, 15, 8, .92); color: var(--light); border: 1px solid var(--gold3); font: 600 15px var(--f-body); box-shadow: 0 6px 22px rgba(0, 0, 0, .6); }
#aiveil img { width: 24px; height: 28px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(220, 184, 99, .3); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- telefoni ---------------- */
@media (max-width: 760px) {
  :root { --top-h: 46px; }
  .topbar { padding-left: 118px; gap: 5px; padding-right: 6px; }
  .topbar .fac span { display: none; }
  .stat { font-size: 13.5px; padding: 2px 7px; }
  .stat.date { font-size: 11.5px; }
  .nav { position: fixed; left: max(8px, env(safe-area-inset-left)); top: calc(var(--top-h) + 8px); flex-direction: column; gap: 6px; }
  .nav .btn { padding: 8px; }
  .nav .btn .lbl { display: none; }
  .feed { width: min(270px, 70vw); top: calc(var(--top-h) + 8px); }
  .feed.collapsed { width: auto; }
  .sheet { left: 0; right: 0; width: 100%; bottom: 0; border-radius: 14px 14px 0 0; max-height: 58vh; padding-bottom: env(safe-area-inset-bottom); }
  .endturn { width: 74px; height: 74px; right: 10px; font-size: 10.5px; }
  .endturn.lifted { bottom: calc(58vh + 10px); }
  .mapbtns { right: 92px; }
  #hud.sheet-open .mapbtns { display: none; }
  .dip { grid-template-columns: 1fr; }
  .dip .list { max-height: 30vh; }
  .modal .mb { padding: 12px; }
  .bside { grid-template-columns: 1fr; }
  #newgame { padding-bottom: 210px; }
  .ng-bar { gap: 7px; padding-top: 30px; }
  .modal table.tbl { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .seg button { padding: 7px 9px; font-size: 13px; }
  .vs { text-align: center; font-size: 20px; }
}
@media (max-width: 420px) {
  .topbar .fac { display: none; }
  .topbar { padding-left: 116px; }
}

/* ---------------- battaglia ---------------- */
#battle { position: fixed; inset: 0; z-index: 5; background: #1a130c; touch-action: none; }
#bhud { position: fixed; inset: 0; pointer-events: none; z-index: 12; }
#bhud > * { pointer-events: auto; }
.btop { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; flex-wrap: nowrap;
  padding: 6px 10px; border-radius: 12px; background: rgba(24, 15, 8, .9); border: 1px solid var(--gold3); color: var(--light); box-shadow: 0 6px 18px rgba(0, 0, 0, .5); max-width: calc(100vw - 130px); }
.bttl { display: flex; align-items: center; gap: 6px; font: 700 14px var(--f-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bttl img { width: 18px; height: 21px; }
.bclock { font: 700 14px var(--f-body); min-width: 42px; text-align: center; color: var(--gold); }
.bsp { display: flex; gap: 3px; }
.bsp .btn { padding: 4px 7px; }
.bsp small { font-size: 9px; margin-left: 1px; }
.bbal { width: 110px; height: 10px; display: flex; border-radius: 5px; overflow: hidden; border: 1px solid rgba(0, 0, 0, .6); flex: none; }
.bbal i { display: block; height: 100%; }
.bbal i:last-child { flex: 1; }
.bcards { position: absolute; left: 10px; right: 62px; bottom: calc(8px + env(safe-area-inset-bottom)); display: flex; gap: 5px; overflow-x: auto; padding: 4px 2px; }
.bcards .ucard { width: 58px; height: 82px; }
.bcards .ucard img { width: 54px; height: 60px; left: 1px; }
.bcards .ucard .n { bottom: 12px; font-size: 11.5px; }
.bcards .ucard .hp { bottom: 7px; }
.bcards .ucard.fight { box-shadow: 0 0 0 2px #c9412c, 0 0 10px rgba(201,65,44,.55); animation: bfight 1.1s ease-in-out infinite; }
.bcards .ucard.hurt::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(200,40,24,.35); pointer-events: none; }
@keyframes bfight { 50% { box-shadow: 0 0 0 2px #e8664a, 0 0 16px rgba(232,102,74,.75); } }
.bvig { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse 75% 70% at 50% 48%, transparent 60%, rgba(18,10,4,.42) 100%); }
.bc .mo { position: absolute; left: 4px; top: 4px; width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .6); }
.bc .am { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; background: rgba(0, 0, 0, .55); border-radius: 2px; overflow: hidden; }
.bc .am i { display: block; height: 100%; background: #e2c26a; }
.bmini { position: absolute; right: 10px; top: calc(max(8px, env(safe-area-inset-top)) + 54px); pointer-events: auto; touch-action: none; cursor: crosshair;
  border: 1px solid rgba(220, 184, 99, .55); border-radius: 6px; box-shadow: 0 6px 16px rgba(0, 0, 0, .55); background: #2a2014; }
.border { position: absolute; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 5px; }
.border .btn { padding: 8px; }
.bdeploy { position: absolute; top: calc(64px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; max-width: 92vw;
  padding: 10px 14px; border-radius: 10px; background: linear-gradient(175deg, var(--parch), var(--parch2)); border: 2px solid var(--gold2); box-shadow: 0 8px 26px rgba(0, 0, 0, .6); font-size: 14.5px; }
.bbox { position: fixed; border: 1.5px dashed #ffd66e; background: rgba(255, 214, 110, .1); pointer-events: none !important; }
.bresult { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: min(360px, 92vw); padding: 18px; border-radius: 12px; text-align: center;
  background: linear-gradient(175deg, var(--parch), var(--parch2)); border: 2px solid var(--gold2); box-shadow: 0 0 0 5px rgba(30, 20, 10, .85), 0 20px 60px rgba(0, 0, 0, .8); animation: rise .3s; }
.bresult table { margin: 10px 0 14px; }
.bresult img { width: 16px; height: 18px; vertical-align: middle; }
@media (max-width: 760px) {
  .btop { gap: 5px; padding: 5px 7px; left: auto; right: 8px; transform: none; max-width: calc(100vw - 118px); flex-wrap: wrap; justify-content: flex-end; }
  .bttl span, .btop .lbl { display: none; }
  .bbal { width: 70px; }
  .bdeploy { top: calc(92px + env(safe-area-inset-top)); flex-direction: column; gap: 8px; text-align: center; }
}
