:root {
  --yellow: #F5C518;
  --ink: #0F0E0C;
  --cream: #F4ECD8;
  --bronze: #7A5C1E;
  --ink-2: #17150F;
  --ink-3: #211E16;
  --line: #33301F;
  --cream-dim: rgba(244,236,216,.55);
  --cream-faint: rgba(244,236,216,.32);
  --serif: 'Playfair Display', serif;
  --body: 'Inter Tight', sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

/* светлая тема — UI становится кремово-светлым, 3D-сцена остаётся тёмной */
body.theme-light {
  color-scheme: light;
  --ink: #F3ECDC;
  --cream: #211C14;
  --ink-2: #FFFFFF;
  --ink-3: #EFE6D2;
  --line: rgba(33,28,20,.14);
  --cream-dim: rgba(33,28,20,.62);
  --cream-faint: rgba(33,28,20,.42);
}
body.theme-light { background: var(--ink); background-image: radial-gradient(120% 80% at 50% -10%, rgba(245,197,24,.10), transparent 60%); }
/* 3D-сцена в светлой теме — светлый фон */
body.theme-light .map-card { background: linear-gradient(180deg, #ece4cf, #ddd2b6); border-color: rgba(33,28,20,.16); }
body.theme-light .scene-veil { background: #e6ddc7; }
body.theme-light .map-eyebrow { color: rgba(33,28,20,.5); }
body.theme-light .stat-num, body.theme-light .gate-title .i { color: var(--yellow); }
/* подписи/чипы на светлой сцене — светлые плашки с тёмным текстом */
body.theme-light .c2d { background: rgba(255,253,247,.86); border-color: rgba(33,28,20,.16); color: #2a2418; }
body.theme-light .c2d.done { color: var(--bronze); }
body.theme-light .c2d.cur { color: #1a1610; border-color: rgba(245,197,24,.7); }
body.theme-light .c2d-title { color: rgba(33,28,20,.62); }
body.theme-light .ct-chip { background: rgba(255,253,247,.9); border-color: rgba(33,28,20,.16); }
body.theme-light .ct-t { color: rgba(33,28,20,.7); }
body.theme-light .city-back, body.theme-light .city-more { background: rgba(255,253,247,.82); color: #2a2418; border-color: rgba(33,28,20,.18); }
body.theme-light .city-name { color: #1a1610; text-shadow: none; }
body.theme-light .city-tag { color: rgba(33,28,20,.6); text-shadow: none; }
body.theme-light .ct-head { color: var(--bronze); text-shadow: none; }
/* календарь в светлой теме (карточка месяца не должна быть тёмной) */
body.theme-light .cal-month { background: linear-gradient(180deg, #ffffff, #f0e8d4); }
body.theme-light .cal-next { background: #fffdf7; }
/* тёмный текст на жёлтых кнопках/акцентах в светлой теме */
body.theme-light .gate-btn, body.theme-light .welcome-btn, body.theme-light .hw-submit,
body.theme-light .hw-type.active, body.theme-light .cal-tab.active, body.theme-light .cal-day.live,
body.theme-light .ct-chip.done .ct-n { color: #0F0E0C; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  color-scheme: dark;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  background-image: radial-gradient(120% 80% at 50% -10%, rgba(245,197,24,.07), transparent 60%);
}
.mono { font-family: var(--mono); }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
a { color: var(--yellow); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== PIN GATE ===== */
#gate {
  position: fixed; inset: 0; z-index: 50; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #0a0907;
  transition: opacity .6s ease, visibility .6s;
  padding: 24px;
}
#gate.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

/* круглые бренд-градиенты, медленно дрейфующие по кругу */
.gate-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.gate-bg .gblob { position: absolute; left: 50%; top: 50%; border-radius: 50%;
  mix-blend-mode: screen; filter: blur(54px); }
.gate-bg .g1 { width: 56vmin; height: 56vmin; margin: -28vmin 0 0 -28vmin;
  background: radial-gradient(circle, rgba(245,197,24,.62), transparent 66%); animation: orbitA 26s ease-in-out infinite; }
.gate-bg .g2 { width: 48vmin; height: 48vmin; margin: -24vmin 0 0 -24vmin;
  background: radial-gradient(circle, rgba(244,236,216,.46), transparent 66%); animation: orbitB 32s ease-in-out infinite; }
.gate-bg .g3 { width: 44vmin; height: 44vmin; margin: -22vmin 0 0 -22vmin;
  background: radial-gradient(circle, rgba(122,92,30,.6), transparent 66%); animation: orbitC 29s ease-in-out infinite; }
.gate-bg .g4 { width: 38vmin; height: 38vmin; margin: -19vmin 0 0 -19vmin;
  background: radial-gradient(circle, rgba(216,210,196,.30), transparent 66%); animation: orbitA 35s ease-in-out infinite reverse; }
@keyframes orbitA {
  0%{transform:translate(-32vw,-26vh)} 25%{transform:translate(28vw,-20vh)}
  50%{transform:translate(32vw,24vh)} 75%{transform:translate(-22vw,22vh)} 100%{transform:translate(-32vw,-26vh)} }
@keyframes orbitB {
  0%{transform:translate(30vw,-22vh)} 25%{transform:translate(26vw,24vh)}
  50%{transform:translate(-28vw,26vh)} 75%{transform:translate(-30vw,-18vh)} 100%{transform:translate(30vw,-22vh)} }
@keyframes orbitC {
  0%{transform:translate(-10vw,28vh)} 25%{transform:translate(-32vw,-8vh)}
  50%{transform:translate(12vw,-28vh)} 75%{transform:translate(34vw,6vh)} 100%{transform:translate(-10vw,28vh)} }
@media (prefers-reduced-motion: reduce) { .gate-bg .gblob { animation: none !important; } }

.gate-card { position: relative; z-index: 1; width: 100%; max-width: 460px; text-align: center; }
.gate-mark { font-family: var(--mono); font-size: 12px; letter-spacing: .42em; color: var(--yellow); text-transform: uppercase; margin-bottom: 26px; }
.gate-title { font-family: var(--serif); font-weight: 700; font-size: clamp(54px,13vw,104px); line-height: .92; letter-spacing: -.015em;
  text-shadow: 0 6px 40px rgba(0,0,0,.5); }
.gate-title .i { font-style: italic; color: var(--yellow); }
.gate-sub { color: var(--cream-dim); font-size: clamp(14px,1.5vw,17px); margin-top: 20px; line-height: 1.5; }

.key-wrap { margin: 32px 0 16px; }
.key-label { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; color: var(--cream-faint); text-transform: uppercase; margin-bottom: 10px; }
.key-input {
  width: 100%; background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; font-family: var(--mono); font-size: 16px;
  color: var(--cream); outline: none; letter-spacing: .12em; text-align: center;
  transition: border-color .2s, box-shadow .2s;
}
.key-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow), 0 0 22px rgba(245,197,24,.18); }

.name-wrap { margin: 0 0 16px; display: none; }
.name-wrap.show { display: block; }
.name-input {
  width: 100%; background: var(--ink-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px; font-family: var(--body); font-size: 15px;
  color: var(--cream); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.name-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 1px var(--yellow), 0 0 22px rgba(245,197,24,.18); }
.name-input::placeholder { color: var(--cream-faint); }

.gate-btn {
  width: 100%; background: var(--yellow); color: var(--ink); font-weight: 600;
  font-size: 15px; padding: 15px; border-radius: 11px; letter-spacing: .01em;
  transition: transform .15s, box-shadow .2s;
  box-shadow: 0 8px 30px rgba(245,197,24,.18);
}
.gate-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 36px rgba(245,197,24,.28); }
.gate-btn:active { transform: scale(.98); }
.gate-err { color: #E5705B; font-size: 13px; height: 18px; margin-top: 14px; font-family: var(--mono); opacity: 0; transition: opacity .2s; }
.gate-err.show { opacity: 1; }
.gate-hint { margin-top: 30px; font-family: var(--mono); font-size: 11px; color: var(--cream-faint); letter-spacing: .04em; }

.shake { animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }

/* ===== APP ===== */
#app { opacity: 0; transition: opacity .7s ease .1s; max-width: 1180px; margin: 0 auto; padding: 26px 20px 80px; }
#app.show { opacity: 1; }

.top {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 18px; padding-bottom: 22px; border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--mono); font-size: 11px; letter-spacing: .4em; color: var(--yellow); text-transform: uppercase; }
.who { font-family: var(--serif); font-size: clamp(26px,5vw,34px); font-weight: 600; line-height: 1.05; margin-top: 8px; }
.who span { font-style: italic; }
.dates { font-family: var(--mono); font-size: 11.5px; color: var(--cream-dim); margin-top: 9px; letter-spacing: .02em; }
.stat { text-align: right; min-width: 130px; }
.stat-num { font-family: var(--serif); font-size: clamp(40px,9vw,56px); font-weight: 700; line-height: 1; color: var(--yellow); }
.stat-lab { font-family: var(--mono); font-size: 11px; color: var(--cream-dim); letter-spacing: .08em; margin-top: 6px; }

/* Progress bar */
.bar-wrap { margin: 22px 0 8px; }
.bar-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; color: var(--cream-dim); margin-bottom: 9px; letter-spacing: .03em; }
.bar { height: 7px; background: var(--ink-3); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--bronze), var(--yellow)); border-radius: 99px; width: 0; transition: width 1.1s cubic-bezier(.5,0,.1,1); box-shadow: 0 0 16px rgba(245,197,24,.4); }

/* Tabs */
.tabs { display: flex; gap: 4px; margin: 28px 0 0; border-bottom: 1px solid var(--line); }
.tab-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  padding: 10px 18px 12px; color: var(--cream-faint); cursor: pointer;
  border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
  margin-bottom: -1px;
}
.tab-btn.active { color: var(--yellow); border-bottom-color: var(--yellow); }
.tab-btn:hover:not(.active) { color: var(--cream-dim); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* переключатель темы */
.theme-toggle { margin-left: auto; align-self: center; font-size: 16px; line-height: 1; padding: 7px 11px; cursor: pointer;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 9px; transition: border-color .2s, transform .15s; }
.theme-toggle:hover { border-color: var(--yellow); }
.theme-toggle:active { transform: scale(.94); }
@media (max-width: 560px) { .tabs { flex-wrap: wrap; } .theme-toggle { margin-left: auto; } }

/* ===== Домашние задания ===== */
.hw-wrap { max-width: 640px; margin: 32px auto 0; }
.hw-head { margin-bottom: 26px; }
.hw-title { font-family: var(--serif); font-weight: 600; font-size: clamp(24px,4vw,32px); color: var(--cream); }
.hw-sub { color: var(--cream-dim); font-size: 14.5px; line-height: 1.55; margin-top: 8px; }
.hw-form { display: flex; flex-direction: column; gap: 16px; }
.hw-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--cream-faint);
  display: flex; flex-direction: column; gap: 8px; }
.hw-input { font-family: var(--body); font-size: 15px; color: var(--cream); background: var(--ink-2);
  border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; outline: none; transition: border-color .2s; width: 100%; }
.hw-input:focus { border-color: var(--yellow); }
.hw-input option { background: var(--ink-2); color: var(--cream); }
.hw-textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.hw-types { display: flex; gap: 8px; flex-wrap: wrap; }
.hw-type { font-family: var(--mono); font-size: 12px; letter-spacing: .04em; padding: 10px 16px; border-radius: 10px;
  background: var(--ink-2); border: 1px solid var(--line); color: var(--cream-dim); cursor: pointer; transition: all .18s; }
.hw-type.active { border-color: var(--yellow); color: var(--ink); background: var(--yellow); font-weight: 600; }
.hw-file { display: block; border: 1.5px dashed var(--line); border-radius: 11px; padding: 22px 16px; text-align: center;
  cursor: pointer; transition: border-color .2s, background .2s; }
.hw-file:hover { border-color: var(--yellow); background: rgba(245,197,24,.04); }
.hw-fileinput { display: none; }
.hw-file-label { font-size: 13.5px; color: var(--cream-dim); }
.hw-submit { background: var(--yellow); color: var(--ink); font-weight: 600; font-size: 15px; padding: 15px; border-radius: 11px;
  cursor: pointer; box-shadow: 0 8px 28px rgba(245,197,24,.18); transition: transform .15s, opacity .2s; margin-top: 4px; }
.hw-submit:hover { transform: translateY(-2px); }
.hw-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.hw-status { font-size: 13.5px; line-height: 1.5; min-height: 20px; text-align: center; }
.hw-status.ok { color: var(--yellow); }
.hw-status.err { color: #E5705B; }

/* ===== HOMEWORK TASK CARD ===== */
.hw-task { background: var(--ink-2); border: 1px solid var(--line); border-left: 3px solid var(--yellow);
  border-radius: 14px; padding: 20px 20px 18px; }
.hw-task--soon { border-left-color: var(--line); }
.hw-task-soon { font-size: 13.5px; color: var(--cream-dim); line-height: 1.55; }
.hw-task-tag { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--yellow); margin-bottom: 9px; }
.hw-task-title { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--cream); line-height: 1.25; }
.hw-task-intro { font-size: 13.5px; color: var(--cream-dim); line-height: 1.55; margin-top: 8px; }
.hw-task-h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--cream-faint); margin: 16px 0 7px; }
.hw-task-steps, .hw-task-crit { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.hw-task-steps li, .hw-task-crit li { font-size: 14px; color: var(--cream); line-height: 1.5; }
.hw-task-steps li::marker { color: var(--yellow); font-family: var(--mono); font-weight: 700; }
.hw-task-crit { list-style: none; padding-left: 0; }
.hw-task-crit li { position: relative; padding-left: 24px; }
.hw-task-crit li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--yellow); font-weight: 700; }
.hw-task-deadline { font-family: var(--mono); font-size: 12px; color: var(--cream-dim); margin-top: 16px;
  padding-top: 13px; border-top: 1px solid var(--line); }

