:root {
    --bg-color: #0d0f14;
    --accent-color: #7c4dff;
    --accent-gradient: linear-gradient(135deg, #7c4dff 0%, #3f51b5 100%);
    --panel-bg: rgba(255, 255, 255, 0.05);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --hp-color: #ff5252;
    --xp-color: #40c4ff;
    --gold-color: #ffd740;
    --glass-blur: blur(12px);
    --msg-player-bg: rgba(124, 77, 255, 0.15);
    --msg-velmira-bg: rgba(255, 255, 255, 0.05);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 77, 255, 0.55) transparent;
}

/* ─── Global scrollbar (Webkit) ─── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.45);
    border-radius: 999px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 77, 255, 0.75);
}

::-webkit-scrollbar-corner {
    background: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: visible;
    box-sizing: border-box;
    padding-bottom: 30px;
    align-self: stretch;
    height: 100vh;
    width: 100vw;
}

h1,
h2,
h3,
.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Background Decorations */
.bg-blur-circle {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-color);
    top: -100px;
    right: -100px;
}

.circle-2 {
    width: 300px;
    height: 300px;
    background: #3f51b5;
    bottom: -50px;
    left: -50px;
}

/* Glass Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 16px;
    gap: 16px;
}

/* Легаси-дубли .game-header/.logo/.player-stats удалены: шапку задают
   .game-header.glass-panel и .header-left/.header-right ниже. */

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #a090c0;
}

.game-layout {
    display: flex;
    flex: 1;
    gap: 16px;
    min-height: 0;
    /* Important for flex child scrolling */
    overflow: visible;
    box-sizing: border-box;
    padding-bottom: 30px;
    align-self: stretch;
}

/* Character Sheet */
.character-sheet {
    width: 340px;
    flex: 0 0 340px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-height: 0;
    overflow-y: auto;
}

.character-portrait {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid var(--accent-color);
    background: #1a1c23;
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.2);
}

.character-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.health-bar-container {
    width: 100%;
    height: 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--panel-border);
}

.health-bar {
    height: 100%;
    background: var(--hp-color);
    transition: width 0.3s ease;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.stats-grid {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

/* Game Console (Chat) */
.game-console {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}


.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.5;
    animation: fadeInSlide 0.3s ease-out forwards;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.velmira {
    align-self: flex-start;
    background: var(--msg-velmira-bg);
    border-bottom-left-radius: 2px;
}

.message.player {
    align-self: flex-end;
    background: var(--msg-player-bg);
    border-bottom-right-radius: 2px;
    color: #fff;
}

.message.system {
    align-self: center;
    background: transparent;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

.msg-image {
    display: block;
    width: 100%;
    max-width: min(100%, 720px);
    max-height: min(52vh, 560px);
    margin-top: 10px;
    border-radius: 12px;
    object-fit: contain;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(124, 77, 255, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
    cursor: zoom-in;
}

.image-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.image-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 6, 14, 0.88);
    backdrop-filter: blur(10px);
}

.image-lightbox-img {
    position: relative;
    z-index: 1;
    display: block;
    max-width: min(96vw, 1600px);
    max-height: 92vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(124, 77, 255, 0.24);
}

.image-lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 2;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(124, 77, 255, 0.35);
    border-radius: 50%;
    background: rgba(16, 12, 26, 0.86);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.image-lightbox-close:hover {
    background: rgba(28, 21, 44, 0.94);
}

@media (max-width: 768px) {
    .message {
        max-width: 92%;
    }

    .msg-image {
        max-width: 100%;
        max-height: min(42vh, 360px);
        border-radius: 10px;
    }

    .image-lightbox {
        padding: 16px;
    }

    .image-lightbox-img {
        max-width: 100%;
        max-height: 84vh;
        border-radius: 12px;
    }
}

/* Input Area */
.input-area {
    min-height: 60px;
    display: flex;
    align-items: flex-end;
    padding: 0 12px 0 20px;
    gap: 12px;
}

#player-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    resize: none;
    line-height: 1.5;
    overflow-y: auto;
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.send-button:hover {
    transform: scale(1.1);
}

.icon-send {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Keyboard / Buttons */
.action-keyboard {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.game-btn {
    padding: 10px 20px;
    border-radius: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.game-btn:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* New styles added here */
body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: radial-gradient(circle at top right, #1a1c2c 0%, #0d0f14 100%);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 10;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

/* Utility hidden state for non-screen elements (modals/images/placeholders). */
.hidden:not(.screen) {
    display: none !important;
}

.quiz-input-panel {
    width: 100%;
    max-width: 640px;
    margin: 0 auto 8px;
    padding: clamp(14px, 2vw, 22px);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: var(--glass-blur);
}

.quiz-input-panel.hidden {
    display: none;
}

/* Текст-шаг (предыстория, способность): прячем пустую сетку карточек и
   центрируем панель ввода по вертикали в свободном пространстве экрана. */
#quiz-screen.quiz-input-mode .quiz-container {
    display: none;
}

#quiz-screen.quiz-input-mode .quiz-input-panel {
    margin-top: auto;
    margin-bottom: auto;
}

.quiz-input-hint {
    margin: 0 0 10px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.quiz-input-hint.hidden {
    display: none;
}

.quiz-input-hint b {
    color: var(--text-primary);
}

#quiz-input-label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#quiz-text-input {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    background: rgba(13, 15, 20, 0.8);
    color: var(--text-primary);
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    min-height: 92px;
    outline: none;
}

#quiz-text-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.2);
}

.quiz-input-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 10px;
    flex-wrap: wrap;
}

.quiz-input-actions .secondary-btn,
.quiz-input-actions .primary-btn {
    min-width: 160px;
}

/* Background Decor */
.bg-blur-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(34px);
    z-index: 1;
    opacity: 0.22;
}

.circle-1 {
    width: 400px;
    height: 400px;
    background: var(--accent-color);
    top: -100px;
    right: -100px;
}

.circle-2 {
    width: 300px;
    height: 300px;
    background: #3f51b5;
    bottom: -50px;
    left: -50px;
}

/* Menu Screen Styles */
#welcome-screen,
#character-name-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: rgba(13, 15, 20, 0.8);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#main-menu-screen,
#characters-screen,
#catalog-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background: rgba(13, 15, 20, 0.8);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

#welcome-screen,
#character-name-screen,
#main-menu-screen,
#characters-screen,
#catalog-screen {
    overflow: hidden;
}

#characters-screen {
    justify-content: flex-start;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 1.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

#catalog-screen {
    justify-content: flex-start;
    align-items: stretch;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 1.5rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

#welcome-screen::before,
#character-name-screen::before,
#main-menu-screen::before,
#characters-screen::before,
#catalog-screen::before {
    content: "";
    position: absolute;
    inset: -20%;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 12% 18%, rgba(124, 77, 255, 0.32) 0%, rgba(124, 77, 255, 0) 44%),
        radial-gradient(circle at 82% 22%, rgba(64, 196, 255, 0.24) 0%, rgba(64, 196, 255, 0) 48%),
        radial-gradient(circle at 52% 86%, rgba(255, 215, 64, 0.14) 0%, rgba(255, 215, 64, 0) 52%),
        linear-gradient(120deg, rgba(18, 20, 30, 0.96), rgba(20, 24, 40, 0.92), rgba(16, 19, 34, 0.95));
    transform: translate3d(0, 0, 0) scale(1.02);
    animation: menuBgDriftLite 24s ease-in-out infinite alternate;
    will-change: transform, opacity;
    display: block;
}

#welcome-screen::after,
#character-name-screen::after,
#main-menu-screen::after,
#characters-screen::after,
#catalog-screen::after {
    content: "";
    position: absolute;
    inset: -30%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.24;
    display: block;
    background:
        radial-gradient(60% 40% at 30% 25%, rgba(124, 77, 255, 0.16), rgba(124, 77, 255, 0)),
        radial-gradient(55% 35% at 75% 70%, rgba(64, 196, 255, 0.12), rgba(64, 196, 255, 0));
    animation: menuBgFadeLite 10s ease-in-out infinite;
    will-change: opacity;
}

#welcome-screen>*,
#character-name-screen>*,
#main-menu-screen>*,
#characters-screen>*,
#catalog-screen>* {
    position: relative;
    z-index: 1;
}

/* На прокручиваемых экранах (overflow-y:auto) декор с inset:-20/-30% растягивал
   область прокрутки → фантомный скролл при коротком контенте. position:fixed
   убирает декор из потока прокрутки, оставляя его фоном во весь экран. */
#characters-screen::before,
#characters-screen::after,
#catalog-screen::before,
#catalog-screen::after {
    position: fixed;
    inset: 0;
}

#welcome-screen .registration-box,
#character-name-screen .registration-box {
    width: min(480px, 100%);
    margin: 0 auto 2rem;
}

#welcome-screen .menu-footer,
#character-name-screen .menu-footer {
    width: min(480px, 100%);
}

.menu-header {
    text-align: center;
    margin-bottom: 3rem;
}

.glow-text {
    font-family: 'Outfit', sans-serif;
    font-size: 4rem;
    font-weight: 800;
    letter-spacing: 0.5rem;
    background: linear-gradient(to bottom, #fff 0%, #7c4dff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(124, 77, 255, 0.5));
    margin-bottom: 0.5rem;
}

/* Приписка «beta» к логотипу VELMIRA */
.beta-badge {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    color: #c9b6ff;
    -webkit-text-fill-color: #c9b6ff;
    background: rgba(124, 77, 255, 0.18);
    border: 1px solid rgba(124, 77, 255, 0.4);
    border-radius: 6px;
    padding: 1px 6px;
    margin-left: 8px;
    vertical-align: super;
    filter: none;
    white-space: nowrap;
}

.logo .beta-badge {
    font-size: 0.6rem;
    margin-left: 6px;
    padding: 0 5px;
}

.fire-particles {
    position: fixed;
    inset: 0;
    z-index: 7000;
    pointer-events: none;
    overflow: hidden;
    mix-blend-mode: screen;
}

.fire-particle {
    position: absolute;
    top: 104vh;
    left: var(--x, 50%);
    width: 1px;
    height: 1px;
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.85);
    animation: fireSparkRise var(--duration, 8s) linear infinite;
    animation-delay: var(--delay, 0s);
    will-change: transform, opacity;
}

.fire-particle-core {
    display: block;
    width: var(--size, 2px);
    height: calc(var(--size, 2px) * 1.75);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 235, 180, 0.95), rgba(255, 145, 64, 0.9) 52%, rgba(255, 90, 40, 0.75));
    box-shadow:
        0 0 3px rgba(255, 205, 130, 0.55),
        0 0 8px rgba(255, 110, 42, 0.28);
    transform: translateX(0);
    animation: fireSparkSway var(--sway-duration, 2.4s) cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite,
        fireSparkFlicker 1.35s ease-in-out infinite;
    animation-delay: var(--sway-delay, 0s), var(--delay, 0s);
    will-change: transform, opacity;
}

.subtitle {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3rem;
    font-size: 0.9rem;
}

#main-menu-info {
    font-family: 'Outfit', sans-serif;
    text-transform: none;
    letter-spacing: 0.04em;
    font-size: clamp(1.1rem, 2.2vw, 1.45rem);
    line-height: 1.5;
    text-align: center;
    color: rgba(233, 236, 244, 0.95);
    max-width: 640px;
    margin: 0 auto;
}

#main-menu-screen.no-characters .registration-box {
    max-width: 680px;
}

#main-menu-screen.no-characters .menu-footer {
    width: min(780px, 100%);
}

.registration-box {
    width: 100%;
    max-width: 400px;
    margin-bottom: 2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.input-group input {
    width: 100%;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Burning outline for name inputs */
#profile-name-input,
#new-character-name-input {
    border-color: rgba(255, 148, 46, 0.7);
    box-shadow:
        0 0 0 1px rgba(255, 148, 46, 0.35),
        0 0 12px rgba(255, 120, 24, 0.45),
        0 0 24px rgba(124, 77, 255, 0.18);
    animation: fireOutlinePulse 2.2s ease-in-out infinite;
}

#profile-name-input:focus,
#new-character-name-input:focus {
    border-color: rgba(255, 171, 64, 0.95);
    box-shadow:
        0 0 0 1px rgba(255, 183, 77, 0.8),
        0 0 14px rgba(255, 138, 34, 0.75),
        0 0 30px rgba(255, 112, 67, 0.55),
        0 0 42px rgba(124, 77, 255, 0.35);
    animation-duration: 1.25s;
}

