:root {
  --bg: #0d1a2b; --panel: #142338; --panel2: #1b2e47; --line: #33496a; --gold: #c9a24a; --gold2: #f0d27a;
  --text: #e9e3d2; --mut: #9fb0c4; --red: #e8112d; --good: #6fcf7f; --bad: #ef6b6b;
  --sans: 'Noto Sans Georgian', system-ui, sans-serif; --serif: 'Noto Serif Georgian', Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
#map { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
#map.dragging { cursor: grabbing; }

/* top bar */
.topbar { position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: linear-gradient(#1a2c45, #101d30); border-bottom: 2px solid #4a3a1a; box-shadow: 0 2px 10px #0008; }
.emblem { width: 30px; height: 30px; padding: 0; border: 2px solid var(--gold); border-radius: 50%; background: none; flex: none; }
.emblem svg { width: 100%; height: 100%; display: block; border-radius: 50%; }
.yields { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.yields::-webkit-scrollbar { display: none; }
.yield { display: flex; align-items: center; gap: 5px; padding: 3px 8px; border: 1px solid transparent; border-radius: 6px; background: none; white-space: nowrap; font-weight: 700; font-size: 13px; }
.yield:hover, .yield:focus-visible { border-color: var(--line); background: #ffffff0d; }
.yield svg { width: 16px; height: 16px; }
.search { position: relative; flex: 0 1 230px; }
.search input { width: 100%; height: 30px; padding: 0 30px 0 12px; border-radius: 15px; border: 1px solid var(--line); background: #0b1626; color: var(--text); font: inherit; }
.search input:focus { outline: 2px solid var(--gold); }
.search kbd { position: absolute; right: 9px; top: 6px; font-size: 11px; color: var(--mut); border: 1px solid var(--line); border-radius: 3px; padding: 0 5px; }
#search-results { position: absolute; top: 34px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; max-height: 60vh; overflow: auto; box-shadow: 0 6px 20px #000a; }
#search-results li { padding: 6px 8px; border-radius: 5px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#search-results li[aria-selected="true"], #search-results li:hover { background: var(--panel2); }
#search-results small { color: var(--mut); }
.tools { display: flex; gap: 6px; }
.tools button { width: 32px; height: 30px; display: grid; place-items: center; border: 1px solid #5d4a22; border-radius: 6px; background: linear-gradient(#2a3a52, #18263a); font-weight: 800; }
.tools button:hover { border-color: var(--gold); }
.tools svg { width: 17px; height: 17px; fill: currentColor; }

/* side panel */
.panel { position: fixed; top: 52px; right: 8px; bottom: 8px; width: min(380px, calc(100vw - 16px)); z-index: 6; overflow: auto; background: linear-gradient(#16273f, #101c2e); border: 1px solid var(--line); border-radius: 10px; box-shadow: -4px 0 24px #000a; }
.panel .head { position: sticky; top: 0; padding: 14px 16px 12px; background: linear-gradient(#1d3050, #16273f); border-bottom: 1px solid var(--line); border-left: 5px solid var(--accent, var(--gold)); }
.panel .kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--mut); }
.panel h2 { margin: 2px 0 4px; font: 800 24px/1.2 var(--serif); color: var(--gold2); }
.panel .close { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: #0b1626; }
.panel .sub { color: var(--mut); font-size: 13px; }
.panel .big { font-size: 18px; font-weight: 700; margin-top: 6px; }
.panel section { padding: 12px 16px; border-bottom: 1px solid #22364f; }
.panel h3 { margin: 0 0 8px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #ffffff14; border: 1px solid var(--line); margin-right: 4px; }
.chip.occ { background: #5a1b1b; border-color: #a33; }
.rows { display: grid; gap: 6px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: baseline; }
.row .v { font-weight: 700; text-align: right; }
.row .cmp { grid-column: 1 / -1; font-size: 12px; color: var(--mut); margin-top: -4px; }
.up { color: var(--good); } .down { color: var(--bad); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.tile { padding: 8px 4px; text-align: center; border-radius: 8px; background: #0b1626; border: 1px solid var(--line); }
.tile b { display: block; font-size: 15px; } .tile small { color: var(--mut); font-size: 11px; }
.btn { display: block; width: 100%; padding: 10px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--gold); background: linear-gradient(#e0b958, #a47c27); color: #1b1305; font-weight: 800; text-align: left; }
.btn.ghost { background: #0b1626; color: var(--text); border-color: var(--line); font-weight: 600; }
.linklist { display: flex; flex-wrap: wrap; gap: 6px; }
.linklist button { padding: 3px 10px; border-radius: 12px; border: 1px solid var(--line); background: #0b1626; font-size: 13px; }
.linklist button:hover { border-color: var(--gold); }
.note { color: var(--mut); font-size: 12px; }
.bar { height: 6px; border-radius: 3px; background: #0b1626; overflow: hidden; margin-top: 2px; }
.bar i { display: block; height: 100%; background: var(--gold); }

/* minimap */
.minimap { position: fixed; left: 8px; bottom: 8px; z-index: 4; width: 230px; height: 140px; border: 2px solid #5d4a22; border-radius: 8px; background: #0a1422; overflow: hidden; box-shadow: 0 4px 16px #000a; }
.minimap canvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }

/* lens bar */
.lensbar { position: fixed; right: 8px; bottom: 8px; z-index: 4; display: flex; gap: 4px; padding: 5px; border-radius: 10px; background: #0e1a2bdd; border: 1px solid #5d4a22; box-shadow: 0 4px 16px #000a; max-width: calc(100vw - 260px); overflow-x: auto; scrollbar-width: none; }
.lensbar button { display: flex; gap: 5px; align-items: center; padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line); background: #15243a; white-space: nowrap; font-size: 13px; }
.lensbar button.gold { border-color: #6d5526; }
.lensbar button.on { background: linear-gradient(#e0b958, #a47c27); color: #1b1305; border-color: var(--gold2); font-weight: 700; }
.lensbar .ic { font-size: 12px; }
.lensmenu { position: fixed; right: 8px; bottom: 56px; z-index: 7; width: min(430px, calc(100vw - 16px)); padding: 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 30px #000c; }
.lensmenu h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: .1em; color: var(--gold); text-transform: uppercase; }
.lensmenu .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.lensmenu button { text-align: left; padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); background: #0b1626; }
.lensmenu button.on { border-color: var(--gold); }
.lensmenu button i { display: block; height: 4px; margin-top: 6px; border-radius: 2px; }

/* legend */
.legend { position: fixed; left: 250px; bottom: 8px; z-index: 4; padding: 8px 12px; border-radius: 8px; background: #0e1a2bdd; border: 1px solid var(--line); min-width: 220px; font-size: 12px; }
.legend b { display: block; margin-bottom: 4px; font-size: 13px; }
.legend .ramp { height: 10px; border-radius: 3px; }
.legend .ends { display: flex; justify-content: space-between; color: var(--mut); margin-top: 2px; }

/* modal */
dialog#modal { width: min(820px, calc(100vw - 24px)); max-height: calc(100vh - 60px); padding: 0; border: 1px solid var(--gold); border-radius: 12px; background: linear-gradient(#17283f, #0f1b2d); color: var(--text); box-shadow: 0 20px 60px #000; }
dialog::backdrop { background: #000a; }
.modal-body { padding: 18px 22px 22px; overflow: auto; max-height: calc(100vh - 62px); }
.modal-body h2 { margin: 0 32px 6px 0; font: 800 26px/1.2 var(--serif); color: var(--gold2); }
.modal-body h3 { color: var(--gold); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; margin: 18px 0 8px; }
.modal-body .x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: #0b1626; }
.modal-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal-body th, .modal-body td { padding: 6px 8px; border-bottom: 1px solid #22364f; text-align: right; }
.modal-body th:first-child, .modal-body td:first-child { text-align: left; }
.modal-body th { color: var(--mut); font-weight: 600; cursor: pointer; user-select: none; position: sticky; top: -18px; background: #17283f; }
.modal-body th.sorted { color: var(--gold2); }
.modal-body tr:hover td { background: #ffffff08; }
.modal-body a { color: var(--gold2); }
.modal-body kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; background: #0b1626; }
.hbar { display: grid; grid-template-columns: 170px 1fr 90px; gap: 8px; align-items: center; margin: 4px 0; font-size: 13px; }
.hbar .track { height: 12px; background: #0b1626; border-radius: 3px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 3px; }
.hbar .n { text-align: right; font-weight: 700; }
.toast { position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 9; padding: 8px 16px; border-radius: 8px; background: var(--gold); color: #1b1305; font-weight: 700; }

@media (max-width: 760px) {
  .search { flex-basis: 40px; } .search kbd { display: none; }
  .search input:not(:focus) { padding: 0; width: 34px; color: transparent; background: #0b1626 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6' fill='none' stroke='%239fb0c4' stroke-width='2'/%3E%3Cpath d='M15 15l5 5' stroke='%239fb0c4' stroke-width='2'/%3E%3C/svg%3E") center/16px no-repeat; }
  .search input:focus { position: fixed; left: 8px; right: 8px; top: 7px; width: auto; z-index: 8; }
  .search input:focus ~ #search-results { position: fixed; left: 8px; right: 8px; top: 42px; }
  .tools button#btn-almanac, .tools button#btn-help { display: none; }
  .minimap { width: 120px; height: 74px; bottom: 60px; }
  .lensbar { left: 8px; right: 8px; max-width: none; }
  .legend { left: 136px; bottom: 60px; min-width: 0; right: 8px; }
  .panel { top: auto; height: 58vh; bottom: 0; right: 0; width: 100vw; border-radius: 12px 12px 0 0; z-index: 8; }
  .hbar { grid-template-columns: 110px 1fr 70px; }
}