/* ===== SCHEDULE / CALENDAR TAB ===== */
.cal-wrap { max-width: 760px; margin: 32px auto 0; }
.cal-head { margin-bottom: 26px; }
.cal-title { font-family: var(--serif); font-weight: 600; font-size: clamp(24px,4vw,32px); color: var(--cream); }
.cal-sub { color: var(--cream-dim); font-size: 14.5px; line-height: 1.6; margin-top: 8px; }
.cal-sub b { color: var(--cream); font-weight: 600; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 18px; }
.cal-legend-item { display: inline-flex; align-items: center; gap: 9px; font-family: var(--mono);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--cream-faint); }
.cal-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.cal-dot.live { background: var(--yellow); box-shadow: 0 0 0 3px rgba(245,197,24,.16), 0 0 14px rgba(245,197,24,.6); }
.cal-count { color: var(--yellow); font-size: 13px; letter-spacing: .06em; }

/* переключатель месяцев */
.cal-switch { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 22px 0 16px; }
.cal-nav { width: 38px; height: 38px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 50%; color: var(--cream);
  font-size: 20px; line-height: 1; cursor: pointer; transition: border-color .2s, transform .15s, color .2s; }
.cal-nav:hover { border-color: var(--yellow); color: var(--yellow); }
.cal-nav:active { transform: scale(.92); }
.cal-nav:disabled { opacity: .3; cursor: default; border-color: var(--line); color: var(--cream-faint); transform: none; }
.cal-switch-tabs { display: flex; gap: 6px; }
.cal-tab { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line); background: transparent;
  color: var(--cream-faint); cursor: pointer; transition: all .18s; }
