/* Королевства — стили интерфейса */
:root {
  --wood: #2b2118; --wood2: #3b2d20; --wood3: #4a3826; --line: #6b5237;
  --parch: #f3e7cb; --parch2: #e8d7b0; --parch3: #d9c493; --ink: #2c2115; --ink2: #6b5a43;
  --gold: #d9a441; --gold2: #f3d27a; --red: #b23a2a; --green: #3f8f3a; --blue: #2f6aa8;
  --good: #2e7d32; --bad: #c0392b; --shadow: 0 6px 24px rgba(0,0,0,.45);
  color-scheme: light;
}
/* Игра намеренно использует один визуальный мир (дерево и пергамент) в любой теме системы. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1611; color: var(--ink); font: 14px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; cursor: grab; }
button { font: inherit; }
h1, h2, h3, h4 { font-family: Georgia, "Times New Roman", serif; margin: .3em 0; }
h3 { font-size: 16px; } h4 { font-size: 14px; margin-top: .8em; }
small { font-size: 12px; }
.muted { color: var(--ink2); }
.good { color: var(--good); font-weight: 600; }
.warn { color: var(--bad); font-weight: 600; }
.up { color: var(--good); }
.c { text-align: center; }
.hidden { display: none !important; }
code { background: rgba(0,0,0,.08); padding: 1px 4px; border-radius: 4px; }
img.ri { width: 18px; height: 18px; vertical-align: -4px; }
img.ri.big { width: 28px; height: 28px; vertical-align: -9px; border-radius: 6px; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; border: 1px solid #00000055; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  background: linear-gradient(#efe0b8, #d6bf8a); color: var(--ink); font-weight: 600; box-shadow: inset 0 1px 0 #fff7, 0 2px 0 #0003; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); box-shadow: inset 0 1px 0 #fff5; }
.btn:disabled { opacity: .5; cursor: default; filter: grayscale(.4); }
.btn.green { background: linear-gradient(#5fb15a, #357c31); color: #fff; text-shadow: 0 1px 0 #0006; }
.btn.red { background: linear-gradient(#d8604c, #9b2e20); color: #fff; text-shadow: 0 1px 0 #0006; }
.btn.blue { background: linear-gradient(#5591d1, #2a5d96); color: #fff; text-shadow: 0 1px 0 #0006; }
.btn.gold { background: linear-gradient(#f5d77c, #c9922d); color: #3a2608; }
.btn.gem { background: linear-gradient(#e46d9a, #a8285a); color: #fff; text-shadow: 0 1px 0 #0006; }
.btn.small { padding: 4px 8px; font-size: 12px; border-radius: 6px; }
.btn.big { padding: 11px 22px; font-size: 16px; }
.btn.icon { padding: 3px 5px; }
.btn.tab, .tab { background: var(--parch2); border: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--ink2); box-shadow: none; }
.tab.on { background: var(--parch); color: var(--ink); border-bottom-color: var(--parch); }
.tab:disabled { opacity: .45; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tabs.small .tab { padding: 4px 10px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.wrap { flex-wrap: wrap; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#hud-top { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: linear-gradient(#2b2118f0, #2b2118c0); border-bottom: 2px solid var(--gold); color: #f5e6c4; }
.ava { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.ava img { width: 40px; height: 40px; }
.ainfo { display: flex; flex-direction: column; line-height: 1.15; }
.ainfo b { font-family: Georgia, serif; font-size: 15px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ainfo span { font-size: 12px; color: var(--gold2); }
.vip { background: linear-gradient(#f5d77c, #b77d1e); color: #3a2608; font-weight: 800; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.apbar { position: relative; width: 90px; height: 16px; background: #0006; border-radius: 8px; overflow: hidden; border: 1px solid #0008; }
.apbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#6fcf5a, #2f8f2a); }
.apbar span { position: relative; font-size: 11px; font-weight: 700; display: block; text-align: center; line-height: 15px; text-shadow: 0 1px 1px #000; }
.shield { font-size: 12px; color: #9fd3ff; white-space: nowrap; }
.res { margin-left: auto; display: flex; gap: 6px; flex-wrap: nowrap; }
.rchip { display: flex; align-items: center; gap: 4px; background: #0005; border: 1px solid #ffffff22; border-radius: 14px; padding: 2px 9px 2px 3px; cursor: pointer; font-weight: 700; font-size: 13px; }
.rchip img { width: 22px; height: 22px; }
.rchip.gem em { font-style: normal; background: var(--green); color: #fff; border-radius: 50%; width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 13px; }
#alarm { position: absolute; top: 62px; left: 50%; transform: translateX(-50%); background: #a11d12ee; color: #fff; padding: 6px 16px; border-radius: 10px; font-weight: 700; display: none; animation: pulse 1s infinite alternate; box-shadow: var(--shadow); }
#alarm.show { display: block; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }

#side { position: absolute; left: 8px; top: 62px; width: 250px; display: flex; flex-direction: column; gap: 6px; max-height: calc(100% - 140px); overflow: auto; scrollbar-width: thin; }
#quest-ribbon { display: flex; align-items: center; gap: 8px; background: linear-gradient(90deg, #3b2d20ee, #3b2d20aa); border: 1px solid var(--gold); color: #f5e6c4; border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 13px; flex-wrap: wrap; }
#quest-ribbon small { color: var(--gold2); width: 100%; padding-left: 26px; }
#quest-ribbon.done { background: linear-gradient(90deg, #2f6b2aee, #2f6b2aaa); animation: pulse 1.2s infinite alternate; }
#queues { display: flex; flex-direction: column; gap: 4px; }
.qrow { display: flex; align-items: center; gap: 6px; background: #2b2118dd; border: 1px solid #ffffff1c; border-radius: 9px; padding: 4px 6px; color: #f5e6c4; cursor: pointer; font-size: 12px; }
.qrow:hover { border-color: var(--gold); }
.qrow > img { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; }
.qrow .qic { width: 34px; text-align: center; font-size: 18px; }
.qrow.idle { opacity: .8; } .qrow.idle.small { opacity: .6; }
.qinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qinfo > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qbtn { background: #ffffff1a; border: 1px solid #ffffff33; color: #ffe9a8; border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.qbtn.help { color: #9fd3ff; }
.tbar { position: relative; height: 15px; background: #00000040; border-radius: 8px; overflow: hidden; }
.tbar.big { height: 18px; margin: 6px 0; }
.tbar i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(#7bd06a, #3d9a36); border-radius: 8px; transition: width .25s linear; }
.tbar span { position: relative; display: block; text-align: center; font-size: 11px; font-weight: 700; line-height: 15px; color: #fff; text-shadow: 0 1px 1px #000; }
.panel .tbar { background: #0002; margin: 6px 0; }

#nav { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 2px; padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); background: linear-gradient(#2b2118c0, #2b2118f5); border-top: 2px solid var(--gold); overflow-x: auto; }
#nav button { flex: none; position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 66px; padding: 4px 6px; background: none; border: 0; color: #f0dcae; cursor: pointer; border-radius: 8px; }
#nav button:hover { background: #ffffff14; color: #fff; }
#nav button span { font-size: 11px; }
#nav button .badge { position: absolute; top: 0; right: 8px; }
#viewBtn { background: linear-gradient(#5591d1, #2a5d96) !important; color: #fff !important; }
#more { position: absolute; bottom: 64px; right: 10px; display: none; flex-direction: column; background: var(--wood); border: 1px solid var(--gold); border-radius: 10px; padding: 6px; box-shadow: var(--shadow); }
#more.show { display: flex; }
#more button { background: none; border: 0; color: #f0dcae; text-align: left; padding: 8px 18px; cursor: pointer; border-radius: 6px; font-weight: 600; }
#more button:hover { background: #ffffff18; }

#maptools, #minimap, #coords, #zoom { display: none; }
body.map #maptools { display: flex; position: absolute; top: 62px; right: 10px; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 280px); background: #2b2118cc; border: 1px solid #ffffff22; border-radius: 10px; padding: 5px 8px; color: #f5e6c4; font-size: 12px; }
#maptools input { width: 52px; padding: 3px 4px; border-radius: 5px; border: 1px solid #0006; }
#maptools select { padding: 3px; border-radius: 5px; }
#maptools span { display: inline-flex; gap: 4px; align-items: center; }
body.map #minimap { display: block; position: absolute; right: 10px; bottom: 72px; background: #1d3a57cc; border: 2px solid var(--gold); border-radius: 10px; cursor: crosshair; }
body.map #coords { display: block; position: absolute; right: 220px; bottom: 76px; background: #0008; color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-variant-numeric: tabular-nums; }
#zoom { position: absolute; right: 10px; flex-direction: column; gap: 4px; top: 50%; transform: translateY(-50%); }
#hud:not(.hidden) #zoom { display: flex; }
#zoom .btn { width: 34px; height: 34px; font-size: 18px; padding: 0; }

/* ---------- модальные окна ---------- */
#modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: #0007; z-index: 20; padding: 12px; }
#modal.show { display: flex; }
.panel { width: min(560px, 100%); max-height: min(88vh, 100%); display: flex; flex-direction: column; background: var(--parch); border: 3px solid var(--wood3); border-radius: 14px; box-shadow: var(--shadow), inset 0 0 40px #b8955a40; animation: pop .15s ease-out; }
.panel.wide { width: min(940px, 100%); }
@keyframes pop { from { transform: scale(.96); opacity: .5; } to { transform: none; opacity: 1; } }
.phead { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(#4a3826, #2b2118); color: #f5e6c4; border-radius: 10px 10px 0 0; border-bottom: 2px solid var(--gold); }
.phead h2 { flex: 1; font-size: 19px; margin: 0; }
.phead h2 small { font-size: 13px; color: var(--gold2); }
.pclose, .pback { background: #ffffff1a; border: 1px solid #ffffff33; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 16px; line-height: 1; }
.pback { font-size: 22px; }
.pbody { padding: 12px 14px; overflow: auto; flex: 1; }
.box { background: #fff6; border: 1px solid var(--parch3); border-radius: 10px; padding: 8px 12px; margin: 10px 0; }
.box h3 { margin-top: 0; }
.cost { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: #fff8; border: 1px solid var(--parch3); border-radius: 12px; padding: 2px 8px 2px 3px; font-weight: 700; }
.chip.bad { color: var(--bad); border-color: #e2a59c; background: #ffe9e5; }
.reqs { list-style: none; padding: 0; margin: 6px 0; }
.reqs li.ok { color: var(--good); } .reqs li.no { color: var(--bad); font-weight: 600; }
.time { color: var(--ink2); margin: 6px 0; }
.bhead { display: flex; gap: 12px; align-items: flex-start; }
.bimg { width: 96px; height: 96px; border-radius: 10px; flex: none; }
.bhead p { margin: 0 0 6px; }
table.stats { width: 100%; border-collapse: collapse; font-size: 13px; }
table.stats td, table.stats th { padding: 4px 6px; border-bottom: 1px solid #0000001a; text-align: left; }
table.stats.mini td, table.stats.mini th { padding: 2px 5px; }
table.stats.list td:last-child { text-align: right; white-space: nowrap; }
table.stats tr.click { cursor: pointer; } table.stats tr.click:hover { background: #fff6; }
table.stats tr.me { background: #f3d27a66; }
.ltable { width: 100%; font-size: 12px; border-collapse: collapse; }
.ltable td, .ltable th { padding: 2px 4px; border-bottom: 1px solid #0001; text-align: right; }
.ltable tr.cur { background: #f3d27a80; font-weight: 700; }
details.lvls { margin-top: 10px; } details.lvls summary { cursor: pointer; font-weight: 600; color: var(--ink2); }
.funcs .btn { min-width: 120px; }

/* юниты */
.units { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.ucard { position: relative; flex: none; width: 104px; text-align: center; background: #fff7; border: 2px solid var(--parch3); border-radius: 10px; padding: 6px 4px; cursor: pointer; }
.ucard.on { border-color: var(--gold); background: #fff3c8; box-shadow: 0 0 0 2px #f3d27a; }
.ucard img { width: 76px; height: 76px; }
.ucard span { display: block; font-size: 12px; font-weight: 600; line-height: 1.15; }
.ucard small { color: var(--ink2); }
.ucard.locked img { filter: grayscale(1) brightness(.8); }
.ucard em { position: absolute; top: 4px; right: 6px; font-style: normal; }
.ustats { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: 14px; align-items: start; } .ustats > img { width: 72px; height: 72px; }
canvas.wport { width: 100%; aspect-ratio: 400 / 260; border-radius: 12px; border: 3px solid #3a2a1a; box-shadow: 0 4px 14px #0005, inset 0 0 0 1px #f3d27a; background-size: contain; background-repeat: no-repeat; background-position: center; background-color: #6a8a4a; }
@media (max-width: 700px) { .ustats { grid-template-columns: 1fr; } }
.slider { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.slider input[type=range] { flex: 1; accent-color: var(--green); }
.slider input[type=number] { width: 90px; padding: 5px; border-radius: 6px; border: 1px solid var(--line); }
.troops { display: flex; flex-direction: column; gap: 3px; }
.trow { display: flex; align-items: center; gap: 8px; } .trow img { width: 30px; height: 30px; } .trow span { flex: 1; } .barbic { width: 30px; text-align: center; }

/* академия */
.acwrap { display: grid; grid-template-columns: 1fr 300px; gap: 12px; }
.techgrid { max-height: 58vh; overflow: auto; padding-right: 4px; }
.tgroup { display: flex; gap: 8px; margin-bottom: 8px; align-items: stretch; }
.tglabel { flex: none; width: 74px; font-size: 11px; color: var(--ink2); font-weight: 700; display: flex; align-items: center; border-right: 2px solid var(--parch3); }
.tgitems { display: flex; flex-wrap: wrap; gap: 6px; }
.tcard { width: 104px; text-align: center; background: #fff8; border: 2px solid var(--parch3); border-radius: 10px; padding: 5px 3px; cursor: pointer; position: relative; }
.tcard img { width: 44px; height: 44px; } .tcard span { display: block; font-size: 11px; font-weight: 600; line-height: 1.15; min-height: 26px; } .tcard small { color: var(--ink2); font-weight: 700; }
.tcard.locked { opacity: .55; } .tcard.locked img { filter: grayscale(1); }
.tcard.avail { border-color: #7bbf6a; } .tcard.max { border-color: var(--gold); background: #fff2c4; }
.tcard.on { box-shadow: 0 0 0 3px var(--blue); } .tcard.busy::after { content: "⏳"; position: absolute; top: 2px; right: 4px; }
.tdetail { background: #fff6; border: 1px solid var(--parch3); border-radius: 10px; padding: 10px; align-self: start; position: sticky; top: 0; }
.thead { display: flex; gap: 10px; } .thead img { width: 64px; height: 64px; } .thead p { margin: 2px 0; }

/* ускорения */
.splist { display: flex; flex-direction: column; gap: 4px; }
.sprow { display: flex; align-items: center; gap: 8px; } .sprow span { flex: 1; font-size: 13px; }
.islot { position: relative; width: 48px; height: 48px; flex: none; cursor: pointer; }
.islot img { width: 48px; height: 48px; display: block; }
.islot b { position: absolute; right: 2px; bottom: 0; color: #fff; font-size: 11px; text-shadow: 0 0 3px #000, 0 0 2px #000; }

/* командиры */
.cwrap { display: grid; grid-template-columns: 300px 1fr; gap: 12px; }
.clist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-height: 64vh; overflow: auto; align-content: start; padding-right: 4px; }
.ccard { position: relative; text-align: center; cursor: pointer; background: #fff7; border: 2px solid transparent; border-radius: 10px; padding: 4px; }
.ccard.on { border-color: var(--blue); background: #fff; }
.ccard img { width: 72px; height: 72px; } .ccard span { display: block; font-size: 11px; font-weight: 700; line-height: 1.1; } .ccard small { font-size: 10px; color: var(--ink2); }
.ccard em { position: absolute; top: 6px; left: 6px; background: #000a; color: #fff; font-size: 9px; font-style: normal; padding: 0 4px; border-radius: 4px; }
.ccard.locked img { filter: grayscale(.9) brightness(.75); }
.ccard .dot, .dot { position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; background: var(--bad); border-radius: 50%; }
.csep { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--ink2); border-top: 1px solid var(--parch3); padding-top: 6px; }
.chead { display: flex; gap: 12px; align-items: center; } .chead img, .chead canvas.cport { width: 116px; height: 116px; border-radius: 12px; flex: none; }
canvas.cport { background-size: cover; cursor: pointer; box-shadow: 0 4px 14px #0006; }
.rar { color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tals { display: flex; gap: 4px; flex-wrap: wrap; } .tal { background: var(--wood3); color: var(--gold2); font-size: 11px; padding: 2px 7px; border-radius: 6px; }
.stars { color: #e6a817; letter-spacing: 1px; } .stars .off, .sl .off { color: #0002; }
.sl { color: #e6a817; font-size: 11px; margin-left: 6px; letter-spacing: 1px; }
.tomes { display: flex; flex-wrap: wrap; gap: 8px; } .tome { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.skill { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; background: #fff7; border-radius: 8px; padding: 6px 8px; margin: 4px 0; }
.skill span { grid-column: 1; font-size: 12px; color: var(--ink2); } .skill .btn { grid-row: 1 / 3; grid-column: 2; }
.skill.off { opacity: .7; }
.talents { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.talent { background: #fff7; border-radius: 8px; padding: 6px; } .talent b span { color: var(--ink2); font-size: 12px; } .talent small { display: block; color: var(--ink2); min-height: 32px; }
.equip { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; }
.eslot { background: #fff7; border: 1px dashed var(--parch3); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.eslot em { font-style: normal; color: var(--good); }

/* предметы */
.iwrap { display: grid; grid-template-columns: 1fr 300px; gap: 12px; }
.igrid { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; max-height: 58vh; overflow: auto; }
.igrid > div { border: 2px solid transparent; border-radius: 10px; } .igrid > div.on { border-color: var(--blue); }
.idetail { background: #fff6; border: 1px solid var(--parch3); border-radius: 10px; padding: 10px; }
.ihead { display: flex; gap: 10px; } .ihead p { margin: 2px 0; font-size: 13px; }
.idetail input[type=text] { width: 100%; padding: 6px; margin: 6px 0; border-radius: 6px; border: 1px solid var(--line); }
.shop { max-height: 60vh; overflow: auto; }
.srow { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid #0000001a; }
.srow > div { flex: 1; display: flex; flex-direction: column; } .srow small { color: var(--ink2); }

/* таверна */
.chests { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chest { text-align: center; border-radius: 14px; padding: 10px; border: 2px solid var(--parch3); }
.chest.silver { background: linear-gradient(#f0f2f5aa, #c9d1da88); } .chest.gold { background: linear-gradient(#fff3c8cc, #e9c46a88); }
.chest .row { justify-content: center; }
.cimg svg { filter: drop-shadow(0 4px 4px #0004); }
.loot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lcard { width: 120px; background: #fff; border: 2px solid var(--gold); border-radius: 10px; padding: 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; animation: flip .45s both; font-size: 12px; }
.lcard.cmd { background: linear-gradient(#fff3c8, #f5d77c); } .lcard img, .lcard canvas.cport { width: 72px; height: 72px; border-radius: 8px; }
@keyframes flip { from { transform: rotateY(90deg) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* альянс, формы */
.form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.form.col { flex-direction: column; align-items: stretch; }
.form input[type=text], .form select, .form textarea, .form input[type=number] { padding: 7px; border-radius: 6px; border: 1px solid var(--line); background: #fffdf6; font: inherit; }
.resin { display: inline-flex; align-items: center; gap: 4px; } .resin input { width: 100px; }
.rank { background: var(--wood3); color: var(--gold2); font-size: 10px; padding: 1px 5px; border-radius: 4px; }
.on { color: var(--good); }
ul.log { list-style: none; padding: 0; max-height: 200px; overflow: auto; font-size: 13px; } ul.log li { padding: 2px 0; border-bottom: 1px solid #0001; }
label.chk { display: block; margin: 6px 0; cursor: pointer; }

/* почта */
.mwrap { display: grid; grid-template-columns: 300px 1fr; gap: 12px; }
.mlist { max-height: 60vh; overflow: auto; }
.mrow { padding: 6px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; }
.mrow:hover { background: #fff6; } .mrow.on { background: #fff; border-color: var(--blue); }
.mrow.unread b::before { content: "● "; color: var(--bad); }
.mrow small { color: var(--ink2); }
.mdetail { background: #fff6; border-radius: 10px; padding: 10px; min-height: 200px; }
.banner { text-align: center; font-family: Georgia, serif; font-size: 26px; font-weight: 800; letter-spacing: 3px; padding: 6px; border-radius: 10px; color: #fff; margin: 6px 0; }
.banner.win { background: linear-gradient(#5fb15a, #2f6b2a); } .banner.lose { background: linear-gradient(#d8604c, #8a2a1e); }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.side { background: #fff7; border-radius: 8px; padding: 6px 8px; }
.pm { white-space: pre-wrap; background: #fff; padding: 10px; border-radius: 8px; }

/* задания */
.quest { display: flex; align-items: center; gap: 10px; background: #fff7; border: 1px solid var(--parch3); border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
.quest > div { flex: 1; } .quest.done { border-color: #7bbf6a; background: #eaf6e1; }
.dchests { display: flex; justify-content: space-between; gap: 6px; margin: 6px 0; }
.dchest { flex: 1; text-align: center; background: #fff7; border: 2px solid var(--parch3); border-radius: 10px; padding: 4px; font-size: 18px; }
.dchest b { display: block; font-size: 12px; } .dchest.ready { border-color: var(--gold); background: #fff3c8; cursor: pointer; animation: pulse 1s infinite alternate; } .dchest.claimed { opacity: .5; }
.vipbig { font-family: Georgia, serif; font-size: 40px; font-weight: 800; text-align: center; color: #b77d1e; text-shadow: 0 2px 0 #fff; }
.answers { display: flex; flex-direction: column; gap: 6px; } .btn.ans { justify-content: flex-start; white-space: normal; text-align: left; }

/* поход */
.mcmd { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cpick { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.cp { flex: none; width: 70px; text-align: center; cursor: pointer; border: 2px solid transparent; border-radius: 10px; padding: 3px; }
.cp.on { border-color: var(--blue); background: #fff; } .cp img { width: 56px; height: 56px; } .cp small { display: block; font-size: 10px; line-height: 1.1; }
.cp .none { display: flex; width: 56px; height: 56px; align-items: center; justify-content: center; font-size: 24px; color: var(--ink2); margin: 0 auto; }
.mtroops { display: flex; flex-direction: column; gap: 4px; max-height: 40vh; overflow: auto; }
.mt { display: grid; grid-template-columns: 34px 150px 1fr 80px; gap: 8px; align-items: center; }
.mt img { width: 34px; height: 34px; } .mt span { font-size: 12px; font-weight: 600; display: flex; flex-direction: column; } .mt span small { color: var(--ink2); font-weight: 400; }
.mt input[type=number] { width: 80px; padding: 4px; border-radius: 6px; border: 1px solid var(--line); }
.mt input[type=range] { accent-color: var(--red); }

/* всплывающее окно карты */
#mappop { position: fixed; display: none; z-index: 15; width: 290px; background: var(--parch); border: 2px solid var(--wood3); border-radius: 12px; padding: 8px 12px; box-shadow: var(--shadow); }
#mappop.show { display: block; }
#mappop .pclose { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; font-size: 12px; background: var(--wood3); }
#mappop h3 { margin-right: 26px; }
#mappop p { margin: 4px 0; }

/* чат */
#chat { position: fixed; right: 0; top: 56px; bottom: 60px; width: 360px; max-width: 100%; z-index: 12; background: #2b2118f2; border-left: 2px solid var(--gold); display: none; flex-direction: column; color: #f5e6c4; box-shadow: var(--shadow); }
#chat.show { display: flex; }
.chead2 { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid #ffffff22; }
.chead2 .tab { background: #ffffff14; color: #e8d8b8; border: 1px solid #ffffff22; border-radius: 8px; }
.chead2 .tab.on { background: var(--gold); color: #2b2118; }
.chead2 .pclose { margin-left: auto; }
.cmsgs { flex: 1; overflow: auto; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.cmsg { display: flex; gap: 6px; } .cmsg img { width: 26px; height: 26px; } .cmsg b { color: var(--gold2); cursor: pointer; font-size: 12px; } .cmsg small { color: #bfae8e; font-size: 10px; }
.cmsg p { margin: 2px 0 0; background: #ffffff12; padding: 4px 8px; border-radius: 0 8px 8px 8px; word-break: break-word; }
.cmsg.me p { background: #3f8f3a55; }
.cform { display: flex; gap: 6px; padding: 6px; border-top: 1px solid #ffffff22; }
.cform input { flex: 1; padding: 8px; border-radius: 8px; border: 1px solid #0006; background: #fffdf6; }

/* подтверждение, уведомления */
#confirm { position: fixed; inset: 0; z-index: 40; background: #0008; display: none; align-items: center; justify-content: center; padding: 16px; }
#confirm.show { display: flex; }
.cbox { background: var(--parch); border: 3px solid var(--wood3); border-radius: 14px; padding: 16px 20px; max-width: 420px; box-shadow: var(--shadow); text-align: center; }
.cbox .row { justify-content: center; }
#toasts { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, calc(100% - 32px)); }
.toast { background: #2b2118ee; color: #f5e6c4; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--gold); box-shadow: var(--shadow); font-weight: 600; transition: opacity .5s, transform .5s; animation: tin .25s; text-align: center; }
.toast.good { border-color: #6fcf5a; } .toast.bad { border-color: #ff6b5a; background: #4a1a14ee; }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes tin { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
#conn { position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%); background: #a11d12; color: #fff; padding: 8px 16px; border-radius: 10px; z-index: 60; display: none; font-weight: 700; }
#conn.show { display: block; }

/* экран входа */
#login { position: fixed; inset: 0; z-index: 30; display: none; align-items: flex-start; justify-content: center; overflow: auto; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 0%, #5c4a2e 0%, #2b2118 55%, #140f0b 100%); }
#login.show { display: flex; }
.lbox { width: min(760px, 100%); background: var(--parch); border: 3px solid var(--gold); border-radius: 16px; padding: 18px 22px; box-shadow: 0 10px 40px #000a; margin: auto; }
.logo { text-align: center; }
.logo h1 { font-size: 44px; letter-spacing: 2px; color: #6b3a12; margin: 4px 0; text-shadow: 0 2px 0 #fff8; }
.logo p { margin: 0 0 12px; color: var(--ink2); }
.lbox input[type=text], .lbox input[type=password] { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 16px; margin: 6px 0; background: #fffdf6; }
.lbox > .btn.big { width: 100%; margin-top: 10px; }
.civs { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 6px; }
.civ { text-align: center; background: #fff7; border: 2px solid var(--parch3); border-radius: 10px; padding: 6px 4px; cursor: pointer; }
.civ.on { border-color: var(--gold); background: #fff3c8; box-shadow: 0 0 0 2px #f3d27a; }
.civ img { width: 40px; height: 40px; } .civ b { display: block; font-size: 13px; } .civ small { color: var(--ink2); font-size: 11px; line-height: 1.2; display: block; }
.civinfo { display: flex; gap: 12px; align-items: center; background: #fff7; border-radius: 10px; padding: 8px; margin-top: 8px; }
.civinfo img { width: 72px; height: 72px; }
.save { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff7; border: 2px solid var(--gold); border-radius: 12px; padding: 10px 14px; margin: 6px 0; }
.err { color: var(--bad); font-weight: 700; text-align: center; }
.srvinfo { background: #fff7; border: 1px solid var(--parch3); border-radius: 10px; padding: 6px 10px; text-align: center; font-size: 13px; margin: 4px 0 8px; }
#lForm .btn.big { width: 100%; margin-top: 10px; }
.lbox a { color: var(--blue); font-weight: 600; }
.credit { font-size: 11px; color: var(--ink2); text-align: center; margin-top: 10px; }
.small { font-size: 12px; }

/* ---------- адаптив ---------- */
@media (max-width: 900px) {
  .acwrap, .iwrap, .cwrap, .mwrap { grid-template-columns: 1fr; }
  .clist { grid-template-columns: repeat(4, 1fr); max-height: 34vh; }
  .techgrid, .igrid, .mlist { max-height: 40vh; }
  .tdetail { position: static; }
}
@media (max-width: 700px) {
  #hud-top { flex-wrap: wrap; gap: 6px; padding: 4px 6px; }
  .res { margin-left: 0; width: 100%; justify-content: space-between; gap: 3px; }
  .rchip { padding: 1px 6px 1px 2px; font-size: 12px; } .rchip img { width: 18px; height: 18px; }
  .apbar { width: 70px; }
  #side { top: 92px; width: 200px; font-size: 11px; }
  #side .qrow > img { width: 26px; height: 26px; }
  #alarm { top: 92px; }
  #nav button { min-width: 58px; padding: 3px 2px; } #nav button span { font-size: 10px; }
  #nav button svg { width: 20px; height: 20px; }
  #nav { justify-content: flex-start; }
  .panel { max-height: 100%; border-radius: 10px; } #modal { padding: 4px; }
  .chests, .sides, .mcmd, .talents { grid-template-columns: 1fr; }
  .mt { grid-template-columns: 30px 1fr 70px; } .mt input[type=range] { grid-column: 1 / -1; grid-row: 2; }
  body.map #maptools { top: 92px; max-width: calc(100% - 20px); left: 10px; right: 10px; justify-content: flex-start; }
  body.map #maptools .mt-go { display: none; }
  body.map #side { top: 178px; width: 180px; }
  body.map #quest-ribbon { display: none; }
  body.map #minimap { width: 150px; height: 82px; }
  body.map #coords { right: 168px; }
  #chat { top: 0; bottom: 0; width: 100%; }
  .logo h1 { font-size: 32px; }
  .bhead { flex-direction: column; align-items: center; }
}

/* ---------- рынок: биржа и аукцион ---------- */
.panel.market { width: min(1060px, 100%); }
.mtabs { align-items: flex-end; }
.mwallet { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding-bottom: 4px; }
.mwallet b { margin-right: 8px; }
.mres { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
.mchip { display: flex; align-items: center; gap: 8px; text-align: left; background: linear-gradient(#fffaf0, #f1e2bd); border: 1px solid var(--parch3); border-radius: 12px; padding: 6px 10px; cursor: pointer; font: inherit; color: var(--ink); box-shadow: 0 2px 0 #0001; }
.mchip span { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.mchip small { color: var(--ink2); white-space: nowrap; }
.mchip em { font-style: normal; font-size: 12px; font-weight: 700; color: var(--ink2); white-space: nowrap; }
.mchip em.up { color: #2e7d32; } .mchip em.down { color: #c0392b; }
.mchip.on { border-color: var(--gold); background: linear-gradient(#fff3c8, #f3d27a); box-shadow: 0 0 0 2px #f3d27a88; }
.mgrid { display: grid; grid-template-columns: 1.35fr 0.9fr 1fr; gap: 12px; align-items: start; }
.mcol { background: #fff7; border: 1px solid var(--parch3); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.mcol h4 { margin-top: 0; }
.pchart { position: relative; width: 100%; aspect-ratio: 420 / 150; }
.pchart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.pchart.empty { aspect-ratio: auto; padding: 24px 6px; text-align: center; }
.pchart .cg { stroke: #6b5a4322; stroke-width: 1; }
.pchart .cl { fill: #6b5a43; font-size: 10px; font-family: inherit; }
.pchart .cline { fill: none; stroke: #b07a1e; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pchart .cdot { fill: #b07a1e; stroke: #fff7e6; stroke-width: 2; }
.pchart .cv { fill: #6b5a4333; }
.pchart .cx { stroke: #2c2115; stroke-width: 1; stroke-dasharray: 3 3; }
.ctip { position: fixed; z-index: 70; display: none; pointer-events: none; background: #2b2118f2; color: #f5e6c4; border: 1px solid var(--gold); border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.35; box-shadow: var(--shadow); }
.book { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.bh { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink2); padding: 0 6px; }
.brow { position: relative; display: flex; justify-content: space-between; padding: 3px 6px; border-radius: 5px; cursor: pointer; font-size: 13px; overflow: hidden; }
.brow i { position: absolute; right: 0; top: 0; bottom: 0; opacity: .22; }
.brow.ask i { background: #c0392b; } .brow.bid i { background: #2e7d32; }
.brow.ask span:first-child { color: #b03a2a; font-weight: 700; } .brow.bid span:first-child { color: #2e7d32; font-weight: 700; }
.brow span { position: relative; }
.brow:hover { background: #fff; }
.bmid { text-align: center; font-weight: 800; font-size: 16px; padding: 5px 0; margin: 2px 0; border-top: 1px dashed var(--parch3); border-bottom: 1px dashed var(--parch3); }
.bmid small { font-weight: 400; color: var(--ink2); font-size: 11px; }
.mform label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--ink2); margin: 6px 0; }
.mform input, .sform input, .sform select { padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fffdf6; font: inherit; color: var(--ink); width: 100%; }
.mform .quick { margin: 4px 0; gap: 4px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #0000000f; border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 6px; }
.seg button { border: 0; background: none; border-radius: 8px; padding: 7px; cursor: pointer; font-weight: 700; color: var(--ink2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px #0003; }
.seg button.on.buy { background: linear-gradient(#6fbf5f, #3f8f3a); color: #fff; } .seg button.on.sell { background: linear-gradient(#d8604c, #a83a28); color: #fff; }
table.mtable { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.mtable th { text-align: left; color: var(--ink2); font-weight: 600; padding: 3px 4px; border-bottom: 1px solid var(--parch3); }
table.mtable td { padding: 4px; border-bottom: 1px solid #0000000d; }
td.ell, .ell { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: var(--parch2); color: var(--ink2); }
.pill.buy { background: #dff0d8; color: #2e7d32; } .pill.sell { background: #fbe1dc; color: #b03a2a; } .pill.lead { background: #dff0d8; color: #2e7d32; }
.acats { margin: 0 0 8px; } .acats .tab { border-radius: 16px; border: 1px solid var(--parch3); }
.acats .tab.on { background: var(--gold2); border-color: var(--gold); }
.lots { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; max-height: 46vh; overflow: auto; padding: 2px; }
.lot { display: grid; grid-template-columns: 60px 1fr; grid-template-rows: auto auto; gap: 4px 10px; background: linear-gradient(#fffaf0, #f6ead0); border: 1px solid var(--parch3); border-radius: 12px; padding: 8px; box-shadow: 0 2px 0 #0000000f; }
.lot.lead { border-color: #7bbf6a; box-shadow: 0 0 0 2px #7bbf6a55; } .lot.mine { border-color: var(--gold); } .lot.hot .timer { color: var(--bad); font-weight: 700; }
.licon { position: relative; grid-row: 1 / 3; } .licon img { width: 60px; height: 60px; border-radius: 10px; display: block; }
.licon b { position: absolute; right: 2px; bottom: 2px; background: #000a; color: #fff; font-size: 11px; padding: 0 4px; border-radius: 5px; }
.linfo { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.lprice { display: flex; align-items: center; gap: 4px; font-size: 15px; } .lprice small { color: var(--ink2); font-size: 11px; }
.lact { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.bidrow { display: flex; gap: 4px; } .bidrow input { width: 96px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line); background: #fffdf6; }
.sellf .sform { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 10px; }
.sellf .sform label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; font-weight: 600; color: var(--ink2); }
.sellf .seg { max-width: 280px; }
ul.mlog { list-style: none; padding: 0; margin: 0; max-height: 240px; overflow: auto; font-size: 13px; }
ul.mlog li { padding: 3px 0; border-bottom: 1px solid #0000000d; } ul.mlog small { color: var(--ink2); margin-right: 6px; }
.ltable tr.next { background: #dff0d880; }
@media (max-width: 900px) {
  .mgrid { grid-template-columns: 1fr; }
  .mres { grid-template-columns: repeat(2, 1fr); }
}

/* =====================================================================
   Оформление v2: кнопки, панели, вкладки, HUD и нижнее меню
   ===================================================================== */
:root {
  --tex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .25 0 0 0 0 .12 0 0 0 .55 0'/></filter><rect width='160' height='160' filter='url(%23n)' opacity='.22'/></svg>");
  --woodtex: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='60'><filter id='w'><feTurbulence type='fractalNoise' baseFrequency='.015 .5' numOctaves='3' seed='4'/><feColorMatrix values='0 0 0 0 .1 0 0 0 0 .06 0 0 0 0 .02 0 0 0 .7 0'/></filter><rect width='300' height='60' filter='url(%23w)' opacity='.55'/></svg>");
}
/* кнопки */
.btn { position: relative; border: 1px solid #2a1a0c; border-radius: 10px; padding: 8px 14px; letter-spacing: .2px;
  background: linear-gradient(#fbf0cf 0%, #ecd7a2 46%, #dcbf7c 54%, #cfae68 100%); color: #3a2608; text-shadow: 0 1px 0 #fff8;
  box-shadow: inset 0 1px 0 #fffbea, inset 0 -2px 0 #0000001f, 0 2px 0 #4a3015, 0 4px 8px #0003; transition: filter .12s, transform .06s; }
.btn::before { content: ""; position: absolute; left: 6px; right: 6px; top: 2px; height: 38%; border-radius: 8px 8px 12px 12px; background: linear-gradient(#ffffff70, #ffffff00); pointer-events: none; }
.btn:hover { filter: brightness(1.08) saturate(1.05); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #fff6, 0 0 0 #000, 0 1px 3px #0003; }
.btn:disabled { opacity: .55; filter: grayscale(.6); cursor: default; transform: none; }
.btn.green { background: linear-gradient(#9be283 0%, #5fb34c 46%, #3f9532 54%, #2f7b26 100%); border-color: #163d10; color: #fff; text-shadow: 0 1px 1px #0009; box-shadow: inset 0 1px 0 #d8ffc9b0, inset 0 -2px 0 #0003, 0 2px 0 #163d10, 0 4px 8px #0003; }
.btn.red { background: linear-gradient(#f08a72 0%, #d4583f 46%, #b33c27 54%, #8f2a19 100%); border-color: #4a120a; color: #fff; text-shadow: 0 1px 1px #0009; box-shadow: inset 0 1px 0 #ffd2c4a0, inset 0 -2px 0 #0003, 0 2px 0 #4a120a, 0 4px 8px #0003; }
.btn.blue { background: linear-gradient(#88bdf0 0%, #4f8fd3 46%, #336fb3 54%, #245594 100%); border-color: #0f2a4f; color: #fff; text-shadow: 0 1px 1px #0009; box-shadow: inset 0 1px 0 #d6ebffb0, inset 0 -2px 0 #0003, 0 2px 0 #0f2a4f, 0 4px 8px #0003; }
.btn.gold { background: linear-gradient(#fff0b0 0%, #f6cf62 46%, #dfa92e 54%, #b9801a 100%); border-color: #5a3a06; color: #3a2405; box-shadow: inset 0 1px 0 #fffbe0, inset 0 -2px 0 #0002, 0 2px 0 #5a3a06, 0 4px 8px #0003; }
.btn.gem { background: linear-gradient(#f59ac0 0%, #e05a92 46%, #c13a76 54%, #93245a 100%); border-color: #4a0f2c; color: #fff; text-shadow: 0 1px 1px #0009; box-shadow: inset 0 1px 0 #ffd6e8b0, inset 0 -2px 0 #0003, 0 2px 0 #4a0f2c, 0 4px 8px #0003; }
.btn.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.small::before { border-radius: 6px; }
.btn.big { padding: 12px 24px; font-size: 16px; border-radius: 12px; }
.btn img.ri { filter: drop-shadow(0 1px 1px #0006); }
/* вкладки */
.tabs { border-bottom: 2px solid #8a6a40; gap: 5px; }
.tab, .btn.tab { position: relative; background: linear-gradient(#e9d6a8, #d6bd86); border: 1px solid #8a6a40; border-bottom: 0; border-radius: 10px 10px 0 0; padding: 7px 14px; color: #6b5233; font-weight: 700; box-shadow: inset 0 1px 0 #fff8; top: 2px; }
.tab:hover { filter: brightness(1.05); }
.tab.on { background: linear-gradient(#fffaf0, #f3e7cb); color: #3a2608; border-color: #8a6a40; z-index: 1; box-shadow: inset 0 2px 0 var(--gold); }
.tabs.small .tab, .acats .tab { top: 0; border-radius: 16px; border: 1px solid #b89a64; box-shadow: none; }
/* панели */
#modal { background: radial-gradient(ellipse at center, #0006, #000a); backdrop-filter: blur(1.5px); }
.panel { position: relative; background: var(--tex), radial-gradient(ellipse at 50% 0%, #fffaf0 0%, #f3e7cb 45%, #e3cf9f 100%); border: 3px solid #3a2a1a;
  box-shadow: 0 0 0 1px #c9a24a, 0 0 0 4px #2a1d10, 0 16px 50px #000c, inset 0 0 60px #9a74304a; border-radius: 16px; }
.phead { position: relative; background: var(--woodtex), linear-gradient(#5a432c, #3a2a1a 60%, #2b1f13); border-bottom: 0; border-radius: 12px 12px 0 0; padding: 10px 14px; box-shadow: inset 0 1px 0 #ffffff26, 0 2px 0 #c9a24a, 0 4px 0 #2a1d10, 0 6px 10px #0004; }
.phead h2 { font-size: 20px; color: #ffe9b0; text-shadow: 0 2px 0 #000, 0 0 12px #f3d27a40; letter-spacing: .5px; }
.phead::before, .phead::after { content: ""; position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2c0, #c9a24a 55%, #6a4a14); box-shadow: 0 1px 1px #000; }
.phead::before { left: 6px; } .phead::after { right: 6px; }
.phead h2 { padding-left: 8px; }
.pclose, .pback { background: linear-gradient(#a8432f, #6a1f12); border: 1px solid #2a0a04; box-shadow: inset 0 1px 0 #ffffff40, 0 2px 0 #000; font-weight: 800; margin-right: 6px; }
.pclose:hover, .pback:hover { filter: brightness(1.15); }
.pbody { padding: 14px 16px; }
.box, .mcol, .tdetail, .idetail, .mdetail { background: linear-gradient(#fffaf0b8, #fbf2dcb0); border: 1px solid #c9ad74; box-shadow: inset 0 1px 0 #fff, 0 2px 4px #0000001a; }
.box h3, .mcol h4 { font-family: Georgia, serif; color: #4a3210; }
h3, h4 { color: #4a3210; }
.chip { background: linear-gradient(#fffdf6, #f3e7cb); border: 1px solid #c9ad74; box-shadow: inset 0 1px 0 #fff, 0 1px 1px #0000001a; }
.chip img.ri { width: 22px; height: 22px; vertical-align: -6px; filter: drop-shadow(0 1px 1px #0005); }
input[type=number], input[type=text], input[type=password], select, textarea { accent-color: var(--gold); }
.form input[type=text], .form select, .form textarea, .form input[type=number], .mform input, .sform input, .sform select, .bidrow input, .slider input[type=number] { border: 1px solid #a8885a; background: linear-gradient(#fffef9, #fbf3e0); box-shadow: inset 0 1px 2px #0000001f; }
/* карточки */
.ucard, .tcard, .ccard, .civ, .quest, .dchest, .lot, .mchip { transition: transform .12s, box-shadow .12s; }
.ucard:hover, .tcard:hover, .ccard:hover, .civ:hover, .lot:hover, .mchip:hover { transform: translateY(-2px); box-shadow: 0 6px 12px #0000002a; }
.ucard { background: linear-gradient(#fffaf0, #f1e2bd); border: 2px solid #c9ad74; }
.ucard.on { border-color: var(--gold); background: linear-gradient(#fff6d4, #f3d27a); box-shadow: 0 0 0 2px #f3d27a, 0 6px 14px #0003; }
.islot img { border-radius: 10px; filter: drop-shadow(0 2px 2px #0004); }
/* HUD */
#hud-top { background: var(--woodtex), linear-gradient(#4a3826, #2b2118 70%, #1f170f); border-bottom: 0; box-shadow: 0 2px 0 #c9a24a, 0 4px 0 #2a1d10, 0 8px 18px #0008; padding: 6px 12px; }
.ava img { width: 44px; height: 44px; filter: drop-shadow(0 2px 3px #000a); }
.ainfo b { color: #ffe9b0; text-shadow: 0 1px 0 #000; }
.vip { box-shadow: inset 0 1px 0 #fff8, 0 1px 0 #000; border: 1px solid #5a3a06; }
.apbar { height: 18px; border: 1px solid #000; box-shadow: inset 0 2px 3px #000a, 0 1px 0 #ffffff1a; background: #1a120b; }
.apbar i { background: linear-gradient(#9be283, #3f9532 55%, #2f7b26); box-shadow: inset 0 1px 0 #ffffff60; }
.rchip { position: relative; background: linear-gradient(#1a120bcc, #2b2118cc); border: 1px solid #c9a24a8c; box-shadow: inset 0 1px 0 #ffffff14, 0 1px 0 #000; padding: 3px 12px 3px 30px; border-radius: 16px; min-width: 76px; }
.rchip img { position: absolute; left: -4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; filter: drop-shadow(0 2px 2px #000c); }
.rchip span { color: #fff6dc; text-shadow: 0 1px 1px #000; font-variant-numeric: tabular-nums; }
.rchip:hover { border-color: var(--gold2); }
.rchip.gem em { background: linear-gradient(#9be283, #2f7b26); box-shadow: 0 1px 0 #000; }
.res { gap: 10px; }
/* нижнее меню */
#nav { background: var(--woodtex), linear-gradient(#3a2a1ae6, #1f170ff8); border-top: 0; box-shadow: 0 -2px 0 #c9a24a, 0 -4px 0 #2a1d10, 0 -8px 18px #0007; padding-top: 6px; gap: 4px; }
#nav button { min-width: 70px; padding: 2px 6px 4px; color: #f0dcae; text-shadow: 0 1px 1px #000; }
#nav button:hover { background: none; color: #fff; }
#nav button:hover .nico { transform: translateY(-3px) scale(1.06); box-shadow: 0 0 0 2px #f3d27a, 0 6px 12px #000a; }
.nico { display: flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; margin-top: -14px; background: radial-gradient(circle at 40% 30%, #6a4f30, #2b1f13 70%); box-shadow: 0 0 0 2px #c9a24a, 0 0 0 4px #1a120b, 0 4px 8px #0009; transition: transform .12s, box-shadow .12s; }
.nico img { width: 32px; height: 32px; }
#nav button span { font-size: 11px; font-weight: 700; margin-top: 2px; }
#viewBtn { background: none !important; }
#viewBtn .nico { background: radial-gradient(circle at 40% 30%, #6fa8e0, #1f4a86 70%); }
#nav button .badge { top: -10px; right: 6px; box-shadow: 0 1px 2px #000; }
#more { background: var(--woodtex), linear-gradient(#3a2a1a, #1f170f); box-shadow: 0 0 0 1px #c9a24a, 0 0 0 3px #1a120b, var(--shadow); bottom: 74px; }
/* очереди слева */
.qrow { background: linear-gradient(90deg, #2b2118ee, #3a2a1acc); border: 1px solid #c9a24a55; box-shadow: 0 2px 6px #0006; }
#quest-ribbon { box-shadow: 0 2px 8px #0006; }
.tbar i { background: linear-gradient(#9be283, #3f9532 55%, #2f7b26); box-shadow: inset 0 1px 0 #ffffff60; }
.toast { background: var(--woodtex), linear-gradient(#3a2a1af2, #1f170ff2); box-shadow: 0 0 0 1px #c9a24a, 0 8px 22px #000a; }
@media (max-width: 700px) {
  .nico { width: 34px; height: 34px; margin-top: -10px; } .nico img { width: 26px; height: 26px; }
  #nav button { min-width: 56px; }
  .rchip { padding: 2px 8px 2px 24px; min-width: 0; } .rchip img { width: 26px; height: 26px; }
}

/* =====================================================================
   v3: HUD поверх карты — без верхней и нижней полос, полупрозрачные
   плашки и кнопки, крупные цифры ресурсов и кнопки для телефона
   ===================================================================== */
:root {
  --toph: 64px; --navh: 76px; --mth: 0px;
  --glass: rgba(24, 16, 8, .5);
  --glass2: rgba(24, 16, 8, .36);
  --glassb: rgba(233, 196, 106, .6);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
/* верх: пусто между плашками — карта под ним остаётся кликабельной */
#hud-top { background: none; box-shadow: none; border: 0; pointer-events: none; padding: calc(8px + var(--sat)) 10px 0; gap: 10px; align-items: center; }
#hud-top > *, #hud-top .res > * { pointer-events: auto; }
#hud-top .res { pointer-events: none; }
.ava { background: var(--glass); border: 1px solid var(--glassb); border-radius: 32px; padding: 3px 12px 3px 3px; box-shadow: 0 2px 10px #0005; }
.ava img { width: 46px; height: 46px; }
.ainfo b { font-size: 16px; text-shadow: 0 1px 2px #000, 0 0 6px #000; }
.ainfo span { font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.apbar { width: 104px; height: 22px; border-radius: 11px; background: rgba(10, 6, 2, .55); border: 1px solid var(--glassb); box-shadow: 0 2px 8px #0005; }
.apbar i { opacity: .88; }
.apbar span { font-size: 12.5px; line-height: 20px; }
.shield { background: var(--glass); border: 1px solid #9fd3ff66; border-radius: 12px; padding: 3px 9px; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.res { gap: 12px; }
.rchip { background: var(--glass); border: 1px solid var(--glassb); box-shadow: 0 2px 8px #0005; padding: 4px 14px 4px 36px; border-radius: 18px; min-width: 88px; }
.rchip img { width: 40px; height: 40px; left: -6px; }
.rchip span { font-size: 17px; font-weight: 800; letter-spacing: .2px; text-shadow: 0 1px 2px #000, 0 0 5px #000a; }
.rchip.gem em { width: 20px; height: 20px; line-height: 20px; font-size: 16px; margin-left: 2px; }
#alarm { top: calc(var(--toph) + 8px); }
#side { top: calc(var(--toph) + 10px); max-height: calc(100% - var(--toph) - var(--navh) - 24px); }
#quest-ribbon { background: linear-gradient(90deg, rgba(48, 34, 20, .72), rgba(48, 34, 20, .42)); border-color: var(--glassb); }
#quest-ribbon.done { background: linear-gradient(90deg, rgba(47, 107, 42, .82), rgba(47, 107, 42, .5)); }
.qrow { background: linear-gradient(90deg, rgba(30, 21, 12, .68), rgba(30, 21, 12, .4)); border-color: rgba(201, 162, 74, .4); box-shadow: 0 2px 6px #0004; text-shadow: 0 1px 1px #000; }
body.map #maptools { top: calc(var(--toph) + 8px); background: var(--glass); border-color: var(--glassb); box-shadow: 0 2px 10px #0005; }
body.map #minimap { bottom: calc(var(--navh) + 10px); background: rgba(29, 58, 87, .55); border-color: var(--glassb); box-shadow: 0 2px 12px #0006; }
body.map #coords { bottom: calc(var(--navh) + 14px); background: var(--glass); }
#toasts { bottom: calc(var(--navh) + 16px); }
#more { bottom: calc(var(--navh) + 8px); background: var(--woodtex), linear-gradient(rgba(58, 42, 26, .9), rgba(31, 23, 15, .92)); }
#more button { font-size: 15px; padding: 10px 20px; }
#chat { top: var(--toph); bottom: var(--navh); }
#zoom .btn { width: 40px; height: 40px; font-size: 20px; opacity: .82; }
/* низ: только медальоны с подписями, без деревянной полосы */
#nav { background: none; box-shadow: none; border: 0; pointer-events: none; overflow: visible; padding: 0 8px calc(8px + var(--sab)); gap: 6px; }
#nav button { pointer-events: auto; min-width: 76px; padding: 0 4px; gap: 3px; }
.nico { width: 54px; height: 54px; margin-top: 0; background: radial-gradient(circle at 40% 30%, rgba(112, 84, 52, .74), rgba(40, 28, 16, .62) 72%); box-shadow: 0 0 0 2px rgba(233, 196, 106, .85), 0 0 0 4px rgba(26, 18, 11, .45), 0 4px 10px #0007; }
.nico img { width: 40px; height: 40px; filter: drop-shadow(0 2px 2px #0008); }
#viewBtn .nico { background: radial-gradient(circle at 40% 30%, rgba(111, 168, 224, .82), rgba(31, 74, 134, .7) 70%); }
#nav button span { font-size: 13.5px; font-weight: 800; color: #fff3d2; white-space: nowrap; background: var(--glass2); border-radius: 9px; padding: 0 7px; line-height: 19px; text-shadow: 0 1px 2px #000, 0 0 4px #000; margin-top: 0; }
#nav button:hover .nico { transform: translateY(-3px) scale(1.06); }
#nav button .badge { top: -4px; right: calc(50% - 34px); font-size: 12px; min-width: 20px; line-height: 20px; }
/* телефон и узкое окно: кнопки в две строки по 5, всё видно без прокрутки */
@media (max-width: 760px) {
  #hud-top { display: grid; grid-template-columns: auto auto 1fr; grid-template-areas: "res res res" "ava ap ." "ava sh ."; align-items: center; justify-items: start; gap: 5px 6px; padding: calc(6px + var(--sat)) 6px 0; }
  #hud-top .res { grid-area: res; } #hud-top .ava { grid-area: ava; } #hud-top .apbar { grid-area: ap; } #hud-top .shield { grid-area: sh; padding: 1px 8px; font-size: 12.5px; }
  .ava { padding: 2px 10px 2px 2px; gap: 6px; }
  .ava img { width: 40px; height: 40px; }
  .ainfo b { font-size: 15px; max-width: 120px; }
  .ainfo span { font-size: 13px; }
  .apbar { width: 92px; height: 22px; }
  .res { margin-left: 0; width: 100%; justify-content: space-between; gap: 7px; }
  .rchip { flex: 1 1 auto; min-width: 0; justify-content: center; padding: 4px 4px 4px 25px; border-radius: 16px; }
  .rchip img { width: 31px; height: 31px; left: -5px; }
  .rchip span { font-size: 16px; letter-spacing: -.3px; }
  .rchip.gem em { display: none; }
  #nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px 2px; padding: 0 2px calc(6px + var(--sab)); }
  #nav button { min-width: 0; padding: 0; order: 2; }
  /* длинные подписи не рядом: Карта, Командиры, Рынок, Предметы, Таверна / Альянс, Почта, Задания, Чат, Ещё */
  #nav button:nth-child(1) { order: 0; } #nav button:nth-child(2), #nav button:nth-child(5) { order: 1; }
  .nico { width: 50px; height: 50px; }
  .nico img { width: 36px; height: 36px; }
  #nav button span { font-size: 12.5px; padding: 0 4px; line-height: 18px; }
  #quest-ribbon { font-size: 12.5px; padding: 5px 8px; gap: 6px; flex-wrap: nowrap; }
  #quest-ribbon > span:nth-child(2) { flex: 1 1 0; min-width: 0; }
  #quest-ribbon small { width: auto; padding-left: 0; white-space: nowrap; }
  #nav button .badge { right: calc(50% - 31px); }
  #side { width: 210px; font-size: 12px; }
  body.map #maptools { top: calc(var(--toph) + 6px); left: 6px; right: 6px; max-width: none; }
  body.map #side { top: calc(var(--toph) + var(--mth) + 14px); }
  body.map #minimap { width: 150px; height: 82px; right: 8px; }
  body.map #coords { right: 166px; }
  #zoom .btn { width: 44px; height: 44px; }
  #chat { top: 0; bottom: 0; }
}
@media (max-width: 400px) {
  #nav button span { font-size: 12px; padding: 0 2px; letter-spacing: -.3px; }
  .res { gap: 5px; }
  .rchip { padding: 4px 3px 4px 24px; } .rchip img { left: -6px; }
}
@media (max-width: 350px) {
  .res { gap: 4px; }
  .rchip { padding: 3px 2px 3px 21px; } .rchip img { width: 27px; height: 27px; left: -5px; }
  .rchip span { font-size: 15px; letter-spacing: -.4px; }
  #nav button span { font-size: 12px; padding: 0 1px; letter-spacing: -.4px; }
  .nico { width: 46px; height: 46px; } .nico img { width: 33px; height: 33px; }
  .ainfo b { max-width: 96px; }
}
/* телефон в горизонтальном положении: одна строка кнопок, поменьше по высоте */
@media (max-height: 480px) and (min-width: 600px) {
  #hud-top { display: flex; flex-wrap: nowrap; padding-top: calc(4px + var(--sat)); }
  #nav { display: flex; justify-content: center; gap: 0; padding-bottom: calc(4px + var(--sab)); }
  .nico { width: 44px; height: 44px; } .nico img { width: 32px; height: 32px; }
  #nav button { min-width: 0; flex: 1 1 0; max-width: 84px; }
  #nav button span { font-size: 11.5px; padding: 0 3px; letter-spacing: -.2px; }
  .res { width: auto; margin-left: auto; gap: 8px; }
  .rchip { flex: 0 1 auto; min-width: 0; padding: 3px 6px 3px 26px; }
  .rchip img { width: 31px; height: 31px; left: -5px; }
  .rchip span { font-size: 16px; }
  .rchip.gem em { display: none; }
  .ainfo b { max-width: 100px; }
  .apbar { width: 84px; }
  #side { width: 220px; }
}
.res.tight .rchip span { font-size: 15px; letter-spacing: -.6px; }
@media (max-width: 350px) { .res.tight .rchip span { font-size: 14px; } }
/* игроки в сети */
.onl { display: inline-flex; align-items: center; gap: 6px; background: var(--glass); border: 1px solid rgba(76, 211, 90, .55); border-radius: 14px; padding: 3px 10px 3px 8px; color: #eaffea; font-weight: 800; font-size: 14px; cursor: pointer; box-shadow: 0 2px 8px #0005; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.onl i, .odot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #4cd35a; box-shadow: 0 0 6px #4cd35a; animation: onpulse 1.6s infinite; flex: none; }
.onl small { font-size: 11px; font-weight: 600; color: #bfe8c0; }
.onl.inline { background: none; border: 0; box-shadow: none; padding: 0; color: inherit; text-shadow: none; cursor: default; font-weight: 600; font-size: inherit; }
@keyframes onpulse { 50% { opacity: .45; } }
.olist { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.orow { display: flex; align-items: center; gap: 10px; background: linear-gradient(#fffaf0b8, #fbf2dcb0); border: 1px solid #c9ad74; border-radius: 10px; padding: 6px 10px; }
.orow.me { border-color: #4c9a4c; background: linear-gradient(#f2ffe9, #e3f4d4); }
.orow > img { width: 38px; height: 38px; flex: none; }
.oinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.oinfo b { display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.oinfo small { color: var(--ink2); }
.obtn { display: flex; gap: 4px; flex: none; }
@media (max-width: 760px) {
  #hud-top { grid-template-areas: "res res res" "ava ap on" "ava sh on"; grid-template-columns: auto auto 1fr; }
  #hud-top .onl { grid-area: on; justify-self: end; flex-direction: column; gap: 0; padding: 4px 10px; border-radius: 12px; line-height: 1.1; }
  #hud-top .onl i { position: absolute; margin: -2px 0 0 -14px; }
  #hud-top .onl { position: relative; padding-left: 20px; }
  #hud-top .onl i { left: 22px; top: 50%; margin: -4px 0 0 -14px; }
  .orow { flex-wrap: wrap; } .obtn { width: 100%; justify-content: flex-end; }
}
@media (max-height: 480px) and (min-width: 600px) { #hud-top .onl small { display: none; } }
