/* SYNAPSE — личная колода трансформации */
:root {
    --bg: #07090F;
    --surface: #10141F;
    --surface-2: #161C2C;
    --line: rgba(148, 163, 184, 0.16);
    --cyan: #22D3EE;
    --violet: #8B5CF6;
    --orange: #F97316;
    --text: #E6EDF6;
    --muted: #7C8AA0;
    --font-display: 'Unbounded', sans-serif;
    --font-text: 'Manrope', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-text);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 520px;
    margin: 0 auto;
    min-height: 100dvh;
    padding: 0 16px calc(24px + env(safe-area-inset-bottom));
    background:
        radial-gradient(ellipse 120% 60% at 50% -10%, rgba(34, 211, 238, 0.08), transparent 60%),
        var(--bg);
}

/* ── Header ── */
header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: calc(12px + env(safe-area-inset-top)) 2px 12px;
    background: linear-gradient(var(--bg) 70%, transparent);
}

.logo {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-shrink: 0;
}

.logo-sigil {
    width: 26px;
    height: 26px;
    color: var(--cyan);
    filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.5));
}

.logo h1 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text);
}

.progress {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#progress-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.progress-bar {
    flex: 1;
    height: 3px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--cyan);
    border-radius: 2px;
    transition: width 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
    box-shadow: 0 0 8px rgba(34, 211, 238, 0.7);
}

/* ── Chapters (levels) ── */
.level { margin: 34px 0; }

.level-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 14px;
}

.level-num {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 500;
    color: var(--cyan);
    letter-spacing: 0.08em;
}

.level-name {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}

.level-count {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* ── Mini card ── */
.card {
    aspect-ratio: 63 / 88;
    background: linear-gradient(160deg, var(--surface-2), var(--surface) 70%);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 9px 6px 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease;
}

.card:active { transform: scale(0.96); }

.card:focus-visible,
button:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

.card .num {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card .constellation {
    width: 78%;
    color: rgba(34, 211, 238, 0.55);
}

.card .name {
    font-size: 12px;
    line-height: 1.25;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* states */
.card.locked {
    cursor: default;
    opacity: 0.35;
    filter: saturate(0);
}

.card.locked .constellation { color: rgba(124, 138, 160, 0.5); }

.card.active {
    border-color: var(--orange);
    box-shadow: 0 0 22px rgba(249, 115, 22, 0.28), inset 0 0 14px rgba(249, 115, 22, 0.06);
}

.card.active .constellation { color: rgba(249, 115, 22, 0.8); }
.card.active .num { color: var(--orange); }

.card.completed {
    border-color: rgba(34, 211, 238, 0.65);
    background: linear-gradient(160deg, rgba(34, 211, 238, 0.08), var(--surface) 60%);
}

.card.completed .constellation { color: var(--cyan); }

.card:not(.locked):not(.active):hover {
    border-color: rgba(34, 211, 238, 0.5);
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.15);
}

.card .done-badge,
.card .lock-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 15px;
    height: 15px;
}

.card .done-badge { color: var(--cyan); }
.card .lock-badge { color: var(--muted); }

/* one orchestrated moment: active card breathes */
@keyframes breathe {
    0%, 100% { box-shadow: 0 0 16px rgba(249, 115, 22, 0.22), inset 0 0 12px rgba(249, 115, 22, 0.05); }
    50% { box-shadow: 0 0 30px rgba(249, 115, 22, 0.4), inset 0 0 18px rgba(249, 115, 22, 0.1); }
}

.card.active { animation: breathe 2.6s ease-in-out infinite; }

/* ── Skeleton (loading) ── */
.skeleton .sk-block {
    border-radius: 10px;
    background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

@keyframes shimmer { to { background-position: -200% 0; } }

.sk-line { height: 22px; width: 55%; margin: 34px 0 14px; }
.sk-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sk-card { aspect-ratio: 63 / 88; }

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.9);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show { display: flex; }

.modal-content {
    width: 100%;
    max-width: 340px;
    max-height: 92dvh;
    overflow-y: auto;
}

/* flip */
.card3d {
    position: relative;
    width: 100%;
    aspect-ratio: 63 / 88;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.3, 0.8, 0.3, 1);
    margin-bottom: 16px;
}

.card3d.flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 18px 20px;
    overflow: hidden;
}

.card-back {
    background:
        radial-gradient(circle at 50% 38%, rgba(34, 211, 238, 0.12), transparent 55%),
        linear-gradient(160deg, var(--surface-2), var(--bg));
    border: 1px solid rgba(34, 211, 238, 0.4);
    justify-content: center;
    gap: 14px;
}

.card-back .sigil {
    width: 46%;
    color: var(--cyan);
    filter: drop-shadow(0 0 14px rgba(34, 211, 238, 0.45));
}