.cal-tab:hover { color: var(--cream-dim); }
.cal-tab.active { color: var(--ink); background: var(--yellow); border-color: var(--yellow); font-weight: 700;
  box-shadow: 0 0 0 1px rgba(245,197,24,.35), 0 0 18px rgba(245,197,24,.55);
  animation: calPulse 2.6s ease-in-out infinite; }

.cal-months { max-width: 420px; margin: 0 auto; }
.cal-month { animation: calFade .28s ease; }
@keyframes calFade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.cal-month {
  background: linear-gradient(180deg, var(--ink-2), #100f0a);
  border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px 22px;
}
.cal-month-name { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--cream); margin-bottom: 2px; }
.cal-month-meta { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--cream-faint); margin-bottom: 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--cream-faint); text-align: center; padding-bottom: 8px; }
.cal-day { aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 13px; color: var(--cream-dim); border-radius: 10px;
  border: 1px solid transparent; transition: transform .15s; }
.cal-day.empty { visibility: hidden; }
.cal-day.live {
  color: var(--ink); font-weight: 700; background: var(--yellow);
  border-color: rgba(245,197,24,.5);
  box-shadow: 0 0 0 1px rgba(245,197,24,.35), 0 0 16px rgba(245,197,24,.45);
  animation: calPulse 2.6s ease-in-out infinite;
}
.cal-day.live:hover { transform: scale(1.08); }
@keyframes calPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(245,197,24,.30), 0 0 10px rgba(245,197,24,.35); }
  50%      { box-shadow: 0 0 0 1px rgba(245,197,24,.55), 0 0 22px rgba(245,197,24,.75); }
}

