/* FoldQuest — Styles */

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

:root {
    --nav-offset: 84px; /* высота sticky-панели (~72px) + зазор 12px; уточняется из JS по фактической высоте панели */
    --bg: #0b0b14;
    --bg-2: #0f0f1a;
    --surface: #161625;
    --surface-2: #1e1e32;
    --surface-3: #262640;
    --border: #2a2a4a;
    --border-hover: #3a3a6a;
    --text: #e8e8f0;
    --text-dim: #8888aa;
    --text-muted: #5a5a7a;
    --primary: #7c5cbf;
    --primary-hover: #9370db;
    --primary-glow: rgba(124, 92, 191, 0.35);
    --accent: #a78bfa;
    --accent-glow: rgba(167, 139, 250, 0.25);
    --success: #4caf50;
    --success-glow: rgba(76, 175, 80, 0.2);
    --error: #e74c3c;
    --error-glow: rgba(231, 76, 60, 0.2);
    --radius: 12px;
    --radius-lg: 18px;
    --shadow: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 24px var(--primary-glow);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; scroll-padding-top: var(--nav-offset); }

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 60% at 50% -20%, rgba(124,92,191,0.12), transparent),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(167,139,250,0.06), transparent);
    color: var(--text);
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip; /* full-bleed блоки (100vw) не дают горизонтального скролла */
}

/* ── Nav ── */
.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    /* Без backdrop-filter: при прокрутке под панель уезжает баннер с
       анимацией кадров, и размытие поверх него мерцало (Safari, Chrome/Mac) */
    background: rgba(11,11,20,0.95);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand-logo { border-radius: 8px; }

