* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #cdcdcd; font-family: Ubuntu, "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: none; transition: filter .4s; }
.hidden { display: none !important; }
.o, .num, .rate, .lbl, h1, h2, .tagline, button, .big-text, .mid-text, #advisor, .toast, label, #lobby-players, .how {
  color: #fff; font-weight: 800; paint-order: stroke fill; -webkit-text-stroke: 4px #333; letter-spacing: .2px;
}
button { font-family: inherit; cursor: pointer; border: 3px solid #333; border-radius: 8px; padding: 8px 16px; font-size: 17px; -webkit-text-stroke: 3.5px #333; transition: transform .06s, filter .1s; }
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button.green { background: #00E16E; } button.blue { background: #00B2E1; } button.grey { background: #a0a0a0; } button.red { background: #F14E54; }
button.big { font-size: 24px; padding: 12px 30px; }
button:disabled { filter: grayscale(.8) brightness(.9); cursor: default; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20; }
#title { background: #cdcdcd; }
#titlebg { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-box { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px 34px; }
.logo { font-size: 96px; margin: 0; -webkit-text-stroke: 14px #333; color: #fff; letter-spacing: 3px; line-height: 1; }
.logo.small { font-size: 72px; -webkit-text-stroke: 11px #333; }
.tagline { font-size: 17px; -webkit-text-stroke: 3.5px #333; margin-top: -4px; }
.row { display: flex; gap: 10px; align-items: center; }
.small-row button { font-size: 14px; padding: 5px 10px; }
input { font-family: inherit; font-weight: 800; font-size: 20px; padding: 9px 14px; border: 3px solid #333; border-radius: 8px; outline: none; background: #fff; color: #333; text-align: center; }
#name { width: 300px; }
#code { width: 100px; text-transform: uppercase; }
.seg { display: flex; border-radius: 8px; overflow: hidden; border: 3px solid #333; }
.seg button { border: none; border-radius: 0; background: #a0a0a0; border-right: 2px solid #333; }
.seg button:last-child { border-right: none; }
.seg button.on { background: #00B2E1; }
.err { color: #fff; -webkit-text-stroke: 3px #b43a3f; font-weight: 800; min-height: 20px; paint-order: stroke fill; }
.how { position: absolute; bottom: 18px; font-size: 14px; -webkit-text-stroke: 3px #333; opacity: .9; }
.corner-btn { position: absolute; top: 16px; right: 16px; font-size: 22px; padding: 4px 11px; background: #a0a0a0; }
.lobby-code { font-size: 44px; color: #fff; font-weight: 800; -webkit-text-stroke: 8px #333; paint-order: stroke fill; }
#lobby { background: #cdcdcd; }
#lobby-players { display: flex; flex-direction: column; gap: 6px; min-width: 320px; font-size: 18px; -webkit-text-stroke: 3.5px #333; }
.lp { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,.18); padding: 6px 12px; border-radius: 8px; }
.lp .dot { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #333; }
.lp .x { margin-left: auto; font-size: 13px; padding: 2px 8px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
#res { position: absolute; left: 14px; top: 12px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.res-row { display: flex; align-items: center; gap: 8px; height: 38px; }
.res-row img { width: 32px; height: 32px; }
.num { font-size: 30px; -webkit-text-stroke: 6px #333; min-width: 70px; font-variant-numeric: tabular-nums; }
.num.small { font-size: 22px; -webkit-text-stroke: 5px #333; min-width: 0; }
.rate { font-size: 17px; -webkit-text-stroke: 4px #333; color: #b8ffb0; font-variant-numeric: tabular-nums; }
.lbl { font-size: 18px; -webkit-text-stroke: 4px #333; width: 32px; margin-right: 8px; }
.army-row { height: 30px; }
.army-row .lbl { width: auto; }
#advisor { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font-size: 20px; -webkit-text-stroke: 4.5px #333; background: rgba(0,0,0,.22); padding: 7px 18px; border-radius: 12px; white-space: nowrap; pointer-events: none; transition: opacity .3s; }
#advisor:empty { opacity: 0; }
#toasts { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { font-size: 17px; -webkit-text-stroke: 4px #333; padding: 4px 14px; border-radius: 10px; background: rgba(0,0,0,.2); animation: tin .2s ease-out; pointer-events: none; }
.toast.bad { -webkit-text-stroke: 4px #8a2327; }
.toast.alert { background: #F14E54; border: 3px solid #333; cursor: pointer; pointer-events: auto; font-size: 19px; }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
#mm-wrap { position: absolute; right: 14px; top: 12px; }
#minimap { width: 210px; height: 210px; display: block; border: 4px solid #555; border-radius: 6px; background: #b9b9b9; cursor: crosshair; }
.mini-btn { position: absolute; left: -38px; top: 0; font-size: 16px; padding: 1px 6px; background: #a0a0a0; -webkit-text-stroke: 3px #333; }

#herobox { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px; width: 300px; pointer-events: none; }
#stats { display: flex; flex-direction: column; gap: 3px; pointer-events: auto; }
.st { display: flex; align-items: center; height: 22px; border-radius: 11px; background: #555; border: 3px solid #555; position: relative; cursor: pointer; overflow: hidden; }
.st .seg7 { display: flex; flex: 1; gap: 2px; height: 100%; padding-right: 26px; }
.st .seg7 i { flex: 1; border-radius: 3px; background: rgba(255,255,255,.08); }
.st .name { position: absolute; left: 0; right: 26px; text-align: center; font-size: 12px; color: #fff; -webkit-text-stroke: 2.5px #333; paint-order: stroke fill; font-weight: 800; pointer-events: none; }
.st .plus { position: absolute; right: 0; top: 0; bottom: 0; width: 24px; display: flex; align-items: center; justify-content: center; font-size: 17px; color: #fff; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; }
.st.max .plus { opacity: .25; }
.st:hover { filter: brightness(1.1); }
#stats-title { font-size: 15px; color: #fff; -webkit-text-stroke: 3.5px #333; paint-order: stroke fill; font-weight: 800; margin-bottom: 1px; }
#lvl, #hpbar { position: relative; height: 24px; border-radius: 12px; background: #555; border: 3px solid #555; overflow: hidden; }
#lvl-fill { height: 100%; background: #FFE869; border-radius: 9px; width: 0; transition: width .25s; }
#hp-fill { height: 100%; background: #85E37D; border-radius: 9px; width: 100%; transition: width .15s; }
#lvl-text, #hp-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; }
#evo { position: absolute; left: 14px; top: 140px; display: flex; flex-direction: column; gap: 6px; }
#evo .evo-title { font-size: 16px; color: #fff; -webkit-text-stroke: 3.5px #333; paint-order: stroke fill; font-weight: 800; }
#evo .evo-row { display: flex; gap: 8px; }
.evo-card { width: 92px; height: 104px; border: 4px solid #333; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 4px; cursor: pointer; font-size: 12px; -webkit-text-stroke: 3px #333; color: #fff; font-weight: 800; paint-order: stroke fill; }
.evo-card img { width: 72px; height: 72px; }

#buildbar { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 8px; }
.bb { width: 82px; height: 94px; background: rgba(0,0,0,.25); border: 3px solid #444; border-radius: 10px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 2px; cursor: pointer; transition: transform .08s, background .1s; }
.bb:hover { background: rgba(0,0,0,.35); transform: translateY(-2px); }
.bb.sel { background: rgba(0,178,225,.45); border-color: #fff; }
.bb.poor .cost { -webkit-text-stroke: 3px #8a2327; }
.bb img { width: 46px; height: 46px; }
.bb .nm { font-size: 12px; color: #fff; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; white-space: nowrap; }
.bb .cost { font-size: 12px; color: #FFE869; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; white-space: nowrap; }
.bb .cost .sc { color: #ddd; }
.bb .key { position: absolute; left: 4px; top: 2px; font-size: 12px; color: #fff; -webkit-text-stroke: 2.5px #333; paint-order: stroke fill; font-weight: 800; }
.bb .new { position: absolute; right: -8px; top: -10px; background: #F14E54; border: 2px solid #333; border-radius: 6px; font-size: 11px; padding: 1px 5px; color: #fff; -webkit-text-stroke: 2.5px #333; paint-order: stroke fill; font-weight: 800; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { transform: scale(1.15); } }

#army { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#squads { display: flex; gap: 6px; }
.sq { min-width: 92px; height: 50px; background: rgba(0,0,0,.22); border: 3px solid #555; border-radius: 10px; display: flex; align-items: center; gap: 4px; padding: 2px 8px; cursor: pointer; position: relative; }
.sq.on { border-color: #fff; background: rgba(0,178,225,.35); }
.sq.empty { opacity: .55; }
.sq .sqn { position: absolute; left: 4px; top: -2px; font-size: 11px; color: #fff; -webkit-text-stroke: 2.5px #333; paint-order: stroke fill; font-weight: 800; }
.sq .u { display: flex; align-items: center; font-size: 14px; color: #fff; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; cursor: grab; }
.sq .u img { width: 26px; height: 26px; }
.sq .emp { font-size: 12px; color: #fff; -webkit-text-stroke: 2.5px #333; paint-order: stroke fill; font-weight: 800; padding-left: 10px; }
.sq.drop { border-color: #FFE869; }
#cmds { display: flex; gap: 8px; }
.cmd { width: 128px; height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; background: rgba(0,0,0,.25); border: 3px solid #555; padding: 4px; position: relative; }
.cmd .ck { position: absolute; left: 6px; top: 3px; font-size: 11px; -webkit-text-stroke: 2.5px #333; }
.cmd .cn { font-size: 18px; -webkit-text-stroke: 4px #333; }
.cmd .cs { font-size: 11px; -webkit-text-stroke: 2.5px #333; color: #e8e8e8; min-height: 13px; white-space: nowrap; }
.cmd.on { background: #00B2E1; border-color: #fff; }
.cmd[data-c=home].on { background: #00E16E; }
.cmd[data-c=attack].on { background: #F14E54; }

#panel { position: absolute; width: 270px; background: rgba(40,40,40,.82); border: 3px solid #222; border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 7px; color: #fff; font-weight: 800; }
#panel .ph { display: flex; align-items: center; gap: 8px; }
#panel .ph img { width: 40px; height: 40px; }
#panel .pt { font-size: 19px; -webkit-text-stroke: 4px #222; paint-order: stroke fill; }
#panel .plv { margin-left: auto; font-size: 14px; color: #FFE869; -webkit-text-stroke: 3px #222; paint-order: stroke fill; }
#panel .pclose { position: absolute; right: -12px; top: -12px; width: 28px; height: 28px; padding: 0; font-size: 15px; border-radius: 50%; background: #a0a0a0; }
#panel .info { font-size: 13px; color: #ddd; -webkit-text-stroke: 0; line-height: 1.35; }
#panel .info b { color: #b8ffb0; }
#panel .pbtn { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; font-size: 15px; padding: 6px 10px; text-align: left; }
#panel .pbtn .c { font-size: 13px; color: #FFE869; }
#panel .pbtn .c .sc { color: #ddd; }
#panel .pbtn.poor .c { -webkit-text-stroke: 3px #8a2327; }
#panel .bar { height: 10px; border-radius: 5px; background: #555; overflow: hidden; }
#panel .bar > div { height: 100%; background: #85E37D; }
#panel .bar.up > div { background: #FFE869; }
#panel .trow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
#panel .tb { display: flex; flex-direction: column; align-items: center; padding: 3px 2px; font-size: 12px; -webkit-text-stroke: 3px #333; gap: 0; position: relative; }
#panel .tb img { width: 34px; height: 34px; }
#panel .tb .c { font-size: 11px; color: #FFE869; }
#panel .tb.lock { opacity: .45; }
#panel .tb.rep { background: #00E16E; }
#panel .tb .rp { position: absolute; right: 2px; top: 1px; font-size: 10px; }
#panel .queue { display: flex; gap: 4px; align-items: center; min-height: 34px; }
#panel .queue img { width: 28px; height: 28px; background: rgba(255,255,255,.08); border-radius: 6px; }
#panel .queue .first { position: relative; }
#panel .hint { font-size: 11px; color: #bbb; -webkit-text-stroke: 0; }
#panel .gear { display: flex; align-items: center; gap: 6px; }
#panel .gear img { width: 34px; height: 34px; }
#panel .pips { display: flex; gap: 3px; }
#panel .pips i { width: 10px; height: 10px; border-radius: 50%; background: #555; border: 2px solid #222; }
#panel .pips i.f { background: #FFE869; }
#panel .sell { font-size: 12px; padding: 3px 8px; align-self: flex-end; background: #a0a0a0; }
#panel .rally { display: flex; gap: 4px; align-items: center; font-size: 12px; -webkit-text-stroke: 3px #222; paint-order: stroke fill; }
#panel .rally button { font-size: 12px; padding: 1px 8px; background: #a0a0a0; }
#panel .rally button.on { background: #00B2E1; }

#recall { position: absolute; left: 50%; top: 62%; transform: translateX(-50%); width: 200px; height: 22px; border-radius: 11px; background: #555; border: 3px solid #555; overflow: hidden; }
#recall-fill { height: 100%; background: #00B2E1; width: 0; }
#recall span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: #fff; -webkit-text-stroke: 3px #333; paint-order: stroke fill; font-weight: 800; }
#edge { position: fixed; inset: 0; pointer-events: none; z-index: 6; box-shadow: inset 0 0 90px 30px rgba(241,78,84,.75); opacity: 0; transition: opacity .25s; }
#death { position: fixed; inset: 0; z-index: 8; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; }
.big-text { font-size: 64px; -webkit-text-stroke: 10px #333; }
.mid-text { font-size: 30px; -webkit-text-stroke: 6px #333; color: #fff; font-weight: 800; paint-order: stroke fill; }
.small-text { font-size: 16px; color: #fff; -webkit-text-stroke: 3.5px #333; paint-order: stroke fill; font-weight: 800; }
#end { background: rgba(0,0,0,.35); }
#end-stats { display: grid; grid-template-columns: auto repeat(5, auto); gap: 4px 16px; font-size: 15px; color: #fff; -webkit-text-stroke: 3.5px #333; paint-order: stroke fill; font-weight: 800; background: rgba(0,0,0,.25); padding: 12px 18px; border-radius: 12px; }
#end-stats .hd { color: #ddd; font-size: 13px; }
#end-stats .win { color: #FFE869; }
#settings { background: rgba(0,0,0,.4); z-index: 30; }
#settings .title-box { background: rgba(40,40,40,.85); border: 3px solid #222; border-radius: 14px; }
#settings h2 { margin: 0; font-size: 34px; -webkit-text-stroke: 7px #333; }
#settings label { display: flex; gap: 14px; align-items: center; font-size: 18px; -webkit-text-stroke: 4px #333; width: 320px; justify-content: space-between; }
