/* TERRA INCOGNITA — стили. Тёмный научно-картографический интерфейс. */
:root {
  --bg: #08131f;
  --bg2: #0b1a2b;
  --panel: #0f2133;
  --panel2: #142a40;
  --line: #27465f;
  --text: #e8f1f5;
  --muted: #a3b9c7;
  --teal: #4fc3c0;
  --teal-d: #1f7f7d;
  --teal-l: #8fe3de;
  --ok: #6fd9a6;
  --bad: #f09a8f;
  --focus: #ffffff;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 16px; line-height: 1.5; overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 .8em; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: #fff; color: #000; padding: 8px 12px; z-index: 1000; border-radius: 6px; }
.skip-link:focus { left: 8px; }
.noscript, .boot-error { margin: 16px; padding: 16px; border: 1px solid var(--bad); border-radius: var(--radius); background: var(--panel); }
.boot-error pre { white-space: pre-wrap; font-size: 13px; color: var(--muted); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Кнопки ---------- */
.btn {
  font: inherit; font-weight: 600; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 18px; min-height: 44px;
  cursor: pointer; transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { border-color: var(--teal); background: #183450; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: #04202a; border-color: var(--teal); }
.btn-primary:hover:not(:disabled) { background: var(--teal-l); border-color: var(--teal-l); }
.btn-ghost { background: transparent; }
.btn-danger { background: #5a2a2e; border-color: #a35b61; }
.btn-danger:hover:not(:disabled) { background: #74343a; border-color: var(--bad); }
.btn-big { min-height: 56px; font-size: 18px; padding: 12px 28px; }
.btn-wide { width: 100%; }

/* ---------- Стартовый экран ---------- */
.start {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; gap: 48px; padding: 32px 24px;
  background: radial-gradient(1000px 600px at 70% 20%, #11304a 0%, transparent 60%), var(--bg);
}
.start-card { max-width: 620px; }
.eyebrow { text-transform: uppercase; letter-spacing: .18em; color: var(--teal); font-size: 14px; margin-bottom: .6em; }
.start h1 { font-size: clamp(34px, 7vw, 64px); letter-spacing: .08em; margin-bottom: .3em; }
.lead { font-size: 19px; color: #cfe0e8; }
.continue-info { color: var(--teal-l); border-left: 3px solid var(--teal); padding-left: 12px; }
.start-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 24px 0 18px; }
.start-foot { color: var(--muted); font-size: 14px; }
.start-globe { width: min(300px, 34vw); height: auto; flex: none; }
.g-sphere { fill: #0d2b46; stroke: var(--teal); stroke-width: 2; }
.g-line { fill: none; stroke: #2f6f86; stroke-width: 1; }
.g-land { fill: #7fd6d0; opacity: .85; }
@media (max-width: 820px) { .start { flex-direction: column-reverse; gap: 20px; } .start-globe { width: 140px; } .lead { font-size: 17px; } }

/* ---------- Игровой экран ---------- */
.game { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 10px 18px;
  background: var(--bg2); border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.1; }
.logo { font-weight: 800; letter-spacing: .14em; font-size: 18px; }
.planet { color: var(--teal); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.topbar-progress { flex: 1 1 220px; min-width: 180px; }
.progress-label { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.progress-label strong { color: var(--text); }
.bar { height: 10px; background: #0b1624; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: repeating-linear-gradient(45deg, var(--teal) 0 8px, var(--teal-d) 8px 16px); transition: width .5s; }
.topbar-points { font-size: 15px; color: var(--muted); white-space: nowrap; }
.topbar-points strong { font-size: 24px; color: var(--teal-l); }
.topbar-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.layout {
  flex: 1; display: grid; gap: 14px; padding: 14px; align-items: start;
  grid-template-columns: 270px minmax(0, 1fr) 330px;
  grid-template-areas: "left map right";
}
.map-wrap { grid-area: map; min-width: 0; outline: none; }
.panel-left { grid-area: left; }
.panel-right { grid-area: right; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  max-height: calc(100vh - 100px); overflow-y: auto; position: sticky; top: 14px;
}
.panel h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; color: var(--teal); margin-top: 1.1em; }
.panel section:first-child h2, .panel #sector-body > h2:first-child { margin-top: 0; }
.panel-right h2#sector-title { font-size: 22px; text-transform: none; letter-spacing: 0; color: var(--text); }
.panel h3 { font-size: 15px; color: var(--teal-l); margin: 1.2em 0 .4em; }
.placeholder { color: var(--muted); }
.note { color: var(--muted); font-size: 14px; }

.stats { margin: 0 0 8px; display: grid; gap: 6px; }
.stat { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.stat dt { color: var(--muted); } .stat dd { margin: 0; font-weight: 700; }
.journal-list, .ach-list, .events { list-style: none; padding: 0; margin: 0 0 10px; }
.journal-list li, .events li { font-size: 14px; padding: 6px 0 6px 12px; border-left: 3px solid var(--line); margin-bottom: 6px; }
.j-new, .j-discovery { border-left-color: var(--teal) !important; }
.j-achievement { border-left-color: var(--teal-l) !important; }
.ach { display: flex; gap: 8px; font-size: 14px; margin-bottom: 8px; color: var(--muted); }
.ach-got { color: var(--text); } .ach-got .ach-mark { color: var(--teal-l); }
.ach-desc { color: var(--muted); }

.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 12px; border: 2px solid var(--line); border-radius: 999px; font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.status-glyph { display: inline-block; min-width: 1em; text-align: center; }
.status-discovered { border-style: dashed; border-color: var(--teal); }
.status-exploring { border-color: var(--teal-l); }
.status-explored { border-color: var(--teal-l); background: #123a44; }
.status-full { border-color: #fff; background: #1b4a5a; }
.sector-desc { color: #d3e2ea; }
.sector-progress { font-size: 14px; color: var(--muted); }
.task-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.task-btn {
  width: 100%; display: flex; gap: 10px; align-items: center; text-align: left; font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; min-height: 52px; cursor: pointer;
}
.task-btn:hover:not(:disabled) { border-color: var(--teal); }
.task-btn.done { border-color: var(--teal-d); }
.task-btn.locked { opacity: .6; cursor: not-allowed; }
.task-state { width: 1.6em; text-align: center; color: var(--teal-l); flex: none; }
.task-name { display: flex; flex-direction: column; }
.task-sub { font-size: 13px; color: var(--muted); }
.discovery { background: var(--panel2); border-left: 3px solid var(--teal); border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
.discovery p { margin: 4px 0 0; font-size: 14px; color: #d3e2ea; }
.sector-geo { font-style: italic; color: #d3e2ea; }

/* ---------- Карта ---------- */
.map { background: #071626; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
.planet-map { display: block; width: 100%; height: auto; max-height: calc(100vh - 150px); min-width: 600px; }
.graticule line { stroke: #12304a; stroke-width: 1; }
.map-caption { fill: #5f8197; font-size: 14px; letter-spacing: .06em; }
.ocean-label { fill: #3b6784; font-size: 18px; letter-spacing: .6em; text-anchor: middle; }
.compass circle { fill: none; stroke: #3b6784; stroke-width: 1.5; }
.compass-needle { fill: #4fc3c0; opacity: .8; }
.compass text { fill: #a3b9c7; font-size: 15px; font-weight: 700; }
.sector { cursor: pointer; outline: none; }
.sector-shape { stroke-linejoin: round; transition: stroke .2s, fill .3s; }
.sector[data-status="hidden"] { cursor: default; }
.sector[data-status="hidden"] .sector-shape { fill: url(#pat-fog); stroke: #1c3249; stroke-width: 1.5; opacity: .75; }
.sector[data-status="discovered"] .sector-shape { fill: url(#pat-hatch); stroke: var(--teal); stroke-width: 3; stroke-dasharray: 10 6; }
.sector[data-status="exploring"] .sector-shape { fill: url(#pat-dots); stroke: var(--teal-l); stroke-width: 4; }
.sector[data-status="explored"] .sector-shape, .sector[data-status="full"] .sector-shape { fill: var(--tint, #b8d4b0); stroke: #e8f1f5; stroke-width: 2.5; }
.sector[data-status="full"] .sector-shape { stroke: #fff; stroke-width: 6; paint-order: stroke; }
.sector[data-type="coastal_plain"] { --tint: #b8d4b0; } .sector[data-type="mountains"] { --tint: #c7bcae; }
.sector[data-type="rain_shadow_plain"] { --tint: #dccf9f; } .sector[data-type="river_valley"] { --tint: #a9d0c4; }
.sector[data-type="basin"] { --tint: #b9c4d6; } .sector[data-type="forest"] { --tint: #8fbf8a; }
.sector[data-type="volcanic"] { --tint: #cf9f8a; } .sector[data-type="island"] { --tint: #b0d2cf; }
.sector[data-type="polar"] { --tint: #e3eef5; } .sector[data-type="desert"] { --tint: #e0c99b; }
.sector[data-type="delta"] { --tint: #a6d1b9; } .sector[data-type="ocean_current"] { --tint: #9ec9e0; }
.sector[data-status]:not([data-status="hidden"]):hover .sector-shape { stroke: #fff; }
.sector.active .sector-shape { stroke: #fff; stroke-width: 6; stroke-dasharray: none; filter: drop-shadow(0 0 10px rgba(79, 195, 192, .9)); }
.sector:focus-visible .sector-shape { stroke: #fff; stroke-width: 7; stroke-dasharray: 3 3; }
.badge circle { fill: #08131f; stroke: #e8f1f5; stroke-width: 2; }
.badge[data-status="hidden"] circle { stroke: #3b6784; }
.badge[data-status="discovered"] circle { stroke: var(--teal); stroke-dasharray: 4 3; }
.badge[data-status="full"] circle { stroke-width: 4; }
.badge-glyph { fill: #e8f1f5; font-size: 22px; font-weight: 800; }
.badge[data-status="hidden"] .badge-glyph { fill: #4a6a82; }
.sector-name { font-size: 19px; font-weight: 700; fill: #fff; stroke: #06101b; stroke-width: 5; paint-order: stroke; stroke-linejoin: round; pointer-events: none; }
.route { stroke: var(--teal); stroke-width: 2.5; stroke-dasharray: 3 8; stroke-linecap: round; opacity: .7; pointer-events: none; }
.route-open { stroke-dasharray: none; opacity: .9; }
.route-new { animation: dash 1.4s ease-out 1; }
.labels { pointer-events: none; }
.sector.reveal { animation: reveal 1.1s ease-out 1; }
@keyframes reveal { 0% { opacity: 0; filter: brightness(2.4); } 100% { opacity: 1; filter: none; } }
@keyframes dash { from { stroke-dashoffset: 120; opacity: 0; } to { stroke-dashoffset: 0; opacity: .9; } }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 10px 2px 0; margin: 0; font-size: 14px; color: var(--muted); }
.lg { display: inline-block; width: 24px; height: 24px; line-height: 20px; text-align: center; border-radius: 6px; border: 2px solid var(--line); font-weight: 800; color: var(--text); background: var(--bg2); margin-right: 4px; }
.lg-hidden { border-color: #3b6784; color: #4a6a82; } .lg-discovered { border: 2px dashed var(--teal); }
.lg-exploring { border-color: var(--teal-l); background: #1b4a63; } .lg-explored { background: #b8d4b0; color: #06101b; border-color: #e8f1f5; }
.lg-full { background: #e3eef5; color: #06101b; border: 3px solid #fff; line-height: 17px; }

/* ---------- Окна ---------- */
.overlay { position: fixed; inset: 0; z-index: 500; background: rgba(3, 9, 16, .78); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s ease-out; }
.modal { background: var(--panel); border: 1px solid var(--teal-d); border-radius: 14px; width: min(760px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); outline: none; }
.modal-small { width: min(520px, 100%); } .modal-wide { width: min(820px, 100%); } .modal-task { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-close { padding: 6px 12px; min-height: 40px; flex: none; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-text { font-size: 17px; }
.intro p { font-size: 17px; }
.settings h3 { margin-top: 1.2em; }
.settings-actions { display: flex; flex-direction: column; gap: 10px; }
.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 17px; cursor: pointer; }
.switch input { width: 24px; height: 24px; accent-color: var(--teal); flex: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Задание ---------- */
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag { font-size: 13px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.tag-type { color: var(--teal-l); border-color: var(--teal-d); }
.task-title { font-size: 24px; }
.task-situation { color: #d3e2ea; font-size: 17px; }
.task-figure { margin: 10px 0; }
.diagram { display: block; width: 100%; max-width: 640px; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 8px; background: #0d2b46; }
.task-question { font-size: 19px; font-weight: 700; margin: 14px 0 10px; }
.options { border: 0; padding: 0; margin: 0; display: grid; gap: 10px; }
.option { position: relative; display: flex; gap: 12px; align-items: center; padding: 12px 14px; min-height: 56px; background: var(--panel2); border: 2px solid var(--line); border-radius: var(--radius); cursor: pointer; font-size: 17px; }
.option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.option:hover { border-color: var(--teal); }
.option-mark { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
.option:has(input:checked) { border-color: var(--teal-l); background: #17405a; }
.option:has(input:checked) .option-mark { background: var(--teal); color: #04202a; border-color: var(--teal); }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.option input:focus-visible ~ .option-mark { outline: 3px solid var(--focus); outline-offset: 2px; }
.option.is-correct { border-color: var(--ok); background: #123e33; }
.option.is-correct::after { content: "✓ верно"; margin-left: auto; color: var(--ok); font-weight: 700; font-size: 14px; }
.option.is-wrong { border-color: var(--bad); background: #4a2a2e; }
.option.is-wrong::after { content: "✕ неверно"; margin-left: auto; color: var(--bad); font-weight: 700; font-size: 14px; }
.option.is-right-answer { border: 2px dashed var(--ok); }
.option.is-right-answer::after { content: "← правильный ответ"; margin-left: auto; color: var(--ok); font-weight: 700; font-size: 14px; }
.hint { margin: 12px 0; padding: 10px 14px; border-left: 4px solid var(--teal-l); background: #123144; border-radius: 6px; }
.task-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; justify-content: flex-end; }
.result { margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); border: 2px solid var(--line); }
.result:empty { display: none; }
.result-ok { border-color: var(--ok); background: #0f2f2b; }
.result-bad { border-color: var(--bad); background: #35242a; }
.result-head { font-size: 20px; font-weight: 800; display: flex; gap: 10px; align-items: center; }
.result-icon { display: inline-flex; width: 32px; height: 32px; align-items: center; justify-content: center; border-radius: 50%; border: 2px solid currentColor; }
.result-ok .result-head { color: var(--ok); } .result-bad .result-head { color: var(--bad); }
.result-expl { font-size: 17px; }
.rewards { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.reward-line { margin: 0 0 4px; } .reward-new { color: var(--teal-l); }

/* diagram */
.d-water { --c: #174a6b; } .d-land { --c: #2d4b45; } .d-low { --c: #3d7a5e; } .d-hill { --c: #6f6c52; }
.d-mount { --c: #8a7f72; } .d-dry { --c: #8f7d55; } .d-forest { --c: #2f6b45; } .d-ice { --c: #7f9db0; } .d-lava { --c: #8a4a3c; }
.diagram rect, .diagram polygon { fill: var(--c); }
.dz rect { fill: var(--c); stroke: #e8f1f5; stroke-opacity: .55; stroke-width: 1.5; }
.dz-active { cursor: pointer; } .dz-active:hover rect { stroke-opacity: 1; stroke-width: 2.5; }
.dz.selected rect { stroke: var(--teal-l); stroke-opacity: 1; stroke-width: 4; }
.dz.is-correct rect { stroke: var(--ok); stroke-opacity: 1; stroke-width: 4; }
.dz.is-wrong rect { stroke: var(--bad); stroke-opacity: 1; stroke-width: 4; }
.dz.is-right-answer rect { stroke: var(--ok); stroke-opacity: 1; stroke-width: 4; stroke-dasharray: 8 4; }
.dz:focus-visible rect { stroke: #fff; stroke-opacity: 1; stroke-width: 4; }
.dz { outline: none; }
.dz-label, .d-text { fill: #fff; font-family: var(--font); font-weight: 700; font-size: 11px; pointer-events: none; }
.d-halo { stroke: #06101b; stroke-width: 3.5px; paint-order: stroke; stroke-linejoin: round; }
.dz-label { stroke: #06101b; stroke-width: 3px; paint-order: stroke; stroke-linejoin: round; }
.d-caption { font-size: 12px; }
.d-arrow { stroke: #e8f1f5; stroke-width: 2.5; fill: none; }
.d-dot { fill: #fff; stroke: #06101b; stroke-width: 2; }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 900; display: grid; gap: 8px; width: min(380px, calc(100vw - 28px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; background: #123a44; border: 1px solid var(--teal); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: slide .25s ease-out; font-size: 15px; }
.toast-new { border-color: var(--teal-l); } .toast-ach { border-color: #fff; background: #1b4a5a; }
.toast-close { background: none; border: 0; color: var(--text); font-size: 16px; cursor: pointer; min-width: 32px; min-height: 32px; }
@keyframes slide { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Адаптивность ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "map right" "left right"; }
  .panel-right { position: static; max-height: none; }
  .panel-left { position: static; max-height: none; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "right" "left"; padding: 10px; }
  .panel { position: static; max-height: none; }
  .topbar { gap: 10px; padding: 8px 10px; }
  .topbar-buttons { width: 100%; } .topbar-buttons .btn { flex: 1; padding: 8px 10px; }
  .planet-map { max-height: none; }
  .task-title { font-size: 21px; }
  .modal-body { padding: 14px; }
}
@media (max-width: 480px) {
  .overlay { padding: 0; align-items: stretch; }
  .modal { max-height: 100vh; height: 100%; border-radius: 0; width: 100%; }
  .task-actions .btn { flex: 1; }
  .option { font-size: 16px; }
}
@media (hover: none) { .btn:hover:not(:disabled) { background: var(--panel2); } .btn-primary:hover:not(:disabled) { background: var(--teal); } }

/* Отключённые анимации: системная настройка и переключатель в игре */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }
