:root {
  --bg: #14111c; --panel: rgba(20, 17, 28, 0.88); --line: #3b3350; --gold: #f4d35e;
  --text: #ece6d8; --muted: #a49cb3; --err: #ff7b7b; --accent: #8e52e0;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--mono); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: #2a2338; border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; }
button:hover { border-color: var(--gold); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: linear-gradient(#6b3fb0, #4d2b85); border-color: #9a6be8; font-weight: bold; }
input, select, textarea { background: #0e0c14; border: 1px solid var(--line); border-radius: 4px; padding: 7px 8px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.2em; margin: 8px 0 0; }
.swatch { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border: 1px solid #000; image-rendering: pixelated; vertical-align: -1px; }
.screen { position: fixed; inset: 0; }

/* auth */
#auth { display: grid; place-items: center; overflow-y: auto; padding: 16px;
  background: radial-gradient(ellipse at 50% 20%, #2c1f47 0%, #14111c 60%), #14111c; }
.auth-card { width: min(520px, 100%); background: var(--panel); border: 2px solid var(--line); border-radius: 6px; padding: 22px; box-shadow: 0 0 0 4px #0b0910, 0 20px 60px #000a; }
.logo { font: bold 40px/1 var(--serif); letter-spacing: 3px; text-align: center; color: var(--gold); margin: 6px 0 4px; text-shadow: 3px 3px 0 #5b3f8c; }
.crown { display: block; width: 48px; height: 32px; margin: 0 auto 10px; background: url(/icon.svg) center / contain no-repeat; image-rendering: pixelated; }
.tagline { text-align: center; color: var(--muted); margin: 0 0 16px; font-family: var(--serif); font-style: italic; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button { flex: 1; }
.tabs button.active, .class-btn.active { border-color: var(--gold); background: #3a2d55; }
.auth-form { display: grid; gap: 10px; }
.auth-form label { display: grid; gap: 4px; color: var(--muted); }
.auth-form label input { color: var(--text); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px 10px; margin: 0; }
legend { color: var(--muted); padding: 0 4px; }
.picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#kingdom-select { width: 100%; }
.kingdom-info { margin-top: 8px; color: var(--muted); font-size: 12px; }
.kingdom-info b { color: var(--text); }
.online-line { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* game */
#map { position: fixed; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: none; cursor: pointer; }
.hud-top { position: fixed; top: 0; left: 0; right: 0; display: flex; gap: 8px; align-items: flex-start; padding: 8px; padding-top: max(8px, env(safe-area-inset-top)); pointer-events: none; flex-wrap: wrap; }
.hud-top > * { pointer-events: auto; }
.hud-block { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; }
.world-name { color: var(--gold); font: bold 16px var(--serif); letter-spacing: 1px; }
.clock { font-size: 12px; color: var(--muted); }
.hero-block { font-size: 12px; }
.hero-block b { font-size: 13px; }
.online { font-size: 12px; color: var(--muted); }
.hud-buttons { margin-left: auto; display: flex; gap: 4px; }
.hud-buttons button { width: 36px; height: 36px; padding: 0; background: var(--panel); font-size: 16px; }
.actions { position: fixed; right: 8px; top: 64px; display: grid; gap: 6px; }
.action { background: linear-gradient(#6b3fb0, #4d2b85); border-color: #9a6be8; font-weight: bold; }
.hex-info { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; font-size: 12px; color: var(--muted); pointer-events: none; max-width: calc(100% - 20px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast { position: fixed; left: 50%; top: 80px; transform: translate(-50%, -10px); background: #2a1f3d; border: 1px solid var(--gold); border-radius: 4px; padding: 8px 14px; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 30; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* chat */
.chat { position: fixed; left: 8px; bottom: 40px; width: min(440px, calc(100% - 16px)); height: min(340px, 45vh); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; z-index: 10; }
.chat.collapsed { height: auto; }
.chat.collapsed .chat-log, .chat.collapsed .chat-form { display: none; }
.chat-head { display: flex; border-bottom: 1px solid var(--line); }
.chat-tabs { display: flex; overflow-x: auto; flex: 1; scrollbar-width: none; }
.chat-tab { border: 0; border-radius: 0; background: none; padding: 6px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; position: relative; }
.chat-tab.active { color: var(--gold); box-shadow: inset 0 -2px 0 var(--gold); }
.badge { background: #c0392b; color: #fff; border-radius: 8px; font-size: 10px; padding: 0 5px; margin-left: 4px; }
.chat-toggle { border: 0; border-left: 1px solid var(--line); border-radius: 0; background: none; width: 36px; }
.chat-toggle.ping { color: var(--gold); animation: ping 1s infinite alternate; }
@keyframes ping { to { background: #4d2b85; } }
.chat-log { list-style: none; margin: 0; padding: 6px 8px; overflow-y: auto; flex: 1; font-size: 13px; overscroll-behavior: contain; }
.msg { padding: 1px 0; word-wrap: break-word; }
.msg .time { color: #6d6580; font-size: 11px; margin-right: 6px; }
.msg .tag { display: inline-block; min-width: 18px; font-size: 10px; text-align: center; border-radius: 3px; padding: 0 3px; margin-right: 5px; background: #333; color: #ddd; }
.ch-global .tag { background: #2f5d8a; } .ch-world .tag { background: #5b3f8c; } .ch-kingdom .tag { background: #8a6d1f; }
.ch-local .tag { background: #2f7a4d; } .ch-whisper .tag { background: #8a2f6d; } .ch-whisper .text { color: #f3b6e2; }
.msg .name { background: none; border: 0; padding: 0; margin-right: 6px; font-weight: bold; }
.msg .name::after { content: ':'; color: var(--muted); }
.ch-sys .text { color: var(--muted); font-style: italic; } .ch-err .text { color: var(--err); }
.chat-form { display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--line); }
#chat-channel { flex: 0 0 auto; }
#chat-to { width: 90px; flex: 0 0 auto; }
#chat-input { flex: 1; }

/* popups & modals */
.popup { position: fixed; z-index: 20; background: var(--panel); border: 1px solid var(--gold); border-radius: 4px; padding: 8px 10px; min-width: 170px; }
.popup-buttons { display: flex; gap: 6px; margin-top: 8px; }
.modal { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal-card { background: var(--bg); border: 2px solid var(--line); border-radius: 6px; padding: 18px 20px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; }
.modal-card h2 { font: bold 22px var(--serif); color: var(--gold); margin: 0 0 10px; }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.gate-worlds { display: grid; gap: 8px; }
.help { padding-left: 18px; } .help li { margin-bottom: 6px; }
code { background: #2a2338; padding: 0 4px; border-radius: 3px; }

@media (max-width: 700px) {
  .hero-block .muted:not(div) { display: none; }
  .online { display: none; }
  .chat { bottom: 36px; height: 42vh; }
  .row2 { grid-template-columns: 1fr; }
  .picker { grid-template-columns: repeat(2, 1fr); }
  #chat-channel { max-width: 82px; }
}

/* legal, moderation, deletion */
a { color: #c9a8ff; }
.legal { text-align: center; color: var(--muted); font-size: 11px; margin: 10px 0 0; }
.menu-legal { text-align: left; margin-top: 14px; }
button.link { background: none; border: 0; padding: 0; text-decoration: underline; font-size: inherit; }
.danger { color: var(--err); }
.danger-btn { background: #5a1e26; border-color: #a33a48; }
.stack { display: grid; gap: 4px; color: var(--muted); }
.modal-card.wide { width: min(720px, 100%); }
.reports { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.report { border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; }
.report textarea, #write-admin-form textarea { width: 100%; box-sizing: border-box; margin: 6px 0; resize: vertical; }
blockquote { margin: 6px 0; padding: 4px 8px; border-left: 3px solid var(--line); color: var(--text); word-wrap: break-word; }
.popup select { width: 100%; margin: 6px 0; }
.popup { max-width: 260px; }
.small { font-size: 11px; margin-bottom: 6px; }
#btn-menu { position: relative; }
.dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: #e74c3c; }
.hud-block:empty { display: none; }

/* camps, barracks */
.camp-units { margin: 6px 0; font-size: 12px; }
.camp-units li { list-style: none; }
.camp-units { padding: 0; }
.recruits { display: grid; gap: 8px; }
.recruit { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px 12px; align-items: start; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: rgba(255, 255, 255, 0.02); }
.recruit canvas { width: 52px; height: 66px; }
.recruit .info { font-size: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.recruit .r-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.recruit .r-head b { font-size: 15px; }
.recruit .r-tag { font-size: 11px; color: var(--gold); border: 1px solid var(--line); border-radius: 10px; padding: 0 6px; }
.recruit .r-owned { margin-left: auto; font-weight: bold; font-size: 13px; background: #2a2338; border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; }
.recruit .r-owned.none { opacity: 0.5; }
.recruit .r-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.recruit .chip { font-size: 11px; background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 1px 7px; white-space: nowrap; }
.recruit .buy { grid-column: 1 / -1; display: flex; gap: 6px; }
.recruit .buy button { flex: 1; white-space: nowrap; padding: 7px 6px; }
.recruit .buy .danger-btn { flex: 0 0 52px; }
.recruit.locked canvas { opacity: 0.45; filter: grayscale(0.6); }
.gold { color: var(--gold); }

/* hero screen, market */
#character-body h3, #market-body h3 { margin: 12px 0 6px; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); border-radius: 6px; padding: 6px 2px; font-size: 11px; }
.stat b { font-size: 18px; }
.stat-icon { font-size: 18px; }
.stat-help { margin: 6px 0 0; padding-left: 18px; }
.items { display: grid; gap: 6px; }
.item { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.item .icon { font-size: 22px; width: 28px; text-align: center; flex: 0 0 auto; }
.item .info { flex: 1; font-size: 12px; }
.item .info b { font-size: 13px; }
.item.empty { opacity: 0.6; }
.item canvas.figure { width: 28px; height: 36px; flex: 0 0 auto; }
.item.tier2 { border-color: #4f8f4a; }
.item.tier3 { border-color: #3f6fc4; }
.item.tier4 { border-color: #d39a2a; box-shadow: 0 0 6px rgba(211, 154, 42, 0.5); }
.item .playing { color: var(--gold); font-weight: bold; font-size: 12px; }

/* battle */
.battle { position: fixed; inset: 0; z-index: 25; background: #1b1524; touch-action: none; user-select: none; -webkit-user-select: none; }
#battle-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.battle-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); background: linear-gradient(#0d0a12ee, #0d0a1200); }
.battle-title { font: bold 16px var(--serif); color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-title span { font: 12px var(--mono); }
.battle-count { margin-left: auto; font-weight: bold; background: #0008; border-radius: 12px; padding: 3px 10px; }
.battle-btns { display: flex; gap: 6px; }
.battle-btns button { min-width: 40px; }
.battle-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(118px + env(safe-area-inset-bottom)); font-size: 12px; color: #fff; background: #0009; border-radius: 12px; padding: 4px 12px; white-space: nowrap; max-width: 94%; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.battle-bar { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); background: linear-gradient(#0d0a1200, #0d0a12f0 30%); }
.mana { position: relative; height: 16px; border-radius: 8px; background: #0b1630; border: 2px solid #2b2233; overflow: hidden; max-width: 520px; margin: 0 auto 8px; }
.mana-fill { position: absolute; inset: 0 auto 0 0; background: linear-gradient(#7fd3ff, #2f7bd8); transition: width .1s linear; }
.mana span { position: relative; display: block; text-align: center; font-size: 11px; line-height: 12px; font-weight: bold; text-shadow: 0 1px 2px #000; }
.spells { display: flex; gap: 10px; justify-content: center; }
.spell { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-items: center; column-gap: 6px; padding: 7px 14px; min-width: 96px; border-radius: 12px; border: 3px solid #2b2233; box-shadow: 0 4px 0 #2b2233; font-weight: bold; color: #fff; text-shadow: 0 1px 2px #000; }
.spell:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #2b2233; }
.spell-fireball { background: linear-gradient(#ff9a3c, #d2453c); }
.spell-lightning { background: linear-gradient(#8fd0ff, #3a6fd0); }
.spell-heal { background: linear-gradient(#7fe08a, #2f9a4a); }
.spell-icon { grid-row: span 2; font-size: 24px; }
.spell-name { font-size: 13px; }
.spell-cost { font-size: 11px; opacity: 0.9; }
.spell-cost::after { content: ' mana'; }
.spell:disabled { filter: grayscale(0.85) brightness(0.7); opacity: 1; }
.spell.armed { outline: 3px solid #fff; outline-offset: 2px; animation: armed .5s infinite alternate; }
@keyframes armed { to { outline-color: var(--gold); } }
.battle-result { position: absolute; inset: 0; display: grid; place-items: center; background: #0008; padding: 16px; }
.result-card { background: var(--bg); border: 3px solid var(--gold); border-radius: 12px; padding: 18px 22px; width: min(420px, 100%); text-align: center; box-shadow: 0 10px 40px #000a; }
.result-card.lose { border-color: #a33a48; }
.result-card h2 { font: bold 32px var(--serif); color: var(--gold); margin: 0 0 8px; }
.result-card .loot { color: #9fe3a0; font-weight: bold; }
.result-card.lose h2 { color: #ff8a8a; }
.result-card .reward { font-size: 18px; font-weight: bold; color: var(--gold); }
.result-card .levelup { font-weight: bold; color: #8dff9a; }
.result-card .losses { color: #ffb4b4; }
.result-card button { margin-top: 8px; min-width: 160px; padding: 10px; }
@media (max-width: 700px) {
  .spell { min-width: 0; padding: 6px 10px; }
  .spell-name { font-size: 12px; }
  .battle-title span { display: none; }
}
.hero-block .stats { color: var(--gold); }
.email-form { display: grid; gap: 6px; margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.vip { color: var(--gold); font-weight: bold; }
.action.roam { background: linear-gradient(#2f8f6a, #1f6a4d); border-color: #5fd3a0; }
#btn-teleport { background: linear-gradient(#6a4bb0, #44307a); border-color: #b49cff; }
#btn-teleport.on { background: linear-gradient(#a33a48, #6a1f2a); border-color: #ff8a8a; }
.action.roam.on { background: linear-gradient(#a33a48, #6a1f2a); border-color: #ff8a8a; }
#b-auto.on { background: linear-gradient(#2f8f6a, #1f6a4d); border-color: #5fd3a0; }
.battle-count { white-space: nowrap; }
@media not ((hover: hover) and (pointer: fine)) { .desk-only { display: none; } }
@media (max-width: 700px) {
  .battle-top { gap: 5px; padding-left: 6px; padding-right: 6px; }
  .battle-title { flex: 1; min-width: 0; font-size: 14px; }
  .battle-count { margin-left: 0; padding: 3px 7px; font-size: 12px; }
  .battle-btns { gap: 4px; }
  .battle-btns button { min-width: 0; padding: 5px 7px; font-size: 12px; }
}

/* spell bar: one button per known spell, colour by style */
.spell { position: relative; }
.style-fire { background: linear-gradient(#ff9a3c, #d2453c); }
.style-storm { background: linear-gradient(#8fd0ff, #3a6fd0); }
.style-frost { background: linear-gradient(#c8f0ff, #4a9ad8); }
.style-holy { background: linear-gradient(#7fe08a, #2f9a4a); }
.style-nature { background: linear-gradient(#a8e06a, #3f8a2a); }
.style-shadow { background: linear-gradient(#a07ad8, #4a2a7a); }
.style-blood { background: linear-gradient(#ff7a7a, #8a1f2a); }
.style-plague { background: linear-gradient(#c8f06a, #5a8a1a); }
.style-blade { background: linear-gradient(#c9ced8, #5a5f6a); }
.style-rage { background: linear-gradient(#ff9a6a, #b83a1a); }
.style-steel { background: linear-gradient(#d6dbe4, #6a7280); }
.spell-cd { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 900; color: #fff; text-shadow: 0 2px 3px #000; pointer-events: none; }
.spell-cd:empty { display: none; }
.spells.many { display: grid; grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); gap: 6px; max-width: 560px; margin: 0 auto; }
.spells.many .spell { grid-template-columns: 1fr; grid-template-rows: auto auto; justify-items: center; min-width: 0; padding: 4px 2px; border-radius: 10px; box-shadow: 0 3px 0 #2b2233; }
.spells.many .spell-icon { grid-row: auto; font-size: 20px; line-height: 1; }
.spells.many .spell-name { display: none; }
.spells.many .spell-cost::after { content: ''; }
.spells.many .spell-cost { font-size: 11px; }

/* talent trees */
.talent-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.talent-points { color: var(--gold); font-weight: bold; }
.tree { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.branch { background: #1c1728; border: 1px solid var(--line); border-radius: 8px; padding: 8px 4px; display: grid; gap: 6px; justify-items: center; }
.branch h3 { margin: 0 0 2px; font: bold 14px var(--serif); color: var(--gold); text-align: center; }
.tnode { position: relative; width: 100%; max-width: 120px; display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; border: 2px solid #3b3350; background: #241d33; filter: grayscale(0.9) brightness(0.65); }
.tnode .ticon { font-size: 26px; line-height: 1; }
.tnode .tname { font-size: 10px; text-align: center; line-height: 1.15; }
.tnode .trank { font-size: 10px; color: var(--muted); }
.tnode.open { filter: none; border-color: #6b5a8c; }
.tnode.open.can { border-color: #8dff9a; box-shadow: 0 0 10px #8dff9a55; }
.tnode.got { filter: none; border-color: var(--gold); background: #3a2d55; }
.tnode.spellnode::before { content: '✦'; position: absolute; top: 2px; right: 5px; color: #7fd3ff; font-size: 10px; }
.tnode.sel { outline: 2px solid #fff; }
.tlink { width: 3px; height: 8px; background: #3b3350; margin: -6px 0; }
.tlink.got { background: var(--gold); }
.talent-detail { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 92px; }
.talent-detail h4 { margin: 0 0 4px; font: bold 16px var(--serif); color: var(--gold); }
.talent-detail .why { color: var(--err); font-size: 12px; }
.talent-detail .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.dot.green { background: #5fd35a; }
@media (max-width: 700px) {
  .tree { gap: 4px; }
  .tnode .ticon { font-size: 22px; }
}
.action.talents { background: linear-gradient(#b8862f, #7a5a1a); border-color: #f4d35e; }
.action.talents.ping { animation: ping 1s infinite alternate; }

/* install-app bar (browser tabs only) */
:root { --install-h: 0px; }
body.has-install { --install-h: 46px; }
.install-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 35; height: calc(46px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 12px; display: flex; align-items: center; gap: 8px; background: linear-gradient(#3a2d55, #2a2140); border-bottom: 1px solid var(--gold); box-shadow: 0 2px 10px #0008; }
.install-text { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.install-bar .primary { padding: 6px 12px; white-space: nowrap; }
.install-x { background: none; border: 0; font-size: 16px; padding: 6px 8px; color: var(--muted); }
body.has-install .hud-top { top: var(--install-h); }
body.has-install #auth { padding-top: calc(16px + var(--install-h)); }
body.in-battle .install-bar { display: none; }

/* bigger talent tree */
#talent-modal .modal-card { width: min(900px, 100%); }
.tree { gap: 10px; }
.branch { padding: 10px 6px; gap: 8px; }
.branch h3 { font-size: 16px; }
.tnode { max-width: 170px; padding: 10px 4px; min-height: 92px; border-radius: 14px; }
.tnode .ticon { font-size: 36px; }
.tnode .tname { font-size: 12px; font-weight: bold; }
.tnode .trank { font-size: 11px; }
.tnode.ultimate { border-width: 3px; background: linear-gradient(#3a2d55, #241d33); }
.tnode.ultimate.got { background: linear-gradient(#6b4a1a, #3a2d55); box-shadow: 0 0 14px #f4d35e88; }
.tnode .tlvl { position: absolute; top: 3px; left: 6px; font-size: 9px; color: var(--muted); }
.tlink { height: 12px; width: 4px; margin: -8px 0; }
.talent-detail { position: sticky; bottom: -18px; background: var(--bg); box-shadow: 0 -8px 16px var(--bg); }
@media (max-width: 700px) {
  .tree { gap: 5px; }
  .branch { padding: 8px 3px; }
  .tnode { min-height: 84px; padding: 8px 2px; }
  .tnode .ticon { font-size: 30px; }
  .tnode .tname { font-size: 10.5px; }
}
body.has-install .modal { padding-top: calc(16px + var(--install-h)); }

/* heroes */
#hud-hero { cursor: pointer; }
.hero-list { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 8px; }
.hero-row { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.hero-row.active { border-color: var(--gold); background: #2a2140; }
.hero-row canvas { width: 36px; height: 46px; }
.hero-row .info { flex: 1; font-size: 12px; }
.hero-row .info b { font-size: 14px; }
.hero-row .playing { color: var(--gold); font-weight: bold; font-size: 12px; }
.new-hero { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.popup .easy { color: #8dff9a; font-size: 12px; margin-top: 4px; }
.popup .danger { color: var(--err); font-size: 12px; margin-top: 4px; }

/* talent star */
#talent-modal .modal-card { width: min(980px, 100%); }
#talent-tree.tree { display: block; position: relative; }
.star-wrap { overflow: auto; max-height: min(62vh, 760px); border: 1px solid var(--line); border-radius: 10px;
  background: radial-gradient(circle at center, #2a2140 0%, #15111f 70%); touch-action: pan-x pan-y; }
.star { position: relative; margin: 0 auto; }
.star svg { position: absolute; inset: 0; }
.star .ring { fill: none; stroke: #3b3350; stroke-width: 1; stroke-dasharray: 4 6; }
.star .ring.open { stroke: #6b5a8c; }
.star .slink { stroke: #3b3350; stroke-width: 3; stroke-linecap: round; }
.star .slink.open { stroke: #6b5a8c; }
.star .slink.got { stroke: var(--gold); stroke-width: 4; }
.snode { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; padding: 0; border-radius: 50%;
  border: 2px solid #3b3350; background: #241d33; display: grid; place-items: center; filter: grayscale(0.9) brightness(0.6); cursor: pointer; }
.snode .sicon { font-size: 21px; line-height: 1; }
.snode .srank { position: absolute; bottom: -7px; right: -8px; font-size: 9px; background: #15111f; border: 1px solid #3b3350; border-radius: 6px; padding: 0 3px; color: var(--muted); }
.snode.open { filter: none; border-color: #6b5a8c; }
.snode.open.can { border-color: #8dff9a; box-shadow: 0 0 10px #8dff9a66; }
.snode.got { filter: none; border-color: var(--gold); background: #3a2d55; box-shadow: 0 0 8px #f4d35e55; }
.snode.got .srank { color: var(--gold); border-color: var(--gold); }
.snode.spellnode::after { content: '✦'; position: absolute; top: -6px; right: -3px; color: #7fd3ff; font-size: 11px; text-shadow: 0 0 3px #000; }
.snode.ultimate { width: 46px; height: 46px; margin: -23px 0 0 -23px; border-width: 3px; }
.snode.ultimate.got { background: linear-gradient(#6b4a1a, #3a2d55); box-shadow: 0 0 14px #f4d35e99; }
.snode.core { width: 64px; height: 64px; margin: -32px 0 0 -32px; border-width: 3px; }
.snode.core .sicon { font-size: 34px; }
.snode.sel { outline: 3px solid #fff; outline-offset: 2px; }
.sbranch { position: absolute; transform: translate(-50%, -50%); font: bold 13px var(--serif); color: var(--gold); white-space: nowrap;
  pointer-events: none; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.ringlvl { position: absolute; transform: translate(-50%, -50%); font-size: 10px; font-weight: bold; color: #6b5a8c; background: #15111f; border-radius: 6px; padding: 0 3px; pointer-events: none; }
.ringlvl.open { color: var(--muted); }
.star-tools { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; }
.star-tools button { min-width: 34px; font-weight: bold; height: 34px; padding: 0; font-size: 18px; border-radius: 8px; }

/* cities & missions */
.action.city { background: linear-gradient(#b8862f, #7a5a1a); border-color: #f4d35e; }
.action.missions { background: linear-gradient(#3a6ab8, #234a8a); border-color: #7fb0ff; }
.action.missions.ping { animation: ping 1s infinite alternate; }
.found-form { display: flex; gap: 8px; flex-wrap: wrap; }
.found-form input { flex: 1; min-width: 160px; }
.city-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.city-stat b { font-size: 20px; color: var(--gold); }
.city-buildings { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.cbuild { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; display: grid; gap: 2px; }
.cbuild.have { border-color: var(--gold); }
.cbuild .cicon { font-size: 24px; }
.build-opts { display: grid; gap: 4px; margin-top: 6px; }
.build-opts button { text-align: left; font-size: 13px; }
.mission { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0; display: grid; gap: 4px; }
.mission.offer { border-color: #7fb0ff; }
.mission button { justify-self: start; }
.mbar { height: 8px; background: #241d33; border-radius: 4px; overflow: hidden; }
.mfill { height: 100%; background: linear-gradient(90deg, #5fd3a0, #f4d35e); }
.small-btn { font-size: 12px; padding: 2px 8px; }

/* item comparison & gear tools */
.cmp { font-size: 12px; font-weight: bold; }
.cmp.better { color: #8dff9a; }
.cmp.worse { color: var(--err); }
.cmp.same { color: var(--muted); }
.gear-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin: 6px 0 2px; }
.gear-tools .check { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.wear-on { max-width: 96px; font-size: 12px; }
.companion-stats { margin: -2px 0 2px 8px; }

.why-not { color: #ffb4a8; font-size: 12px; }
.why-not.big { font-size: 13px; background: rgba(163, 58, 72, 0.25); border: 1px solid #a33a48; border-radius: 6px; padding: 6px 8px; }

/* ---------- HUD look (glass cards, compact action chips) ---------- */
.hud-block {
  background: linear-gradient(180deg, rgba(36, 28, 52, 0.86), rgba(18, 14, 28, 0.86));
  border: 1px solid rgba(244, 211, 94, 0.28); border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  padding: 6px 11px;
}
.hud-buttons button {
  border-radius: 10px; border: 1px solid rgba(244, 211, 94, 0.28);
  background: linear-gradient(180deg, rgba(36, 28, 52, 0.88), rgba(18, 14, 28, 0.88));
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.action {
  border-radius: 999px; padding: 6px 14px; font-size: 13px; line-height: 1.2;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); white-space: nowrap;
}
.actions { justify-items: end; }
.hex-info, .chat { border-radius: 12px; }

/* Phones: one compact card top-left (world, time, hero), the four map buttons
   in a 2x2 block beside it, and the actions as a row of chips just below —
   the map in the middle stays free. */
@media (max-width: 700px) {
  .hud-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 6px; padding: 6px; padding-top: max(6px, env(safe-area-inset-top)); }
  .hud-top > .hud-block { grid-column: 1; min-width: 0; justify-self: start; max-width: 100%; }
  .hud-top > .hud-block:first-child { display: flex; align-items: baseline; gap: 8px; border-radius: 12px 12px 0 0; border-bottom: 0; padding: 4px 10px 0; box-shadow: none; }
  .hud-top > .hero-block { border-radius: 0 12px 12px 12px; border-top: 0; padding: 2px 10px 5px; width: 100%; }
  .hud-top > .online { margin-top: 4px; border-radius: 12px; }
  .world-name { font-size: 14px; letter-spacing: 0.5px; }
  .clock { font-size: 11px; }
  .hero-block { font-size: 11px; line-height: 1.35; }
  .hero-block b { font-size: 12.5px; }
  .hud-buttons { grid-column: 2; grid-row: 1 / span 3; display: grid; grid-template-columns: repeat(2, 32px); gap: 4px; margin: 0; align-self: start; }
  .hud-buttons button { width: 32px; height: 32px; font-size: 14px; }
  .actions { left: 6px; right: 6px; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; pointer-events: none; }
  .actions > * { pointer-events: auto; }
  .action { padding: 5px 11px; font-size: 12px; }
}
.action.hunt { background: linear-gradient(#b0453a, #7a2620); border-color: #ff9a7a; }
#hunt-list h3 { margin: 14px 0 2px; font-size: 14px; color: var(--gold); }
.hunt-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.hunt-row .info { min-width: 0; }
.hunt-row button { flex: 0 0 auto; }
.hero-btns { display: flex; gap: 6px; align-items: center; }

.guide-block { position: relative; cursor: pointer; border-color: #c9a227; max-width: 270px; padding-right: 28px; }
.guide-block .guide-step { color: #ffd76a; font-weight: bold; }
.guide-block .guide-skip { position: absolute; top: 2px; right: 2px; background: none; border: none; color: #aaa; padding: 2px 6px; cursor: pointer; }
.scout-bar { display: block; width: 100%; margin: 0 0 8px; padding: 6px 10px; text-align: left; border: 1px solid var(--line); border-radius: 6px; background: rgba(63,125,58,.18); color: inherit; font-size: 13px; cursor: pointer; }
.scout-bar.sel { border-color: var(--gold); }

/* Choose a race (heroes made before races existed) */
.race-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 60vh; overflow-y: auto; }
.race-choice { text-align: left; padding: 8px 10px; border: 1px solid var(--line, #4a3d66); border-radius: 8px; background: #2a2140; color: inherit; cursor: pointer; }
.race-choice:hover { border-color: var(--gold); background: #3a2d55; }
.race-choice b { display: block; margin-bottom: 3px; }
.item .plus { color: #7fe3ff; }
.strong-vs { color: #ffcf7a; }