.brand-name {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-actions { display: flex; align-items: center; gap: 8px; }

/* Главная кнопка панели «Создать квест» — видна и на мобильном (остальные скрыты) */
.nav-play {
    margin-left: 8px;
    padding: 4px 16px 6px;
    font-family: "Handjet", sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    background: linear-gradient(#9d7ee3, #7c5cbf);
    box-shadow: 0 -3px 0 0 #1d1436, 0 3px 0 0 #1d1436, -3px 0 0 0 #1d1436, 3px 0 0 0 #1d1436,
        inset 0 -4px 0 0 #5a3d9e;
    transition: filter 0.2s ease;
}
.nav-play:hover { filter: brightness(1.15); }

/* ── Page ── */
.page {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 20px 60px;
}

/* ── Hero: витрина готовых игр ──
   Фон — пиксельный key art (assets/hero/keyart.png, растягивается с
   image-rendering: pixelated), справа «экран игры» со слайдами книг
   галереи (app.js), по нижнему краю идут герои книг. */
@font-face {
    font-family: "Handjet";
    src: url("/assets/fonts/handjet.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

.hero {
    --pixel-ink: #1d1436;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    /* full-bleed: break out of .page max-width (как у галереи) */
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-bottom: 40px;
    padding: 64px 24px 72px;
}

.hero-art {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--bg) url("/assets/hero/keyart.png") 70% 100% / cover no-repeat;
    image-rendering: pixelated;
}

/* затемнение под текст слева и плавный переход в фон страницы снизу */
.hero-art::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(11,11,20,0.8) 0%, rgba(11,11,20,0.55) 40%, rgba(11,11,20,0.15) 75%),
        linear-gradient(to bottom, rgba(11,11,20,0.35) 0%, transparent 25%, transparent 80%, var(--bg) 100%);
}

.hero-inner {
    max-width: 1180px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 48px;
    align-items: center;
}

.pill {
    display: inline-block;
    padding: 2px 14px 4px;
    background: rgba(29, 20, 54, 0.85);
    box-shadow: 0 -3px 0 0 var(--primary), 0 3px 0 0 var(--primary), -3px 0 0 0 var(--primary), 3px 0 0 0 var(--primary);
    color: var(--accent);
    font-family: "Handjet", sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 3px 3px 20px;
}

.hero-title {
    font-family: "Handjet", sans-serif;
    font-size: clamp(3rem, 6.2vw, 4.6rem);
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: 0.01em;
    color: #fff;
    text-shadow: 4px 4px 0 #4b2f8f, 0 0 40px var(--primary-glow);
    margin-bottom: 18px;
}

.hero .subtitle {
    color: #c9c6e0;
    font-size: 1.12rem;
    line-height: 1.55;
    max-width: 30em;
    margin-bottom: 30px;
}

.hero-actions {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 26px;
}

/* Пиксельная кнопка: контур без углов (тени по четырём сторонам) и фаска */
.btn-pixel {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 4px;
    padding: 8px 26px 12px;
    font-family: "Handjet", sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(#9d7ee3, #7c5cbf);
    box-shadow:
        0 -4px 0 0 var(--pixel-ink), 0 4px 0 0 var(--pixel-ink),
        -4px 0 0 0 var(--pixel-ink), 4px 0 0 0 var(--pixel-ink),
        inset 0 -6px 0 0 #5a3d9e, inset 0 4px 0 0 #c4b5fd,
        0 10px 30px var(--primary-glow);
    transition: transform 0.12s steps(2), filter 0.2s ease;
    cursor: pointer;
}
.btn-pixel:hover { transform: translateY(-3px); filter: brightness(1.12); }
.btn-pixel:active {
    transform: translateY(2px);
    box-shadow:
        0 -4px 0 0 var(--pixel-ink), 0 4px 0 0 var(--pixel-ink),
        -4px 0 0 0 var(--pixel-ink), 4px 0 0 0 var(--pixel-ink),
        inset 0 6px 0 0 #5a3d9e;
}
.btn-pixel:focus-visible { outline: 3px solid var(--accent); outline-offset: 8px; }

.hero-create { background: rgba(22, 22, 37, 0.9); }

/* Подпись над витриной: галерея — примеры того, что получится, а не главное */
.hero-stage-label {
    width: fit-content;
    margin: 0 12px 12px;
    padding: 4px 10px;
    font-size: 0.85rem;
    color: #c9c6e4;
    background: rgba(10, 10, 18, 0.85);
}

.hero-badges {
    list-style: none;
    display: flex;
    gap: 8px 20px;
    flex-wrap: wrap;
    color: #a9a6c8;
    font-size: 0.88rem;
}

.hero-badges li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-badges li::before {
    content: "";
    width: 6px;
    height: 6px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--primary-glow);
}

/* «Экран игры»: ступенчатая рамка, слайды с медленным наездом */
.hero-screen {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    color: var(--text);
    text-decoration: none;
    box-shadow:
        0 0 0 4px var(--pixel-ink),
        0 0 0 8px #7c5cbf,
        0 0 0 12px var(--pixel-ink),
        0 30px 60px rgba(0, 0, 0, 0.55),
        0 0 90px rgba(124, 92, 191, 0.35);
    margin: 12px;
}

.hero-shot {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.9s ease;
    /* Каждый кадр — на своём постоянном слое: без этого браузер создаёт слой
       при старте наезда и убирает при конце, перерисовка давала вспышку */
    will-change: opacity, transform;
    backface-visibility: hidden;
}
/* Смена кадра: новый (.is-active, последний в DOM) проявляется ПОВЕРХ
   прежнего, а прежний (.is-prev) остаётся непрозрачным и продолжает наезд.
   Раньше оба гасли/проявлялись одновременно — в середине перехода сквозь
   них на четверть просвечивал чёрный фон: баннер мигал раз в 7 с. */
.hero-shot.is-active,
.hero-shot.is-prev {
    opacity: 1;
    animation: hero-pan 9s ease-out both;
}
.hero-shot.is-prev { transition: none; }
@keyframes hero-pan {
    from { transform: scale(1.08) translateX(2%); }
    to   { transform: scale(1.0) translateX(0); }
}

.hero-screen-stats {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hero-screen-stats span {
    font-size: 0.72rem;
    color: var(--text);
    background: rgba(11, 11, 20, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.14);
    padding: 1px 8px;
}

.hero-screen-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 6px;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    color: #fff;
    background: rgba(124, 92, 191, 0.82);
    box-shadow:
        0 -4px 0 0 var(--pixel-ink), 0 4px 0 0 var(--pixel-ink),
        -4px 0 0 0 var(--pixel-ink), 4px 0 0 0 var(--pixel-ink),
        inset 0 -5px 0 0 #5a3d9e, inset 0 4px 0 0 #c4b5fd;
    transition: transform 0.2s ease, background 0.2s ease;
}
/* Пульс — прозрачность свечения (анимация на компоновщике); прежний
   filter: drop-shadow перерисовывал кнопку поверх кадров каждый кадр */
.hero-screen-play::before {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: 0 0 18px 4px rgba(196, 181, 253, 0.7);
    opacity: 0;
    pointer-events: none;
    animation: hero-play-pulse 2.4s ease-in-out infinite;
}
.hero-screen:hover .hero-screen-play,
.hero-screen:focus-visible .hero-screen-play {
    transform: translate(-50%, -50%) scale(1.12);
    background: rgba(147, 112, 219, 0.95);
}
@keyframes hero-play-pulse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}
.hero-screen:focus-visible { outline: 3px solid var(--accent); outline-offset: 16px; }