.theme-selection {
    width: 100%;
    max-width: 800px;
    margin-bottom: 3rem;
}

.menu-footer {
    width: min(760px, 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.menu-footer .primary-btn,
.menu-footer .secondary-btn {
    min-width: 220px;
}

#main-menu-screen .menu-footer {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
}

#main-menu-screen .menu-footer .primary-btn,
#main-menu-screen .menu-footer .secondary-btn {
    width: 100%;
    min-width: 0;
}

/* Контейнер кнопок из ядра на главном экране «растворяется» в грид-сетке
   родителя, чтобы «Продолжить игру» и ядро-кнопки лежали единообразно 2×N. */
#main-menu-screen .menu-core-buttons { display: contents; }

/* Единая типографика кнопок меню из ядра: вторичные (Настройки/Помощь)
   совпадают по размеру/начертанию/высоте текста с основными — отличается
   только фон (по ButtonColor). Контент центрирован по вертикали и горизонтали. */
.menu-core-buttons .primary-btn,
.menu-core-buttons .secondary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    line-height: 1.1;
}

/* Одинокая кнопка в последнем ряду (нечётное число) — на всю ширину и по центру. */
.menu-core-buttons .menu-btn-span {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 360px);
}
/* На главном экране контейнер — display:contents, поэтому span-кнопка
   управляется родительским гридом #main-menu-screen .menu-footer. */
#main-menu-screen .menu-footer .menu-btn-span {
    grid-column: 1 / -1;
    justify-self: center;
    width: min(100%, 360px);
}

/* Цветовые акценты ядро-кнопок по ButtonColor. */
.menu-core-buttons .menu-btn-positive {
    box-shadow: 0 0 0 1px rgba(80, 220, 140, 0.5) inset, 0 8px 22px rgba(0, 0, 0, 0.25);
}
.menu-core-buttons .menu-btn-negative {
    border-color: rgba(255, 99, 99, 0.55);
    color: #ffd9d9;
}


/* Сетка героев и футер выровнены по одной ширине и явно центрированы
   (align-self перебивает align-items родителя — иначе футер «съезжал»).
   На широком ПК до ~5 колонок; при многих героях экран прокручивается
   вертикально (#characters-screen overflow-y:auto), футер уходит вниз. */
#characters-screen .themes-grid,
#characters-screen .menu-footer {
    width: min(1100px, 100%);
    align-self: center;
    margin-left: auto;
    margin-right: auto;
}
#characters-screen .themes-grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 195px));
    justify-content: center;
    max-height: none;
    overflow: visible;
    margin-bottom: 1.25rem;
    gap: 16px;
}
#characters-screen .menu-footer {
    justify-content: center;
    flex-wrap: wrap;
}

#characters-screen .theme-card {
    min-height: 96px;
}

.theme-selection h3 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.theme-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.theme-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.theme-card.selected {
    border-color: var(--accent-color);
    background: rgba(124, 77, 255, 0.1);
    box-shadow: 0 0 15px rgba(124, 77, 255, 0.3);
}

.theme-img {
    height: 120px;
    background-size: cover;
    background-position: center;
}

.theme-info {
    padding: 1rem;
}

.theme-info h4 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.theme-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.primary-btn {
    padding: 1rem 3rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 30px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

#continue-init-btn:not(:disabled),
#continue-character-name-btn:not(:disabled) {
    border: 1px solid rgba(255, 170, 80, 0.85);
    animation: fireButtonIgnite 1.35s ease-in-out infinite;
}

#main-menu-screen.no-characters #new-game-btn:hover,
#main-menu-screen.no-characters #my-characters-btn:hover {
    border: 1px solid rgba(255, 170, 80, 0.85);
    animation: fireButtonIgnite 1.35s ease-in-out infinite;
}

.glow-effect:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(124, 77, 255, 0.6);
    transform: scale(1.05);
}

/* Inventory Panel */
.inventory-panel {
    width: 300px;
    flex: 0 0 300px;
    padding: 20px;
    min-height: 0;
    overflow-y: auto;
}

.inventory-list {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.inv-category-header {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 4px 4px;
    margin-top: 6px;
}

.inv-category-header:first-child {
    margin-top: 0;
}

.inv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.2s ease;
}

.inv-row.inv-equipped {
    background: rgba(124, 77, 255, 0.08);
    border-color: rgba(124, 77, 255, 0.25);
}

.inv-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.inv-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.inv-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.inv-meta {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.inv-equipped-badge {
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 999px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.inv-equip-btn {
    background: rgba(124, 77, 255, 0.15);
    border: 1px solid rgba(124, 77, 255, 0.3);
    color: var(--text-primary);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.inv-equip-btn:hover {
    background: rgba(124, 77, 255, 0.3);
    border-color: rgba(124, 77, 255, 0.5);
}

.inv-equip-btn.equipped {
    background: rgba(255, 77, 77, 0.15);
    border-color: rgba(255, 77, 77, 0.3);
}

.inv-equip-btn.equipped:hover {
    background: rgba(255, 77, 77, 0.3);
}

.inv-empty {
    color: var(--text-secondary);
    font-style: italic;
    padding: 8px 0;
}

/* Loading Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid var(--panel-border);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

@keyframes menuBgFlow {
    0% {
        transform: translate3d(-3%, -2%, 0) scale(1.02) rotate(-1deg);
        filter: hue-rotate(0deg) saturate(1.02) brightness(0.95);
    }

    25% {
        transform: translate3d(3.5%, 1.2%, 0) scale(1.1) rotate(1.2deg);
        filter: hue-rotate(10deg) saturate(1.15) brightness(1.04);
    }

    50% {
        transform: translate3d(-1.2%, 3.2%, 0) scale(1.08) rotate(-0.8deg);
        filter: hue-rotate(16deg) saturate(1.2) brightness(1.06);
    }

    75% {
        transform: translate3d(2.6%, -2.2%, 0) scale(1.11) rotate(0.9deg);
        filter: hue-rotate(5deg) saturate(1.12) brightness(1.02);
    }

    100% {
        transform: translate3d(-3.2%, 2.8%, 0) scale(1.03) rotate(-1.1deg);
        filter: hue-rotate(-12deg) saturate(1.05) brightness(0.96);
    }
}

@keyframes menuAuroraSpin {
    0% {
        transform: rotate(0deg) scale(1.05);
        opacity: 0.35;
    }

    25% {
        transform: rotate(90deg) scale(1.12);
        opacity: 0.6;
    }

    50% {
        transform: rotate(180deg) scale(1.08);
        opacity: 0.45;
    }

    75% {
        transform: rotate(270deg) scale(1.14);
        opacity: 0.62;
    }

    100% {
        transform: rotate(360deg) scale(1.05);
        opacity: 0.35;
    }
}

@keyframes menuBgDriftLite {
    0% {
        transform: translate3d(-1.2%, -1%, 0) scale(1.02);
    }

    50% {
        transform: translate3d(1.4%, 0.8%, 0) scale(1.05);
    }

    100% {
        transform: translate3d(-0.8%, 1.4%, 0) scale(1.03);
    }
}

@keyframes menuBgFadeLite {
    0% {
        opacity: 0.16;
    }

    50% {
        opacity: 0.28;
    }

    100% {
        opacity: 0.18;
    }
}

@keyframes fireSparkRise {
    0% {
        transform: translate3d(0, 0, 0) scale(0.85);
        opacity: 0;
    }

    8% {
        opacity: var(--opacity, 0.65);
    }

    78% {
        opacity: calc(var(--opacity, 0.65) * 0.92);
    }

    100% {
        transform: translate3d(var(--drift, 0px), -132vh, 0) scale(0.55);
        opacity: 0;
    }
}

@keyframes fireSparkSway {
    0% {
        transform: translateX(0);
    }

    12.5% {
        transform: translateX(calc(var(--sway, 8px) * 0.55));
    }

    25% {
        transform: translateX(calc(var(--sway, 8px) * -0.35));
    }

    37.5% {
        transform: translateX(calc(var(--sway, 8px) * 0.9));
    }

    50% {
        transform: translateX(calc(var(--sway, 8px) * -0.65));
    }

    62.5% {
        transform: translateX(calc(var(--sway, 8px) * 0.35));
    }

    75% {
        transform: translateX(calc(var(--sway, 8px) * -1));
    }

    87.5% {
        transform: translateX(calc(var(--sway, 8px) * 0.45));
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes fireSparkFlicker {
    0% {
        opacity: 0.88;
    }

    100% {
        opacity: 1;
    }
}

@keyframes fireOutlinePulse {
    0% {
        box-shadow:
            0 0 0 1px rgba(255, 148, 46, 0.35),
            0 0 10px rgba(255, 120, 24, 0.35),
            0 0 18px rgba(124, 77, 255, 0.15);
    }

    35% {
        box-shadow:
            0 0 0 1px rgba(255, 171, 64, 0.55),
            0 0 16px rgba(255, 138, 34, 0.6),
            0 0 28px rgba(255, 112, 67, 0.35);
    }

    70% {
        box-shadow:
            0 0 0 1px rgba(255, 138, 101, 0.55),
            0 0 12px rgba(255, 99, 71, 0.5),
            0 0 24px rgba(124, 77, 255, 0.25);
    }

    100% {
        box-shadow:
            0 0 0 1px rgba(255, 148, 46, 0.35),
            0 0 10px rgba(255, 120, 24, 0.35),
            0 0 18px rgba(124, 77, 255, 0.15);
    }
}

@keyframes fireButtonIgnite {
    0% {
        box-shadow:
            0 0 0 0 rgba(255, 152, 64, 0.0),
            0 0 10px rgba(255, 120, 24, 0.35),
            0 0 20px rgba(124, 77, 255, 0.25);
        transform: scale(1);
        filter: saturate(1);
    }

    45% {
        box-shadow:
            0 0 0 1px rgba(255, 179, 102, 0.85),
            0 0 20px rgba(255, 138, 34, 0.75),
            0 0 36px rgba(255, 87, 34, 0.45);
        transform: scale(1.03);
        filter: saturate(1.12);
    }

    100% {
        box-shadow:
            0 0 0 0 rgba(255, 152, 64, 0.0),
            0 0 12px rgba(255, 120, 24, 0.42),
            0 0 22px rgba(124, 77, 255, 0.28);
        transform: scale(1);
        filter: saturate(1);
    }
}

/* Quiz Screen */
#quiz-screen {
    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
    padding: clamp(0.75rem, 2vh, 2rem) clamp(0.75rem, 2.5vw, 2rem);
    background: rgba(13, 15, 20, 0.85);
    backdrop-filter: var(--glass-blur);
    perspective: 1000px;
    overflow: hidden;
    position: relative;
}

#quiz-screen::before {
    content: "";
    position: absolute;
    inset: -14%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.28s ease;
    background:
        radial-gradient(circle at 52% 45%, rgba(74, 154, 255, 0.34) 0%, rgba(74, 154, 255, 0.04) 38%, rgba(74, 154, 255, 0) 62%),
        radial-gradient(circle at 20% 32%, rgba(88, 184, 255, 0.2) 0%, rgba(88, 184, 255, 0) 44%),
        radial-gradient(circle at 82% 68%, rgba(58, 130, 234, 0.18) 0%, rgba(58, 130, 234, 0) 46%);
}

body.male-hover-bg #quiz-screen::before {
    opacity: 1;
}

body.female-hover-bg #quiz-screen::before {
    opacity: 1;
    background:
        radial-gradient(circle at 52% 45%, rgba(255, 132, 203, 0.34) 0%, rgba(255, 132, 203, 0.04) 38%, rgba(255, 132, 203, 0) 62%),
        radial-gradient(circle at 20% 32%, rgba(255, 157, 218, 0.2) 0%, rgba(255, 157, 218, 0) 44%),
        radial-gradient(circle at 82% 68%, rgba(234, 98, 176, 0.18) 0%, rgba(234, 98, 176, 0) 46%);
}

body.gender-selected-male #quiz-screen::before {
    opacity: 1;
}

