:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --text: #1f2a37;
    --muted: #6b7785;
    --border: #dde3ec;
    --primary: #2563eb;
    --primary-soft: #e0e9ff;
    --success: #16a34a;
    --danger: #dc2626;
    --ocean: #d6ecfa;
    --other-land: #e5e7eb;
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 14px; }

.top {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.top h1 { margin: 0; font-size: 22px; }
.switch { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: 18px; height: 18px; accent-color: var(--primary); }

.layout {
    display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px;
    max-width: 1500px; margin: 0 auto; padding: 20px 24px;
}
@media (max-width: 1000px) {
    .layout { grid-template-columns: 1fr; padding: 16px; }
}

/* ---- карта ---- */
.map-card, .panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}
.map-card { padding: 12px; align-self: start; position: sticky; top: 16px; }
@media (max-width: 1000px) {
    .map-card { position: static; }
    /* На телефоне вопрос — над картой, список стран — под ней. */
    .layout .side { display: contents; }
    #setup, #play, #result { order: -1; }
    .prompt-name { font-size: 22px; }
}
.map-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #f8fbff; }
#map { display: block; width: 100%; height: auto; touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }
.hint { margin: 8px 4px 0; color: var(--muted); font-size: 13px; }

.sphere { fill: var(--ocean); }
.country { stroke: #fff; stroke-width: .6; vector-effect: non-scaling-stroke; transition: fill .15s ease, opacity .2s ease; }
.country.other { fill: var(--other-land); }
.country.active { cursor: pointer; }
/* Вне выбранного материка: серая подложка без номеров. */
.country.off { fill: var(--other-land) !important; pointer-events: none; }
.locked .country.active, .locked .marker { cursor: default; }
.map-wrap:not(.locked) .country.active:hover, .map-wrap:not(.locked) .marker:hover circle { filter: brightness(.88); }
.country.correct, .marker.correct circle { fill: var(--success) !important; }
.country.wrong, .marker.wrong circle { fill: var(--danger) !important; }
.country.picked, .marker.picked circle { fill: var(--primary) !important; }
.country.target, .marker.target circle {
    stroke: #0f172a; stroke-width: 2.5; animation: pulse 1s ease-in-out infinite alternate;
}
@keyframes pulse { from { stroke-opacity: 1; } to { stroke-opacity: .25; } }

.marker circle { stroke: #fff; vector-effect: non-scaling-stroke; stroke-width: 1.2; cursor: pointer; }
.marker.off { display: none; }
.num-label, .marker text {
    fill: #1f2a37; font-weight: 700; text-anchor: middle; dominant-baseline: central;
    font-size: 20px; stroke-width: 5.5px;
    pointer-events: none; paint-order: stroke; stroke: rgba(255, 255, 255, .85); stroke-linejoin: round;
}
.marker text { stroke: none; }
.no-numbers .num-label, .no-numbers .marker text { display: none; }
.num-label.off { display: none; }
.correct-label { fill: #fff !important; stroke: none !important; }

.zoom-btns { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 6px; }
.zoom-btns button {
    width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); font-size: 20px; line-height: 1; cursor: pointer; color: var(--text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .1);
}
.zoom-btns button:hover { background: var(--primary-soft); }
.map-msg {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 20px; background: rgba(248, 251, 255, .9); font-weight: 600;
}
.map-msg.error { color: var(--danger); }
.tooltip {
    position: absolute; pointer-events: none; background: #0f172a; color: #fff;
    padding: 4px 9px; border-radius: 6px; font-size: 13px; white-space: nowrap; transform: translate(-50%, -130%);
}

/* ---- боковая панель ---- */
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { padding: 18px; }
.panel h2 { margin: 0 0 14px; font-size: 18px; }
.panel h3 { margin: 16px 0 8px; font-size: 15px; }
.field { margin-bottom: 14px; }
.label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px;
}
.chips button:hover { border-color: var(--primary); }
.chips button.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.btn {
    border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 600;
    cursor: pointer;
}
.btn.wide { width: 100%; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled { opacity: .55; cursor: default; filter: none; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover { border-color: var(--primary); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.row .btn { flex: 1; }
#nextLevelBtn { flex-basis: 100%; }

.play-top { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.bar { height: 6px; background: var(--primary-soft); border-radius: 99px; margin: 8px 0 16px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--primary); transition: width .3s ease; }
.prompt { text-align: center; margin-bottom: 14px; }
.prompt-label { display: block; color: var(--muted); font-size: 14px; }
.prompt-name { display: block; font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.prompt-sub { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.choices:empty { display: none; }
.choices button {
    border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 10px 8px;
    font: inherit; font-weight: 600; cursor: pointer;
}
.choices button:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-soft); }
.choices button.correct { background: var(--success); border-color: var(--success); color: #fff; }
.choices button.wrong { background: var(--danger); border-color: var(--danger); color: #fff; }
.feedback { min-height: 24px; text-align: center; font-weight: 600; margin-bottom: 12px; }
.feedback.ok { color: var(--success); }
.feedback.bad { color: var(--danger); }
.feedback.info { color: var(--text); font-weight: 400; }

.final { text-align: center; }
.final-score { font-size: 40px; font-weight: 800; color: var(--primary); }
.best { margin-top: 6px; font-size: 14px; font-weight: 600; }
.missed { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.missed li { background: #fde8e8; color: #991b1b; border-radius: 8px; padding: 4px 10px; font-size: 14px; }

#listSearch {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; font: inherit; margin-bottom: 10px;
}
#listSearch:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.country-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.country-list li {
    display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.country-list li:hover { background: var(--primary-soft); }
.country-list .num {
    flex: 0 0 auto; min-width: 34px; text-align: center; font-weight: 700; font-size: 13px;
    border-radius: 6px; padding: 2px 4px; color: #1f2a37;
}
.country-list .cap { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---- уровни ---- */
.levels-note { margin: -6px 0 10px; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.level {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
    border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 12px;
    font: inherit; color: var(--text); cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.level:hover { border-color: var(--primary); background: var(--primary-soft); }
.level.done { border-color: #bbd3ff; }
.level-n { font-size: 12px; font-weight: 600; color: var(--muted); }
.level-name { font-weight: 700; line-height: 1.25; }
.level-meta { font-size: 12px; color: var(--muted); }
.level-stars, .final-stars { color: #f59e0b; letter-spacing: 2px; }
.final-stars { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.free-title { padding-top: 16px; border-top: 1px solid var(--border); }