.hero-screen-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 48px 18px 14px;
    background: linear-gradient(to top, rgba(11,11,20,0.92), rgba(11,11,20,0.5) 60%, transparent);
}
.hero-screen-book {
    font-family: "Handjet", sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.1;
    color: #fff;
    text-shadow: 2px 2px 0 var(--pixel-ink);
}
.hero-screen-quest { font-size: 0.9rem; color: var(--text-dim); }

/* Выбор книги: пиксельные вкладки, у активной — полоска времени до смены */
.hero-books {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 26px 12px 0;
}
.hero-book {
    position: relative;
    flex: none;
    overflow: hidden;
    padding: 3px 12px 5px;
    font-family: "Handjet", sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(22, 22, 37, 0.8);
    border: 2px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.hero-book:hover { color: var(--text); border-color: var(--border-hover); }
.hero-book[aria-pressed="true"] {
    color: #fff;
    border-color: var(--primary);
    background: rgba(124, 92, 191, 0.3);
}
.hero-book[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--accent);
    transform-origin: left;
    animation: hero-book-timer var(--hero-interval, 7s) linear both;
}
.hero-books.is-paused .hero-book::after { animation-play-state: paused; }
@keyframes hero-book-timer { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* подложка: ссылка лежит поверх светлых страниц книги на key art */
.hero-download {
    display: inline-block;
    margin: 12px 12px 0;
    padding: 3px 10px;
    font-size: 0.8rem;
    color: var(--text-dim);
    text-decoration: none;
    background: rgba(11, 11, 20, 0.88);
    border: 1px solid var(--border);
    transition: color 0.2s ease, border-color 0.2s ease;
}
.hero-download:hover { color: var(--text); border-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
    .hero-shot.is-active, .hero-shot.is-prev, .hero-screen-play::before, .hero-book[aria-pressed="true"]::after { animation: none; }
    .hero-book[aria-pressed="true"]::after { transform: none; }
}

@media (max-width: 960px) {
    .hero { padding-top: 44px; }
    .hero-inner { grid-template-columns: minmax(0, 1fr); gap: 28px; text-align: center; }
    .hero-copy { display: flex; flex-direction: column; align-items: center; }
    .hero .subtitle { margin-left: auto; margin-right: auto; }
    .hero-actions, .hero-badges { justify-content: center; }
    .hero-stage { width: 100%; max-width: 680px; margin: 0 auto; }
    .hero-stage-label { margin-left: auto; margin-right: auto; text-align: center; }
    .hero-books { justify-content: center; }
    .hero-art::after {
        background: linear-gradient(to bottom, rgba(11,11,20,0.75) 0%, rgba(11,11,20,0.55) 45%, rgba(11,11,20,0.35) 80%, var(--bg) 100%);
    }
}

/* ── Section ── */
.section { margin-bottom: 32px; scroll-margin-top: var(--nav-offset); }

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}

/* ── Form ── */
.quest-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: var(--text);
}

.hint {
    margin-top: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ── Char counter & limit warnings ── */
.char-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.char-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.char-counter--limit {
    color: var(--error);
    font-weight: 600;
}

.char-warning {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--error);
    text-align: center;
}