body.gender-selected-female #quiz-screen::before {
    opacity: 1;
    background:
        radial-gradient(circle at 52% 45%, rgba(255, 132, 203, 0.34) 0%, rgba(255, 132, 203, 0.04) 38%, rgba(255, 132, 203, 0) 62%),
        radial-gradient(circle at 20% 32%, rgba(255, 157, 218, 0.2) 0%, rgba(255, 157, 218, 0) 44%),
        radial-gradient(circle at 82% 68%, rgba(234, 98, 176, 0.18) 0%, rgba(234, 98, 176, 0) 46%);
}

.quiz-header {
    text-align: center;
    margin-bottom: clamp(0.4rem, 1.5vh, 1.2rem);
}

.quiz-container {
    width: 100%;
    max-width: 1400px;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.quiz-cards-grid {
    --quiz-cols: 3;
    --quiz-card-scale: 1;
    --quiz-card-base-w: 220px;
    --quiz-card-base-h: 280px;
    --quiz-gap: 18px;
    display: grid;
    grid-template-columns: repeat(var(--quiz-cols), minmax(0, calc(var(--quiz-card-base-w) * var(--quiz-card-scale))));
    grid-auto-rows: calc(var(--quiz-card-base-h) * var(--quiz-card-scale));
    gap: var(--quiz-gap);
    justify-content: center;
    align-content: start;
    justify-items: center;
    align-items: stretch;
    width: 100%;
    height: auto;
    padding: 4px 0;
}

.quiz-cards-grid.quiz-cards-grid--stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    justify-content: flex-start;
    width: min(900px, 100%);
    height: auto;
    margin: 0 auto;
}

.quiz-page-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    min-width: 54px;
    padding: 0;
    border-radius: 999px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 700;
}

.quiz-page-prev {
    left: 8px;
}

.quiz-page-next {
    right: 8px;
}

.quiz-page-indicator {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    color: var(--text-secondary);
    font-size: 0.85rem;
    letter-spacing: 0.08em;
}

/* Beautiful Flying Cards */
.quiz-card {
    width: calc(var(--quiz-card-base-w) * var(--quiz-card-scale));
    height: calc(var(--quiz-card-base-h) * var(--quiz-card-scale));
    border-radius: calc(12px * var(--quiz-card-scale));
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: block;
    padding: 0;
    background: #07050f;
    border: 1.5px solid rgba(80, 60, 140, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform .22s ease, border-color .22s, box-shadow .22s;
    transform-style: preserve-3d;
    opacity: 0;
    animation: flyIn 0.6s ease-out forwards;
}



@keyframes flyIn {
    to {
        opacity: 1;
        transform: translateY(0) rotateX(0);
    }
}

.quiz-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: rgba(160, 120, 255, 0.75);
    box-shadow: 0 16px 48px rgba(80, 40, 200, 0.45);
}

.quiz-card.selected {
    border-color: #ffd740;
    box-shadow: 0 0 0 1px #ffd740, 0 0 32px rgba(255, 215, 64, 0.4);
    transform: scale(1.03);
}

.quiz-card.selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 215, 64, 0.18);
    border: 1px solid rgba(255, 215, 64, 0.6);
    color: #ffd740;
    font-size: 0.65rem;
    font-weight: 800;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    z-index: 10;
    backdrop-filter: blur(6px);
}

.gender-card {
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s ease, box-shadow 0.35s ease;
}

.gender-card-male {
    border-color: rgba(116, 176, 255, 0.62);
}

.gender-card-male:hover {
    border-color: rgba(102, 184, 255, 0.9);
    box-shadow: 0 14px 36px rgba(45, 131, 255, 0.35), 0 0 20px rgba(92, 174, 255, 0.25);
}

.gender-card-female {
    border-color: rgba(255, 132, 196, 0.62);
}

.gender-card-female:hover {
    border-color: rgba(255, 138, 206, 0.95);
    box-shadow: 0 14px 36px rgba(255, 95, 181, 0.35), 0 0 20px rgba(255, 148, 213, 0.25);
}

.card-preview-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.quiz-card p {
    font-size: clamp(0.72rem, calc(0.85rem * var(--quiz-card-scale)), 0.85rem);
    color: var(--text-secondary);
    line-height: 1.4;
}

.quiz-card .desc-text {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
}

.quiz-response-box {
    width: min(900px, 100%);
    margin: 0 auto;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(124, 77, 255, 0.38);
    background: rgba(12, 20, 38, 0.72);
    box-shadow: 0 8px 24px rgba(9, 14, 26, 0.36);
}

.quiz-cards-grid.quiz-cards-grid--stack .quiz-response-box {
    width: 100%;
}

.quiz-input-panel.ability-review-panel .quiz-input-actions {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 12px;
}

.quiz-input-panel.ability-review-panel .quiz-input-actions .primary-btn,
.quiz-input-panel.ability-review-panel .quiz-input-actions .secondary-btn {
    width: 100%;
    min-width: 0;
}

.quiz-response-text {
    color: #e7ecf8;
    font-size: 0.96rem;
    line-height: 1.55;
    text-align: left;
}

.quiz-footer {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
}

.quiz-footer .primary-btn,
.quiz-footer .secondary-btn {
    min-width: 180px;
}

.secondary-btn {
    padding: 0.8rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 30px;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.3s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.catalog-layout {
    width: 100%;
    max-width: 1220px;
    display: flex;
    flex-direction: column;
    margin: 10px auto 0;
}

.catalog-list-block {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.catalog-helper {
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(24, 30, 48, 0.82) 0%, rgba(15, 20, 33, 0.68) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.catalog-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 195px));
    gap: 16px;
    justify-content: center;
    align-content: start;
    width: 100%;
    height: auto;
    padding-bottom: 8px;
}

.catalog-card {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: block;
    padding: 0;
    background: #07050f;
    border: 1.5px solid rgba(80, 60, 140, 0.4);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
    transition: transform .22s ease, border-color .22s, box-shadow .22s;
    transform-style: preserve-3d;
    appearance: none;
    -webkit-appearance: none;
    color: inherit;
    font: inherit;
}

.catalog-empty-state {
    display: grid;
    place-items: center;
    min-height: 220px;
    border-radius: 18px;
    background: rgba(16, 21, 33, 0.72);
    border: 1px dashed rgba(255, 255, 255, 0.16);
    color: var(--text-secondary);
    text-align: center;
    padding: 24px;
}

.catalog-card:hover {
    transform: translateY(-6px) scale(1.03);
    border-color: rgba(160, 120, 255, 0.75);
    box-shadow: 0 16px 48px rgba(80, 40, 200, 0.45);
}

.catalog-card.active,
.catalog-card.selected {
    border-color: #ffd740;
    box-shadow: 0 0 0 1px #ffd740, 0 0 32px rgba(255, 215, 64, 0.4);
}

.catalog-card:focus-visible {
    outline: none;
    border-color: rgba(160, 120, 255, 0.9);
    box-shadow: 0 0 0 2px rgba(124, 77, 255, 0.6);
}

.catalog-page-indicator {
    min-width: 64px;
    text-align: center;
    color: #d9d7ea;
    font-size: 1rem;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(19, 24, 38, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.catalog-side-nav {
    display: none;
}

@media (max-height: 840px) {
    #catalog-screen {
        overflow-y: auto;
        padding-top: 0.75rem;
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    #catalog-screen .menu-header {
        margin-bottom: 0.65rem;
    }

    .catalog-layout {
        margin-top: 0;
    }

    .catalog-menu-footer {
        margin-top: 8px;
    }
}

/* Кикер «Готовый герой» и блок описания внутри единой модалки персонажа. */
.hero-modal-kicker {
    margin: 0 0 12px;
    text-align: center;
    color: #cdb6ff;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.hero-modal-desc {
    white-space: pre-wrap;
    line-height: 1.6;
    margin: 8px 0 0;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(221, 227, 248, 0.86);
    font-size: 0.9rem;
}

.catalog-menu-footer {
    width: 100%;
    margin-top: 14px;
}

/* ─── Karaoke Lyrics ─── */
.karaoke-lyrics {
    position: fixed;
    right: 18px;
    bottom: 76px;
    max-width: min(420px, calc(100vw - 36px));
    min-width: 180px;
    z-index: 1199;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

.karaoke-line {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: clamp(0.82rem, 1.8vw, 1.05rem);
    font-weight: 500;
    line-height: 1.5;
    color: #f0ecff;
    text-align: right;
    text-shadow:
        0 0 12px rgba(124, 77, 255, 0.7),
        0 0 28px rgba(124, 77, 255, 0.35),
        0 1px 3px rgba(0, 0, 0, 0.8);
    padding: 6px 14px;
    border-radius: 8px;
    background: rgba(11, 15, 28, 0.55);
    border: 1px solid rgba(124, 77, 255, 0.18);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    will-change: opacity, transform;
}

.karaoke-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.karaoke-line.fading {
    opacity: 0;
    transform: translateY(-6px);
}

/* Accent pulse on active word rhythmic feel */
@keyframes karaokePulse {

    0%,
    100% {
        text-shadow: 0 0 12px rgba(124, 77, 255, 0.7), 0 0 28px rgba(124, 77, 255, 0.35), 0 1px 3px rgba(0, 0, 0, 0.8);
    }

    50% {
        text-shadow: 0 0 18px rgba(124, 77, 255, 0.95), 0 0 36px rgba(124, 77, 255, 0.55), 0 1px 3px rgba(0, 0, 0, 0.9);
    }
}

.karaoke-line.visible {
    animation: karaokePulse 2.2s ease-in-out infinite;
}

/* Progress bar inside karaoke line */
.karaoke-line .karaoke-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, #7c4dff, #b388ff);
    border-radius: 0 0 8px 8px;
    transition: width 0.15s linear;
    pointer-events: none;
}

.karaoke-line {
    position: relative;
    overflow: hidden;
}

@media (max-width: 768px) {
    /* Караоке — в одну строку СЛЕВА от кнопок музыки (та же нижняя полоса). */
    .karaoke-lyrics {
        left: 12px;
        right: 116px;            /* место под кнопки музыки/фуллскрина справа */
        bottom: calc(16px + env(safe-area-inset-bottom));
        max-width: none;
        align-items: flex-start;
    }

    .karaoke-line {
        font-size: clamp(0.72rem, 3vw, 0.9rem);
        padding: 6px 10px;
        text-align: left;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ─── Мобильная адаптация главного меню ─── */
@media (max-width: 768px) {
    /* Колонки сжимаются под экран (было minmax(220px,...) → грид вылезал и резал текст). */
    #main-menu-screen .menu-footer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    /* Текст кнопок всегда виден: перенос + уменьшение шрифта при нехватке места. */
    .menu-core-buttons .primary-btn,
    .menu-core-buttons .secondary-btn,
    #main-menu-screen .menu-footer .primary-btn,
    #main-menu-screen .menu-footer .secondary-btn {
        padding: 0.7rem 0.5rem;
        font-size: clamp(0.6rem, 3vw, 0.95rem);
        letter-spacing: 0.01rem;
        white-space: normal;
        word-break: break-word;
        text-align: center;
        min-width: 0;
        line-height: 1.15;
    }

    /* Меню прокручивается, снизу зарезервирована полоса под музыку/караоке —
       чтобы контролы не перекрывали кнопки и карточки. */
    #main-menu-screen {
        justify-content: flex-start;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 1.25rem 0.9rem calc(64px + env(safe-area-inset-bottom));
    }
    /* Декор фиксируем фоном, иначе inset:-20% даёт фантомную прокрутку. */
    #main-menu-screen::before,
    #main-menu-screen::after {
        position: fixed;
        inset: 0;
    }

    /* Закреплённая нижняя полоса: кнопки музыки/фуллскрина справа, высотой ~как текст караоке. */
    .music-controls {
        right: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        gap: 8px;
    }
    .music-toggle-btn,
    .fullscreen-toggle-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    /* На прокручиваемых экранах тоже резервируем место под полосу контролов. */
    #characters-screen,
    #catalog-screen {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    /* Кнопки добавления ключей (менеджер ключей) — сжимаются, не вылезают за экран. */
    .keys-add-actions button {
        min-width: 0;
    }
}

.music-controls {
    --music-panel-width: 220px;
    --music-panel-gap: 10px;
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    z-index: 1200;
}

