:root { --bg:#14121f; --panel:#221f33; --panel2:#2d2944; --line:#4a4470; --ink:#f2efe6; --dim:#9a95b3; --gold:#f2d24b; --bad:#ff5470; --good:#5fe3a1;
  --weave:#9bd13a; --bastion:#6aa7ff; --kiln:#ff7a3a; --mire:#b07cff; --order:#efe9d6; --bram:#b9c46a; --isk:#ff8f6a; --odda:#6fd6cd; }
* { box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { margin:0; height:100%; background:#0c0b14; color:var(--ink); font:15px/1.3 ui-monospace,Menlo,Consolas,"DejaVu Sans Mono",monospace; touch-action:manipulation; overscroll-behavior:none; user-select:none; -webkit-user-select:none; }
#app { position:relative; max-width:480px; height:100%; height:100dvh; margin:0 auto; background:var(--bg); overflow:hidden; }
button { font:inherit; color:var(--ink); background:var(--panel2); border:2px solid var(--line); padding:9px 8px; min-height:44px; cursor:pointer; border-radius:0; }
button:active { transform:translateY(1px); } button:disabled { opacity:.55; }
button.primary { background:var(--gold); color:#1a1608; border-color:#fff3a8; font-weight:bold; }
button.sel { border-color:var(--ink); background:#463f6e; }
button.ghost { background:transparent; border-color:#3a3558; color:var(--dim); }
.small { font-size:12px; color:var(--dim); } .bad { color:var(--bad); } .good { color:var(--good); } .gold { color:var(--gold); }
h2 { font-size:16px; margin:0 0 6px; letter-spacing:1px; } h3 { font-size:13px; margin:10px 0 4px; color:var(--dim); letter-spacing:1px; text-transform:uppercase; } p { margin:4px 0; }
.row { display:flex; gap:6px; flex-wrap:wrap; align-items:center; } .grow { flex:1; }
.panel { background:var(--panel); border:2px solid #3a3558; padding:8px; margin-bottom:8px; }
img.spr, canvas.spr { image-rendering:pixelated; image-rendering:crisp-edges; display:block; }

/* world */
#world { position:absolute; inset:0; display:flex; flex-direction:column; }
#topbar { display:flex; justify-content:space-between; padding:6px 10px; font-size:12px; background:#0c0b14; color:var(--dim); }
#topbar #place { color:var(--ink); letter-spacing:1px; }
#hint { padding:2px 10px 6px; font-size:12px; color:var(--dim); background:#0c0b14; min-height:20px; }
#mapwrap { flex:1; min-height:0; display:flex; align-items:center; justify-content:center; background:#0c0b14; overflow:hidden; }
#map { image-rendering:pixelated; image-rendering:crisp-edges; touch-action:none; }
#hud { display:grid; grid-template-columns:1fr 1fr 56px; gap:6px; padding:6px 6px calc(6px + env(safe-area-inset-bottom)); background:#0c0b14; }

/* overlay screens */
#overlay { position:absolute; inset:0; background:var(--bg); display:none; flex-direction:column; overflow:hidden; z-index:5; }
#overlay.on { display:flex; }
.scr { flex:1; overflow-y:auto; padding:8px 8px 4px; -webkit-overflow-scrolling:touch; }
.scr > .low { min-height:100%; display:flex; flex-direction:column; justify-content:flex-end; }
.foot { padding:6px 8px calc(6px + env(safe-area-inset-bottom)); background:#0c0b14; display:flex; gap:6px; }
.foot button { flex:1; }

/* dialogue */
#dialog { position:absolute; left:0; right:0; bottom:0; z-index:20; display:none; padding:8px 8px calc(10px + env(safe-area-inset-bottom)); background:linear-gradient(transparent, rgba(8,7,14,.9) 18%); }
#dialog.on { display:block; }
#dialog .box { background:#0c0b14; border:2px solid var(--line); border-left:5px solid var(--gold); padding:10px 12px; min-height:84px; }
#dialog .who { font-weight:bold; font-size:13px; letter-spacing:1px; margin-bottom:2px; }
#dialog .txt { font-size:15px; line-height:1.35; }
#dialog .txt.nar { font-style:italic; color:#cfc9b8; }
#dialog .more { text-align:right; color:var(--dim); font-size:11px; margin-top:4px; }
#dialog .opts { display:flex; flex-direction:column; gap:6px; margin-top:8px; }
#dialog .opts button { text-align:left; } #dialog .opts small { display:block; color:var(--dim); font-size:12px; }
#pop { position:absolute; inset:0; z-index:30; display:none; background:rgba(8,7,14,.94); padding:14px; overflow:auto; }
#pop.on { display:block; }

/* chips */
.chip { display:inline-block; padding:0 4px; margin:1px 1px 1px 0; font-size:10px; color:#10101a; font-weight:bold; white-space:nowrap; }
.chip.weave { background:var(--weave); } .chip.bastion { background:var(--bastion); } .chip.kiln { background:var(--kiln); } .chip.mire { background:var(--mire); } .chip.order { background:var(--order); } .chip.orchard { background:var(--gold); }
.chip.off { opacity:.4; text-decoration:line-through; } .chip.kw { background:#3a3558; color:var(--ink); font-weight:normal; } .chip.warn { background:var(--bad); }
.fam-weave { border-color:var(--weave) !important; } .fam-bastion { border-color:var(--bastion) !important; } .fam-kiln { border-color:var(--kiln) !important; } .fam-mire { border-color:var(--mire) !important; } .fam-order { border-color:var(--order) !important; } .fam-orchard { border-color:var(--gold) !important; }
.c-bram { color:var(--bram); } .c-isk { color:var(--isk); } .c-odda { color:var(--odda); }

/* cards */
.gcard { border-left:6px solid var(--line); padding:6px 8px; background:var(--panel2); margin-bottom:6px; }
.gcard .row button { flex:1; padding:6px 2px; min-height:40px; font-size:13px; }
.lost { text-decoration:line-through; color:var(--bad); }
.unitrow { display:flex; gap:8px; align-items:flex-start; margin:5px 0; } .unitrow img { width:32px; height:32px; flex:none; }
.opt { display:block; width:100%; text-align:left; margin-bottom:8px; }

/* battle */
.battle { display:flex; flex-direction:column; height:100%; }
.bbanner { min-height:40px; font-size:12px; padding:5px 8px; background:#0c0b14; border-left:3px solid var(--gold); white-space:pre-line; }
.bbanner.coach { border-left-color:var(--good); color:var(--good); }
.bfield { flex:1; overflow-y:auto; padding:6px; background-size:100% 100%; display:flex; flex-direction:column; justify-content:space-between; gap:8px; }
.foes { display:grid; grid-template-columns:repeat(4,1fr); gap:4px; margin-bottom:6px; }
.foes.few { grid-template-columns:repeat(3,1fr); }
.tok { position:relative; background:rgba(34,31,51,.92); border:2px solid #3a3558; padding:3px 2px; text-align:center; min-height:104px; font-size:11px; overflow:hidden; }
.tok img { width:48px; height:48px; margin:0 auto; } .tok.big img { width:64px; height:64px; }
.tok.dead { opacity:.15; } .tok.target { border-color:var(--ink); animation:pulse .7s infinite alternate; cursor:pointer; }
.tok.acted { opacity:.6; } .tok.cur { border-color:var(--gold); } .tok.wind { box-shadow:inset 0 0 0 2px var(--bad); }
@keyframes pulse { to { background:#3b3660; } }
.hp { height:5px; background:#000; margin:2px 3px; } .hp i { display:block; height:100%; background:var(--good); } .hp i.low { background:var(--bad); }
.hpn { font-size:11px; } .fc { color:var(--bad); font-weight:bold; } .fc.ok { color:var(--dim); font-weight:normal; }
.tags { font-size:11px; min-height:12px; line-height:1.25; }
.intent { font-size:10px; margin-top:1px; line-height:1.2; } .intent .small { font-size:10px; } .intent.wind { color:var(--gold); } .intent.none { color:var(--dim); } .intent b { font-weight:bold; }
.heroes { display:grid; grid-template-columns:repeat(3,1fr); gap:4px; }
.heroes .tok { min-height:128px; } .pos { font-size:9px; letter-spacing:1px; color:var(--dim); }
.float { position:absolute; left:0; right:0; top:14px; font-size:18px; font-weight:bold; color:var(--bad); pointer-events:none; animation:floatup .7s forwards; text-shadow:0 0 3px #000,0 0 3px #000,0 0 3px #000; z-index:2; }
.float.heal { color:var(--good); } .float.miss { color:var(--ink); font-size:12px; } .float.st { color:var(--gold); font-size:12px; top:30px; }
@keyframes floatup { from { transform:translateY(8px); opacity:1; } to { transform:translateY(-16px); opacity:0; } }
.shake { animation:shake .18s; } @keyframes shake { 25% { transform:translateX(-3px); } 75% { transform:translateX(3px); } }
.blog { flex:1; min-height:0; overflow:hidden; display:flex; flex-direction:column; justify-content:flex-end; font-size:11px; line-height:1.35; color:rgba(242,239,230,.75); padding:2px 6px; text-shadow:0 0 2px #000; }
.blog div:last-child { color:var(--ink); }
.bactions { background:#0c0b14; padding:6px 6px calc(6px + env(safe-area-inset-bottom)); }
.agrid { display:grid; grid-template-columns:1fr 1fr; gap:5px; min-height:98px; max-height:204px; overflow-y:auto; align-content:start; }
.agrid button { text-align:left; padding:6px 8px; min-height:46px; } .agrid button small { display:block; color:var(--dim); font-size:11px; }
.afree { display:flex; gap:5px; margin-top:5px; } .afree button { flex:1; min-height:38px; padding:4px; font-size:12px; }
.info { position:absolute; right:0; top:0; width:22px; height:22px; font-size:11px; color:var(--dim); background:rgba(12,11,20,.7); line-height:22px; }

/* title */
.title { display:flex; flex-direction:column; align-items:center; justify-content:center; height:100%; padding:24px; text-align:center; gap:12px; }
.title h1 { font-size:34px; letter-spacing:8px; margin:0; color:var(--gold); } .title canvas { width:192px; height:192px; image-rendering:pixelated; }
.title button { width:240px; }
.meter { display:inline-block; width:12px; height:12px; border:2px solid var(--line); margin-right:2px; vertical-align:middle; } .meter.on { background:var(--gold); border-color:var(--gold); }
.epi p { margin:10px 0; line-height:1.5; }
