/* Atlas Evropy – same palette and lettering rules as the game */
:root {
  --paper: #f4f7f9;
  --sea: #d3e5ef;
  --land: #ffffff;
  --ink: #14212d;
  --ink-2: #4d5f6f;
  --ink-3: #8a9aa8;
  --rule: #d6e1e9;
  --prussian: #1d4b84;
  --coast: #3f5d7a;

  --c-more: #5aa9d6;
  --c-reky: #1d4b84;
  --c-ostrovy: #2f9e93;
  --c-poloostrovy: #7484d4;
  --c-niziny: #7dbea3;
  --c-pohori: #56627e;

  --display: 'Sofia Sans Extra Condensed', 'Arial Narrow', sans-serif;
  --ui: 'Sofia Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  background: var(--paper); color: var(--ink);
  font: 500 16px/1.4 var(--ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--prussian); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.w { font-style: italic; color: var(--prussian); }
.l { text-transform: uppercase; letter-spacing: .12em; font-size: .82em; }

.shell { height: 100%; display: grid; grid-template-columns: 340px 1fr; }

/* ---------- panel ---------- */
.panel {
  height: 100%; overflow-y: auto; background: var(--paper); border-right: 1px solid var(--rule);
  padding: 22px 22px 40px; scrollbar-width: thin;
}
.head { display: flex; justify-content: space-between; align-items: flex-start; }
.cartouche {
  display: inline-block; background: #fff; padding: 13px 18px 11px;
  border: 1px solid var(--ink); box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px var(--ink);
}
.cartouche h1 { margin: 0 -.3em 0 0; font: 800 40px/.9 var(--display); letter-spacing: .3em; text-transform: uppercase; }
.cartouche p { margin: 6px 0 0; font: italic 600 16px/1.2 var(--ui); color: var(--prussian); }

.eyebrow {
  font: 700 12px/1 var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3);
  margin: 28px 0 8px; display: flex; align-items: baseline; gap: 10px;
}
.eyebrow::after { content: ''; flex: 1; height: 1px; background: var(--rule); transform: translateY(-4px); order: 1; }
.eb-act, .eb-count { order: 2; letter-spacing: .04em; text-transform: none; font-size: 13px; color: var(--ink-3); }
.linkish { color: var(--ink-2); font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.linkish:hover { color: var(--ink); text-decoration-color: currentColor; }

.legend, .toggles { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.legend li, .toggles li { border-bottom: 1px solid var(--rule); }
.leg { width: 100%; display: grid; grid-template-columns: 20px 34px 1fr auto; align-items: center; gap: 12px; padding: 10px 2px; text-align: left; }
.toggles .leg { grid-template-columns: 20px 1fr; }
.chk { width: 20px; height: 20px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--ink-3); display: grid; place-items: center; transition: background-color .15s; }
.chk::after { content: ''; width: 10px; height: 5px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); opacity: 0; }
.leg.on .chk { background: var(--prussian); box-shadow: none; }
.leg.on .chk::after { opacity: 1; }
.leg .nm, .leg .sw { transition: opacity .15s; }
.leg:not(.on) .nm, .leg:not(.on) .sw { opacity: .4; }
.leg .nm { font-weight: 600; }
.leg .ct { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.leg:hover .nm { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }

.sw { --c: var(--ink-3); width: 34px; height: 20px; border-radius: 3px; display: block; flex: none; }
.sw.area { background: color-mix(in srgb, var(--c) 38%, #fff); box-shadow: inset 0 0 0 1.5px var(--c); }
.sw.hatch { background: repeating-linear-gradient(45deg, var(--c) 0 1.5px, #fff 1.5px 5px); box-shadow: inset 0 0 0 1.5px var(--c); }
.sw.sea { background: color-mix(in srgb, var(--c) 45%, #fff); }
.sw.line { background: linear-gradient(var(--c), var(--c)) center / 100% 3px no-repeat; border-radius: 0; }

.search {
  width: 100%; height: 42px; padding: 0 12px; border-radius: var(--r); border: 0; outline: none;
  background: #fff; box-shadow: inset 0 0 0 1.5px var(--rule); font-weight: 600;
}
.search:focus { box-shadow: inset 0 0 0 1.5px var(--prussian); }
.search::placeholder { color: var(--ink-3); font-weight: 500; }

.group h3 { margin: 18px 0 4px; font: 700 13px/1.2 var(--ui); color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.group h3 .sw { width: 18px; height: 10px; }
.group ul { list-style: none; margin: 0; padding: 0; }
.place {
  width: 100%; text-align: left; padding: 6px 8px; margin: 0 -8px; border-radius: 6px; display: block;
  font-weight: 600; font-size: 15px; width: calc(100% + 16px);
}
.place.l { font-size: 12.5px; font-weight: 700; padding-top: 8px; padding-bottom: 8px; }
.place:hover, .place.hot { background: #fff; box-shadow: inset 0 0 0 1px var(--rule); }
.place.sel { background: var(--prussian); color: #fff; box-shadow: none; }
.empty { color: var(--ink-3); padding: 14px 0; font-size: 15px; }

/* ---------- map ---------- */
.stage { position: relative; height: 100%; overflow: hidden; background: var(--sea); }
.map-host, .map-host svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.map-host svg { touch-action: none; cursor: grab; }
.map-host svg.dragging { cursor: grabbing; }

.m-paper { fill: var(--paper); pointer-events: none; }
.m-frame { fill: none; stroke: var(--coast); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.m-land { fill: var(--land); stroke: var(--coast); stroke-width: .7; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.m-border { fill: none; stroke: #c3d2de; stroke-width: .7; vector-effect: non-scaling-stroke; stroke-dasharray: 3 2; pointer-events: none; }
.m-river { fill: none; stroke: #8fb6d6; stroke-width: .8; vector-effect: non-scaling-stroke; stroke-linecap: round; pointer-events: none; }
.m-lake { fill: var(--sea); stroke: #8fb6d6; stroke-width: .6; vector-effect: non-scaling-stroke; pointer-events: none; }
.g-grat path { fill: none; stroke: #b9cfdd; stroke-width: .6; vector-effect: non-scaling-stroke; pointer-events: none; }

.f { cursor: pointer; transition: opacity .2s, fill-opacity .15s; }
.f.area { fill: var(--c); fill-opacity: .26; stroke: var(--c); stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.f.area.cat-pohori { fill: url(#hatch); fill-opacity: .85; }
.f.line { fill: none; stroke: var(--c); stroke-width: 2.6; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.f.line.hit { stroke: transparent; stroke-width: 18; }
.f.hot.area { fill-opacity: .5; stroke-width: 2.2; }
.f.hot.area.cat-pohori { fill-opacity: 1; }
.f.hot.line:not(.hit) { stroke-width: 4.5; }
.f.sel.area { fill-opacity: .55; stroke-width: 2.6; }
.f.sel.area.cat-pohori { fill-opacity: 1; }
.f.sel.line:not(.hit) { stroke-width: 5; }
.has-sel .f:not(.sel) { opacity: .35; }

.lbl {
  font-family: var(--ui); font-weight: 700; paint-order: stroke; stroke: #fff; stroke-linejoin: round;
  fill: var(--ink); text-anchor: middle; dominant-baseline: middle; pointer-events: none; transition: opacity .15s;
}
.lbl.w { font-style: italic; fill: var(--prussian); }
.lbl.l { text-transform: uppercase; letter-spacing: .12em; }
.lbl.off { opacity: 0; }
.lbl.sel { font-weight: 800; }
.has-sel .lbl:not(.sel) { opacity: .25; }
.has-sel .lbl.off:not(.sel) { opacity: 0; }

.zoom { position: absolute; z-index: 5; right: 14px; top: 14px; display: flex; flex-direction: column; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--r); background: #fff; display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--rule); font-size: 20px; color: var(--ink); flex: none;
}
.icon-btn:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }

.info {
  position: absolute; z-index: 6; left: 14px; top: 14px; max-width: min(360px, calc(100% - 90px));
  background: #fff; border-radius: var(--r); box-shadow: inset 0 0 0 1px var(--rule), 0 8px 24px -12px rgba(20, 33, 45, .3);
  padding: 12px 12px 12px 16px; display: flex; gap: 14px; align-items: center;
}
.info .t small { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; font-weight: 700; }
.info .t small .sw { width: 18px; height: 10px; }
.info .t div { font: 800 26px/1.05 var(--display); letter-spacing: .02em; margin-top: 3px; }
.info .t div.w { font-family: var(--ui); font-size: 21px; font-weight: 700; }
.info .t div.l { font-size: 22px; letter-spacing: .14em; }
.info .x { width: 34px; height: 34px; font-size: 18px; margin-left: auto; }

.tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: #fff;
  font-weight: 600; font-size: 14px; padding: 5px 9px; border-radius: 6px; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 16px; border-radius: var(--r);
  background: #fff; box-shadow: inset 0 0 0 1px var(--rule); font-weight: 700; font-size: 15px;
}
.chips { position: absolute; z-index: 5; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip {
  height: 36px; padding: 0 12px; border-radius: 8px; background: #fff; box-shadow: inset 0 0 0 1px var(--rule);
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; flex: none;
}
.chip .sw { width: 16px; height: 9px; }
.chip:not(.on) { color: var(--ink-3); }
.chip:not(.on) .sw { opacity: .4; }
.chip.on { box-shadow: inset 0 0 0 1.5px var(--ink); }

.only-mobile { display: none; }

@media (max-width: 760px) {
  .shell { display: block; }
  .stage { position: fixed; inset: 0; }
  .only-mobile { display: revert; }
  .icon-btn.only-mobile { display: grid; }
  .chips.only-mobile { display: flex; }
  .open-panel { position: absolute; z-index: 5; left: 12px; top: calc(12px + env(safe-area-inset-top)); }
  .zoom { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
  .zoom .icon-btn { width: 40px; height: 40px; }
  .info { top: auto; left: 12px; right: 12px; max-width: none; bottom: calc(58px + env(safe-area-inset-bottom)); }
  .panel {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: auto; max-height: 82%;
    border-right: 0; border-top: 1px solid var(--rule); border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px -16px rgba(20, 33, 45, .35);
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
  .panel.open { transform: none; }
  .cartouche h1 { font-size: 32px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