.drop-hint {
    margin-top: 2px;
}

textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 14px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    min-height: 140px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea::placeholder { color: var(--text-muted); }

/* ── Divider ── */
.divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
}

/* ── File upload ── */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
    cursor: pointer;
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--primary);
    background: rgba(124, 92, 191, 0.05);
    box-shadow: 0 0 16px var(--primary-glow);
}

.drop-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
}

.drop-content p {
    color: var(--text-dim);
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.file-name {
    font-weight: 600;
    color: var(--accent);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    transition: transform var(--transition);
}

.btn-remove:hover { transform: scale(1.2); }

/* ── Buttons ── */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 14px 28px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 0.92rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), border-color var(--transition);
}

.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--border-hover);
}

.btn-play {
    font-size: 1.2rem;
    padding: 16px 40px;
}

/* ── Progress ── */
.progress-container {
    text-align: center;
    padding: 32px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.3s ease;
    box-shadow: 0 0 12px var(--primary-glow);
}

.progress-text {
    color: var(--text-dim);
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.progress-percent {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

/* ── Result / Error ── */
.result-card,
.error-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}

.result-card h2 {
    color: var(--success);
    margin-bottom: 12px;
    text-shadow: 0 0 16px var(--success-glow);
}

.quest-title {
    font-size: 1.15rem;
    margin-bottom: 24px;
    color: var(--text);
}

/* Кампания из глав: число глав и их названия под заголовком */
.quest-campaign {
    margin: -14px 0 24px;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-dim);
}

.result-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-card {
    border-color: var(--error);
    box-shadow: 0 0 20px var(--error-glow);
}

.error-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
    animation: error-emoji-shake 0.6s ease-in-out 0.3s;
}

@keyframes error-emoji-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-12deg); }
    50% { transform: rotate(10deg); }
    75% { transform: rotate(-6deg); }
}

.error-card h2 {
    color: var(--error);
    margin-bottom: 12px;
}

.error-card p {
    color: var(--text-dim);
    margin-bottom: 20px;
}

.error-detail {
    font-size: 0.85rem;
    opacity: 0.65;
    margin-top: -12px;
    margin-bottom: 24px;
    word-break: break-word;
}

/* ── Features ── */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.feature-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3), 0 0 16px var(--accent-glow);
}

/* ── Features groups ── */
.features-header {
    text-align: center;
    margin-bottom: 28px;
}

.features-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.features-subtitle {
    color: var(--text-dim);
    font-size: 1rem;
}

.features-group { margin-bottom: 28px; }

