:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1d2433; --mute: #667085; --line: #e2ded6;
  --accent: #1f6feb; --ok: #1a8f4c; --mid: #c77700; --bad: #d1343b;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: 8px 14px; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.ghost { background: transparent; }
button.small { font-size: 13px; padding: 5px 10px; color: var(--mute); }

.top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 18px; margin: 0; }
.top h1 span { color: var(--mute); font-weight: 500; }
.modes { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.modes button { border: 0; border-radius: 0; padding: 6px 14px; font-size: 14px; }
.modes button.on { background: var(--ink); color: #fff; }
.progress { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--mute); }
.bar { width: 140px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .3s; }

main { max-width: 1500px; margin: 0 auto; padding: 12px 16px 24px; }
.task { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--accent);
  border-radius: 10px; padding: 10px 14px; min-height: 62px; margin-bottom: 12px; }
.task[data-v="ok"] { border-left-color: var(--ok); }
.task[data-v="mid"] { border-left-color: var(--mid); }
.task[data-v="bad"], .task[data-v="skip"] { border-left-color: var(--bad); }
.ask { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lead { color: var(--mute); font-size: 14px; }
#term { font-size: 24px; line-height: 1.15; }
.kind { font-size: 13px; color: var(--mute); border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; }
.kind:empty { display: none; }
.fb { flex: 1 1 220px; font-size: 15px; }
.fb b { font-weight: 700; }
.task[data-v="ok"] .fb b { color: var(--ok); }
.task[data-v="mid"] .fb b { color: var(--mid); }
.task[data-v="bad"] .fb b, .task[data-v="skip"] .fb b { color: var(--bad); }
.fb small { display: block; color: var(--mute); font-size: 13px; }
.btns { display: flex; gap: 8px; margin-left: auto; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 14px; align-items: start; }
.mapwrap { position: relative; width: 100%; max-width: max(320px, calc((100dvh - 170px) * 1.39)); margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  line-height: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.mapwrap img { width: 100%; height: auto; display: block; pointer-events: none; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pinch-zoom; cursor: crosshair; }
body.browse #overlay, body.full #overlay, body.race .panel:not([hidden]) ~ #overlay, .task[data-v] ~ .layout #overlay { cursor: default; }

.ans-area { fill: rgba(31,111,235,.30); stroke: #1552b8; stroke-width: 2; stroke-linejoin: round; }
.ans-halo { fill: none; stroke: #fff; stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.ans-line { fill: none; stroke: #1f6feb; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.ans-dot { fill: #1f6feb; stroke: #fff; stroke-width: 2.5; }
.ans-ring { fill: none; stroke: #1f6feb; stroke-width: 2.5; transform-box: fill-box; transform-origin: center; animation: ring 1.4s ease-out infinite; }
@keyframes ring { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.ans-label { font: 700 19px system-ui, sans-serif; fill: #0d2c66; stroke: #fff; stroke-width: 5; paint-order: stroke;
  stroke-linejoin: round; text-anchor: middle; pointer-events: none; }
#answer > g { animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; } to { opacity: 1; } }
.user { fill: rgba(120,120,120,.12); stroke: #555; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.user.ok { fill: rgba(26,143,76,.14); stroke: var(--ok); stroke-dasharray: 7 5; }
.user.mid { fill: rgba(199,119,0,.14); stroke: var(--mid); stroke-dasharray: 7 5; }
.user.bad { fill: rgba(209,52,59,.12); stroke: var(--bad); stroke-dasharray: 7 5; }

.side h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin: 4px 0 8px; }
.cats { display: flex; flex-direction: column; gap: 6px; }
.cats label { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; cursor: pointer; font-size: 15px; }
.cats label span { margin-left: auto; color: var(--mute); font-size: 13px; font-variant-numeric: tabular-nums; }
.hint { color: var(--mute); font-size: 13.5px; }
.list { margin-top: 12px; max-height: 60vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.list h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--mute); margin: 8px 6px 4px; }
.list button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; border: 0; padding: 5px 6px; font-size: 14.5px; border-radius: 6px; }
.list button:hover { background: var(--bg); }
.list button.on { background: #e3edff; font-weight: 600; }
.list button i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); flex: none; }
.list button i.b1 { background: var(--bad); } .list button i.b2 { background: var(--mid); } .list button i.b3 { background: var(--ok); }
.list button small { margin-left: auto; color: var(--mute); font-weight: 400; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .cats { flex-direction: row; flex-wrap: wrap; }
  .cats label { flex: 1 1 140px; }
  main { padding: 8px; }
  #term { font-size: 20px; }
  .bar { width: 80px; }
  .btns { margin-left: 0; }
}

/* ----- režim Celá mapa ----- */
#full .f path, #full .f circle { transition: fill-opacity .12s, stroke-width .12s; }
#full .area { stroke-width: 1.2; stroke-linejoin: round; fill-opacity: .16; }
#full .k-water .area { fill: #2b7fd6; stroke: #2b7fd6; }
#full .k-mount .area { fill: #9a5b2b; stroke: #9a5b2b; }
#full .k-low .area { fill: #3d9a48; stroke: #3d9a48; }
#full .k-other .area { fill: #c98a12; stroke: #c98a12; }
#full .k-isle .area { fill: #8b4fc7; stroke: #8b4fc7; }
#full .line { fill: none; stroke: #1f6feb; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
#full .hit { fill: none; stroke: transparent; stroke-width: 16; stroke-linecap: round; pointer-events: stroke; }
#full .dot { stroke: #fff; stroke-width: 2; fill: #d1343b; }
#full .k-spot .dot { fill: #1d2433; }
#full circle.hit { fill: transparent; stroke: none; pointer-events: fill; }
#full .hl .area { fill-opacity: .5; stroke-width: 2.5; }
#full .hl .line { stroke-width: 6.5; stroke: #0b3fa8; }
#full .hl .dot { stroke: #1d2433; stroke-width: 3; }
.tip { position: absolute; z-index: 3; pointer-events: none; background: #1d2433; color: #fff; border-radius: 8px;
  padding: 6px 10px; font-size: 14px; line-height: 1.35; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.tip b { font-size: 15.5px; }
.tip span { opacity: .7; font-size: 12.5px; margin-left: 6px; }
.tip div + div { opacity: .85; font-size: 13px; }

/* ----- závod ----- */
.modes .race-tab { background: #fff4d6; font-weight: 600; }
.modes .race-tab.on { background: #d97706; color: #fff; }
body.race .task { border-left-color: #d97706; }
body.race .task[data-v="ok"] { border-left-color: var(--ok); }
body.race .task[data-v="bad"] { border-left-color: var(--bad); }
.racebox { display: flex; align-items: baseline; gap: 14px; font-variant-numeric: tabular-nums; font-weight: 700; }
#streak { font-size: 20px; background: var(--ink); color: #fff; border-radius: 8px; padding: 2px 10px; }
#timer { font-size: 22px; min-width: 4.6em; }
#board { display: none; }
body.race #board { display: block; }
body.race .side > :not(#board) { display: none; }
#board-list { list-style: none; margin: 0; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  max-height: 62vh; overflow: auto; }
#board-list:empty { display: none; }
#board-list li { display: flex; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 6px; font-size: 15px; }
#board-list li + li { border-top: 1px solid var(--bg); }
#board-list .rk { width: 1.9em; color: var(--mute); font-variant-numeric: tabular-nums; text-align: right; flex: none; }
#board-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board-list .tm { font-variant-numeric: tabular-nums; font-weight: 600; }
#board-list li.me { background: #fff4d6; font-weight: 700; }
#board-list li:nth-child(1) .rk, #board-list li:nth-child(2) .rk, #board-list li:nth-child(3) .rk { color: #d97706; font-weight: 700; }
.panel { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 12px; line-height: 1.4;
  background: rgba(244,242,238,.8); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.panel .card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px; box-shadow: 0 10px 40px rgba(0,0,0,.18); text-align: center; }
.panel h2 { margin: 0 0 6px; font-size: 24px; }
.panel p { margin: 6px 0; color: var(--mute); font-size: 15px; }
.panel p strong { color: var(--ink); }
.panel .big { font-size: 46px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); margin: 4px 0; line-height: 1.1; }
.panel form { display: flex; gap: 8px; margin-top: 14px; }
.panel input { flex: 1; min-width: 0; font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; }
.panel input:focus { outline: 2px solid #d97706; outline-offset: 1px; }
.panel .go { background: #d97706; border-color: #d97706; color: #fff; font-weight: 700; padding: 9px 18px; }
.panel .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.panel .status { min-height: 1.5em; color: var(--ink); }
@media (max-width: 560px) {
  .panel .card { padding: 12px 14px; }
  .panel h2 { font-size: 19px; } .panel p { font-size: 13px; margin: 3px 0; } .panel .big { font-size: 32px; }
  .panel form, .panel .row { margin-top: 8px; }
}
