:root {
  --panel: rgba(16, 20, 22, 0.92); --edge: #6b5a3a; --gold: #e8c26a; --teal: #6fd3c8;
  --text: #efe6d2; --muted: #a99f8a; --red: #e0705a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07161d; color: var(--text); font-family: Georgia, 'Times New Roman', serif; overflow: hidden; user-select: none; }
#gl, #ov { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.45; }
.center { text-align: center; }
.fav { color: var(--gold); }
.lack { color: var(--red); }
.site { color: #c8a8ff; }
.fatal { padding: 40px; font-size: 18px; }

button {
  font-family: inherit; background: linear-gradient(#4a3a26, #2b2115); color: var(--text);
  border: 1px solid var(--edge); border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 14px;
}
button:hover:not(:disabled) { filter: brightness(1.25); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: linear-gradient(#2f6a64, #1a3e3a); border-color: var(--teal); }
button.sel { outline: 2px solid var(--teal); }
button.mini { font-size: 12px; padding: 3px 8px; }

/* resource icons */
.ri { display: inline-block; width: 16px; height: 16px; vertical-align: -3px; margin-right: 3px; flex: none; background: center / contain no-repeat; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }
.ri.wood { background-image: url(icons/wood.svg); }
.ri.stone { background-image: url(icons/stone.svg); }
.ri.food { background-image: url(icons/food.svg); }
.ri.iron { background-image: url(icons/iron.svg); }
.ri.life { background-image: url(icons/life.svg); }
.ri.history { background-image: url(icons/history.svg); }
.stat .ri.life { width: 24px; height: 24px; vertical-align: -6px; }
.res .ri { width: 24px; height: 24px; vertical-align: -6px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#topbar {
  pointer-events: auto; position: absolute; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center;
  gap: 16px; padding: 0 14px; background: linear-gradient(rgba(8, 12, 14, 0.96), rgba(8, 12, 14, 0.78)); border-bottom: 1px solid var(--edge);
}
#resbar { display: flex; gap: 14px; }
#topbar button { white-space: nowrap; }
@media (max-width: 1100px) { #topbar { gap: 8px; } .res { min-width: 0; font-size: 15px; } #hWave { display: none; } }
.res { display: flex; align-items: center; gap: 3px; font-size: 17px; min-width: 74px; }
.res small { color: #8fd08a; font-size: 12px; margin-left: 2px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 16px; white-space: nowrap; }
#hRerolls { color: #c8a8ff; }
.grow { flex: 1; }

#minimap { pointer-events: auto; position: absolute; top: 62px; right: 12px; border: 1px solid var(--edge); border-radius: 8px; background: #0d2a36; box-shadow: 0 6px 20px rgba(0,0,0,0.5); cursor: pointer; }
#alerts { position: absolute; top: 62px; left: 12px; width: 380px; display: flex; flex-direction: column; gap: 6px; }
.alert { pointer-events: auto; background: rgba(16, 20, 22, 0.9); border-left: 3px solid var(--teal); padding: 7px 10px; font-size: 13px; border-radius: 4px; transition: opacity 1s; }
.alert.danger { border-left-color: var(--red); }
.alert.link { cursor: pointer; }
.alert.fade { opacity: 0; }

#bottombar {
  pointer-events: auto; position: absolute; left: 0; right: 0; bottom: 0; min-height: 150px; display: flex; gap: 14px; padding: 10px 14px;
  background: linear-gradient(rgba(8, 12, 14, 0.82), rgba(8, 12, 14, 0.97)); border-top: 1px solid var(--edge);
}
#heroPanel { width: 280px; flex: none; display: flex; flex-direction: column; gap: 8px; }
.hrow { display: flex; gap: 8px; align-items: center; }
#heroIcon { width: 56px; height: 56px; border: 1px solid var(--edge); border-radius: 8px; background: #1a2226; cursor: pointer; }
.hinfo { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.bar { height: 8px; background: #2a1a18; border-radius: 4px; overflow: hidden; }
#hHp { height: 100%; background: linear-gradient(90deg, #3fb7a8, #6fd3c8); width: 100%; transition: width 0.15s; }
.abil { display: flex; gap: 8px; }
.ab {
  flex: 1; position: relative; display: flex; align-items: center; gap: 6px; padding: 7px 8px; font-size: 12px; text-align: left;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) var(--cd, 0%), transparent var(--cd, 0%)), linear-gradient(#3a3226, #221c12);
}
.ab .k { color: var(--teal); font-weight: bold; font-size: 15px; }
.ab .cdv { position: absolute; right: 8px; color: var(--gold); font-weight: bold; }

#buildBar { flex: 0 1 auto; display: flex; gap: 12px; min-width: 0; overflow-x: auto; padding-right: 4px; border-right: 1px solid rgba(107, 90, 58, 0.5); }
.bgroup { display: flex; flex-direction: column; gap: 4px; }
.blabel { color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; padding-left: 2px; }
.bcards { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 1280px) {
  #heroPanel { width: 220px; }
  #ctxPanel { min-width: 240px; }
  .bcards { flex-wrap: nowrap; }
  .bcard { width: 60px; }
  .bcard img { width: 34px; height: 34px; }
  .bcard .nm { font-size: 10px; }
}
.bcard {
  width: 74px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 3px 3px 5px; position: relative; cursor: grab;
  border: 1px solid var(--edge); border-radius: 8px; background: linear-gradient(#3a2e1e, #211a10); font-size: 11px; transition: transform 0.12s, border-color 0.12s;
}
.bcard:hover { transform: translateY(-3px); border-color: var(--gold); filter: brightness(1.15); }
.bcard:active { cursor: grabbing; }
.bcard.on { border-color: var(--teal); box-shadow: 0 0 10px rgba(111, 211, 200, 0.45); }
.bcard.poor img { filter: grayscale(0.6) brightness(0.8); }
.bcard img { width: 46px; height: 46px; pointer-events: none; }
.bcard .nm { text-align: center; line-height: 1.05; min-height: 2.1em; display: flex; align-items: center; }
.bcard .key { position: absolute; top: 2px; left: 5px; color: var(--muted); font-size: 10px; }
.bcard .costs { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.bcard .cost { font-size: 11px; }
.bcard .ri { width: 13px; height: 13px; margin-right: 1px; }
#ctxPanel { min-width: 280px; flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 14px; max-height: 210px; overflow-y: auto; }
.ititle { color: var(--gold); font-size: 17px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pal { display: flex; gap: 8px; flex-wrap: wrap; }
.pbtn {
  width: 104px; min-height: 118px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 4px 6px; font-size: 12px; position: relative; border-radius: 8px;
}
.pbtn.wide { width: auto; min-height: 0; flex-direction: row; gap: 8px; padding: 8px 14px; font-size: 14px; }
.pbtn img { width: 60px; height: 60px; }
.pbtn .nm { text-align: center; line-height: 1.1; }
.pbtn .key { position: absolute; top: 3px; left: 6px; color: var(--muted); font-size: 11px; }
.pbtn .costs { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.cost { font-size: 12px; color: var(--text); white-space: nowrap; }
.cost.lack { color: var(--red); }
.cost.free { color: #8fd08a; }
.prod { color: #8fd08a; font-size: 12px; }

/* ---------- banners & modals ---------- */
#banner { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.5s; width: 70%; }
#banner.show { opacity: 1; }
#banner h2 { margin: 0; font-size: 34px; color: var(--gold); text-shadow: 0 2px 10px #000, 0 0 2px #000; }
#banner p { margin: 6px 0 0; text-shadow: 0 1px 4px #000; font-size: 16px; }

#runeModal, #screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 20px; }
#runeModal { background: radial-gradient(ellipse at 50% 45%, rgba(20, 30, 32, 0.55), rgba(2, 4, 6, 0.86)); z-index: 5; animation: runeBg 0.5s ease-out; }
#screen { background: rgba(4, 8, 10, 0.72); z-index: 6; }
#screen.menu-bg { background: radial-gradient(ellipse at center, rgba(4, 8, 10, 0.15), rgba(4, 8, 10, 0.75)); }
.panel { background: var(--panel); border: 1px solid var(--edge); border-radius: 12px; padding: 24px 30px; max-width: 1000px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.panel.glass { backdrop-filter: blur(6px); background: rgba(16, 20, 22, 0.82); }
.panel h2 { color: var(--gold); margin: 0 0 6px; }
.panel h4 { color: var(--gold); margin: 14px 0 6px; }
h1.title { font-size: 62px; margin: 0; color: var(--gold); letter-spacing: 2px; text-shadow: 0 3px 14px #000; }
h1.title.lose { color: var(--red); }
.runeline { color: var(--teal); letter-spacing: 10px; font-size: 20px; opacity: 0.8; }
.sub { color: var(--muted); margin: 6px 0 20px; }
.menu { display: flex; flex-direction: column; gap: 10px; width: 320px; margin: 0 auto 10px; }
.menu button { font-size: 18px; padding: 10px; }
.foot { color: var(--muted); font-size: 13px; margin-top: 10px; }

.cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 10px 0 18px; }
.card {
  width: 230px; min-height: 230px; padding: 16px; border: 1px solid var(--edge); border-radius: 10px; text-align: left;
  background: linear-gradient(#2a2218, #15110b); cursor: pointer; display: flex; flex-direction: column; gap: 8px; transition: transform 0.15s, border-color 0.15s; position: relative;
}
.card:hover { transform: translateY(-4px); border-color: var(--gold); }
.card.locked { opacity: 0.5; cursor: default; transform: none; }
.card .glyph { font-size: 54px; text-align: center; color: var(--teal); text-shadow: 0 0 14px rgba(111, 211, 200, 0.6); height: 72px; line-height: 72px; }
.card h3 { margin: 0; color: var(--gold); text-align: center; font-size: 17px; }
.card p { margin: 0; font-size: 14px; line-height: 1.4; }
.card .tag { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.card .key { position: absolute; top: 8px; left: 10px; color: var(--muted); font-size: 12px; }
.card.hero { width: 270px; }
.heroimg { width: 110px; height: 110px; align-self: center; }
.lock { position: absolute; top: 10px; right: 10px; font-size: 11px; color: var(--gold); background: rgba(0, 0, 0, 0.6); padding: 2px 6px; border-radius: 4px; }
.rune { width: 30px; height: 30px; border: 1px solid var(--edge); border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--teal); font-size: 18px; cursor: help; background: rgba(0, 0, 0, 0.3); margin: 2px; }
.endstats { display: flex; gap: 26px; justify-content: center; margin: 14px 0; }
.endstats div { display: flex; flex-direction: column; align-items: center; }
.endstats b { font-size: 30px; color: var(--gold); }
.endstats span { color: var(--muted); font-size: 13px; }

.help { max-width: 980px; }
.help .cols { display: flex; gap: 30px; }
.help .cols > div { flex: 1; }
.help p { font-size: 14px; line-height: 1.5; }
.help table { font-size: 14px; border-collapse: collapse; }
.help td { padding: 4px 8px; border-bottom: 1px solid #2a2418; vertical-align: top; }
.help td:first-child { color: var(--teal); white-space: nowrap; font-weight: bold; }
.meta { width: 640px; }
.metalist { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 18px; }
.metarow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid #3a3020; border-radius: 8px; background: rgba(0, 0, 0, 0.25); }
.metarow button { min-width: 80px; }

/* tower specializations */
.specs { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.spec-row { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.spec { display: flex; flex-direction: column; gap: 3px; text-align: left; max-width: 260px; padding: 6px 10px; background: linear-gradient(#2f4a44, #1a2a26); border-color: var(--teal); }
.spec b { color: var(--gold); }
.spec-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; margin-right: 6px; border: 1px solid; cursor: help; }
.spec-badge.t2 { color: var(--teal); border-color: var(--teal); }
.spec-badge.t3 { color: var(--gold); border-color: var(--gold); }

/* tactical pause */
#holdTag {
  position: absolute; top: 62px; left: 50%; transform: translateX(-50%); padding: 7px 16px; border-radius: 18px;
  background: rgba(16, 28, 30, 0.92); border: 1px solid var(--teal); color: var(--teal); font-size: 14px; letter-spacing: 0.5px;
  box-shadow: 0 0 18px rgba(111, 211, 200, 0.35); white-space: nowrap; animation: holdPulse 2s ease-in-out infinite;
}
@keyframes holdPulse { 50% { box-shadow: 0 0 6px rgba(111, 211, 200, 0.15); } }
#holdTag.shake { animation: holdShake 0.35s; border-color: var(--red); color: #ffb0a0; }
@keyframes holdShake { 20%, 60% { transform: translateX(calc(-50% - 6px)); } 40%, 80% { transform: translateX(calc(-50% + 6px)); } }

/* runestone history */
.iconbtn { position: relative; padding: 4px 7px; line-height: 0; }
.iconbtn .ri { width: 24px; height: 24px; margin: 0; vertical-align: 0; }
.iconbtn.sel { outline: 2px solid var(--teal); }
#historyCount { position: absolute; right: -5px; top: -5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--teal); color: #0b1a1a; font-size: 11px; line-height: 16px; font-weight: bold; }
#historyCount:empty { display: none; }
#historyPanel {
  pointer-events: auto; position: absolute; top: 58px; left: 330px; width: 380px; max-width: calc(100vw - 24px); z-index: 4;
  background: rgba(16, 20, 22, 0.95); border: 1px solid var(--edge); border-radius: 10px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  display: flex; flex-direction: column; gap: 8px; backdrop-filter: blur(6px);
}
#historyPanel .hhead { display: flex; justify-content: space-between; align-items: baseline; color: var(--gold); font-size: 16px; }
#historyPanel .hlist { display: flex; flex-direction: column; gap: 6px; }
#historyPanel .hrow { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 8px; background: rgba(0, 0, 0, 0.28); border-left: 3px solid var(--fam); }
#historyPanel .hglyph { font-size: 24px; width: 28px; text-align: center; color: var(--fam); text-shadow: 0 0 10px var(--fam); line-height: 1.1; }
#historyPanel .htext { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
#historyPanel .hempty { padding: 8px 0; }
#historyPanel .hpager { display: flex; justify-content: center; align-items: center; gap: 12px; }
@media (max-width: 1100px) { #historyPanel { left: 12px; } }

/* enemy info */
.gold { color: var(--gold); }
.fbars { display: flex; flex-direction: column; gap: 2px; max-width: 360px; }
.fbar { height: 7px; background: #2a1a18; border-radius: 4px; overflow: hidden; margin-bottom: 3px; }
.fbar > div { height: 100%; transition: width 0.15s; }
.fbar.hp > div { background: linear-gradient(90deg, #a8302a, #e05a40); }
.fbar.ward > div { background: linear-gradient(90deg, #8a9ac8, #dfe8ff); }
.fstatus { font-size: 12px; padding: 1px 8px; border-radius: 10px; border: 1px solid; }
.fstatus.stun { color: #ffe680; border-color: #ffe680; }
.fstatus.slow { color: #8fe0ff; border-color: #8fe0ff; }
.fstatus.burn { color: #ff9a50; border-color: #ff9a50; }
.fstatus.mark { color: #c8a8ff; border-color: #c8a8ff; }
.fstatus.haste { color: #ff7a6a; border-color: #ff7a6a; }

/* unit strengths on the war camp's training cards */
.pbtn.unitbtn { width: 116px; }
.pbtn .vs { font-size: 10.5px; line-height: 1.15; text-align: center; }
.pbtn .vs.good { color: #9ee08a; }
.pbtn .vs.bad { color: #e8907a; }

/* in-page confirmation */
.confirm { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(4, 8, 10, 0.55); animation: fadeIn 0.15s; }
.confirm .panel { max-width: 440px; }
.confirm p { font-size: 16px; margin: 0 0 16px; line-height: 1.45; }
.confirm .row-btns { justify-content: center; }
@keyframes fadeIn { from { opacity: 0; } }

/* ---------- runestone offer ---------- */
@keyframes runeBg { from { opacity: 0; backdrop-filter: blur(0); } }
#runeModal { backdrop-filter: blur(3px); }
#runeModal.leaving { animation: runeBgOut 0.9s ease-in forwards; }
@keyframes runeBgOut { 60% { opacity: 1; } to { opacity: 0; } }
.runes-panel { display: flex; flex-direction: column; align-items: center; gap: 6px; perspective: 1200px; }
.rune-title { text-align: center; animation: titleIn 0.7s ease-out both; }
.rune-title .rl { color: var(--teal); letter-spacing: 14px; font-size: 18px; opacity: 0.7; text-shadow: 0 0 12px var(--teal); }
.rune-title h2 { margin: 4px 0 0; font-size: 34px; color: var(--gold); letter-spacing: 2px; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9), 0 0 24px rgba(232, 194, 106, 0.35); }
.rune-title .sub { margin: 4px 0 10px; }
@keyframes titleIn { from { opacity: 0; transform: translateY(-14px); letter-spacing: 8px; } }
#runeModal.leaving .rune-title, #runeModal.leaving .reroll { animation: fadeOut 0.4s forwards; }
@keyframes fadeOut { to { opacity: 0; } }

.rune-card {
  --stoneA: #57524a; --stoneB: #2e2b27; position: relative; width: 236px; cursor: pointer;
  animation: runeRise 0.75s cubic-bezier(.2, .9, .25, 1.15) both; animation-delay: calc(0.18s + var(--i) * 0.14s);
  transition: transform 0.2s, filter 0.2s;
}
.rune-card { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 250px; }
.stonewrap { position: relative; filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 1px rgba(0, 0, 0, 0.9)); transition: filter 0.2s; }
.rune-card .stone {
  position: relative; width: 168px; height: 196px; display: flex; align-items: center; justify-content: center;
  /* a rough standing stone, wider at the shoulders, chipped at the edges */
  clip-path: polygon(22% 3%, 48% 0, 76% 4%, 92% 16%, 98% 38%, 95% 62%, 99% 84%, 88% 98%, 52% 100%, 14% 97%, 3% 82%, 6% 58%, 1% 34%, 8% 14%);
  background:
    var(--noise),
    radial-gradient(ellipse at 38% 22%, rgba(255, 255, 255, 0.22), transparent 45%),
    radial-gradient(ellipse at 60% 90%, rgba(0, 0, 0, 0.5), transparent 60%),
    linear-gradient(160deg, color-mix(in srgb, var(--fam) 12%, #6e6a62), #3a3631 70%);
  background-blend-mode: overlay, normal, normal, normal;
}
.rune-card .stone::before { content: ''; position: absolute; inset: 0; clip-path: inherit; box-shadow: inset 0 0 26px rgba(0, 0, 0, 0.55); }
.rune-card.rar2 .stonewrap { filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 8px color-mix(in srgb, var(--rar) 55%, transparent)); }
.rune-card.rar3 .stonewrap { filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 16px var(--rar)); }
.rune-card .gem { position: absolute; top: -6px; left: 50%; margin-left: -8px; width: 16px; height: 16px; transform: rotate(45deg); background: radial-gradient(circle at 35% 35%, #fff, var(--rar) 55%, #000 130%); border: 1px solid rgba(0, 0, 0, 0.6); box-shadow: 0 0 10px var(--rar); }
.rune-card .glyph {
  font-size: 84px; line-height: 1; color: var(--fam); position: relative;
  text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.85), 0 2px 0 rgba(255, 255, 255, 0.16), 0 0 16px var(--fam), 0 0 40px color-mix(in srgb, var(--fam) 60%, transparent);
  animation: glyphGlow 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 0.4s);
}
@keyframes glyphGlow { 50% { filter: brightness(1.4); text-shadow: 0 -2px 0 rgba(0, 0, 0, 0.85), 0 2px 0 rgba(255, 255, 255, 0.16), 0 0 24px var(--fam), 0 0 56px var(--fam); } }
.rune-card .rtext { text-align: center; display: flex; flex-direction: column; gap: 5px; padding: 0 6px; }
.rune-card .tag { font-size: 11px; color: #c8bfae; text-transform: uppercase; letter-spacing: 1.5px; }
.rune-card .rarity { color: var(--rar); }
.rune-card h3 { margin: 0; color: #fff6e0; font-size: 21px; letter-spacing: 1px; text-transform: uppercase; text-shadow: 0 2px 8px #000, 0 0 2px #000; }
.rune-card p { margin: 0; font-size: 14px; line-height: 1.42; color: #e8f0e0; text-shadow: 0 1px 4px #000; }
.rune-card .key { position: absolute; top: 4px; left: 14px; color: #9a9080; font-size: 12px; }
.rune-card:hover .stonewrap { filter: drop-shadow(0 20px 20px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 18px var(--fam)); }
.rune-card:hover { transform: translateY(-10px) scale(1.03); filter: brightness(1.12); }
@keyframes runeRise {
  from { opacity: 0; transform: translateY(90px) rotateX(55deg) scale(0.85); filter: brightness(0.3); }
  60% { opacity: 1; filter: brightness(1.4); }
  to { transform: none; filter: none; }
}
.runes-panel.rerolled .rune-card { animation: runeFlip 0.6s ease-out both; animation-delay: calc(var(--i) * 0.08s); }
@keyframes runeFlip { from { transform: rotateY(90deg); filter: brightness(2); } }

/* the pick: flare, then fly into the history button */
.rune-card.chosen { animation: runeChosen 0.95s cubic-bezier(.5, 0, .7, .4) forwards; pointer-events: none; z-index: 2; }
.rune-card.chosen::after { content: ''; position: absolute; inset: -30%; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, color-mix(in srgb, var(--fam) 70%, white), transparent 60%); animation: runeFlare 0.6s ease-out forwards; mix-blend-mode: screen; }
@keyframes runeChosen {
  0% { transform: none; filter: brightness(1); }
  25% { transform: translateY(-16px) scale(1.12); filter: brightness(1.8) drop-shadow(0 0 24px var(--fam)); }
  45% { transform: translateY(-16px) scale(1.12); filter: brightness(1.5) drop-shadow(0 0 30px var(--fam)); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.08) rotate(-12deg); filter: brightness(2.2); opacity: 0.2; }
}
@keyframes runeFlare { from { opacity: 0; transform: scale(0.4); } 30% { opacity: 0.9; } to { opacity: 0; transform: scale(1.4); } }
.rune-card.dismissed { animation: runeSink 0.5s ease-in forwards; pointer-events: none; }
@keyframes runeSink { to { opacity: 0; transform: translateY(70px) rotateX(-30deg) scale(0.9); filter: brightness(0.3); } }
#btnHistory.pulse { animation: histPulse 0.7s ease-out; }
@keyframes histPulse { 0% { box-shadow: 0 0 0 0 rgba(111, 211, 200, 0.9); transform: scale(1.25); } to { box-shadow: 0 0 0 14px rgba(111, 211, 200, 0); transform: none; } }

/* =====================================================================
   HUD v2 — floating frames over the map (top strip, build dock, info card)
   ===================================================================== */
:root {
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.6  0 0 0 0 0.62  0 0 0 0 0.64  0 0 0 0.5 0'/></filter><rect width='180' height='180' filter='url(%23n)'/></svg>");
  --slate: linear-gradient(180deg, rgba(34, 44, 50, 0.94), rgba(14, 20, 24, 0.96));
  --rim: #8fa4ad;
}
.frame {
  background: var(--noise), var(--slate); background-blend-mode: overlay, normal;
  border: 1px solid rgba(160, 185, 195, 0.45); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 0 0 3px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* ---- top strip ---- */
#topbar { height: 64px; padding: 6px 12px; gap: 12px; background: none; border: none; pointer-events: none; justify-content: space-between; align-items: flex-start; }
#topbar > * { pointer-events: auto; }
#topframe {
  position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; padding: 6px 22px; height: 44px; margin: 0 auto; border-radius: 6px 6px 22px 22px;
  background: var(--noise), var(--slate); background-blend-mode: overlay, normal;
  border: 1px solid rgba(160, 185, 195, 0.45); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.55);
}
@media (min-width: 1400px) { #resbar, .tstats { min-width: 370px; } #topframe { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); margin: 0; } }
#topframe::before, #topframe::after { content: ''; position: absolute; top: 8px; width: 14px; height: 26px; border: 1px solid rgba(160, 185, 195, 0.5); border-radius: 3px; transform: skewX(-18deg); }
#topframe::before { left: -8px; } #topframe::after { right: -8px; transform: skewX(18deg); }
#resbar { gap: 16px; justify-self: end; justify-content: flex-end; }
.emblemwrap { position: relative; display: flex; justify-content: center; }
.res { min-width: 70px; font-size: 16px; }
.tstats { display: flex; align-items: center; gap: 14px; justify-self: start; justify-content: flex-start; }
.emblem {
  position: relative; width: 64px; height: 64px; margin: 0 6px -26px; border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, #3c5a62, #14222a 70%); border: 2px solid #a8c4cc;
  box-shadow: 0 0 0 4px rgba(10, 16, 20, 0.9), 0 0 0 5px rgba(160, 185, 195, 0.5), 0 6px 18px rgba(0, 0, 0, 0.7); font-size: 24px; color: #e8f6ff; font-weight: bold;
}
.emblem:disabled { opacity: 1; cursor: default; }
.emblem.ready { animation: emblemReady 1.6s ease-in-out infinite; cursor: pointer; }
.emblem.ready:hover { filter: brightness(1.3); }
@keyframes emblemReady { 50% { box-shadow: 0 0 0 4px rgba(10, 16, 20, 0.9), 0 0 0 5px rgba(160, 185, 195, 0.5), 0 0 22px 6px rgba(111, 211, 200, 0.65); } }
.emblem.waving { background: radial-gradient(circle at 50% 35%, #7a2a22, #2a0e0c 70%); border-color: #ff9a80; }
#hWave { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); white-space: nowrap; font-size: 12px; color: #cfe2e8; text-shadow: 0 1px 3px #000; pointer-events: none; }
#statLives { gap: 6px; }
.lifebar { width: 120px; height: 10px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(160, 185, 195, 0.4); overflow: hidden; }
#lifeFill { height: 100%; background: repeating-linear-gradient(90deg, #6fd3c8 0 9px, #3fa898 9px 11px); box-shadow: 0 0 8px rgba(111, 211, 200, 0.6); transition: width 0.3s; }
#statLives b { font-size: 13px; color: #bfe8e0; }
#speedctl, #btnPause { display: flex; gap: 2px; padding: 4px; border-radius: 8px; background: var(--noise), var(--slate); background-blend-mode: overlay, normal; border: 1px solid rgba(160, 185, 195, 0.45); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
#btnPause { padding: 7px 9px; }
.tbtn { width: 38px; height: 34px; padding: 6px; background: transparent; border: 1px solid transparent; border-radius: 5px; }
.tbtn svg { width: 100%; height: 100%; fill: none; stroke: #d8e8ee; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tbtn svg .f { fill: #d8e8ee; stroke: none; }
.tbtn.sel { background: rgba(111, 211, 200, 0.18); border-color: rgba(111, 211, 200, 0.6); outline: none; }
.tbtn:hover { background: rgba(255, 255, 255, 0.08); }
#btnPause svg { width: 22px; height: 22px; display: block; fill: none; stroke: #d8e8ee; stroke-width: 2.2; stroke-linecap: round; }
#minimap { top: 66px; right: 14px; }
#alerts { top: 76px; }
#holdTag { top: 104px; }
#historyPanel { top: 64px; left: 50%; transform: translateX(-50%); }

/* ---- hero card (bottom left) ---- */
#heroPanel {
  pointer-events: auto; position: absolute; left: 12px; bottom: 12px; width: 270px; padding: 10px; border-radius: 10px;
  background: var(--noise), var(--slate); background-blend-mode: overlay, normal; border: 1px solid rgba(160, 185, 195, 0.45); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

/* ---- build dock (bottom centre) ---- */
#buildDock { pointer-events: auto; position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; max-width: calc(100vw - 640px); }
#buildBar {
  border: none; padding: 10px 22px; border-radius: 14px 14px 4px 4px; overflow-x: auto; max-width: 100%; min-width: 540px; justify-content: center;
  background: var(--noise), linear-gradient(180deg, rgba(40, 54, 60, 0.92), rgba(16, 24, 28, 0.95)); background-blend-mode: overlay, normal;
  border: 1px solid rgba(160, 185, 195, 0.45); border-bottom: none; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 -4px 20px rgba(0, 0, 0, 0.45);
}
.bcards { gap: 10px; flex-wrap: nowrap; }
.bcard {
  width: 106px; padding: 4px 4px 5px; border-radius: 10px; background: radial-gradient(circle at 50% 30%, rgba(80, 110, 120, 0.35), rgba(10, 16, 20, 0.6)); border: 1px solid rgba(160, 185, 195, 0.3);
}
.bcard:hover { border-color: #dff6ff; box-shadow: 0 0 12px rgba(190, 230, 240, 0.35); }
.bcard.on { border-color: #dff6ff; box-shadow: 0 0 14px rgba(190, 230, 240, 0.6); }
.bcard.off { opacity: 0.5; }
.bcard img { width: 80px; height: 80px; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.6)); }
#buildTabs { display: flex; border-radius: 0 0 10px 10px; overflow: hidden; border: 1px solid rgba(160, 185, 195, 0.45); background: rgba(10, 16, 20, 0.92); }
.btab { display: flex; align-items: center; gap: 8px; background: transparent; border: none; border-radius: 0; padding: 8px 30px; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; color: #b8c8ce; }
.btab + .btab { border-left: 1px solid rgba(160, 185, 195, 0.3); }
.btab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btab.sel { color: #ffffff; background: linear-gradient(180deg, rgba(111, 211, 200, 0.25), rgba(111, 211, 200, 0.05)); outline: none; }

/* ---- info card (bottom right) ---- */
.infocard {
  pointer-events: auto; position: absolute; right: 12px; bottom: 12px; width: 300px; max-height: calc(100vh - 260px); overflow: hidden auto;
  display: flex; flex-direction: column; border-radius: 10px; padding: 0;
  background: var(--noise), var(--slate); background-blend-mode: overlay, normal; border: 1px solid rgba(160, 185, 195, 0.5);
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.infocard::before { content: ''; position: absolute; inset: 4px; border: 1px solid rgba(160, 185, 195, 0.18); border-radius: 7px; pointer-events: none; }
.infocard.enter { animation: cardIn 0.28s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
.cardimg { height: 116px; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 60%, rgba(111, 211, 200, 0.22), rgba(0, 0, 0, 0) 70%), linear-gradient(180deg, rgba(60, 90, 98, 0.5), rgba(10, 16, 20, 0.2)); border-bottom: 1px solid rgba(160, 185, 195, 0.3); }
.cardimg img { height: 112px; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.7)); }
.cardbody { padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.cardbody .ititle { text-align: center; font-size: 18px; letter-spacing: 1px; color: #f0e6cf; text-transform: uppercase; }
.cardbody .pal .pbtn { width: 64px; min-height: 0; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 14px; padding: 6px 8px; background: rgba(0, 0, 0, 0.3); border-radius: 6px; }
.stances { display: flex; justify-content: space-around; gap: 6px; border-top: 1px solid rgba(160, 185, 195, 0.25); padding-top: 8px; }
.stance { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(160, 185, 195, 0.25); font-size: 11px; }
.stance svg { width: 24px; height: 24px; fill: none; stroke: #d8e8ee; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.stance.sel { border-color: #6fd3c8; background: rgba(111, 211, 200, 0.18); outline: none; }
.stance.sel svg { stroke: #9ff0e4; }
#ctxPanel { flex: none; min-width: 0; font-size: 14px; }
@media (max-width: 1280px) { #buildDock { max-width: calc(100vw - 560px); } .infocard { width: 250px; } #heroPanel { width: 230px; } .lifebar { width: 70px; } }
#ctxPanel { max-height: calc(100vh - 260px); gap: 0; overflow: hidden auto; }
#buildBar { scrollbar-width: thin; scrollbar-color: rgba(160, 185, 195, 0.4) transparent; }
#buildDock { max-width: calc(100vw - 600px); }
.bcard .nm { font-size: 12.5px; } .bcard .cost { font-size: 12.5px; } .bcard .ri { width: 15px; height: 15px; } .bcard .key { font-size: 11px; top: 4px; left: 7px; }
@media (max-width: 1500px) { .bcard { width: 88px; } .bcard img { width: 60px; height: 60px; } .bcard .nm, .bcard .cost { font-size: 11px; } .btab { padding: 7px 22px; font-size: 14px; } #buildBar { min-width: 400px; } }

/* accounts */
.acctline { margin-top: 12px; font-size: 14px; color: var(--muted); }
.acctline b { color: var(--text); font-weight: normal; }
.acctline a, .acctlinks a { color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.acct { width: 380px; max-width: 100%; }
.acct form { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 6px; text-align: left; }
.afield { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.afield input { font: inherit; font-size: 16px; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.35); color: var(--text); user-select: text; }
.afield input:focus { outline: 2px solid var(--teal); outline-offset: 1px; }
#acctMsg { min-height: 1.4em; }
.acct .row-btns { display: flex; gap: 8px; justify-content: center; }
.acctlinks { margin-top: 6px; }

/* theme picker */
.skins { max-width: 1180px; }
.skincards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 16px 0 14px; }
.skincard {
  width: 340px; max-width: 100%; padding: 0 0 14px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: center;
  border-radius: 12px; overflow: hidden; border: 1px solid rgba(160, 185, 195, 0.35); background: rgba(10, 14, 16, 0.85);
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.skincard:hover { transform: translateY(-4px); border-color: var(--gold); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5); filter: none; }
.skincard.on { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 10px 28px rgba(0, 0, 0, 0.5); }
.skinimg { aspect-ratio: 360 / 220; background: radial-gradient(ellipse at 50% 30%, var(--fog), var(--deep) 85%); display: flex; align-items: center; justify-content: center; }
.skinimg img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5)); }
.skinname { font-size: 20px; color: var(--gold); margin-top: 6px; }
.skindesc { font-size: 13px; color: var(--muted); padding: 0 14px; line-height: 1.4; min-height: 2.8em; }
.skinpick { align-self: center; margin-top: 4px; font-size: 13px; padding: 4px 14px; border-radius: 14px; border: 1px solid rgba(232, 194, 106, 0.6); color: var(--gold); }
.skincard.on .skinpick { background: rgba(232, 194, 106, 0.18); }
.skins .row-btns { display: flex; justify-content: center; }
