/* Layout: tamsaus medžio ir akmens rėmai su aukso apvadais (Heroes III dvasia), pergamentiniai dialogai.
   Kompiuteris: viršutinė juosta + 3 stulpeliai (herojus | rodinys | vieta ir kronika).
   Vidutinis ekranas: 2 stulpeliai. Telefonas: viena kolona ir apatinis meniu. Sąmoningai viena tamsi tema. */
:root {
  --night: #16120d;
  --wood: #2a2118;
  --wood-2: #352a1e;
  --edge: #5a4630;
  --gold: #d6a640;
  --gold-hi: #f2d283;
  --gold-lo: #8a6a28;
  --text: #f0e6cf;
  --dim: #ad9e80;
  --parch: #eadbb6;
  --parch-2: #dcc89a;
  --ink: #2c1e10;
  --ink-dim: #6d5a3e;
  --red: #c8483a;
  --green: #6cae55;
  --blue: #5b8bd6;
  --mana: #78a6ff;
  --own: #4f86c9;
  --foe: #c25444;
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --body: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;
  --r: 6px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--text);
  font: 16px/1.4 var(--body);
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0.03em; text-wrap: balance; margin: 0; }
small { font-size: 0.82em; }
.dim { color: var(--dim); }
.good { color: var(--green); }
.bad { color: var(--red); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- Mygtukai ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 14px;
  background: linear-gradient(#4a3a28, #33281c);
  border: 1px solid var(--gold-lo);
  border-radius: var(--r);
  box-shadow: inset 0 1px 0 rgb(255 230 170 / 15%);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, transform .08s, filter .15s;
}
.btn:hover:not(:disabled) { border-color: var(--gold-hi); filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, [data-act]:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.gold { background: linear-gradient(#e4b85a, #b8862c); border-color: var(--gold-hi); color: #2a1a06; font-weight: 700; }
.btn.red { background: linear-gradient(#a6402f, #7a2b1f); border-color: #d0705e; }
.btn.ghost { background: transparent; }
.btn.icon { min-width: 38px; padding: 6px; }
.btn.wide { width: 100%; }
.btn .cost { font-size: 0.82em; opacity: 0.85; }
.mp { color: var(--gold-hi); white-space: nowrap; }

/* ---------- Rėmeliai ---------- */
.panel {
  background: linear-gradient(var(--wood-2), var(--wood));
  border: 1px solid var(--edge);
  border-radius: var(--r);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 40%), 0 2px 10px rgb(0 0 0 / 30%);
  padding: 12px;
}
.ptitle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0 0 8px;
  font: 700 13px var(--display);
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px;
  border: 1px solid var(--edge);
  border-radius: 99px;
  font-size: 13px;
  color: var(--dim);
  white-space: nowrap;
}
.chip.good { color: var(--green); border-color: #4c7a3c; }
.chip.bad { color: var(--red); border-color: #8a3a2e; }
.chip.gold { color: var(--gold-hi); border-color: var(--gold-lo); }

.bar { position: relative; height: 8px; background: #0e0b08; border: 1px solid #000; border-radius: 4px; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width .35s; }
.bar.xp > i { background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); }
.bar.mana > i { background: var(--mana); }
.bar.mp > i { background: #c9a35a; }
.bar.foe > i { background: var(--foe); }

/* Karių portretai pagal lygį */
.por {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  font-size: 26px; line-height: 1;
  border: 1px solid var(--gold-lo);
  border-radius: var(--r);
  background: radial-gradient(circle at 50% 35%, #5d4a33, #1d160f);
}
.por.t1, .por.t2 { background: radial-gradient(circle at 50% 35%, #50604a, #161b14); }
.por.t3, .por.t4 { background: radial-gradient(circle at 50% 35%, #4b5a78, #141823); }
.por.t5, .por.t6 { background: radial-gradient(circle at 50% 35%, #6c4a7a, #1d1322); }
.por.t7 { background: radial-gradient(circle at 50% 35%, #9a7a32, #2a1f0a); border-color: var(--gold-hi); }
.por.n { background: radial-gradient(circle at 50% 35%, #6a3a2e, #1f100c); }
.por.sm { width: 32px; height: 32px; font-size: 18px; }
.por.lg { width: 64px; height: 64px; font-size: 40px; }

/* ---------- Pradžios ekranas ---------- */
#splash {
  position: fixed; inset: 0; overflow-y: auto;
  display: grid; place-items: center;
  padding-block: max(24px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background:
    radial-gradient(ellipse at 50% 0%, rgb(214 166 64 / 18%), transparent 60%),
    linear-gradient(#1c1610, #0e0b08);
}
.sp-card { width: min(560px, 100%); text-align: center; }
.sp-crest { font-size: 54px; color: var(--gold); line-height: 1; filter: drop-shadow(0 0 18px rgb(214 166 64 / 35%)); }
.sp-title { font-size: clamp(34px, 7vw, 56px); color: var(--gold-hi); text-shadow: 0 2px 0 #000, 0 0 30px rgb(214 166 64 / 25%); margin-top: 6px; }
.sp-sub { color: var(--dim); margin: 6px 0 22px; font-size: 17px; }
.sp-menu { display: grid; gap: 10px; max-width: 320px; margin: 0 auto; }
.sp-menu .btn { min-height: 46px; font-size: 17px; }
.sp-foot { margin-top: 22px; color: var(--dim); font-size: 14px; }
.sp-foot a { color: var(--gold); }
.newgame { text-align: left; }
.newgame label { display: block; font: 700 13px var(--display); color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; margin: 14px 0 6px; }
.newgame input {
  width: 100%; padding: 10px 12px; font: 18px var(--body);
  background: #0e0b08; color: var(--text);
  border: 1px solid var(--gold-lo); border-radius: var(--r);
}
.classes { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.cls {
  display: grid; gap: 4px; text-align: left; padding: 12px;
  background: var(--wood); border: 1px solid var(--edge); border-radius: var(--r); cursor: pointer;
}
.cls.on { border-color: var(--gold-hi); box-shadow: 0 0 0 1px var(--gold-hi), 0 0 18px rgb(214 166 64 / 25%); }
.cls h3 { font-size: 18px; color: var(--gold-hi); }
.cls p { margin: 0; color: var(--dim); font-size: 14px; }

/* ---------- Programos tinklelis ---------- */
#app {
  display: grid;
  height: 100%;
  grid-template-columns: 290px minmax(0, 1fr) 330px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "left main right";
  gap: 10px;
  padding-block: 0 max(10px, env(safe-area-inset-bottom, 0px));
  padding-left: max(10px, env(safe-area-inset-left, 0px));
  padding-right: max(10px, env(safe-area-inset-right, 0px));
}
#top { grid-area: top; }
#left { grid-area: left; overflow-y: auto; display: grid; gap: 10px; align-content: start; }
#main { grid-area: main; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
#right { grid-area: right; overflow-y: auto; display: grid; gap: 10px; align-content: start; min-height: 0; }
#tabs { display: none; }
#view { flex: 1; min-height: 0; overflow-y: auto; }

/* Viršutinė juosta */
#top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 0 calc(-1 * max(10px, env(safe-area-inset-left, 0px))) 0 calc(-1 * max(10px, env(safe-area-inset-right, 0px)));
  padding: calc(8px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(#2e2419, #1c160f);
  border-bottom: 2px solid var(--gold-lo);
  box-shadow: 0 2px 12px rgb(0 0 0 / 50%);
}
.brand { display: flex; align-items: center; gap: 8px; font: 700 20px var(--display); color: var(--gold-hi); white-space: nowrap; }
.crest { color: var(--gold); font-size: 22px; }
.res { display: flex; gap: 6px; flex: 1; justify-content: center; flex-wrap: wrap; }
.r {
  display: flex; align-items: baseline; gap: 5px;
  padding: 4px 10px;
  background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r);
  font-variant-numeric: tabular-nums;
}
.r b { font-size: 16px; }
.r small { color: var(--green); }
.date { display: grid; text-align: right; line-height: 1.15; }
.date small { color: var(--dim); }
.date b { font-family: var(--display); color: var(--gold-hi); }

/* Rodinių kortelės */
#views { display: flex; gap: 4px; margin-bottom: 8px; }
.tab {
  padding: 8px 16px;
  background: var(--wood); border: 1px solid var(--edge); border-radius: var(--r) var(--r) 0 0;
  border-bottom-color: transparent;
  font: 700 14px var(--display); letter-spacing: 0.05em; color: var(--dim);
  cursor: pointer;
}
.tab.on { color: var(--gold-hi); background: var(--wood-2); border-color: var(--gold-lo); border-bottom-color: transparent; }
.tab kbd { font: 11px var(--body); opacity: 0.6; margin-left: 4px; }

/* Herojaus kortelė */
.hero-top { display: flex; gap: 12px; align-items: center; }
.hero-top h2 { font-size: 20px; color: var(--gold-hi); }
.stats4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; text-align: center; }
.stats4 div { background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); padding: 4px 0; }
.stats4 b { display: block; font-size: 18px; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.stats4 span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; }
.meter { display: grid; grid-template-columns: 74px 1fr auto; gap: 8px; align-items: center; font-size: 14px; margin-top: 6px; }
.meter span:last-child { font-variant-numeric: tabular-nums; color: var(--dim); }

/* Kariuomenės langeliai */
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot {
  position: relative;
  display: grid; place-items: center;
  aspect-ratio: 1; max-width: 100%;
  background: #0f0c08; border: 1px dashed var(--edge); border-radius: var(--r);
  font-size: 28px; cursor: pointer;
}
.slot.full { border-style: solid; border-color: var(--gold-lo); background: radial-gradient(circle at 50% 35%, #4a3b29, #120e09); }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font: 700 13px var(--body); color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.slot:hover.full { border-color: var(--gold-hi); }

/* ---------- Žemėlapis ---------- */
.mapgrid { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.mapwrap {
  position: relative;
  flex: 1;
  min-height: 360px;
  border: 2px solid var(--gold-lo);
  border-radius: var(--r);
  overflow: hidden;
  background: #0d0b08;
  box-shadow: inset 0 0 40px rgb(0 0 0 / 60%);
}
.mapc { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
.mapctl { position: absolute; top: 8px; right: 8px; display: grid; gap: 4px; z-index: 2; }
.mapctl .btn { background: rgb(26 20 14 / 85%); }
.maplegend {
  position: absolute; left: 8px; bottom: 8px; z-index: 2;
  padding: 3px 10px; border-radius: 99px;
  background: rgb(14 11 8 / 82%); border: 1px solid var(--edge);
  font-size: 13px; color: var(--dim); pointer-events: none;
}
.maplegend .lg { color: #8be36f; } .maplegend .lr { color: #e2604c; }
.maphint { margin: 10px 0 0; color: var(--dim); font-size: 13px; }

/* Vietos skydelis */
.loc h2 { font-size: 20px; color: var(--gold-hi); }
.dbig.sm { margin: 6px 0; gap: 10px; }
.mlrow { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 14px; color: var(--dim); }
.skrow { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.sk { position: relative; display: grid; place-items: center; width: 34px; height: 34px; background: #0f0c08; border: 1px solid var(--gold-lo); border-radius: var(--r); font-size: 18px; }
.sk i { position: absolute; right: 1px; bottom: -1px; font: 700 11px var(--body); color: var(--gold-hi); font-style: normal; }
.qrow { display: grid; gap: 4px; padding: 6px 0; border-bottom: 1px solid rgb(90 70 48 / 50%); font-size: 14px; }
.qrow:last-child { border-bottom: 0; }
.qrow.big { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 15px; }
.qrow .qi { font-size: 26px; }
.skills { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.skill { display: flex; gap: 10px; align-items: center; padding: 8px; background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); font-size: 14px; }
.skill .si { font-size: 26px; }
.skill.none { display: block; color: var(--dim); opacity: 0.6; text-align: center; }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.ach { display: flex; gap: 10px; align-items: flex-start; padding: 8px; background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); font-size: 14px; opacity: 0.6; }
.ach > span { font-size: 24px; }
.ach.on { opacity: 1; border-color: var(--gold-lo); }
.ach.on b { color: var(--gold-hi); }
.por.up::after { content: '★'; position: absolute; right: -3px; top: -6px; font-size: 12px; color: var(--gold-hi); text-shadow: 0 0 3px #000; }
.por { position: relative; }
.slot.up::before { content: '★'; position: absolute; left: 3px; top: 0; font-size: 11px; color: var(--gold-hi); }
.arrow { color: var(--gold); font-weight: 700; }
.seg { display: flex; gap: 4px; margin-bottom: 10px; }
.seg button { flex: 1; padding: 8px; border: 1px solid rgb(110 80 40 / 50%); background: rgb(255 250 235 / 50%); border-radius: 4px; font-weight: 700; cursor: pointer; color: var(--ink); }
.seg button.on { background: #8a5a14; color: #fff3d6; border-color: #8a5a14; }
.loc p { margin: 6px 0; }
.loc .who { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.uchip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px 2px 2px;
  background: #0f0c08; border: 1px solid var(--edge); border-radius: 99px;
  cursor: pointer; font-size: 14px;
}
.uchip .por { width: 28px; height: 28px; font-size: 16px; border-radius: 99px; }
.box { margin: 8px 0; padding: 8px 10px; background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); font-size: 15px; }
.box.warn { border-color: #8a3a2e; }
.box.ok { border-color: #4c7a3c; }
.acts { display: grid; gap: 6px; margin-top: 10px; }
.acts .btn { justify-content: space-between; }

/* Kronika */
.chron { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.chron li { padding: 5px 0; border-bottom: 1px solid rgb(90 70 48 / 50%); }
.chron li span { color: var(--gold); font-variant-numeric: tabular-nums; margin-right: 6px; }

/* ---------- Pilis ---------- */
.town-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 10px; }
.town-head h2 { font-size: 24px; color: var(--gold-hi); }
.sect { margin: 16px 0 8px; font: 700 14px var(--display); color: var(--gold); letter-spacing: 0.08em; text-transform: uppercase; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.bcard { display: flex; flex-direction: column; gap: 6px; }
.bcard .bh { display: flex; gap: 10px; align-items: center; }
.bcard h3 { font-size: 15px; color: var(--text); }
.bcard p { margin: 0; color: var(--dim); font-size: 14px; flex: 1; }
.bcard .costs { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.bcard.built { border-color: #4c6a3c; }
.pips { display: inline-flex; gap: 3px; margin-left: 4px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--gold-lo); }
.pips i.on { background: var(--gold); }
.avail { font-size: 22px; font-weight: 700; color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.market { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.mrow { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.mrow .btns { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* ---------- Herojaus rodinys ---------- */
.hgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 10px; }
.arts { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.art { padding: 8px; background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); font-size: 13px; }
.art b { display: block; color: var(--gold-hi); font-size: 14px; }
.art.none { opacity: 0.4; text-align: center; }
.spells { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.spell { padding: 8px; background: #101626; border: 1px solid #34466e; border-radius: var(--r); font-size: 13px; }
.spell b { display: block; color: #bcd0ff; font-size: 14px; }
.spell.no { opacity: 0.35; }
table.ut { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.ut th, .ut td { padding: 6px; border-bottom: 1px solid var(--edge); text-align: left; }
.ut th { color: var(--gold); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.scroll-x { overflow-x: auto; }

/* ---------- Mūšis ---------- */
.battle { display: flex; flex-direction: column; gap: 10px; }
.bhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.bhead h2 { font-size: 20px; color: var(--gold-hi); }
.order { display: flex; gap: 3px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--dim); }
.order .por { width: 28px; height: 28px; font-size: 16px; }
.order .por.o { box-shadow: inset 0 -3px 0 var(--own); }
.order .por.f { box-shadow: inset 0 -3px 0 var(--foe); }
.order .por.now { outline: 2px solid var(--gold-hi); outline-offset: 1px; }
.prompt { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prompt .por { width: 26px; height: 26px; font-size: 15px; }
.field {
  display: grid; grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr); gap: 8px;
  padding: 14px 10px;
  border: 2px solid var(--gold-lo); border-radius: var(--r);
  background:
    radial-gradient(ellipse at 50% 120%, rgb(0 0 0 / 50%), transparent 60%),
    repeating-linear-gradient(115deg, rgb(255 255 255 / 2%) 0 12px, transparent 12px 26px),
    linear-gradient(#55703a, #3b5129);
  min-height: 300px;
}
.field .mid { display: grid; place-items: center; font-size: 22px; color: rgb(255 240 200 / 50%); }
.side { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.card {
  position: relative;
  display: flex; gap: 8px; align-items: center;
  padding: 6px 8px;
  background: rgb(20 15 10 / 82%);
  border: 1px solid var(--edge);
  border-left: 4px solid var(--own);
  border-radius: var(--r);
  transition: transform .18s, box-shadow .18s, opacity .3s;
}
.card.foe { border-left: 1px solid var(--edge); border-right: 4px solid var(--foe); flex-direction: row-reverse; text-align: right; }
.card.foe .por { transform: scaleX(-1); }
.card .ci { min-width: 0; flex: 1; display: grid; gap: 2px; }
.card .ci b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .ci small { color: var(--dim); }
.card .cnt { font: 700 18px var(--display); color: var(--gold-hi); font-variant-numeric: tabular-nums; }
.card.tgt { cursor: pointer; }
.card.tgt:hover { border-color: var(--gold-hi); box-shadow: 0 0 0 1px var(--gold-hi), 0 0 14px rgb(242 210 131 / 30%); }
.card.pick { box-shadow: 0 0 0 2px var(--mana), 0 0 16px rgb(120 166 255 / 45%); cursor: pointer; }
.card.cur { border-color: var(--gold-hi); box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px rgb(242 210 131 / 40%); animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 6px rgb(242 210 131 / 20%); } }
.card.dead { opacity: 0.3; filter: grayscale(1); pointer-events: none; }
.card.act { transform: translateX(10px) scale(1.04); box-shadow: 0 0 0 2px var(--gold-hi); z-index: 2; }
.card.foe.act { transform: translateX(-10px) scale(1.04); }
.card.hit { animation: shake .32s; }
.card.heal { box-shadow: 0 0 0 2px var(--green), 0 0 16px rgb(108 174 85 / 50%); }
@keyframes shake { 0%, 100% { translate: 0 } 20% { translate: -6px 0 } 40% { translate: 6px 0 } 60% { translate: -4px 0 } 80% { translate: 3px 0 } }
.float {
  position: absolute; left: 50%; top: 0;
  font: 700 18px var(--display); color: #ffdfd6; text-shadow: 0 2px 2px #000, 0 0 6px var(--red);
  pointer-events: none; white-space: nowrap;
  animation: rise .9s ease-out forwards;
}
.float.heal { color: #dff7d6; text-shadow: 0 2px 2px #000, 0 0 6px var(--green); }
.float.spell { color: #dbe6ff; text-shadow: 0 2px 2px #000, 0 0 8px var(--mana); }
@keyframes rise { from { opacity: 1; transform: translate(-50%, 0); } to { opacity: 0; transform: translate(-50%, -38px); } }
.bctl { display: flex; gap: 6px; flex-wrap: wrap; }
.bctl .btn { flex: 1 1 auto; }
.blog { margin: 0; padding: 8px 10px; background: #0f0c08; border: 1px solid var(--edge); border-radius: var(--r); font-size: 14px; max-height: 160px; overflow-y: auto; }
.blog div { padding: 1px 0; }
.blog .o { color: #b8d0f0; }
.blog .f { color: #f0c0b5; }
.blog .s { color: #c8d6ff; }
.blog .r { color: var(--gold); margin-top: 4px; }
.blog.tall { max-height: none; }
.targeting { padding: 8px 10px; background: #101626; border: 1px solid var(--mana); border-radius: var(--r); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.busy #view .card, .busy #view .bctl .btn, .busy .mapc { pointer-events: none; }
.busy #view .bctl .btn.stop { pointer-events: auto; }

/* ---------- Dialogai ---------- */
#modal {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding-block: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-bottom, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgb(8 6 4 / 70%);
  backdrop-filter: blur(2px);
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.dlg {
  width: min(480px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: linear-gradient(var(--parch), var(--parch-2));
  color: var(--ink);
  border: 3px solid var(--gold-lo);
  outline: 1px solid #000;
  border-radius: 4px;
  box-shadow: 0 20px 60px rgb(0 0 0 / 60%), inset 0 0 40px rgb(120 80 30 / 25%);
  animation: pop .18s ease-out;
}
.dlg.wide { width: min(640px, 100%); }
@keyframes pop { from { transform: scale(.95); opacity: 0; } }
.dlg > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 6px; border-bottom: 1px solid rgb(110 80 40 / 35%); }
.dlg h2 { font-size: 20px; color: #4a2d0c; }
.dlg .x { background: none; border: 0; font-size: 20px; color: var(--ink-dim); cursor: pointer; padding: 4px 8px; }
.dbody { padding: 12px 16px 16px; }
.dbody p { margin: 6px 0; }
.dbody .dim { color: var(--ink-dim); }
.dbody .good { color: #2f6b20; }
.dbody .bad { color: #9a2a1c; }
.dbody .box { background: rgb(255 250 235 / 55%); border-color: rgb(110 80 40 / 40%); color: var(--ink); }
.dbody .chip { color: var(--ink-dim); border-color: rgb(110 80 40 / 40%); }
.dbody .chip.good { color: #2f6b20; border-color: #5d8a46; }
.dbody .chip.bad { color: #9a2a1c; border-color: #b0604f; }
.dbody .ut th { color: #7a5418; }
.dbody .ut td, .dbody .ut th { border-color: rgb(110 80 40 / 30%); }
.dbig { display: flex; gap: 14px; align-items: center; margin: 6px 0 10px; }
.dbig .emo { font-size: 52px; line-height: 1; }
.dbig h3 { font-size: 20px; color: #4a2d0c; }
.dacts { display: grid; gap: 8px; margin-top: 14px; }
.dacts.two { grid-template-columns: 1fr 1fr; }
.dbody .btn { color: var(--text); }
.dbody .btn.gold { color: #2a1a06; }
.risk { display: flex; gap: 3px; }
.risk i { flex: 1; height: 8px; border-radius: 2px; background: rgb(110 80 40 / 25%); }
.risk.r1 i:nth-child(-n+1) { background: #3d8a2a; }
.risk.r2 i:nth-child(-n+2) { background: #a58a1f; }
.risk.r3 i:nth-child(-n+3) { background: #c26a1f; }
.risk.r4 i:nth-child(-n+4) { background: #b0281a; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 12px 0 4px; }
.slider input { width: 100%; accent-color: #8a5a14; }
.slider output { font: 700 22px var(--display); min-width: 3ch; text-align: right; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.choice .btn { min-height: 74px; flex-direction: column; font-size: 16px; }
.choice .btn b { font: 700 20px var(--display); }
.choice .btn small { font-size: 13px; opacity: 0.9; text-align: center; }
.choice .btn .si { font-size: 28px; }
.lst { margin: 4px 0; padding: 0; list-style: none; }
.lst li { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.lst .por { width: 30px; height: 30px; font-size: 17px; }
.help h3 { font-size: 15px; margin: 12px 0 2px; color: #4a2d0c; }
.help p { margin: 0 0 4px; }
.kb { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 14px; }
.kb kbd { font: 700 13px var(--body); padding: 0 6px; border: 1px solid rgb(110 80 40 / 50%); border-radius: 3px; background: rgb(255 250 235 / 60%); }

/* Pranešimai */
#toasts {
  position: fixed; z-index: 60;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  display: grid; gap: 6px; width: min(360px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  background: linear-gradient(#3a2d1f, #261d14);
  border: 1px solid var(--gold-lo); border-left: 4px solid var(--gold);
  border-radius: var(--r);
  box-shadow: 0 8px 20px rgb(0 0 0 / 50%);
  font-size: 15px;
  animation: tin .2s ease-out;
}
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Vidutinis ekranas: be dešinio stulpelio ---------- */
@media (max-width: 1180px) {
  #app { grid-template-columns: 270px minmax(0, 1fr); grid-template-areas: "top top" "left main"; }
  #right { display: none; }
}

/* ---------- Telefonas ---------- */
@media (max-width: 760px) {
  body { font-size: 15px; }
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "main" "tabs";
    gap: 8px;
    padding-bottom: 0;
  }
  #left, #right, #views { display: none; }
  #top { gap: 6px 10px; padding-bottom: 6px; }
  .brand { font-size: 16px; flex: 1; }
  .brand .crest { font-size: 18px; }
  .res { order: 3; flex-basis: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .r { padding: 3px 6px; justify-content: center; flex-wrap: wrap; gap: 0 4px; }
  .r b { font-size: 14px; }
  .r small { font-size: 11px; }
  .date { font-size: 13px; }
  .date small { display: none; }
  #top .btn.end { min-height: 34px; padding: 4px 10px; font-size: 14px; }
  #tabs {
    grid-area: tabs;
    display: grid; grid-template-columns: repeat(5, 1fr);
    margin: 0 calc(-1 * max(10px, env(safe-area-inset-left, 0px))) 0 calc(-1 * max(10px, env(safe-area-inset-right, 0px)));
    padding: 0 max(6px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(6px, env(safe-area-inset-left, 0px));
    background: linear-gradient(#2e2419, #1c160f);
    border-top: 2px solid var(--gold-lo);
  }
  #tabs button {
    display: grid; justify-items: center; gap: 1px;
    padding: 6px 0 7px;
    background: none; border: 0; color: var(--dim);
    font: 600 11px var(--display); letter-spacing: 0.03em;
    cursor: pointer;
  }
  #tabs button span { font-size: 20px; font-family: var(--body); }
  #tabs button.on { color: var(--gold-hi); }
  #tabs button:disabled { opacity: 0.35; }
  .field { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: 8px 6px; min-height: 0; }
  .field .mid { display: none; }
  .card { padding: 4px; gap: 5px; flex-direction: column; text-align: center; }
  .card.foe { flex-direction: column; text-align: center; }
  .card .ci b { font-size: 12px; white-space: normal; }
  .card .ci small { font-size: 11px; }
  .card .cnt { font-size: 16px; }
  .card.act, .card.foe.act { transform: scale(1.04); }
  .cards { grid-template-columns: 1fr; }
  .mapgrid { height: auto; }
  .mapwrap { flex: none; height: 58vh; min-height: 300px; }
  #tabs { grid-template-columns: repeat(5, 1fr); }
  .choice { grid-template-columns: 1fr; }
  #toasts { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 440px) {
  .brand span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