.music-toggle-btn,
.fullscreen-toggle-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(11, 15, 28, 0.72);
    color: #ece8ff;
    font-size: 1.35rem;
    line-height: 1;
    /* Центрируем содержимое (SVG-иконка фуллскрина / глиф ноты). */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    position: relative;
    z-index: 2;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.music-toggle-btn.playing {
    animation: musicNoteFloat 1.7s ease-in-out infinite, musicNoteGlowLite 1.3s ease-in-out infinite;
    box-shadow: 0 0 14px rgba(124, 77, 255, 0.6), 0 10px 26px rgba(0, 0, 0, 0.35);
}

.music-toggle-btn.playing::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1px solid rgba(124, 77, 255, 0.45);
    animation: musicNotePulse 1.7s ease-out infinite;
}

.fullscreen-toggle-btn {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Inline-SVG иконки фуллскрина (вместо эмодзи — рендерятся одинаково на всех ОС). */
.fullscreen-toggle-btn .icon-fs {
    width: 20px;
    height: 20px;
    display: block;
}
.fullscreen-toggle-btn .icon-fs-exit { display: none; }
.fullscreen-toggle-btn.active .icon-fs-enter { display: none; }
.fullscreen-toggle-btn.active .icon-fs-exit { display: block; }

.fullscreen-toggle-btn.active {
    box-shadow: 0 0 12px rgba(124, 77, 255, 0.55), 0 10px 26px rgba(0, 0, 0, 0.35);
}

.music-controls.panel-open .music-toggle-btn,
.music-controls.panel-open .fullscreen-toggle-btn {
    transform: translateX(calc(-1 * (var(--music-panel-width) + var(--music-panel-gap))));
}

@keyframes musicNoteFloat {
    0% {
        box-shadow: 0 0 10px rgba(124, 77, 255, 0.45), 0 10px 24px rgba(0, 0, 0, 0.35);
    }

    50% {
        box-shadow: 0 0 18px rgba(124, 77, 255, 0.78), 0 12px 28px rgba(0, 0, 0, 0.45);
    }

    100% {
        box-shadow: 0 0 10px rgba(124, 77, 255, 0.45), 0 10px 24px rgba(0, 0, 0, 0.35);
    }
}

@keyframes musicNotePulse {
    0% {
        opacity: 0.9;
        transform: scale(0.9);
    }

    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

@keyframes musicNoteGlowLite {
    0% {
        color: #ece8ff;
        text-shadow: 0 0 3px rgba(124, 77, 255, 0.35);
    }

    50% {
        color: #ffffff;
        text-shadow: 0 0 8px rgba(124, 77, 255, 0.75);
    }

    100% {
        color: #ece8ff;
        text-shadow: 0 0 3px rgba(124, 77, 255, 0.35);
    }
}

.music-volume-panel {
    width: var(--music-panel-width);
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(11, 15, 28, 0.62);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
    position: absolute;
    right: 0;
    bottom: 0;
    opacity: 1;
    visibility: visible;
    transform: translateX(0) scale(1);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.music-volume-panel.collapsed {
    opacity: 0;
    visibility: hidden;
    transform: translateX(12px) scale(0.98);
    pointer-events: none;
}

.music-volume-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(226, 232, 244, 0.86);
}

#music-volume-slider {
    width: 100%;
    height: 18px;
    cursor: pointer;
    accent-color: #7c4dff;
}

#music-volume-slider::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, #7c4dff 0%, #5f6df5 100%);
}

#music-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #d7c8ff;
    margin-top: -5px;
    box-shadow: 0 0 10px rgba(124, 77, 255, 0.6);
}

#music-volume-slider::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(90deg, #7c4dff 0%, #5f6df5 100%);
}

#music-volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #d7c8ff;
    box-shadow: 0 0 10px rgba(124, 77, 255, 0.6);
}

@media (max-width: 1024px) {
    .inventory-panel {
        display: none;
    }
}

@media (max-width: 768px) {
    .character-sheet {
        display: none;
    }

    .game-layout {
        padding-bottom: 80px;
    }

    #quiz-screen {
        padding: 0.75rem;
    }

    .quiz-header {
        width: min(520px, 100%);
        margin-bottom: 0.85rem;
    }

    #quiz-question {
        font-size: clamp(2.2rem, 12vw, 3.2rem);
        letter-spacing: 0.12rem;
        line-height: 0.95;
        margin-bottom: 0.35rem;
        overflow-wrap: anywhere;
    }

    #quiz-subtitle {
        letter-spacing: 0.18rem;
        font-size: 0.78rem;
        line-height: 1.45;
    }

    #welcome-screen,
    #character-name-screen,
    #main-menu-screen,
    #characters-screen,
    #catalog-screen {
        padding: 1rem;
    }

    #catalog-screen {
        justify-content: flex-start;
        align-items: stretch;
        overflow-y: auto;
        overflow-x: hidden;
        padding-top: 0.9rem;
    }

    #characters-screen {
        justify-content: flex-start;
        align-items: stretch;
        overflow-y: auto;
        overflow-x: hidden;
        padding-top: 0.9rem;
    }

    #characters-screen .menu-header {
        margin-bottom: 1.1rem;
    }

    #characters-screen .glow-text {
        font-size: clamp(2.6rem, 13vw, 3.6rem);
        letter-spacing: 0.18rem;
        line-height: 0.95;
        margin-bottom: 0.35rem;
    }

    #characters-screen .subtitle {
        letter-spacing: 0.18rem;
        font-size: 0.82rem;
    }

    .menu-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .menu-footer .primary-btn,
    .menu-footer .secondary-btn {
        width: 100%;
        min-width: 0;
    }

    .catalog-layout,
    .catalog-list-block,
    .catalog-list {
        min-height: 0;
        overflow: visible !important;
        flex-shrink: 0 !important;
    }

    .catalog-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        justify-items: center;
        align-items: start;
        height: auto !important;
        flex-shrink: 0 !important;
    }

    #catalog-screen .glow-text::after {
        content: ' •';
        color: #7c4dff;
    }

    .catalog-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        width: min(520px, 100%);
        margin: 0 auto;
        height: auto;
    }

    .catalog-card {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 380px !important;
        aspect-ratio: 3 / 4 !important;
    }

    .catalog-list-block {
        width: min(520px, 100%);
        max-width: 100%;
        min-height: 0;
        height: auto !important;
        flex-shrink: 0 !important;
    }

    #characters-screen .themes-grid,
    #characters-screen .menu-footer {
        width: min(520px, 100%);
        max-width: 100%;
    }

    #characters-screen .themes-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 0 auto 1rem;
    }


    .music-controls {
        --music-panel-width: min(180px, calc(100vw - 20px));
        right: 10px;
        bottom: 10px;
    }

    /* На игровом экране плавающие контролы (фуллскрин/звук) поднимаются над
       композером, чтобы не перекрывать кнопку отправки. :has() выбирает активный
       (не .hidden) game-screen. */
    body:has(#game-screen:not(.hidden)) .music-controls {
        bottom: 150px;
    }

    .music-toggle-btn {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }

    .fullscreen-toggle-btn {
        width: 42px;
        height: 42px;
        font-size: 1rem;
    }

    .music-volume-panel {
        padding: 8px 10px;
    }

    .music-volume-label {
        font-size: 0.66rem;
        letter-spacing: 0.1em;
    }

    .quiz-input-panel.ability-review-panel .quiz-input-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1024px),
(prefers-reduced-motion: reduce) {
    .bg-blur-circle {
        display: none;
    }

    #welcome-screen::after,
    #character-name-screen::after,
    #main-menu-screen::after,
    #characters-screen::after,
    #catalog-screen::after {
        display: none;
    }

    #welcome-screen::before,
    #character-name-screen::before,
    #main-menu-screen::before,
    #characters-screen::before,
    #catalog-screen::before {
        animation: none;
    }

    #welcome-screen,
    #character-name-screen,
    #main-menu-screen,
    #characters-screen,
    #catalog-screen {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    #quiz-screen {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding-bottom: 0;
    }

    .quiz-container {
        overflow-y: auto;
        overflow-x: hidden;
        align-items: flex-start;
        flex: 1 1 0%;
        min-height: 0;
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }

    .quiz-cards-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        width: min(520px, 100%);
        margin: 0 auto;
        height: auto;
    }

    .quiz-card {
        display: block !important;
        position: relative !important;
        width: 100% !important;
        height: auto !important;
        min-height: 380px !important;
        aspect-ratio: 11 / 14 !important;
    }

    /* Карточки-картинки (выбор пола и т.п.): все слои абсолютны, поэтому при height:auto
       карточка схлопывается в полоску. Возвращаем высоту через портретную пропорцию. */
    .quiz-cards-grid.media-cards .quiz-card {
        aspect-ratio: 11 / 14;
        height: auto;
        min-height: 220px;
        max-height: 70vh;
    }

    .quiz-page-nav,
    .quiz-page-indicator {
        display: none !important;
    }

    .quiz-footer {
        /* Фиксируем прямо над нижней полосой музыки/караоке — без зазора. */
        position: fixed;
        left: 0;
        right: 0;
        bottom: calc(56px + env(safe-area-inset-bottom));
        z-index: 20;
        width: min(520px, calc(100% - 24px));
        margin: 0 auto;
        gap: 10px;
        padding: 0.4rem 0;
    }

    /* Текст-шаги (предыстория, способность): «Назад» переносится в панель к остальным
       кнопкам, поэтому отдельный нижний футер прячем. */
    #quiz-screen.hide-quiz-footer .quiz-footer {
        display: none;
    }

    /* Кнопки футера делят ширину поровну и сжимаются — «Продолжить» не уезжает за экран. */
    .quiz-footer .primary-btn,
    .quiz-footer .secondary-btn {
        min-width: 0;
        flex: 1 1 0;
        padding: 0.7rem 0.5rem;
        font-size: clamp(0.78rem, 3.4vw, 1rem);
        white-space: nowrap;
    }

    /* Кнопки текст-шага (Сгенерировать/Отправить, Пропустить) — тоже гибкие. */
    .quiz-input-actions .secondary-btn,
    .quiz-input-actions .primary-btn {
        min-width: 0;
        flex: 1 1 0;
        padding: 0.7rem 0.5rem;
        font-size: clamp(0.78rem, 3.2vw, 0.95rem);
    }

    .fire-particles {
        opacity: 0.7;
    }
}

@media (max-width: 680px) {
    .catalog-list {
        gap: 12px;
    }

    .catalog-menu-footer {
        margin-top: 12px;
    }
}

/* Hard performance mode + strict hover preview overlay (override duplicate legacy rules). */
.bg-blur-circle,
#welcome-screen::after,
#character-name-screen::after,
#main-menu-screen::after,
#characters-screen::after,
#catalog-screen::after {
    display: none !important;
    animation: none !important;
    filter: none !important;
}

