: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;
}

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 {
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}

.logo {
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.logo .accent {
    color: var(--accent-color);
}

.player-stats {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-shrink: 0;
}

.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;
}

/* Custom Scrollbar */
.chat-log::-webkit-scrollbar {
    width: 6px;
}

.chat-log::-webkit-scrollbar-track {
    background: transparent;
}

.chat-log::-webkit-scrollbar-thumb {
    background: var(--panel-border);
    border-radius: 3px;
}

.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 {
    margin: 0 16px 8px;
    padding: 14px;
    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-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;
}

#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;
}

.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;
}

#characters-screen .themes-grid {
    width: min(760px, 100%);
    max-height: none;
    overflow: visible;
    margin-bottom: 1.25rem;
}

#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: 900px;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    overflow: 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: center;
    justify-items: center;
    align-items: stretch;
    width: 100%;
    height: 100%;
    padding: 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));
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: calc(16px * var(--quiz-card-scale));
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: calc(1.2rem * var(--quiz-card-scale));
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    opacity: 0;
    transform: translateY(50px) rotateX(10deg);
    animation: flyIn 0.6s ease-out forwards;
}

.quiz-cards-grid.media-cards .quiz-card {
    justify-content: flex-start;
    padding-top: calc(0.85rem * var(--quiz-card-scale));
}

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

.quiz-card:hover {
    transform: translateY(calc(-8px * var(--quiz-card-scale))) scale(1.03);
    border-color: var(--accent-color);
    box-shadow: 0 15px 40px rgba(124, 77, 255, 0.4);
}

.quiz-card.selected {
    border-color: var(--accent-color);
    background: rgba(124, 77, 255, 0.15);
    box-shadow: 0 0 25px rgba(124, 77, 255, 0.5);
    transform: scale(1.03);
}

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

.gender-card-male:hover {
    border-color: rgba(102, 184, 255, 0.86);
    background: linear-gradient(180deg, rgba(34, 93, 189, 0.24) 0%, rgba(15, 41, 92, 0.4) 100%);
    box-shadow: 0 14px 32px rgba(45, 131, 255, 0.24), 0 0 14px rgba(92, 174, 255, 0.18);
}

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

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

.gender-card-female:hover {
    border-color: rgba(255, 138, 206, 0.95);
    background: linear-gradient(180deg, rgba(198, 52, 152, 0.24) 0%, rgba(104, 30, 84, 0.4) 100%);
    box-shadow: 0 14px 32px rgba(255, 95, 181, 0.24), 0 0 14px rgba(255, 148, 213, 0.18);
}

.card-icon {
    font-size: clamp(2rem, calc(3.5rem * var(--quiz-card-scale)), 3.5rem);
    margin-bottom: clamp(0.4rem, calc(1rem * var(--quiz-card-scale)), 1rem);
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
    transition: filter 0.3s;
}

.quiz-card:hover .card-icon {
    filter: drop-shadow(0 0 15px rgba(124, 77, 255, 0.6));
}

.card-preview-wrap {
    width: clamp(104px, calc(156px * var(--quiz-card-scale)), 156px);
    height: clamp(104px, calc(156px * var(--quiz-card-scale)), 156px);
    margin-bottom: clamp(0.4rem, calc(1rem * var(--quiz-card-scale)), 1rem);
    border-radius: calc(12px * var(--quiz-card-scale));
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(6, 10, 18, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-cards-grid.media-cards .card-preview-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    margin-bottom: clamp(0.55rem, calc(1.05rem * var(--quiz-card-scale)), 1.1rem);
}

.card-preview-video,
.card-preview-fallback {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.quiz-card h4 {
    font-size: clamp(0.95rem, calc(1.2rem * var(--quiz-card-scale)), 1.2rem);
    margin-bottom: clamp(0.2rem, calc(0.5rem * var(--quiz-card-scale)), 0.5rem);
    color: #fff;
    font-family: 'Outfit', sans-serif;
}

.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: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 26px;
    margin-top: 10px;
}

.catalog-list-block {
    width: 100%;
    max-width: 980px;
    min-height: min(640px, calc(100vh - 260px));
    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(var(--quiz-cols, 3), minmax(0, calc(var(--quiz-card-base-w, 220px) * var(--quiz-card-scale, 1))));
    gap: var(--quiz-gap, 18px);
    min-height: 0;
    grid-auto-rows: calc(var(--quiz-card-base-h, 280px) * var(--quiz-card-scale, 1));
    justify-content: center;
    align-content: start;
    justify-items: center;
    align-items: stretch;
    width: 100%;
    height: auto;
}

.catalog-card {
    width: calc(var(--quiz-card-base-w, 220px) * var(--quiz-card-scale, 1));
    height: calc(var(--quiz-card-base-h, 280px) * var(--quiz-card-scale, 1));
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: calc(16px * var(--quiz-card-scale, 1));
    cursor: pointer;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: calc(0.85rem * var(--quiz-card-scale, 1)) calc(1.2rem * var(--quiz-card-scale, 1)) calc(1.2rem * var(--quiz-card-scale, 1));
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    appearance: none;
    -webkit-appearance: none;
    color: inherit;
    font: inherit;
}

.catalog-card .card-preview-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4;
    margin-bottom: clamp(0.55rem, calc(1.05rem * var(--quiz-card-scale, 1)), 1.1rem);
    border-radius: calc(12px * var(--quiz-card-scale, 1));
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(6, 10, 18, 0.5);
}

.catalog-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1 1 auto;
}

.catalog-card h4 {
    font-size: clamp(0.95rem, calc(1.2rem * var(--quiz-card-scale, 1)), 1.2rem);
    margin-bottom: clamp(0.2rem, calc(0.5rem * var(--quiz-card-scale, 1)), 0.5rem);
    color: #fff;
    font-family: 'Outfit', sans-serif;
}