.features-group-title {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.features-group-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.feature-card p {
    font-size: 0.88rem;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ── Footer ── */
.site-footer {
    text-align: center;
    padding: 32px 0 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ── Toast ── */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 20px;
    color: var(--text);
    font-size: 0.9rem;
    box-shadow: var(--shadow);
    animation: toast-in 0.3s ease;
    max-width: 320px;
}

.toast--error { border-color: var(--error); }
.toast--success { border-color: var(--success); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
    .hero { padding: 32px 16px 48px; }
    .hero .subtitle { font-size: 1rem; margin-bottom: 24px; }
    .btn-pixel { font-size: 1.45rem; padding: 7px 20px 11px; }
    .hero-screen { margin: 10px; }
    .hero-screen-book { font-size: 1.35rem; }
    .hero-screen-play { width: 60px; height: 60px; font-size: 1.6rem; }
    .hero-screen-stats span { font-size: 0.66rem; }
    /* вкладки книг — одной строкой с прокруткой */
    .hero-books { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; margin: 22px 0 0; padding: 0 10px 4px; }
    .hero-books::-webkit-scrollbar { display: none; }
    .btn-play { padding: 14px 28px; font-size: 1.05rem; }
    .card { padding: 20px; }
    .site-nav { padding: 10px 16px; }
    .nav-actions .btn-secondary { display: none; }
    .features-grid { grid-template-columns: 1fr; }
}

/* ── Generation Theater ── */
.gen-theater { padding: 8px 0; }

.gen-header { text-align: center; margin-bottom: 24px; position: relative; }

.gen-title {
    font-size: 1.5rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    margin-bottom: 4px;
}

.gen-subtitle { color: var(--text-dim); font-size: 0.92rem; transition: color var(--transition); }

.gen-orb { width: 48px; height: 48px; margin: 0 auto 12px; position: relative; }

.orb-ring {
    position: absolute; inset: 0; border: 2px solid var(--primary); border-radius: 50%;
    animation: orb-spin 2s linear infinite; border-top-color: transparent; border-left-color: transparent;
}

.orb-core {
    position: absolute; inset: 8px;
    background: radial-gradient(circle, var(--accent), var(--primary));
    border-radius: 50%; animation: orb-pulse 1.5s ease-in-out infinite;
}

@keyframes orb-spin { to { transform: rotate(360deg); } }
@keyframes orb-pulse { 0%, 100% { transform: scale(1); opacity: 0.8; } 50% { transform: scale(1.15); opacity: 1; } }

.gen-phases {
    display: flex; gap: 4px; margin-bottom: 20px; overflow-x: auto;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}
.gen-phases::-webkit-scrollbar { display: none; }

.gen-phase {
    flex: 1; min-width: 0; text-align: center; padding: 8px 4px;
    border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
    transition: all var(--transition); opacity: 0.45;
}
.gen-phase.active { opacity: 1; border-color: var(--primary); background: rgba(124,92,191,0.12); box-shadow: 0 0 12px var(--primary-glow); }
.gen-phase.done { opacity: 0.7; border-color: var(--success); background: rgba(76,175,80,0.08); }
.gp-icon { display: block; font-size: 1.1rem; margin-bottom: 2px; }
.gp-label { font-size: 0.68rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen-phase.active .gp-label { color: var(--text); font-weight: 600; }

.gen-progress-bar { width: 100%; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-bottom: 8px; position: relative; }
.gen-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 3px; transition: width 0.4s ease; }
.gen-progress-glow { position: absolute; top: -4px; left: 0; width: 60px; height: 14px; background: radial-gradient(ellipse, var(--primary-glow), transparent); border-radius: 50%; transition: left 0.4s ease; pointer-events: none; }
.gen-progress-pct { text-align: center; color: var(--accent); font-weight: 700; font-size: 0.95rem; margin-bottom: 20px; }

.gen-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.gen-panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 120px; max-height: 220px; overflow: hidden; display: flex; flex-direction: column; }
.gen-panel-title { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; flex-shrink: 0; }

.entity-grid { display: flex; flex-wrap: wrap; gap: 6px; overflow-y: auto; flex: 1; }

.entity-chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 100px; background: var(--surface-3); border: 1px solid var(--border); font-size: 0.78rem; color: var(--text); animation: chip-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap; }
.entity-chip--char { border-color: rgba(167,139,250,0.3); background: rgba(167,139,250,0.08); }
.entity-chip--loc { border-color: rgba(124,92,191,0.3); background: rgba(124,92,191,0.08); }
.entity-chip .chip-icon { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.6rem; flex-shrink: 0; }
.entity-chip--char .chip-icon { background: rgba(167,139,250,0.2); }
.entity-chip--loc .chip-icon { background: rgba(124,92,191,0.2); }