.glass-panel,
#welcome-screen,
#character-name-screen,
#main-menu-screen,
#characters-screen,
#catalog-screen,
.music-volume-panel {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

.glow-text {
    filter: none !important;
}

/* Skill Check UI */
.skill-check-card {
    background: linear-gradient(145deg, rgba(124, 77, 255, 0.2), rgba(63, 81, 181, 0.1));
    border: 1px solid rgba(124, 77, 255, 0.3);
    border-radius: 16px;
    width: min(100%, 32rem);
    min-height: 0;
    padding: 28px 24px 34px;
    margin: 16px 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    align-self: center;
    animation: slideInUp 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.skill-check-card.resolved {
    display: block !important;
    min-height: max-content !important;
    height: max-content !important;
    max-height: none !important;
    overflow: visible !important;
    align-self: center;
}

.skill-check-card.resolved > * {
    position: relative !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.skill-check-card.resolved .skill-check-description,
.skill-check-card.resolved .skill-check-details,
.skill-check-card.resolved .skill-check-replica,
.skill-check-card.resolved .skill-roll-summary {
    width: 100% !important;
    max-width: none !important;
}

.skill-check-header {
    font-size: 0.8rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 12px;
    font-weight: 700;
    opacity: 0.8;
}

.skill-check-description {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    width: 100%;
    max-width: none;
    line-height: 1.4;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    white-space: normal;
    overflow-wrap: anywhere;
    text-wrap: pretty;
}

.skill-check-details {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

.skill-check-replica {
    width: min(100%, 28rem);
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(8, 12, 24, 0.34);
    border: 1px solid rgba(124, 77, 255, 0.18);
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.96rem;
    line-height: 1.5;
    text-align: left;
}

.dice-container {
    width: 130px;
    height: 130px;
    margin: 0 auto;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
}

.skill-check-card .dice-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 12px;
    padding-top: 0;
    padding-bottom: 18px;
    min-height: 0;
    text-align: center;
}

.skill-check-card .dice-area.resolved {
    display: none;
}

.dice-container::before {
    content: '';
    position: absolute;
    width: 100px;
    height: 20px;
    background: rgba(124, 77, 255, 0.2);
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    filter: blur(10px);
    border-radius: 50%;
}

.dice-container:hover {
    transform: scale(1.1) translateY(-5px);
}

.dice-container:hover .dice-image {
    filter: drop-shadow(0 0 25px rgba(124, 77, 255, 0.8));
}

.dice-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(124, 77, 255, 0.5));
    transition: filter 0.3s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.dice-rolling {
    animation: hyperRoll 0.4s infinite linear;
}

@keyframes hyperRoll {
    0% {
        transform: rotate(0deg) scale(1);
    }

    25% {
        transform: rotate(90deg) translate(2px, -2px);
    }

    50% {
        transform: rotate(180deg) scale(0.95);
    }

    75% {
        transform: rotate(270deg) translate(-2px, 2px);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.roll-result-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

.roll-value {
    font-size: 3.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px #000, 0 0 30px var(--accent-color);
    animation: scaleInBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.roll-outcome {
    margin-top: 16px;
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0;
    transform: translateY(10px);
}

.roll-outcome.visible {
    animation: fadeInUp 0.5s ease forwards;
    animation-delay: 0.3s;
}

.outcome-success {
    color: #4caf50;
    text-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
}

.outcome-fail {
    color: #f44336;
    text-shadow: 0 0 20px rgba(244, 67, 54, 0.4);
}

@keyframes scaleInBounce {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    70% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.roll-btn-hint {
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
}

@media (max-width: 640px) {
    .skill-check-card {
        width: 100%;
        min-height: 0;
        padding: 24px 18px 28px;
    }

    .skill-check-description {
        font-size: 1.1rem;
        max-width: 100%;
    }

    .skill-check-card .dice-area {
        min-height: 0;
        padding-top: 0;
        padding-bottom: 12px;
    }

    .dice-container {
        width: 118px;
        height: 118px;
    }
}

.skill-roll-summary {
    margin-top: 14px;
    width: 100%;
    max-width: 100%;
    text-align: left;
    background: rgba(8, 16, 34, 0.72);
    border: 1px solid rgba(124, 77, 255, 0.35);
    border-radius: 10px;
    padding: 12px 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    box-sizing: border-box;
}

.skill-roll-summary .skill-roll-title {
    font-weight: 700;
    margin-bottom: 8px;
    color: #e8eeff;
}

.skill-roll-summary .skill-roll-line {
    font-size: 0.95rem;
    line-height: 1.4;
    color: #d9e3ff;
}

.skill-roll-summary .skill-roll-status {
    margin-top: 8px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.skill-roll-summary.success .skill-roll-status {
    color: #65d98a;
}

.skill-roll-summary.fail .skill-roll-status {
    color: #ff7b7b;
}


/* --- DARK FANTASY UI REDESIGN --- */

.app-bg-blur {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    --scene-image: url('../assets/placeholder_location.jpg');
    background-image:
        linear-gradient(rgba(10, 8, 18, 0.58), rgba(10, 8, 18, 0.74)),
        var(--scene-image);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    filter: blur(2px) brightness(0.68);
    transform: scale(1.08);
    transform-origin: center;
    transition: background-image 0.35s ease, filter 0.35s ease;
    will-change: background-image, filter;
    z-index: -1;
}

.app-bg-blur.has-dynamic-image {
    filter: blur(3px) brightness(0.64);
}

/* Header Redesign */
.game-header.glass-panel {
    background: rgba(20, 15, 30, 0.85);
    border-bottom: 2px solid rgba(124, 77, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6), inset 0 -1px 10px rgba(124, 77, 255, 0.2);
    border-radius: 0;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-left .logo {
    font-size: 1.2rem;
    color: #e0e0e0;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
    white-space: nowrap;
}

.header-left .logo .accent {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    vertical-align: middle;
    padding: 2px 6px;
    margin-left: 4px;
    border-radius: 6px;
    background: rgba(124, 77, 255, 0.18);
    border: 1px solid rgba(124, 77, 255, 0.4);
    color: var(--accent-color);
}

/* Правый кластер: всё про игрока в одном месте (юзер · лимиты · золото · XP · настройки). */
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
}

.header-right .stat-item { flex-shrink: 0; }

.header-limits {
    display: flex;
    align-items: center;
    min-width: 0;
}

.limit-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    max-width: 100%;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(124, 77, 255, 0.32);
    background: rgba(124, 77, 255, 0.08);
    box-shadow: inset 0 0 14px rgba(124, 77, 255, 0.08);
    color: #cfc5ea;
    font-size: 0.78rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.limit-chip strong {
    color: #f5f1ff;
    font-weight: 700;
}

@media (max-width: 1100px) {
    .header-limits {
        display: none;
    }
}

.icon-btn {
    background: none;
    border: none;
    color: #a090c0;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s, text-shadow 0.3s;
}

.icon-btn:hover {
    color: #fff;
    text-shadow: 0 0 10px rgba(124, 77, 255, 0.8);
}

/* Panel Styles */
.game-layout {
    padding: 20px;
    gap: 20px;
}

.character-sheet.glass-panel,
.inventory-panel.glass-panel,
.chat-log.glass-panel {
    background: rgba(15, 10, 25, 0.7);
    border: 1px solid rgba(100, 80, 150, 0.3);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(124, 77, 255, 0.05);
    backdrop-filter: blur(12px);
}

/* Character Sheet Tweaks */
.character-portrait {
    border: 2px solid rgba(200, 180, 255, 0.4);
    box-shadow: 0 0 15px rgba(124, 77, 255, 0.4);
    border-radius: 16px;
    padding: 4px;
    /* inner glow effect space */
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.2), rgba(0, 0, 0, 0.8));
}

.character-portrait img {
    border-radius: 12px;
}

.health-bar-container {
    border: 1px solid rgba(255, 50, 50, 0.4);
    box-shadow: 0 0 10px rgba(255, 50, 50, 0.2);
    border-radius: 8px;
    height: 20px;
}

.health-bar {
    background: linear-gradient(90deg, #8b0000, #ff4040);
}

/* Stats Grid Redesign */
.stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 10px;
}

.stat-box {
    background: rgba(30, 20, 45, 0.6);
    border: 1px solid rgba(120, 100, 180, 0.4);
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.stat-name {
    font-size: 0.7rem;
    color: #a090c0;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

/* Inventory Panel Additions */
.inventory-panel {
    width: 250px;
    flex: 0 0 250px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.inventory-panel h3 {
    text-align: center;
    color: #e0e0e0;
    margin-bottom: 15px;
    font-size: 1.1rem;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(124, 77, 255, 0.3);
    padding-bottom: 10px;
}

/* Chat Redesign */
.chat-log {
    padding: 20px 40px;
    /* More horizontal padding for floating bubbles */
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    width: 100%;
}

.message-wrapper.velmira {
    align-items: flex-start;
}

.message-wrapper.player {
    align-items: flex-end;
}

.message-sender {
    font-size: 0.75rem;
    color: #ffb74d;
    /* Gold for DM */
    margin-bottom: 4px;
    letter-spacing: 1px;
    margin-left: 10px;
}

.message-wrapper.player .message-sender {
    display: none;
    /* Hide player name above bubble for now */
}

.message {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.message.velmira {
    background: rgba(30, 20, 45, 0.85);
    border: 1px solid rgba(255, 183, 77, 0.4);
    /* Gold border */
    color: #e0e0e0;
    border-top-left-radius: 4px;
}

.message.player {
    background: rgba(50, 30, 90, 0.85);
    /* Dark purple */
    border: 1px solid rgba(100, 180, 255, 0.4);
    /* Neon blue border */
    color: #fff;
    border-top-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), 0 0 10px rgba(100, 180, 255, 0.1);
}

/* Input Area Redesign */
.input-area.glass-panel {
    background: rgba(20, 15, 30, 0.8);
    border: 1px solid rgba(124, 77, 255, 0.4);
    border-radius: 30px;
    padding: 12px 10px 12px 25px;
    margin: 0 20px 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(124, 77, 255, 0.1);
    min-height: 88px;
}

#player-input {
    font-size: 0.95rem;
    color: #e0e0e0;
    min-height: calc(1.5em * 3);
    max-height: calc(1.5em * 15);
    padding: 0;
}

#player-input::placeholder {
    color: #706080;
}

#player-input::-webkit-scrollbar {
    width: 8px;
}

#player-input::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
}

#player-input::-webkit-scrollbar-thumb {
    background: rgba(124, 77, 255, 0.7);
    border-radius: 999px;
    border: 2px solid rgba(20, 15, 30, 0.8);
}

#player-input::-webkit-scrollbar-thumb:hover {
    background: rgba(140, 98, 255, 0.9);
}

.wand-btn {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at center, #9c27b0, #4a148c);
    box-shadow: 0 0 15px #9c27b0;
    border: 2px solid #ce93d8;
    color: #fff;
    font-size: 1.2rem;
}

.wand-btn:hover {
    box-shadow: 0 0 25px #e1bee7;
    transform: scale(1.05) rotate(-10deg);
}

/* Игровая шапка: логин, название, лимиты (энергия/запросы), золото/XP, меню, настройки. */
#game-screen>header.game-header:first-of-type {
    display: flex;
}


/* --- USER FEEDBACK TWEAKS --- */

/* Expand Side Panels */
.character-sheet {
    width: 320px !important;
    flex: 0 0 320px !important;
}

.inventory-panel {
    width: 300px !important;
    flex: 0 0 300px !important;
}

/* Revert send button styling */
.input-area.glass-panel .send-button {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    border-radius: 50%;
    box-shadow: none;
    /* remove wander glow */
}

.input-area.glass-panel .send-button:hover {
    transform: scale(1.1);
    box-shadow: none;
}

.icon-send {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* --- AVATAR FULL WIDTH --- */
.character-portrait {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    /* Контейнер — flex-колонка с overflow; без этого портрет
       сжимается flex-shrink'ом почти в ноль и виден только как полоска. */
    flex-shrink: 0;
    border-radius: 12px;
    padding: 2px;
}

.character-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

/* --- 3D DICE OVERLAY --- */
#dice3d-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: transparent;
    pointer-events: auto;
}

#dice3d-overlay.hidden {
    display: none;
}

#dice3d-canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10000;
}

#dice3d-instruction {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: #94a3b8;
    font-size: 1.2rem;
    animation: pulse 2s infinite;
    z-index: 10001;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    }

    100% {
        opacity: 0.6;
    }
}

#dice3d-result-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 120px;
    font-weight: 900;
    color: #ef4444;
    text-shadow: 0 0 30px rgba(239, 68, 68, 0.8), 4px 4px 0px #000;
    opacity: 0;
    z-index: 10002;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#dice3d-fallback {
    position: absolute;
    left: 50%;
    top: 56%;
    transform: translate(-50%, -50%);
    width: min(220px, 42vw);
    height: auto;
    z-index: 10000;
    pointer-events: none;
    filter: drop-shadow(0 0 16px rgba(124, 77, 255, 0.6));
    opacity: 0.92;
}

#dice3d-fallback.hidden {
    display: none;
}

#dice3d-result-display.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Force dice container to be interactive and visible */
#dice3d-canvas-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    /* Ensure canvas receives clicks */
}

/* Force dice container above absolutely everything */
#dice3d-overlay {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2147483647 !important;
    /* Max 32-bit int */
    pointer-events: auto !important;
    background: rgba(0, 0, 0, 0.5) !important;
}

#dice3d-overlay.hidden {
    display: none !important;
}

#dice3d-canvas-container {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000 !important;
}

#dice3d-instruction {
    z-index: 10001 !important;
}

#dice3d-result-display {
    z-index: 10002 !important;
}

/* ==========================================================
   RICH MESSAGES — Визуальная революция (Фаза 2)
   ========================================================== */