.back-word {
    font-family: var(--font-display);
    font-size: 11px;
    letter-spacing: 0.35em;
    color: var(--muted);
}

.card-front {
    transform: rotateY(180deg);
    background: linear-gradient(170deg, #1A2236, var(--surface) 65%);
    border: 1px solid rgba(34, 211, 238, 0.5);
    box-shadow: 0 0 34px rgba(34, 211, 238, 0.16);
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.card-front .sigil { width: 40%; color: var(--cyan); }

.card-number {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.card-task {
    font-size: 13.5px;
    line-height: 1.55;
    color: #A7B4C7;
}

/* ── Buttons ── */
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 11px;
    font-family: var(--font-text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-height: 44px;
}

.btn-primary:active, .btn-secondary:active { transform: scale(0.97); }

.btn-primary {
    background: var(--cyan);
    color: #06121A;
    box-shadow: 0 4px 18px rgba(34, 211, 238, 0.3);
}

.btn-secondary {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}

.btn-secondary:hover { border-color: rgba(34, 211, 238, 0.4); color: var(--text); }

/* ── Submit modal ── */
.submit-modal .modal-content {
    background: linear-gradient(170deg, #1A2236, var(--surface) 70%);
    border: 1px solid rgba(34, 211, 238, 0.4);
    border-radius: 16px;
    padding: 22px;
}

.submit-modal h2 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}

.submit-modal p {
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 14px;
}

#proof-text {
    width: 100%;
    min-height: 90px;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    font-family: var(--font-text);
    font-size: 14px;
    resize: vertical;
    margin-bottom: 14px;
}

#proof-text:focus { outline: none; border-color: rgba(34, 211, 238, 0.5); }
#proof-text::placeholder { color: var(--muted); opacity: 0.7; }

/* ── HUD: XP-чип + прогресс ── */
.hud {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    justify-content: flex-end;
}
.xp-chip {
    display: inline-flex; align-items: center; gap: 6px;
    font-family: var(--font-display); font-size: 12px; font-weight: 700;
    letter-spacing: .08em; color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, .35);
    background: rgba(251, 191, 36, .07);
    padding: 7px 12px; border-radius: 999px;
    font-variant-numeric: tabular-nums;
}
.xp-chip svg { width: 13px; height: 13px; filter: drop-shadow(0 0 4px rgba(251, 191, 36, .6)); }

/* поле отчёта в модалке карты */
.note-wrap { margin-top: 16px; }
.note-wrap label {
    display: block; font-size: 12px; font-weight: 700;
    letter-spacing: .1em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 8px;
}

/* ── тост ── */
.toast {
    position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60;
    transform: translate(-50%, 16px);
    max-width: min(92vw, 420px);
    background: linear-gradient(170deg, #1A2236, var(--surface));
    border: 1px solid rgba(34, 211, 238, .45);
    border-radius: 14px; padding: 13px 18px;
    color: var(--text); font-size: 14px; font-weight: 600; text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5), 0 0 24px rgba(34, 211, 238, .12);
    opacity: 0; pointer-events: none;
    transition: opacity .25s ease-out, transform .25s ease-out;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.win { border-color: rgba(251, 191, 36, .5); color: #fde68a; }
.toast.warn { border-color: rgba(248, 113, 113, .5); color: #fca5a5; }
.toast.info { border-color: rgba(34, 211, 238, .45); }

/* ── Нижняя навигация (как на LEVEL) ── */
.container { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.tabbar {
    position: fixed; left: 50%; transform: translateX(-50%);
    bottom: 0; width: 100%; max-width: 520px; z-index: 110;
    display: flex; gap: 2px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: rgba(7, 9, 15, 0.96);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
}

.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; border-radius: 12px;
    color: var(--muted); font-family: var(--font-text);
    font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
    text-decoration: none; transition: color 0.2s ease;
}

.tab svg { width: 19px; height: 19px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--cyan); text-shadow: 0 0 6px rgba(34, 211, 238, 0.35); }
.tab.on svg { filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.6)); }

/* центральная кнопка «Колода» — круглая, приподнята над панелью */
.tab-home { flex: 0 0 78px; overflow: visible; }
.tab-home .orb {
    width: 56px; height: 56px; margin-top: -26px;
    display: grid; place-items: center; border-radius: 50%;
    border: 1px solid var(--cyan); color: var(--cyan);
    background: linear-gradient(180deg, rgba(34, 211, 238, 0.18), rgba(7, 9, 15, 0.92) 62%), rgba(7, 9, 15, 0.98);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 16px rgba(34, 211, 238, 0.25), inset 0 0 12px rgba(34, 211, 238, 0.14);
    transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.tab-home .orb svg { width: 25px; height: 25px; }
.tab-home:hover { color: var(--cyan); }
.tab-home:hover .orb { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 20px rgba(34, 211, 238, 0.4), inset 0 0 14px rgba(34, 211, 238, 0.2); }
.tab-home.on .orb {
    background: var(--cyan); color: #06121A;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5), 0 0 24px rgba(34, 211, 238, 0.55);
    transform: none;
}
.tab-home.on .orb svg { filter: none; }

/* ── Вьюхи (SPA: переключение без перезагрузки) ── */
.view { display: none; }
.view.on { display: block; animation: viewin 0.28s ease-out; }

@keyframes viewin {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px;
    margin: -1px; padding: 0; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Секции «Об игре» и «Наставник» ── */
.manifesto { padding: 44px 0 52px; }
.manifesto-line {
    font-family: var(--font-display); font-weight: 700;
    font-size: clamp(22px, 6vw, 30px); line-height: 1.3;
}
.manifesto-line:last-child {
    color: transparent;
    -webkit-text-stroke: 1px var(--muted);
}

.about-view + .about-view { border-top: 1px solid var(--line); }

.how { padding: 44px 0 52px; }
.how h2, .path h2, .mentor h2, .join h2 {
    font-family: var(--font-display); font-weight: 700;
    font-size: 22px; margin-bottom: 8px;
}
.how-steps {
    list-style: none; display: grid;
    grid-template-columns: 1fr; gap: 14px; margin-top: 22px;
}
.how-steps li {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; padding: 20px 18px;
}
.step-num {
    font-family: var(--font-display); font-weight: 700; font-size: 12px;
    color: var(--cyan); letter-spacing: 0.2em;
}
.how-steps h3 { font-size: 16px; font-weight: 700; margin: 10px 0 6px; }
.how-steps p { color: var(--muted); font-size: 14px; line-height: 1.55; }

.path { padding: 44px 0 52px; }
.path-sub { color: var(--muted); margin-bottom: 26px; font-size: 14.5px; }
.path-levels { display: flex; flex-direction: column; gap: 12px; }
.skeleton-block {
    height: 300px; border-radius: 16px;
    background: linear-gradient(100deg, var(--surface) 40%, var(--surface-2) 50%, var(--surface) 60%);
    background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.path-level {
    display: flex; align-items: center; gap: 14px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 15px 16px;
    transition: border-color 0.15s ease-out;
}
.path-level:hover { border-color: rgba(34, 211, 238, 0.4); }
.pl-num {
    font-family: var(--font-display); font-weight: 700; font-size: 12px;
    color: var(--violet); letter-spacing: 0.15em; min-width: 58px;
}
.pl-name { font-weight: 700; font-size: 15px; flex: 1; }
.pl-range { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.mentor { padding: 44px 0 52px; }
.mentor p { color: var(--muted); font-size: 15px; margin-top: 14px; line-height: 1.6; }
.mentor strong { color: var(--cyan); font-weight: 700; }

.join { padding: 44px 0 56px; }
.join-sub { color: var(--muted); margin-bottom: 24px; font-size: 14.5px; line-height: 1.55; }
.join-row {
    display: flex; align-items: stretch; gap: 8px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 14px; padding: 8px;
}
.join-row:focus-within { border-color: rgba(34, 211, 238, 0.55); }
.join-at {
    display: flex; align-items: center; padding-left: 10px;
    color: var(--muted); font-weight: 700; font-size: 16px;
}
#join-username {
    flex: 1; min-width: 0; background: none; border: 0; outline: none;
    color: var(--text); font-family: var(--font-text); font-size: 16px; font-weight: 600;
}
#join-username::placeholder { color: var(--muted); font-weight: 400; }
.join-row .btn-primary {
    width: auto; flex-shrink: 0;
    padding: 12px 20px; border-radius: 10px; font-size: 14px; white-space: nowrap;
}
#join-submit:disabled { filter: grayscale(0.5) brightness(0.8); cursor: wait; }
.join-err { color: #f87171; font-size: 13px; margin-top: 10px; }
.join-fine { color: var(--muted); font-size: 12.5px; margin-top: 14px; }
.join-ok {
    margin-top: 18px; padding: 14px 18px; border-radius: 12px;
    border: 1px solid rgba(34, 211, 238, 0.4); color: var(--cyan);
    font-weight: 700; background: rgba(34, 211, 238, 0.06); font-size: 14.5px;
}

@media (max-width: 400px) {
    .join-row { flex-wrap: wrap; }
    .join-row .btn-primary { width: 100%; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .card3d { transition: none; }
    .card.active { animation: none; }
    .progress-fill { transition: none; }
    .skeleton .sk-block { animation: none; }
    .view.on { animation: none; }
    .skeleton-block { animation: none; }
}