@keyframes chip-in { from { opacity: 0; transform: scale(0.7) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.log-stream { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.log-line { font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace; font-size: 0.72rem; color: var(--text-dim); line-height: 1.4; padding: 3px 0; border-bottom: 1px solid rgba(42,42,74,0.4); animation: log-in 0.3s ease; word-break: break-word; }
.log-line:last-child { color: var(--text); border-bottom: none; }
@keyframes log-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }

.gen-status-msg { text-align: center; color: var(--text-dim); font-size: 0.88rem; animation: fade-pulse 2s ease-in-out infinite; }

/* ── Progress meta row (percent + timer) ── */
.gen-progress-meta { display: flex; align-items: baseline; justify-content: center; gap: 12px; margin-bottom: 20px; }
.gen-progress-meta .gen-progress-pct { margin-bottom: 0; }
.gen-timer { font-family: "JetBrains Mono", "SF Mono", "Fira Code", monospace; font-size: 0.8rem; color: var(--text-dim); background: var(--surface-2); border: 1px solid var(--border); border-radius: 100px; padding: 3px 10px; }
.gen-time-note { text-align: center; font-size: 0.8rem; color: var(--text-dim); margin: -12px 0 20px; }
.gen-time-hint strong { color: var(--text); font-weight: 600; }

/* ── Protagonist card ── */
.protagonist-card { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 auto 16px; padding: 8px 16px; width: fit-content; background: linear-gradient(135deg, rgba(167,139,250,0.12), rgba(124,92,191,0.12)); border: 1px solid rgba(167,139,250,0.35); border-radius: 100px; animation: chip-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.protagonist-card.hidden { display: none; }
.protagonist-icon { font-size: 1rem; }
.protagonist-label { font-size: 0.8rem; color: var(--text-dim); }
.protagonist-name { font-size: 0.92rem; font-weight: 700; color: var(--accent); }

/* ── Panel counters & empty states ── */
.gen-panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.panel-count { min-width: 22px; text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--accent); background: rgba(167,139,250,0.15); border: 1px solid rgba(167,139,250,0.3); border-radius: 100px; padding: 1px 7px; }
.panel-count.hidden { display: none; }
.panel-empty { font-size: 0.78rem; color: var(--text-dim); font-style: italic; opacity: 0.8; margin: auto 0; text-align: center; padding: 12px 8px; animation: fade-pulse 3s ease-in-out infinite; }
.panel-empty.hidden { display: none; }
.gen-panel--characters .gen-panel-title { color: rgba(167,139,250,0.9); }
.gen-panel--locations .gen-panel-title { color: rgba(124,92,191,0.95); }

/* ── Stats chips row ── */
.gen-stats { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 16px; }
.gen-stats.hidden { display: none; }
.stat-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 100px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.75rem; color: var(--text-dim); animation: chip-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); white-space: nowrap; }
.stat-chip .stat-icon { font-size: 0.85rem; }

/* ── Journal: phase headers, events & milestones ── */
.log-line--phase { color: var(--primary); font-weight: 700; text-align: center; border-bottom: none; opacity: 0.85; margin-top: 4px; }
.log-line--milestone { color: var(--accent); }
.log-line--milestone:last-child { color: var(--accent); }
.log-time { color: var(--text-dim); opacity: 0.55; margin-right: 6px; font-size: 0.92em; }
.log-line--event { color: var(--text); border-left: 2px solid var(--accent); padding-left: 8px; }
.log-line--event:last-child { color: var(--text); }
.log-line--done { color: var(--success); font-weight: 700; }
.log-line--done:last-child { color: var(--success); }
@keyframes fade-pulse { 0%, 100% { opacity: 0.7; } 50% { opacity: 1; } }

/* ── Stop button ── */
.btn-stop {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; margin-top: 20px; padding: 14px 0;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.18), rgba(231, 76, 60, 0.08));
    color: #ff6b6b;
    border: 1px solid rgba(231, 76, 60, 0.35); border-radius: var(--radius);
    font-size: 0.95rem; font-weight: 700; cursor: pointer; letter-spacing: 0.02em;
    transition: all var(--transition);
    box-shadow: 0 2px 12px rgba(231, 76, 60, 0.1);
    text-transform: uppercase;
}
.btn-stop:hover {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.3), rgba(231, 76, 60, 0.15));
    border-color: #ff6b6b;
    box-shadow: 0 4px 24px rgba(231, 76, 60, 0.25);
    transform: translateY(-1px);
}
.btn-stop:active { transform: translateY(0) scale(0.98); }
.btn-stop:disabled {
    opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;
}
.btn-stop-icon { font-size: 0.75rem; line-height: 1; }