.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(calc(-8px * var(--quiz-card-scale, 1))) scale(1.03);
    border-color: var(--accent-color);
    box-shadow: 0 15px 40px rgba(124, 77, 255, 0.4);
}

.catalog-card:hover .card-preview-fallback,
.catalog-card:focus-visible .card-preview-fallback {
    transform: scale(1.03);
}

.catalog-card.active {
    border-color: var(--accent-color);
    background: rgba(124, 77, 255, 0.15);
    box-shadow: 0 0 25px rgba(124, 77, 255, 0.5);
    transform: scale(1.03);
}

.catalog-card:focus-visible {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 25px rgba(124, 77, 255, 0.5);
}

.catalog-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.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 {
    width: 56px;
    height: 56px;
    min-width: 56px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    padding: 0;
    background: linear-gradient(180deg, rgba(31, 38, 58, 0.96) 0%, rgba(18, 22, 35, 0.98) 100%);
    border-color: rgba(255, 255, 255, 0.12);
}

.catalog-side-nav:disabled {
    opacity: 0.45;
    cursor: default;
}

@media (max-height: 900px) and (min-width: 900px) {
    .catalog-layout {
        gap: 20px;
    }

    .catalog-list-block {
        min-height: min(540px, calc(100vh - 220px));
    }

    .catalog-list {
        min-height: min(470px, calc(100vh - 290px));
    }

    .catalog-card {
        min-height: 0;
    }

    .catalog-side-nav {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }
}

@media (max-height: 840px) and (min-width: 900px) {
    #catalog-screen {
        justify-content: flex-start;
        align-items: stretch;
        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 {
        gap: 14px;
        margin-top: 0;
    }

    .catalog-list-block {
        min-height: 0;
    }

    .catalog-helper {
        margin-bottom: 8px;
        padding: 8px 12px;
    }

    .catalog-list {
        min-height: 0;
    }

    .catalog-card {
        padding-top: calc(0.75rem * var(--quiz-card-scale, 1));
    }

    .catalog-card h4 {
        font-size: 0.92rem;
    }

    .catalog-card .desc-text {
        font-size: 0.74rem;
    }

    .catalog-side-nav {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

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

.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-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 {
    white-space: pre-wrap;
    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(48vh, 480px);
    overflow-y: auto;
}

.catalog-hover-preview {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 220px;
    min-height: 0;
    z-index: 30;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(14, 20, 35, 0.6);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 18px 30px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    contain: layout paint style;
}

.catalog-hover-preview.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.catalog-hover-image {
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: initial;
    border-radius: 8px;
    display: block;
}

.catalog-hover-placeholder {
    color: var(--text-secondary);
    text-align: center;
}

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

.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 {
        right: 10px;
        bottom: 64px;
        max-width: min(320px, calc(100vw - 20px));
    }

    .karaoke-line {
        font-size: clamp(0.74rem, 3.2vw, 0.92rem);
        padding: 5px 10px;
    }
}

.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;
    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;
}

.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;
    }

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

    .catalog-list {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        align-content: start;
        height: auto;
        width: min(520px, 100%);
        margin: 0 auto;
    }

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

    #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;
    }

    .catalog-side-nav {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }

    .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-hover-preview {
        min-height: 100px;
    }

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

    .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-y: auto;
        overflow-x: hidden;
        padding-bottom: calc(6.5rem + env(safe-area-inset-bottom));
    }

    .quiz-container {
        overflow: visible;
        align-items: flex-start;
        flex: 0 0 auto;
        min-height: 0;
        padding-bottom: 0.5rem;
    }

    .quiz-cards-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        align-content: start;
        height: auto;
        width: min(520px, 100%);
        margin: 0 auto;
    }

    .quiz-card {
        width: 100%;
        height: auto;
        min-height: 0;
    }

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

    .quiz-footer {
        position: sticky;
        bottom: 0;
        z-index: 20;
        width: min(520px, 100%);
        margin-top: 0;
        padding: 0.75rem 0 calc(0.35rem + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(13, 15, 20, 0) 0%, rgba(13, 15, 20, 0.82) 28%, rgba(13, 15, 20, 0.96) 100%);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .catalog-list {
        min-height: 0;
    }

    .fire-particles {
        opacity: 0.7;
    }
}

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

    .catalog-card {
        width: 100%;
        height: auto;
        min-height: 0;
    }

    .catalog-pagination {
        margin-top: 10px;
    }

    .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;
}

#catalog-hover-preview {
    position: fixed !important;
    z-index: 5000 !important;
    left: 0;
    top: 0;
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
}

#catalog-hover-preview.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 1024px),
(hover: none),
(pointer: coarse) {
    #catalog-hover-preview {
        display: 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: 15px;
    min-width: 0;
}

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

.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;
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 77, 255, 0.75) rgba(255, 255, 255, 0.06);
}

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

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

#player-input::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    border: 1px solid rgba(124, 77, 255, 0.18);
}

#player-input::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(124, 77, 255, 0.95) 0%, rgba(63, 81, 181, 0.95) 100%);
    border-radius: 999px;
    border: 2px solid rgba(20, 15, 30, 0.95);
    box-shadow: 0 0 10px rgba(124, 77, 255, 0.28);
}

#player-input::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(140, 98, 255, 1) 0%, rgba(86, 104, 214, 1) 100%);
}

#player-input::-webkit-scrollbar-corner {
    background: transparent;
}

.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);
}

/* Hide old header */
#game-screen>header.game-header:first-of-type {
    /* Keep the new one styles */
}


/* --- 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;
    border-radius: 12px;
    padding: 2px;
}

.character-portrait img {
    width: 100%;
    height: 100%;
    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;
}