.cal-next { margin-top: 24px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--ink-2); display: flex; align-items: center; gap: 14px; }
.cal-next-flag { font-size: 22px; line-height: 1; }
.cal-next-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--cream-faint); }
.cal-next-date { font-family: var(--serif); font-size: 18px; color: var(--cream); margin-top: 3px; }
.cal-next-date b { color: var(--yellow); font-weight: 600; }

/* ===== MAP TAB ===== */
.grid { display: grid; grid-template-columns: 1fr; gap: 26px; margin-top: 30px; align-items: start; }
@media (max-width: 880px) { .grid { gap: 22px; } .stat { text-align: left; min-width: 0; } }

.map-card {
  position: relative; background: linear-gradient(180deg, var(--ink-2), #100f0a);
  border: 1px solid var(--line); border-radius: 18px; padding: 14px; overflow: hidden;
}
.map-eyebrow { position: absolute; top: 16px; left: 18px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .28em; color: var(--cream-faint); text-transform: uppercase; z-index: 2; }
svg.map { width: 100%; height: auto; display: block; }
.kz-hidden { display: none; }

/* ===== 3D SCENE ===== */
.scene3d { position: relative; width: 100%; height: 660px; border-radius: 12px; overflow: hidden; cursor: grab; touch-action: none; }
.scene3d:active { cursor: grabbing; }
.scene3d canvas { display: block; }
@media (max-width: 880px) { .scene3d { height: 480px; } }

.c2d-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.c2d {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-family: var(--mono); text-align: center; line-height: 1.15;
  background: rgba(15,14,12,.78); border: 1px solid var(--line); border-radius: 11px;
  padding: 5px 10px 6px; backdrop-filter: blur(5px);
  transform: translateY(-2px); user-select: none; transition: opacity .3s;
}
.c2d-n { font-size: 10px; font-weight: 700; letter-spacing: .04em; }
.c2d-city { font-size: 12px; font-weight: 600; letter-spacing: .12em; }
.c2d-title { font-family: var(--body); font-size: 10.5px; letter-spacing: .01em; }
.c2d.done  { color: var(--yellow); border-color: rgba(245,197,24,.3); }
.c2d.done .c2d-title { color: var(--cream-dim); }
.c2d.cur   { color: #fff; border-color: rgba(245,197,24,.55); box-shadow: 0 0 18px rgba(245,197,24,.18); }
.c2d.cur .c2d-n { color: var(--yellow); }
.c2d.cur .c2d-title { color: var(--yellow); }
.c2d.lock  { color: var(--cream-faint); opacity: .7; background: rgba(15,14,12,.55); }
.c2d.lock .c2d-title { display: none; }

/* veil перехода */
.scene-veil { position: absolute; inset: 0; background: #0c0b08; opacity: 0; pointer-events: none; transition: opacity .24s ease; z-index: 4; }
.scene-veil.on { opacity: 1; }

/* HUD города */
.city-hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; transition: opacity .35s ease .15s; }
.city-hud.show { opacity: 1; }
.city-back, .city-more { pointer-events: auto; position: absolute; font-family: var(--mono); font-size: 11px; letter-spacing: .08em;
  padding: 10px 16px; border-radius: 99px; border: 1px solid var(--line); background: rgba(15,14,12,.72); color: var(--cream);
  backdrop-filter: blur(8px); transition: border-color .2s, color .2s; cursor: pointer; }
.city-back { top: 16px; left: 16px; }
.city-more { bottom: 18px; left: 18px; color: var(--yellow); border-color: rgba(245,197,24,.35); }
.city-back:hover, .city-more:hover { border-color: var(--yellow); color: var(--yellow); }
.city-hud-title { position: absolute; bottom: 64px; left: 18px; max-width: 52%; text-shadow: 0 2px 14px rgba(0,0,0,.85); }
.city-etap { display: block; font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--yellow); }
.city-name { font-family: var(--serif); font-weight: 600; font-size: clamp(24px,4vw,34px); line-height: 1.05; margin: 6px 0 4px; color: var(--cream); }
.city-tag { font-size: 13px; color: var(--cream-dim); line-height: 1.4; }

/* точки-темы над городом (интерактивные) */
.topic-dot { display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: var(--mono);
  text-align: center; user-select: none; width: 124px; cursor: pointer; }
.topic-n { font-size: 11px; font-weight: 700; color: var(--ink); background: var(--yellow); width: 20px; height: 20px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  box-shadow: 0 0 0 4px rgba(15,14,12,.55); transition: transform .15s, background .2s; }
.topic-text { font-family: var(--body); font-size: 10.5px; font-weight: 500; line-height: 1.25; color: var(--cream);
  background: rgba(15,14,12,.88); border: 1px solid var(--line); border-radius: 9px; padding: 5px 8px;
  backdrop-filter: blur(6px); transition: border-color .2s, color .2s; }
.topic-dot:hover .topic-text { border-color: var(--yellow); }
.topic-dot:hover .topic-n { transform: scale(1.12); }
.topic-dot.done .topic-n { background: var(--yellow); box-shadow: 0 0 0 4px rgba(245,197,24,.22), 0 0 16px rgba(245,197,24,.5); }
.topic-dot.done .topic-text { color: var(--yellow); border-color: rgba(245,197,24,.45); }
.topic-dot.below { flex-direction: column-reverse; }
.city-arc-head { font-family: var(--mono); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--yellow); white-space: nowrap; background: rgba(15,14,12,.7); padding: 5px 12px; border-radius: 99px;
  border: 1px solid rgba(245,197,24,.25); pointer-events: none; }