/* Имя DM/Кайрон над сообщением */
.message-sender {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    opacity: 0.7;
}
.message-wrapper.velmira .message-sender {
    color: #b39ddb;
}
.message-wrapper.player .message-sender {
    color: #82b1ff;
    text-align: right;
}
.message-wrapper.velmira {
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    max-width: 85%;
}
.message-wrapper.player {
    align-self: flex-end;
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

/* Метка времени */
.message-timestamp {
    font-size: 0.65rem;
    opacity: 0.4;
    margin-top: 4px;
    color: var(--text-secondary);
}
.message-wrapper.player .message-timestamp {
    text-align: right;
}

/* Rich текст внутри сообщения */
.message p { margin-bottom: 0.4em; }
.message p:last-child { margin-bottom: 0; }
.message strong { color: #f0e6ff; font-weight: 700; }
.message em { color: #c5b8ff; font-style: italic; }
.message h3, .message h4 {
    font-family: 'Outfit', sans-serif;
    color: #b39ddb;
    margin: 8px 0 4px;
}
.message hr {
    border: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 8px 0;
}

/* Анимация появления сообщения */
.message-wrapper {
    animation: msgSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================
   HP БАР — анимированное изменение HP
   ========================================================== */

.health-bar {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Вспышка при уроне */
@keyframes hpDamageFlash {
    0%   { box-shadow: inset 0 0 0 2px #ff1744, 0 0 12px rgba(255,23,68,0.9); }
    60%  { box-shadow: inset 0 0 0 2px #ff5252, 0 0 6px rgba(255,82,82,0.5); }
    100% { box-shadow: none; }
}
.hp-damaged .health-bar-container {
    animation: hpDamageFlash 0.7s ease-out forwards;
}

/* Вспышка при лечении */
@keyframes hpHealFlash {
    0%   { box-shadow: inset 0 0 0 2px #00e676, 0 0 12px rgba(0,230,118,0.9); }
    60%  { box-shadow: inset 0 0 0 2px #69f0ae, 0 0 6px rgba(105,240,174,0.5); }
    100% { box-shadow: none; }
}
.hp-healed .health-bar-container {
    animation: hpHealFlash 0.7s ease-out forwards;
}

/* Floating combat text */
.floating-text {
    position: absolute;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    pointer-events: none;
    z-index: 9999;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    animation: floatUp 1.6s ease-out forwards;
}
.floating-text.damage { color: #ff5252; }
.floating-text.heal   { color: #69f0ae; }
.floating-text.xp     { color: #ffd740; }
@keyframes floatUp {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    30%  { opacity: 1; transform: translateY(-20px) scale(1.15); }
    100% { opacity: 0; transform: translateY(-70px) scale(0.9); }
}

/* ==========================================================
   LOCATION BACKGROUND — плавный кросс-фейд
   ========================================================== */

.location-bg {
    transition: opacity 0.8s ease-in-out;
}
.location-bg.fading-out {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}
.location-bg.fading-in {
    opacity: 1;
    transition: opacity 0.8s ease-in-out;
}

/* ==========================================================
   CHARACTER PORTRAIT — рамка с классовым эффектом
   ========================================================== */

.character-portrait {
    position: relative;
}
.character-portrait::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 18px;
    background: linear-gradient(135deg, #7c4dff, #3f51b5, #7c4dff);
    background-size: 200% 200%;
    animation: portraitGlow 4s ease infinite;
    z-index: -1;
    opacity: 0.7;
}
@keyframes portraitGlow {
    0%   { background-position: 0% 50%; opacity: 0.6; }
    50%  { background-position: 100% 50%; opacity: 0.9; }
    100% { background-position: 0% 50%; opacity: 0.6; }
}

/* XP ring вокруг портрета */
.xp-ring-container {
    position: relative;
    display: inline-block;
    width: 100%;
}
.xp-ring-svg {
    position: absolute;
    inset: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    pointer-events: none;
    z-index: 1;
}
.xp-ring-bg {
    fill: none;
    stroke: rgba(255,215,64,0.12);
    stroke-width: 3;
}
.xp-ring-progress {
    fill: none;
    stroke: var(--gold-color);
    stroke-width: 3;
    stroke-linecap: round;
    filter: drop-shadow(0 0 4px rgba(255,215,64,0.6));
    transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================
   LEVEL UP notification
   ========================================================== */
.level-up-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    z-index: 10000;
    background: linear-gradient(135deg, #7c4dff, #ffd740);
    border-radius: 20px;
    padding: 24px 40px;
    text-align: center;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 2rem;
    color: #fff;
    box-shadow: 0 0 60px rgba(124,77,255,0.8), 0 0 120px rgba(255,215,64,0.4);
    pointer-events: none;
    opacity: 0;
    animation: levelUpAppear 2.5s ease-out forwards;
}
@keyframes levelUpAppear {
    0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.5); }
    20%  { opacity: 1; transform: translate(-50%,-50%) scale(1.1); }
    35%  { transform: translate(-50%,-50%) scale(1); }
    75%  { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
}


/* ── Авторизация / регистрация (экран приветствия) ───────────────────────── */
.auth-hint { color: var(--text-secondary); font-size: 0.95rem; margin: 0 0 16px; text-align: center; }
.auth-providers { display: flex; flex-direction: column; gap: 12px; }
.auth-btn {
    padding: 14px 18px; border-radius: 14px; border: 1px solid var(--panel-border);
    background: var(--panel-bg); color: var(--text-primary); font-size: 1.05rem;
    cursor: pointer; transition: transform .12s ease, border-color .12s ease, background .12s ease;
    display: flex; align-items: center; justify-content: center; gap: 12px;
    font-weight: 600;
}
.auth-btn:hover { transform: translateY(-2px); border-color: var(--accent-color); background: rgba(124,77,255,0.12); }

/* Иконки внутри кнопок авторизации */
.auth-btn-icon { width: 22px; height: 22px; flex-shrink: 0; transition: transform 0.2s ease; }
.auth-btn:hover .auth-btn-icon { transform: scale(1.1); }

/* Telegram */
.auth-btn--telegram { border-color: rgba(0,136,204,0.35); }
.auth-btn--telegram .auth-btn-icon { color: #29b6f6; }
.auth-btn--telegram:hover { border-color: #29b6f6; background: rgba(0,136,204,0.12); }

/* VK */
.auth-btn--vk { border-color: rgba(0,119,255,0.35); }
.auth-btn--vk .auth-btn-icon { color: #4a76a8; }
.auth-btn--vk:hover { border-color: #4a76a8; background: rgba(0,119,255,0.12); }

/* MAX */
.auth-btn--max { border-color: rgba(0,95,249,0.35); }
.auth-btn--max .auth-btn-icon { color: #005FF9; }
.auth-btn--max:hover { border-color: #005FF9; background: rgba(0,95,249,0.12); }
.auth-pending { margin-top: 18px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.auth-pending.hidden { display: none; }
.auth-pending-title { color: var(--text-primary); margin: 0; }
.auth-code-line { color: var(--text-secondary); font-size: 0.95rem; margin: 0; }
.auth-code-line b { color: var(--gold-color); letter-spacing: 2px; font-size: 1.15rem; }
.auth-waiting { color: var(--accent-color); margin: 0; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }
.auth-guest {
    margin-top: 24px;
    color: var(--text-secondary);
    width: 100%;
}
.auth-guest summary {
    cursor: pointer;
    font-size: 0.95rem;
    text-align: center;
    color: var(--text-secondary);
    user-select: none;
    transition: color 0.2s ease, text-shadow 0.2s ease;
    padding: 8px;
    display: block;
    width: 100%;
    list-style: none;
}
.auth-guest summary::-webkit-details-marker {
    display: none;
}
.auth-guest summary:hover {
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(124, 77, 255, 0.4);
}
.auth-guest[open] summary {
    margin-bottom: 16px;
    color: var(--text-primary);
}
.auth-guest .input-group {
    margin-top: 12px;
    text-align: left;
}
.auth-guest #continue-init-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.3s ease;
}
.secondary-btn:disabled,
#continue-init-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Юзер-бадж и кнопка выхода (Главное меню и шапка) ───────────────────── */
.menu-user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 14px;
    padding: 8px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    backdrop-filter: var(--glass-blur);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.menu-user-badge b {
    color: var(--text-primary);
}
.logout-btn {
    background: none;
    border: none;
    color: var(--hp-color);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    opacity: 0.85;
    transition: opacity 0.2s, transform 0.2s;
    font-weight: 600;
}
.logout-btn:hover {
    opacity: 1;
    transform: translateX(2px);
    text-shadow: 0 0 8px rgba(255, 82, 82, 0.4);
}
.header-user-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    padding: 6px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}
.header-user-display i {
    color: var(--accent-color);
    font-size: 0.95rem;
}
@media (max-width: 768px) {
    .header-user-display {
        display: none !important;
    }
}



/* ── Бургер-меню в шапке (динамическое текущее меню) ─────────────────────── */
.burger-wrap { position: relative; display: inline-block; }
.burger-dropdown {
    position: absolute; top: calc(100% + 8px); left: 0; z-index: 50;
    min-width: 220px; max-height: 60vh; overflow-y: auto;
    background: rgba(20, 15, 30, 0.97); border: 1px solid rgba(124,77,255,0.4);
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.6); padding: 6px;
    display: flex; flex-direction: column; gap: 4px;
}
.burger-dropdown.hidden { display: none; }
.burger-item {
    text-align: left; padding: 10px 12px; border-radius: 8px; border: none;
    background: transparent; color: var(--text-primary); cursor: pointer; font-size: 0.95rem;
}
.burger-item:hover { background: rgba(124,77,255,0.18); }
.burger-empty { padding: 10px 12px; color: var(--text-secondary); font-size: 0.9rem; }

/* ── Центрирование экрана входа (фикс «поехавшего» дизайна) ───────────────── */
#welcome-screen .registration-box { text-align: center; }
#welcome-screen .auth-guest { display: inline-block; text-align: left; width: min(420px, 100%); }
#welcome-screen .auth-guest summary { text-align: center; list-style: none; }
#welcome-screen .auth-guest .secondary-btn { width: 100%; margin-top: 10px; }

/* === M5: модалка управления API-ключами === */
.keys-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10, 8, 16, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 16px;
}
.keys-modal.hidden { display: none; }
.keys-modal-box {
    width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto;
    padding: 24px 28px; border-radius: 16px;
    background: rgba(22, 16, 35, 0.97);
    border: 1px solid rgba(124, 77, 255, 0.35);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(124, 77, 255, 0.2);
    font-family: 'Inter', sans-serif;
}
.keys-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
}
.keys-modal-header h2 {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    color: #fff;
    letter-spacing: 0.02em;
}
.keys-modal-box .subtitle {
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #a090c0;
    margin-top: 6px;
    margin-bottom: 20px;
}
.keys-list { margin: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.keys-empty { opacity: 0.7; font-style: italic; }
.key-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 10px 12px; border-radius: 10px;
    background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.08);
}
.key-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.key-provider { font-weight: 600; }
.key-masked { font-family: monospace; opacity: 0.85; font-size: 0.85rem; }
.key-meta { font-size: 0.75rem; opacity: 0.65; }
.key-del-btn {
    background: transparent; border: none; cursor: pointer;
    font-size: 1.1rem; opacity: 0.7; flex-shrink: 0;
}
.key-del-btn:hover { opacity: 1; }
.keys-add { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.keys-add select, .keys-input, #keys-input {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    background: rgba(0, 0, 0, 0.35); color: inherit;
    border: 1px solid rgba(255, 255, 255, 0.15);
}
.keys-add-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.keys-add-actions button { flex: 1; min-width: 160px; }
.keys-status { margin-top: 10px; min-height: 1.2em; font-size: 0.9rem; }
.keys-status.error { color: #ff8080; }

/* Алиасы кнопок для использования внутри модальных окон */
.btn-primary {
    padding: 0.65rem 1.5rem;
    background: var(--accent-gradient);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.04rem;
}
.btn-primary:hover:not(:disabled) {
    filter: brightness(1.15);
    box-shadow: 0 4px 18px rgba(124, 77, 255, 0.45);
}
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-secondary {
    padding: 0.65rem 1.5rem;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s;
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.16);
}
.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* === M6: настройки ИИ (переиспользует .keys-modal) === */
.ai-label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 0.9rem; }
.ai-section { margin-top: 14px; }
#ai-model-select { width: 100%; padding: 10px 12px; border-radius: 8px;
    background: rgba(0, 0, 0, 0.35); color: inherit; border: 1px solid rgba(255, 255, 255, 0.15); margin-bottom: 8px; }
#ai-model-apply { width: 100%; }
#ai-custom-input { width: 100%; padding: 10px 12px; border-radius: 8px; resize: vertical;
    background: rgba(0, 0, 0, 0.35); color: inherit; border: 1px solid rgba(255, 255, 255, 0.15); margin-bottom: 8px; }
.keys-empty.hidden, #ai-locked-note.hidden { display: none; }

/* === Settings Modal Specific Styles === */
.settings-modal-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 20px 0;
}

.settings-option-btn {
    display: flex;
    align-items: center;
    text-align: left;
    width: 100%;
    padding: 16px 20px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.settings-option-btn:hover {
    transform: translateY(-2px);
    background: rgba(124, 77, 255, 0.1);
    border-color: rgba(124, 77, 255, 0.4);
    box-shadow: 0 4px 20px rgba(124, 77, 255, 0.15);
}

.settings-option-btn .option-icon {
    font-size: 1.8rem;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-option-btn .option-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.settings-option-btn .option-title {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-primary);
}

.settings-option-btn .option-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ============================================================
   Полноценная карточка персонажа (аватар, полосы HP/MP/XP, атрибуты)
   ============================================================ */
#char-name { text-align: center; margin: 10px 0 0; }
.char-subtitle {
    text-align: center; margin: 3px 0 14px;
    font-size: 0.85rem; color: var(--accent-color, #b9a7ff); letter-spacing: 0.02em;
}
.character-portrait { position: relative; }
.char-level-badge {
    position: absolute; bottom: -6px; right: -6px;
    min-width: 28px; height: 28px; padding: 0 7px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #7c4dff, #3f51b5);
    color: #fff; font-weight: 800; font-size: 0.9rem;
    border-radius: 50%; border: 2px solid rgba(20, 15, 30, 0.95);
    box-shadow: 0 2px 10px rgba(124, 77, 255, 0.5); z-index: 3;
}

.vital-bars { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 16px; width: 100%; align-self: stretch; }
.bar-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.bar-label {
    width: 26px; flex-shrink: 0; font-size: 0.7rem; font-weight: 800;
    letter-spacing: 0.05em; color: #a090c0;
}
.health-bar-container, .mana-bar-container, .xp-bar-container {
    flex: 1; width: auto; height: 20px; position: relative;
    border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, 0.4);
}
.health-bar-container { border: 1px solid rgba(255, 50, 50, 0.4); box-shadow: 0 0 8px rgba(255, 50, 50, 0.15); }
.mana-bar-container { border: 1px solid rgba(33, 150, 243, 0.4); box-shadow: 0 0 8px rgba(33, 150, 243, 0.15); }
.xp-bar-container { border: 1px solid rgba(255, 215, 64, 0.4); box-shadow: 0 0 8px rgba(255, 215, 64, 0.15); }
.mana-bar { height: 100%; background: linear-gradient(90deg, #1565c0, #29b6f6); transition: width 0.5s ease; }
.xp-bar { height: 100%; background: linear-gradient(90deg, #c79100, #ffd740); transition: width 0.5s ease; }
.bar-text {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 0.7rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.char-section-title {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
    color: #a090c0; text-align: center; margin: 4px 0 8px; opacity: 0.85;
}

.stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 0; }
.stat-box {
    background: rgba(124, 77, 255, 0.08); border: 1px solid rgba(124, 77, 255, 0.22);
    border-radius: 10px; padding: 7px 2px; text-align: center;
}
.stat-box .stat-name { font-size: 0.62rem; font-weight: 800; color: #a090c0; letter-spacing: 0.04em; }
.stat-box .stat-value { font-size: 1.1rem; font-weight: 800; color: #f5f1ff; line-height: 1.15; }
.stat-box .stat-mod { font-size: 0.68rem; font-weight: 700; color: var(--gold-color, #ffd740); }

.char-meta {
    display: flex; justify-content: center; align-items: center; gap: 8px;
    width: 100%; margin-top: 14px; padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.85rem;
}
.char-meta-item { display: inline-flex; align-items: center; gap: 5px; color: #cfc5ea; font-weight: 600; }
.char-alignment { font-style: italic; opacity: 0.8; font-weight: 400; font-size: 0.78rem; }

/* Старое круговое XP-кольцо вокруг панели заменено полосой XP. */
.xp-ring-svg { display: none !important; }

/* === Карточка: чипы (AC/скорость/фон), уник.способность, списки === */
.char-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; width: 100%; margin: 2px 0 8px; }
.char-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px; font-size: 0.74rem; font-weight: 600;
    color: #cfc5ea; background: rgba(124, 77, 255, 0.1); border: 1px solid rgba(124, 77, 255, 0.28);
}
.char-ability {
    width: 100%; margin: 10px 0 4px; padding: 10px 12px; border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 215, 64, 0.12), rgba(124, 77, 255, 0.1));
    border: 1px solid rgba(255, 215, 64, 0.35);
}
.char-ability .ability-title { font-weight: 800; font-size: 0.85rem; color: #ffe082; margin-bottom: 3px; }
.char-ability .ability-desc { font-size: 0.78rem; color: #d8cff0; line-height: 1.35; }
.char-lists { width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.char-list-block { width: 100%; }
.char-list-item {
    font-size: 0.8rem; color: #d8cff0; padding: 3px 6px; line-height: 1.3;
    border-radius: 6px;
}
.char-list-item:hover { background: rgba(124, 77, 255, 0.08); }

/* === «Мои персонажи»: выровненный список карточек === */
#characters-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px; align-items: stretch; padding: 0 16px; max-width: 760px; margin: 0 auto; width: 100%;
}
.char-mini-card {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: #07050f;
    border: 1.5px solid rgba(80, 60, 140, 0.4);
    transition: transform .22s ease, border-color .22s, box-shadow .22s;
    color: inherit;
    font: inherit;
    appearance: none;
    -webkit-appearance: none;
    padding: 0;
    display: block;
}
.char-mini-card:hover {
    transform: translateY(-5px) scale(1.03);
    border-color: rgba(150, 110, 255, 0.75);
    box-shadow: 0 12px 36px rgba(80, 40, 200, 0.45);
}
.char-mini-card.selected {
    border-color: #ffd740;
    box-shadow: 0 0 0 1px #ffd740, 0 0 28px rgba(255, 215, 64, 0.45);
}

/* Shared hero card inner elements (used in both char-mini-card and catalog-card) */
.hero-card-art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}
.hero-card-art-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    background: linear-gradient(180deg, #1a1030 0%, #050310 100%);
}
.hero-card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        0deg,
        rgba(4, 2, 12, 0.97) 0%,
        rgba(8, 5, 22, 0.62) 38%,
        transparent 66%
    );
    pointer-events: none;
}
.hero-card-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 11px 12px;
}
.hero-card-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #f0eaff;
    line-height: 1.25;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
    margin: 0;
}
.hero-card-sub {
    font-size: 0.7rem;
    color: #c4b0ff;
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.9;
}
.hero-card-level {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(4, 2, 12, 0.82);
    border: 1px solid rgba(255, 215, 64, 0.45);
    color: #ffd740;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    line-height: 1.5;
    letter-spacing: 0.02em;
}
.hero-card-active-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 215, 64, 0.13);
    border: 1px solid rgba(255, 215, 64, 0.55);
    color: #ffd740;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.characters-empty { text-align: center; color: #a090c0; padding: 24px; }

/* Детальная карточка в модалке */
.char-detail-box { max-width: min(560px, 94vw); width: min(560px, 94vw); }
.char-detail-body {
    width: 100%; display: flex; flex-direction: column; align-items: center; gap: 8px;
    max-height: 70vh; overflow-y: auto; padding: 4px 10px 4px 4px;
}
.char-detail-name { text-align: center; margin: 10px 0 0; }
.char-backstory { font-size: 0.8rem; color: #cfc5ea; line-height: 1.4; }

/* Импорт персонажа */
#import-json-input {
    width: 100%; padding: 10px; border-radius: 8px; margin: 8px 0; resize: vertical;
    background: rgba(0, 0, 0, 0.35); color: inherit; border: 1px solid rgba(255, 255, 255, 0.15);
    font-family: monospace; font-size: 0.78rem;
}
#import-file-input { width: 100%; color: #cfc5ea; font-size: 0.82rem; }

/* === M7: Игровые сохранения === */
.saves-list {
    margin: 14px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.save-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s ease;
}
.save-row:hover {
    background: rgba(124, 77, 255, 0.08);
    border-color: rgba(124, 77, 255, 0.3);
}
.save-portrait {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}
.save-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.save-portrait-placeholder {
    font-size: 1.5rem;
}
.save-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.save-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.save-title {
    font-weight: 600;
    color: #fff;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.save-time {
    font-size: 0.75rem;
    color: #a090c0;
    flex-shrink: 0;
}
.save-char-info {
    font-size: 0.85rem;
    color: #ffaa00;
    font-weight: 500;
}
.save-summary {
    font-size: 0.8rem;
    color: #b0a0d0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.save-actions {
    flex-shrink: 0;
}
.saves-empty {
    text-align: center;
    color: #a090c0;
    padding: 24px;
    font-style: italic;
}

/* === M8: Озвучивание и TTS настройки === */
.voice-msg-btn {
    background: rgba(124, 77, 255, 0.15);
    border: 1px solid rgba(124, 77, 255, 0.3);
    color: #dfd8fc;
    font-family: inherit;
    font-size: 0.8rem;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}
.voice-msg-btn:hover:not(:disabled) {
    background: rgba(124, 77, 255, 0.35);
    border-color: rgba(124, 77, 255, 0.6);
    color: #fff;
    box-shadow: 0 0 10px rgba(124, 77, 255, 0.3);
}
.voice-msg-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.settings-form-row {
    margin: 15px 0;
}
.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    color: #fff;
    font-size: 0.95rem;
}
.switch-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #7c4dff;
    cursor: pointer;
}
.switch-text {
    opacity: 0.95;
}

/* === M9: Подписка и баланс === */
.badge-active {
    background: linear-gradient(135deg, #ffaa00, #ff5500);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 85, 0, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-inactive {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.resource-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.resource-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.subscription-status-card {
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* === M11: Помощь === */
#help-btn {
    grid-column: span 2;
}







/* ============================================================
   Мобильная версия игрового экрана: выдвижные панели (drawers)
   ============================================================ */
/* Десктоп-дефолты: всё мобильное скрыто. */
.drawer-handle { display: none; }
.drawer-overlay { display: none; }
.mobile-vitals { display: none; }
.mvital-bar-wrap { display: flex; align-items: center; gap: 6px; flex: 1; }
.mvital-icon { font-size: 0.85rem; flex-shrink: 0; }
.mvital-bar-outer {
    flex: 1; height: 12px; border-radius: 6px; overflow: hidden;
    background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(255, 255, 255, 0.1);
}
.mvital-bar { height: 100%; transition: width 0.4s ease; }
.mvital-hp { background: linear-gradient(90deg, #8b0000, #ff4040); }
.mvital-mp { background: linear-gradient(90deg, #1565c0, #29b6f6); }
.mvital-val { font-size: 0.72rem; font-weight: 700; color: #cfc5ea; min-width: 40px; text-align: right; flex-shrink: 0; }

@media (max-width: 768px) {
    /* Чат на весь экран */
    .game-layout { padding: 8px; gap: 0; padding-bottom: 8px; }
    .game-console { width: 100%; flex: 1 1 auto; min-width: 0; }

    /* Сообщения занимают всю ширину экрана */
    .chat-log { padding: 12px 10px; }
    .message { max-width: 100%; }

    /* Боковые панели → выдвижные drawer'ы (перебиваем display:none выше) */
    .character-sheet,
    .inventory-panel {
        display: flex !important;
        position: fixed; top: 0; bottom: 0; z-index: 200; margin: 0;
        width: 86%; max-width: 340px; border-radius: 0; overflow-y: auto;
        transition: transform 0.28s ease; box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
        /* Непрозрачный фон: текст не должен просвечивать на чат под панелью. */
        background: #150f22 !important;
        backdrop-filter: none !important;
    }
    .character-sheet { left: 0; transform: translateX(-100%); }
    .inventory-panel { right: 0; width: 80%; transform: translateX(100%); }
    .character-sheet.drawer-open,
    .inventory-panel.drawer-open { transform: translateX(0); }

    /* Затемнение под открытым drawer'ом */
    .drawer-overlay {
        display: block; position: fixed; inset: 0; z-index: 150;
        background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none;
        transition: opacity 0.28s ease;
    }
    .drawer-overlay.active { opacity: 1; pointer-events: auto; }

    /* Рукоятки-открывашки по краям */
    .drawer-handle {
        display: flex; align-items: center; justify-content: center;
        position: fixed; top: 50%; transform: translateY(-50%); z-index: 140;
        width: 32px; height: 56px; font-size: 1.15rem; cursor: pointer;
        background: rgba(20, 15, 30, 0.88); color: #cfc5ea;
        border: 1px solid rgba(124, 77, 255, 0.45);
    }
    .drawer-handle-left { left: 0; border-left: none; border-radius: 0 12px 12px 0; }
    .drawer-handle-right { right: 0; border-right: none; border-radius: 12px 0 0 12px; }
    /* Рукоятку прячем, когда её панель открыта */
    .character-sheet.drawer-open ~ .drawer-handle-left,
    .inventory-panel.drawer-open ~ .drawer-handle-right { opacity: 0; pointer-events: none; }

    /* Мини-виталы под строкой ввода */
    .mobile-vitals { display: flex; gap: 12px; padding: 8px 4px 2px; }
}

/* ============================================================
   Фиксы листа персонажа + Наследие (веб-таймлайн)
   ============================================================ */

/* Бейдж уровня не должен «налезать» на границу портрета — сажаем внутрь угла. */
.char-level-badge {
    bottom: 8px !important;
    right: 8px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(124, 77, 255, 0.35);
}

/* Аккуратный тонкий скролл боковых панелей и карточки персонажа вместо системного. */
.character-sheet,
.inventory-panel,

/* Подсказка кликабельности аватара. */
.character-portrait.clickable {
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.character-portrait.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 22px rgba(124, 77, 255, 0.55);
}
.character-portrait.clickable::before {
    content: '📜 Наследие';
    position: absolute;
    left: 50%; bottom: 8px;
    transform: translateX(-50%) translateY(6px);
    padding: 3px 10px;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
    color: #fff; white-space: nowrap;
    background: rgba(20, 15, 35, 0.86);
    border: 1px solid rgba(124, 77, 255, 0.5);
    border-radius: 999px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 4;
}
.character-portrait.clickable:hover::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* --- Модалка наследия --- */
.heritage-modal {
    position: fixed; inset: 0; z-index: 1100;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.heritage-modal.hidden { display: none; }
.heritage-modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(8, 6, 14, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.heritage-modal-content {
    position: relative;
    width: min(720px, 100%);
    max-height: 88vh;
    display: flex; flex-direction: column;
    border-radius: 18px;
    border: 1px solid rgba(124, 77, 255, 0.35);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(124, 77, 255, 0.06);
    overflow: hidden;
    animation: heritagePop 0.22s ease;
}
@keyframes heritagePop {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.heritage-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(124, 77, 255, 0.2);
    background: linear-gradient(135deg, rgba(124, 77, 255, 0.16), rgba(0, 0, 0, 0.1));
}
.heritage-title { display: flex; align-items: center; gap: 12px; }
.heritage-sigil {
    font-size: 1.8rem;
    filter: drop-shadow(0 0 8px rgba(124, 77, 255, 0.6));
}
.heritage-modal-header h2 {
    margin: 0; font-size: 1.25rem; letter-spacing: 0.01em;
}
.heritage-subtitle {
    margin: 2px 0 0; font-size: 0.9rem;
    color: rgba(200, 180, 255, 0.85);
}
.heritage-body {
    padding: 20px 22px 26px;
    overflow-y: auto;
}

.heritage-count {
    font-size: 0.82rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: rgba(190, 170, 255, 0.75);
    margin-bottom: 16px;
}

/* Таймлайн */
.heritage-timeline {
    position: relative;
    display: flex; flex-direction: column; gap: 18px;
    padding-left: 8px;
}
.heritage-timeline::before {
    content: '';
    position: absolute;
    left: 21px; top: 6px; bottom: 6px;
    width: 2px;
    background: linear-gradient(180deg, rgba(124, 77, 255, 0.7), rgba(124, 77, 255, 0.08));
}
.heritage-card {
    position: relative;
    display: flex; gap: 16px;
}
.heritage-node {
    flex: 0 0 auto;
    width: 28px; height: 28px; margin-top: 4px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c4dff, #3f51b5);
    box-shadow: 0 0 0 4px rgba(15, 10, 25, 0.95), 0 0 14px rgba(124, 77, 255, 0.5);
    z-index: 1;
}
.heritage-num { font-size: 0.72rem; font-weight: 800; color: #fff; }
.heritage-card-body {
    flex: 1 1 auto;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(124, 77, 255, 0.18);
    border-radius: 14px;
    padding: 14px 16px;
}
.heritage-card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px; flex-wrap: wrap;
}
.heritage-card-head h3 {
    margin: 0; font-size: 1.05rem; line-height: 1.3;
}
.heritage-date {
    font-size: 0.78rem; color: rgba(180, 165, 220, 0.7); white-space: nowrap;
}
.heritage-summary {
    margin: 8px 0 0; font-size: 0.92rem; line-height: 1.5;
    color: rgba(225, 220, 240, 0.9);
}
.heritage-block { margin-top: 12px; }
.heritage-block-title {
    display: block; margin-bottom: 6px;
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: rgba(160, 140, 210, 0.8);
}
.heritage-facts {
    margin: 0; padding-left: 18px;
    font-size: 0.9rem; line-height: 1.55; color: rgba(220, 215, 235, 0.92);
}
.heritage-facts li { margin: 2px 0; }
.heritage-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.heritage-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    font-size: 0.82rem;
    border-radius: 999px;
    border: 1px solid rgba(124, 77, 255, 0.3);
    background: rgba(124, 77, 255, 0.1);
}
.heritage-chip em {
    font-style: normal; font-size: 0.72rem;
    color: rgba(180, 165, 220, 0.75);
}
.heritage-chip-loc {
    border-color: rgba(80, 180, 160, 0.35);
    background: rgba(80, 180, 160, 0.1);
}
.heritage-artifact {
    margin-top: 12px;
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 200, 90, 0.35);
    background: linear-gradient(135deg, rgba(255, 200, 90, 0.12), rgba(255, 160, 60, 0.04));
}
.heritage-artifact-icon { font-size: 1.2rem; }
.heritage-artifact strong { color: #ffd98a; }
.heritage-artifact p {
    margin: 4px 0 0; font-size: 0.86rem; line-height: 1.45;
    color: rgba(230, 220, 200, 0.85);
}
.heritage-review {
    margin-top: 12px;
    display: flex; gap: 8px; align-items: flex-start;
    font-size: 0.88rem; color: rgba(210, 205, 230, 0.85);
}
.heritage-review em { font-style: italic; }

/* Пустое состояние и загрузка */
.heritage-empty {
    text-align: center;
    padding: 30px 16px 24px;
    color: rgba(220, 215, 235, 0.85);
}
.heritage-empty-glyph {
    font-size: 3rem; margin-bottom: 10px;
    filter: drop-shadow(0 0 12px rgba(124, 77, 255, 0.4));
}
.heritage-empty h3 { margin: 0 0 10px; font-size: 1.15rem; }
.heritage-empty p { margin: 6px auto; max-width: 440px; line-height: 1.5; font-size: 0.92rem; }
.heritage-empty-hint { color: rgba(180, 165, 220, 0.7); font-size: 0.86rem; }
.heritage-loading {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    padding: 40px 16px; color: rgba(200, 185, 230, 0.85);
}

@media (max-width: 768px) {
    .heritage-modal-content { max-height: 92vh; }
    .heritage-card { gap: 12px; }
    .heritage-modal-header { padding: 14px 16px; }
    .heritage-body { padding: 16px; }
}

/* ─── Catalog Character Modal ─── */
.catalog-character-modal {
    position: fixed;
    inset: 0;
    z-index: 1600;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 20px 36px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.catalog-character-modal.hidden {
    display: none;
}

.catalog-character-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 20, 0.32);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 0;
}

.catalog-character-modal-content {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    padding: 22px;
    background: linear-gradient(180deg, rgba(15, 21, 34, 0.92) 0%, rgba(11, 15, 26, 0.94) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

body.catalog-modal-open {
    overflow: hidden;
}

.catalog-detail-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 22px;
    align-items: flex-start;
}

.catalog-detail-visual {
    min-width: 0;
}

.catalog-detail-frame {
    min-height: 420px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: radial-gradient(circle at top, rgba(60, 79, 123, 0.48), rgba(9, 12, 21, 0.96));
    display: flex;
    align-items: center;
    justify-content: center;
}

.catalog-detail-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    margin-bottom: 0;
    display: block;
}

.catalog-detail-placeholder {
    color: rgba(221, 227, 248, 0.62);
    text-align: center;
    padding: 24px;
}

.catalog-detail-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.catalog-detail-kicker {
    margin: 0;
    color: #cdb6ff;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.catalog-detail-copy h3 {
    margin: 0;
    font-size: clamp(1.5rem, 2.1vw, 2rem);
    line-height: 1.1;
}

.catalog-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #dfe4f8;
    font-size: 0.75rem;
    line-height: 1.2;
}

.catalog-chip--accent {
    background: rgba(185, 127, 53, 0.18);
    border-color: rgba(255, 211, 133, 0.28);
    color: #ffe7b8;
}

.catalog-detail-meta-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.catalog-detail-meta {
    color: rgba(221, 227, 248, 0.76);
    margin: 0;
    line-height: 1.5;
}

.catalog-detail-description {
    line-height: 1.6;
    margin: 0;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-height: min(56vh, 560px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.catalog-detail-description .hero-info-desc {
    white-space: pre-wrap;
    margin: 0;
    line-height: 1.6;
    color: rgba(221, 227, 248, 0.88);
}

/* Внутренние блоки богатой карточки внутри скролл-описания не должны
   тянуть собственные внешние отступы — расстояния задаёт gap контейнера. */
.catalog-detail-description .char-chips,
.catalog-detail-description .vital-bars,
.catalog-detail-description .stats-grid,
.catalog-detail-description .char-ability,
.catalog-detail-description .char-meta,
.catalog-detail-description .char-lists,
.catalog-detail-description .char-list-block {
    margin: 0;
}

.catalog-detail-description .char-section-title {
    margin: 0 0 6px;
}

.catalog-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 680px) {
    .catalog-character-modal {
        padding: 10px;
    }

    .catalog-character-modal-content {
        padding: 16px;
    }

    .catalog-detail-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .catalog-detail-frame {
        min-height: 0;
        max-height: 50vh;
    }

    .catalog-detail-description {
        max-height: none;
    }
}

.catalog-detail-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0;
}

/* Кнопка «Назад в меню» в каталоге всегда видна на телефоне (липкая к низу). */
@media (max-width: 768px) {
    .catalog-menu-footer {
        position: sticky;
        bottom: 0;
        z-index: 6;
        margin-top: 16px;
        padding-top: 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: linear-gradient(to top, rgba(13, 15, 20, 0.96) 55%, rgba(13, 15, 20, 0));
    }
    .catalog-menu-footer .secondary-btn {
        width: 100%;
    }
}

/* Дисклеймер о бета-версии веб-игры (вверху чата) */
.web-beta-disclaimer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 9px 12px;
    border-radius: 12px;
    background: rgba(124, 77, 255, 0.12);
    border: 1px solid rgba(124, 77, 255, 0.32);
    color: #e7e0ff;
    font-size: 0.82rem;
    line-height: 1.4;
}
.web-beta-disclaimer.hidden { display: none; }
.web-beta-disclaimer-icon { font-size: 1rem; flex-shrink: 0; }
.web-beta-disclaimer-text { flex: 1; }
.web-beta-disclaimer-text a {
    color: #b79bff;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}
.web-beta-disclaimer-text a:hover { text-decoration: underline; }
.web-beta-disclaimer-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #c9b6ff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.75;
}
.web-beta-disclaimer-close:hover { opacity: 1; }