/* ── Load quest area ── */
.load-quest-area {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.btn-load {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 0.92rem;
}

/* ── Save button in result ── */
.btn-save {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 24px;
    font-size: 0.92rem;
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.btn-save:hover {
    border-color: var(--primary);
    box-shadow: 0 0 16px var(--primary-glow);
}

@media (max-width: 600px) {
    .gen-panels { grid-template-columns: 1fr; }
    .gen-phase .gp-label { font-size: 0.6rem; }
    .gen-title { font-size: 1.3rem; }
}

/* ── Disclaimer ── */
.footer-disclaimer {
    margin-top: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.footer-disclaimer a {
    color: var(--accent);
    text-decoration: none;
}
.footer-disclaimer a:hover {
    text-decoration: underline;
}

/* ── Legal page (disclaimer) ── */
.legal-page {
    max-width: 720px;
    padding-top: 40px;
}

.legal-card h1 {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.legal-updated {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 28px;
}

.legal-section {
    margin-bottom: 24px;
}
.legal-section:last-child {
    margin-bottom: 0;
}
.legal-section h2 {
    font-size: 1.15rem;
    margin-bottom: 8px;
    color: var(--accent);
}
.legal-section p {
    font-size: 0.92rem;
    color: var(--text-dim);
}

/* ── Download section (запуск на своём компьютере) ── */
.download-section { margin-top: 8px; }

.download-card { padding: 28px; }

.download-steps {
    list-style: none;
    counter-reset: download-step;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.download-steps li {
    counter-increment: download-step;
    position: relative;
    padding-left: 44px;
    font-size: 0.92rem;
    color: var(--text-dim);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.download-steps li::before {
    content: counter(download-step);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 0 12px var(--primary-glow);
}
.download-steps a { color: var(--accent); text-decoration: none; }
.download-steps a:hover { text-decoration: underline; }
.download-steps code {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 0.85em;
    color: var(--text);
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    text-decoration: none;
}
.download-btn:hover { text-decoration: none; }

/* Бейдж актуальной версии на кнопке скачивания */
.download-version {
    font-size: 0.78em;
    font-weight: 600;
    background: rgba(11, 11, 20, 0.32);
    border-radius: 999px;
    padding: 3px 10px;
    letter-spacing: 0.3px;
}
.download-version:empty { display: none; }

.download-step-note { color: var(--text-muted); font-size: 0.85rem; }

.download-license {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.download-license a { color: var(--accent); text-decoration: none; }
.download-license a:hover { text-decoration: underline; }

@media (max-width: 600px) {
    .download-steps li { padding-left: 0; padding-top: 42px; align-items: flex-start; }
    .download-steps li::before { top: 6px; }
}

/* ── Footer links & version ── */
.footer-version {
    color: var(--accent);
    font-weight: 600;
}
.footer-links {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.85rem;
}
.footer-links a {
    color: var(--accent);
    text-decoration: none;
}
.footer-links a:hover { text-decoration: underline; }
.footer-links span { color: var(--text-muted); }

/* ── Changelog page ── */
.changelog-loading,
.changelog-empty {
    color: var(--text-dim);
    font-size: 0.92rem;
}
.changelog-release {
    border-left: 2px solid var(--border);
    padding-left: 16px;
    margin-bottom: 28px;
}
.changelog-version {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
}
.changelog-current {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 999px;
    padding: 3px 10px;
    box-shadow: 0 0 10px var(--primary-glow);
}
.changelog-date {
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--text-muted);
}
.changelog-notes {
    margin: 10px 0 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.changelog-notes li {
    font-size: 0.92rem;
    color: var(--text-dim);
}


/* ── Языки (ADR-001 Phase 28): язык квеста, переключатель, предложение ── */
.quest-lang-select {
    width: 100%;
    max-width: 360px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 10px 12px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
}
.quest-lang-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.nav-lang {
    padding: 6px 10px;
    font-family: "Handjet", sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    text-decoration: none;
    border: 2px solid var(--border);
    background: rgba(22, 22, 37, 0.8);
}
.nav-lang:hover { color: var(--text); border-color: var(--border-hover); }
.lang-suggest {
    position: fixed;
    left: 50%;
    bottom: 16px;
    z-index: 150;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 32px);
    padding: 10px 14px;
    color: var(--text);
    background: rgba(11, 11, 20, 0.96);
    border: 2px solid var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-size: 0.95rem;
}
.lang-suggest a { color: var(--accent); font-weight: 700; white-space: nowrap; }
.lang-suggest button {
    background: none;
    border: 0;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 2px 6px;
}