/* кольцо прогресса города */
.city-progress { position: absolute; top: 14px; right: 14px; width: 46px; height: 46px; z-index: 8; pointer-events: none;
  background: rgba(15,14,12,.55); border-radius: 50%; box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.city-progress svg { width: 46px; height: 46px; transform: rotate(-90deg); }
body.theme-light .city-progress { background: rgba(255,253,247,.8); box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.cp-bg { fill: none; stroke: var(--line); stroke-width: 3.2; }
.cp-fill { fill: none; stroke: var(--yellow); stroke-width: 3.2; stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.5,0,.1,1); filter: drop-shadow(0 0 5px rgba(245,197,24,.55)); }
.cp-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: var(--cream); }

.ov-outcome { background: rgba(245,197,24,.06); border: 1px solid rgba(245,197,24,.25); border-radius: 12px; padding: 14px 16px; }
.ov-outcome .ov-text { color: var(--cream); }

/* fx-салют */
.fx-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; }

/* тост-подсказка на карте */
.hub-toast { position: absolute; left: 50%; top: 18px; transform: translateX(-50%) translateY(-8px); z-index: 9;
  max-width: 86%; text-align: center; background: rgba(15,14,12,.92); color: var(--cream); border: 1px solid rgba(245,197,24,.4);
  border-radius: 12px; padding: 11px 18px; font-size: 13.5px; font-weight: 500; line-height: 1.4;
  box-shadow: 0 12px 36px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; }
.hub-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== WELCOME ===== */
.welcome { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: #0a0907; overflow: hidden;
  opacity: 0; visibility: hidden; transition: opacity .6s, visibility .6s; padding: clamp(20px,4vw,60px); }
.welcome.show { opacity: 1; visibility: visible; }

/* плавающий градиент-фон */
.welcome-bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.welcome-bg .blob { position: absolute; left: 50%; top: 50%; border-radius: 50%;
  mix-blend-mode: screen; filter: blur(56px); }
.welcome-bg .b1 { width: 58vmin; height: 58vmin; margin: -29vmin 0 0 -29vmin;
  background: radial-gradient(circle, rgba(245,197,24,.6), transparent 66%); animation: orbitA 27s ease-in-out infinite; }
.welcome-bg .b2 { width: 50vmin; height: 50vmin; margin: -25vmin 0 0 -25vmin;
  background: radial-gradient(circle, rgba(244,236,216,.44), transparent 66%); animation: orbitB 33s ease-in-out infinite; }
.welcome-bg .b3 { width: 44vmin; height: 44vmin; margin: -22vmin 0 0 -22vmin;
  background: radial-gradient(circle, rgba(122,92,30,.58), transparent 66%); animation: orbitC 30s ease-in-out infinite; }
.welcome-bg::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(10,9,7,.1) 0%, rgba(10,9,7,.2) 42%, rgba(10,9,7,.7) 72%, rgba(10,9,7,.9) 100%); }
@media (prefers-reduced-motion: reduce) { .welcome-bg .blob { animation: none !important; } }

.welcome-inner { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center;
  gap: clamp(24px,5vw,72px); width: 100%; max-width: 1180px; }
.welcome-lion-wrap { position: relative; flex: 0 0 auto; height: min(78vh, 680px); display: flex; align-items: flex-end;
  animation: lionIn .9s cubic-bezier(.3,1.3,.4,1) both .15s; }
.welcome-lion, .welcome-lion-vid { height: 100%; width: auto; display: block;
  filter: drop-shadow(0 24px 60px rgba(0,0,0,.6)) drop-shadow(0 0 48px rgba(245,197,24,.16)); }
.welcome-lion-vid { position: absolute; inset: 0; margin: auto; opacity: 0; transition: opacity .5s; }
.welcome-lion-wrap.has-video .welcome-lion-vid { opacity: 1; }
.welcome-lion-wrap.has-video .welcome-lion { opacity: 0; }
/* анимация «дышит / говорит» для статичной картинки (fallback без видео) */
/* лев — анимированный APNG (сам двигается), CSS-анимация не нужна */
.welcome-lion { transform-origin: 50% 100%; }
@keyframes lionIn { from { opacity: 0; transform: translateY(30px) scale(.94); } to { opacity: 1; transform: none; } }

.welcome-right { display: flex; flex-direction: column; gap: clamp(18px,2.4vw,30px); max-width: 560px;
  animation: lionIn .8s ease both .45s; }
.welcome-eyebrow { font-size: clamp(11px,1vw,13px); letter-spacing: .34em; color: var(--yellow); text-transform: uppercase; }
.welcome-text { font-family: var(--serif); font-weight: 600; color: var(--cream);
  font-size: clamp(30px, 4.4vw, 64px); line-height: 1.1; letter-spacing: -.01em; min-height: 2em; }
.welcome-text .hl { color: var(--yellow); font-style: italic; }
.welcome-text::after { content: ''; display: inline-block; width: 3px; height: .9em; background: var(--yellow);
  vertical-align: -.08em; margin-left: 4px; animation: caret 1s steps(2) infinite; }
.welcome-text.done::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }
.welcome-btn { align-self: flex-start; background: var(--yellow); color: var(--ink); font-weight: 600;
  font-size: clamp(15px,1.3vw,17px); padding: 16px 36px; border-radius: 12px; box-shadow: 0 10px 36px rgba(245,197,24,.24);
  opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .4s, box-shadow .25s; pointer-events: none; cursor: pointer; }
.welcome-btn.show { opacity: 1; transform: none; pointer-events: auto; }
.welcome-btn:hover { box-shadow: 0 12px 44px rgba(245,197,24,.4); }
.welcome-btn:active { transform: scale(.97); }
@media (max-width: 760px) {
  .welcome-inner { flex-direction: column; gap: 14px; text-align: center; }
  .welcome-lion-wrap { height: min(42vh, 360px); }
  .welcome-right { align-items: center; }
  .welcome-btn { align-self: center; }
  .welcome-text { min-height: 0; }
}

/* ===== лев-проводник в городе (стоит сбоку, поменьше, не закрывает текст) ===== */
.city-lion { position: absolute; right: 6px; bottom: 0; height: 54%; max-height: 380px; z-index: 6; pointer-events: none;
  opacity: 0; transform: translateY(24px) scale(.96); transition: opacity .55s ease .15s, transform .55s ease .15s;
  filter: drop-shadow(0 14px 34px rgba(0,0,0,.6)) drop-shadow(0 0 26px rgba(245,197,24,.12));
  transform-origin: 50% 100%; }
.map-card.city-mode .city-lion { opacity: 1; transform: none; }
.city-bubble { position: absolute; right: clamp(150px, 15%, 240px); bottom: 40%; z-index: 7; max-width: 220px;
  background: var(--cream); color: var(--ink); font-size: 13.5px; line-height: 1.45; font-weight: 500;
  padding: 12px 15px; border-radius: 15px 15px 4px 15px; box-shadow: 0 12px 34px rgba(0,0,0,.45);
  opacity: 0; transform: translateY(8px) scale(.96); transform-origin: right bottom; transition: opacity .3s, transform .3s;
  pointer-events: none; }
.city-bubble.show { opacity: 1; transform: none; }
@media (max-width: 880px) {
  .city-lion { height: 34%; right: 2px; }
  .city-bubble { right: 30%; bottom: 30%; max-width: 150px; font-size: 12px; }
}

/* ===== темы города — чистая строка наверху ===== */
.city-topics { position: absolute; top: 12px; left: 14px; right: 74px;
  z-index: 5; pointer-events: none; opacity: 0; transition: opacity .4s ease .15s; }
.city-topics.show { opacity: 1; }
.ct-head { text-align: center; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--yellow);
  margin-bottom: 10px; text-shadow: 0 2px 8px rgba(0,0,0,.9); }
.ct-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ct-chip { pointer-events: auto; flex: 1 1 0; min-width: 150px; max-width: 210px; display: flex; align-items: flex-start; gap: 9px;
  text-align: left; background: rgba(18,16,12,.9); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s; backdrop-filter: blur(8px); }
.ct-chip:hover { border-color: var(--yellow); transform: translateY(-2px); }
.ct-n { flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%; background: transparent; border: 1.5px solid var(--bronze);
  color: var(--yellow); font-family: var(--mono); font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.ct-t { font-size: 12.5px; line-height: 1.3; color: var(--cream-dim); font-weight: 500; }
.ct-chip.done { border-color: rgba(245,197,24,.5); background: rgba(245,197,24,.08); }
.ct-chip.done .ct-n { background: var(--yellow); border-color: var(--yellow); color: var(--ink); box-shadow: 0 0 14px rgba(245,197,24,.5); }
.ct-chip.done .ct-t { color: var(--cream); }
@media (max-width: 880px) {
  .city-topics { top: 8px; left: 10px; right: 60px; }
  .ct-row { gap: 7px; }
  .ct-chip { min-width: 0; flex-basis: calc(50% - 4px); padding: 8px 10px; }
  .ct-t { font-size: 11px; }
  .ct-head { margin-bottom: 6px; }
}

/* лев-проводник */
.mascot { position: absolute; left: 18px; bottom: 86px; z-index: 8; display: flex; align-items: flex-end; gap: 12px;
  opacity: 0; transform: translateY(10px); transition: opacity .4s, transform .4s; pointer-events: none; }
.mascot.show { opacity: 1; transform: none; }
.mascot-ava { pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; padding: 0; flex: 0 0 auto;
  border: 2px solid rgba(245,197,24,.55); background: radial-gradient(circle at 50% 35%, #2a2412, #0f0e0c);
  overflow: hidden; box-shadow: 0 10px 34px rgba(0,0,0,.5), 0 0 22px rgba(245,197,24,.25); cursor: pointer;
  display: flex; align-items: center; justify-content: center; position: relative; }
.mascot-ava img { width: 100%; height: 100%; object-fit: cover; }
.mascot-ava img.hide { display: none; }
.mascot-fallback { position: absolute; font-size: 34px; }
.mascot-ava img:not(.hide) + .mascot-fallback { display: none; }
@keyframes mascotPop { 0%{transform:scale(1)} 35%{transform:scale(1.16)} 70%{transform:scale(.95)} 100%{transform:scale(1)} }
.mascot-ava.pop { animation: mascotPop .5s ease; }
.mascot-bubble { max-width: 240px; background: var(--cream); color: var(--ink); font-size: 13px; line-height: 1.4;
  font-weight: 500; padding: 11px 14px; border-radius: 14px 14px 14px 4px; margin-bottom: 6px;
  opacity: 0; transform: translateY(6px) scale(.96); transform-origin: left bottom; transition: opacity .3s, transform .3s;
  box-shadow: 0 8px 26px rgba(0,0,0,.4); pointer-events: none; }
.mascot-bubble.show { opacity: 1; transform: none; }
@media (max-width: 880px) { .mascot { left: 12px; bottom: 76px; } .mascot-ava { width: 60px; height: 60px; } .mascot-bubble { max-width: 180px; font-size: 12px; } }

/* в городе говорит большой лев справа через #cityBubble — маленький маскот прячем */
.map-card.city-mode .mascot { display: none; }

.kz-fill { fill: rgba(244,236,216,.05); stroke: rgba(244,236,216,.2); stroke-width: 1.1; stroke-linejoin: round; }
.route-base { fill: none; stroke: var(--bronze); stroke-width: 2; stroke-dasharray: 2 9; stroke-linecap: round; opacity: .6; }
.route-done { fill: none; stroke: var(--yellow); stroke-width: 2.4; stroke-dasharray: 2 9; stroke-linecap: round; filter: drop-shadow(0 0 5px rgba(245,197,24,.6)); }
.node { cursor: pointer; }
.node circle.hit { fill: transparent; }
.dot-lock { fill: var(--ink-2); stroke: #4a4630; stroke-width: 1.6; }
.dot-done { fill: var(--yellow); filter: drop-shadow(0 0 6px rgba(245,197,24,.55)); }
.dot-cur { fill: var(--ink); stroke: var(--yellow); stroke-width: 2.2; filter: drop-shadow(0 0 6px rgba(245,197,24,.5)); }
.ring-cur { fill: none; stroke: var(--yellow); stroke-width: 1.6; transform-origin: center; transform-box: fill-box; }
.node text.num { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: var(--ink); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node text.numcur { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: var(--yellow); text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node text.numlock { font-family: var(--mono); font-size: 9px; font-weight: 700; fill: #6c6748; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.node text.lab { font-family: var(--mono); font-size: 10px; fill: var(--cream-dim); pointer-events: none; letter-spacing: .02em; }
.node.sel circle.dot-lock, .node.sel circle.dot-done, .node.sel circle.dot-cur { stroke: var(--cream); stroke-width: 2; }
.node.sel text.lab { fill: var(--cream); }
@keyframes pulse { 0%{r:9;opacity:.9} 70%{r:20;opacity:0} 100%{opacity:0} }
.ping { fill: none; stroke: var(--yellow); stroke-width: 1.4; animation: pulse 2.1s ease-out infinite; }

/* Sidebar list */
.side { display: flex; flex-direction: column; gap: 14px; }
.list { background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list-h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--cream-faint); padding: 15px 18px 11px; }
.item { display: flex; align-items: center; gap: 13px; padding: 12px 18px; border-top: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.item:hover { background: var(--ink-3); }
.item.sel { background: var(--ink-3); }
.item.sel .it-name { color: var(--cream); }
.it-ic { width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 10px; font-weight: 700; }
.it-ic.done { background: var(--yellow); color: var(--ink); }
.it-ic.cur { background: transparent; border: 1.6px solid var(--yellow); color: var(--yellow); }
.it-ic.lock { background: transparent; border: 1.6px solid #4a4630; color: #6c6748; }
.it-name { flex: 1; font-size: 14px; color: var(--cream-dim); font-weight: 500; }
.it-city { font-family: var(--mono); font-size: 10.5px; color: var(--cream-faint); letter-spacing: .04em; }

/* ===== MODULE OVERLAY ===== */
.overlay-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,14,12,.7);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.overlay-backdrop.open { opacity: 1; visibility: visible; }

.overlay {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(520px, 100vw);
  z-index: 41;
  background: var(--ink-2);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.overlay.open { transform: translateX(0); }

@media (max-width: 600px) {
  .overlay { width: 100vw; border-left: none; border-top: 1px solid var(--line); top: auto; height: 92dvh; border-radius: 16px 16px 0 0; }
}

.overlay-inner { padding: 28px 28px 48px; }
.overlay-close {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  color: var(--cream-faint); text-transform: uppercase; margin-bottom: 28px;
  padding: 6px 0; transition: color .15s;
}
.overlay-close:hover { color: var(--cream-dim); }
.overlay-close svg { width: 14px; height: 14px; }

.ov-header { margin-bottom: 24px; }
.ov-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ov-num { font-family: var(--mono); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--yellow); }
.ov-city { font-family: var(--mono); font-size: 11px; color: var(--cream-dim); letter-spacing: .05em; }
.ov-title { font-family: var(--serif); font-size: clamp(28px,6vw,38px); font-weight: 600; line-height: 1.05; margin-bottom: 6px; }
.ov-tagline { color: var(--cream-dim); font-size: 14px; line-height: 1.5; }

.ov-status {
  display: inline-flex; align-items: center; gap: 8px; margin: 14px 0 24px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line);
}
.ov-status.done { color: var(--yellow); border-color: rgba(245,197,24,.4); }
.ov-status.cur { color: var(--ink); background: var(--yellow); border-color: var(--yellow); }
.ov-status.lock { color: var(--cream-faint); }

.ov-divider { border: none; border-top: 1px solid var(--line); margin: 22px 0; }

.ov-section { margin-bottom: 22px; }
.ov-label { font-family: var(--mono); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--cream-faint); margin-bottom: 10px; }
.ov-text { font-size: 14.5px; color: var(--cream-dim); line-height: 1.65; }
.ov-calls { font-family: var(--mono); font-size: 13px; color: var(--cream); }

.ov-platforms { display: flex; flex-wrap: wrap; gap: 7px; }
.ov-tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em;
  padding: 5px 11px; border-radius: 6px;
  background: var(--ink-3); border: 1px solid var(--line); color: var(--cream-dim);
}

.ov-learn { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ov-learn li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--cream-dim); line-height: 1.5; }
.ov-learn li::before { content: '→'; font-family: var(--mono); color: var(--yellow); flex: 0 0 auto; margin-top: 1px; }

.ov-materials { display: flex; flex-direction: column; gap: 8px; }
.mat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--ink-3); border: 1px solid var(--line);
  text-decoration: none; color: var(--cream-dim);
  font-size: 14px; transition: border-color .15s, background .15s;
}
.mat-item:hover { border-color: rgba(245,197,24,.3); background: #1a180f; color: var(--cream); text-decoration: none; }
.mat-icon { font-size: 16px; flex: 0 0 auto; }
.mat-title { flex: 1; }
.mat-arrow { font-family: var(--mono); font-size: 12px; color: var(--cream-faint); }
.mat-empty { font-family: var(--mono); font-size: 12px; color: var(--cream-faint); letter-spacing: .04em; }

.ov-locked-note {
  background: var(--ink-3); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; text-align: center; margin-top: 8px;
}
.ov-locked-note .lock-icon { font-size: 28px; margin-bottom: 10px; }
.ov-locked-note p { font-family: var(--mono); font-size: 12px; color: var(--cream-faint); letter-spacing: .04em; line-height: 1.6; }

/* ===== MATERIALS TAB ===== */
.materials-section { margin-top: 30px; }
.mat-group { margin-bottom: 36px; }
.mat-group-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--cream-faint); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.mat-grid { display: flex; flex-direction: column; gap: 8px; }

/* ===== FOOTER ===== */
.foot { text-align: center; margin-top: 48px; font-family: var(--mono); font-size: 11px; color: var(--cream-faint); letter-spacing: .1em; }
.foot b { color: var(--yellow); font-weight: 700; }

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  .ping { display: none; }
  .bar-fill { transition: none; }
  .overlay { transition: none; }
  .overlay-backdrop { transition: none; }
}
