/* ===== CSS Variables & Reset ===== */
:root {
    --primary: #0a0a0f;
    --primary-light: #12121a;
    --secondary: #1a1a24;
    --accent: #8b0000;
    --accent-glow: rgba(139, 0, 0, 0.6);
    --accent-bright: #cc0000;
    --success: #2d5a27;
    --success-glow: rgba(45, 90, 39, 0.5);
    --warning: #8b6914;
    --text-primary: #c9c9c9;
    --text-secondary: #7a7a7a;
    --text-muted: #4a4a4a;
    --glass-bg: rgba(0, 0, 0, 0.4);
    --glass-border: rgba(100, 100, 100, 0.15);
    --fog: rgba(30, 30, 40, 0.3);
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --font-main: 'Noto Sans KR', sans-serif;
    --font-display: 'Creepster', 'Orbitron', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background:
        radial-gradient(ellipse at 20% 80%, rgba(50, 0, 0, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(30, 0, 50, 0.2) 0%, transparent 50%),
        linear-gradient(180deg, #050508 0%, #0a0a10 30%, #0d0d15 70%, #080810 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 9999;
}

.screen {
    display: none !important;
    min-height: 100vh;
}

.screen.active {
    display: block !important;
}

/* ===== Intro Screen ===== */
#intro-screen.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.intro-container {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    position: relative;
    z-index: 10;
}

.logo-container {
    margin-bottom: 3rem;
    position: relative;
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {

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

    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

.game-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 0.1em;
}

.title-vector {
    display: block;
    background: linear-gradient(90deg, #8b0000, #4a0000);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: flicker 4s ease-in-out infinite;
    text-shadow: 0 0 20px rgba(139, 0, 0, 0.5);
}

.title-escape {
    display: block;
    font-size: 2.5rem;
    color: #888;
    margin-top: 0.5rem;
    letter-spacing: 0.2em;
}

@keyframes flicker {

    0%,
    100% {
        opacity: 1;
        filter: drop-shadow(0 0 10px var(--accent-glow));
    }

    92% {
        opacity: 1;
    }

    93% {
        opacity: 0.3;
    }

    94% {
        opacity: 1;
    }

    96% {
        opacity: 0.5;
    }

    97% {
        opacity: 1;
    }
}

.subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    letter-spacing: 0.3em;
}

.story-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
    position: relative;
}

.story-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.story-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.story-text {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
}

.story-text .highlight {
    color: var(--accent);
    font-weight: 700;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-main);
    color: #ddd;
    background: linear-gradient(135deg, #3a0000, #1a0000);
    border: 1px solid #5a0000;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-medium);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    color: var(--text-primary);
    background: transparent;
    border: 2px solid var(--accent);
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--transition-medium);
}

.btn-secondary:hover {
    background: var(--accent);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.intro-decorations {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.vector-arrow {
    position: absolute;
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.3;
}

.vector-arrow::after {
    content: '';
    position: absolute;
    right: 0;
    top: -4px;
    border-left: 10px solid var(--accent);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.arrow-1 {
    top: 20%;
    left: 10%;
    transform: rotate(45deg);
    animation: float 4s ease-in-out infinite;
}

.arrow-2 {
    top: 60%;
    right: 15%;
    transform: rotate(-30deg);
    animation: float 5s ease-in-out infinite 1s;
}

.arrow-3 {
    bottom: 25%;
    left: 20%;
    transform: rotate(15deg);
    animation: float 6s ease-in-out infinite 0.5s;
}

@keyframes float {

    0%,
    100% {
        opacity: 0.2;
        transform: translateY(0);
    }

    50% {
        opacity: 0.5;
        transform: translateY(-20px);
    }
}

/* ===== Game Header ===== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

.room-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.room-icon {
    font-size: 1.3rem;
}

.progress-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: var(--glass-bg);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--success), #7fffcc);
    border-radius: 10px;
    transition: width var(--transition-medium);
}

.progress-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--success);
    min-width: 40px;
}

.btn-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: var(--font-main);
    color: var(--warning);
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid var(--warning);
    border-radius: 25px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-hint:hover {
    background: rgba(255, 193, 7, 0.2);
    box-shadow: 0 0 15px rgba(255, 193, 7, 0.3);
}

.hint-count {
    background: var(--warning);
    color: var(--primary);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.8rem;
}

/* ===== Room Container ===== */
.room-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.room-visual {
    width: 100%;
    max-width: 900px;
    height: 450px;
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    border: 2px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.room {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.room.active {
    display: block;
    animation: roomFadeIn 0.5s ease;
}

@keyframes roomFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.room-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.room-1 .room-background {
    background: url('bg1.png') no-repeat center center;
    background-size: cover;
    filter: brightness(0.7);
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
}

.room-1 .room-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, rgba(200, 0, 0, 0.1) 0%, transparent 60%);
    animation: spookyPulse 4s infinite;
}

.room-1 .room-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100'%3E%3Crect fill='%23111' width='100' height='100'/%3E%3Ccircle fill='%23000' cx='50' cy='50' r='2' opacity='0.3'/%3E%3C/svg%3E");
    opacity: 0.5;
    animation: fogMove 20s linear infinite;
}

.room-2 .room-background {
    background: url('bg2.png') no-repeat center center;
    background-size: cover;
    filter: brightness(0.7);
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
}

.room-2 .room-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: conic-gradient(from 0deg at 50% 50%, transparent 0%, rgba(100, 0, 200, 0.05) 25%, transparent 50%);
    animation: rotate 10s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spookyPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

.room-3 .room-background {
    background: url('bg3.png') no-repeat center center;
    background-size: cover;
    filter: brightness(0.7);
    box-shadow: inset 0 0 150px rgba(0, 0, 0, 1);
}

.room-3 .room-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 0, 0, 0.2), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(255, 0, 0, 0.2), transparent 40%);
    animation: spookyPulse 3s infinite alternate;
}

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

    50% {
        transform: translateX(-10px);
    }

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

.room-objects {
    position: relative;
    width: 100%;
    height: 100%;
}

/* ===== Interactive Objects ===== */
.object {
    position: absolute;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--glass-bg);
    border: 2px solid var(--glass-border);
    border-radius: 16px;
    transition: all var(--transition-medium);
}

.object:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 0 30px var(--accent-glow);
}

.object.solved {
    border-color: var(--success);
    background: rgba(78, 204, 163, 0.1);
}

.object.solved:hover {
    box-shadow: 0 0 30px var(--success-glow);
    cursor: default;
}

.object.solved::after {
    content: '✓';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 30px;
    height: 30px;
    background: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.object-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, currentColor 0%, transparent 70%);
    opacity: 0;
    pointer-events: none;
    color: var(--accent);
}

.object:hover .object-glow {
    opacity: 0.2;
}

.object-label {
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
}

/* Object Positions */
.room-1 .desk {
    top: 60%;
    left: 10%;
    width: 120px;
    height: 100px;
}

.room-1 .computer {
    top: 30%;
    left: 35%;
    width: 120px;
    height: 100px;
}

.room-1 .bookshelf {
    top: 55%;
    left: 60%;
    width: 120px;
    height: 100px;
}

.room-1 .door-next {
    top: 25%;
    right: 8%;
    width: 100px;
    height: 140px;
}

.room-2 .machine {
    top: 55%;
    left: 8%;
    width: 120px;
    height: 100px;
}

.room-2 .formula-board {
    top: 20%;
    left: 25%;
    width: 130px;
    height: 100px;
}

.room-2 .safe-small {
    top: 60%;
    left: 45%;
    width: 110px;
    height: 95px;
}

.room-2 .laser-device {
    top: 30%;
    left: 65%;
    width: 120px;
    height: 100px;
}

.room-2 .door-next {
    top: 25%;
    right: 8%;
    width: 100px;
    height: 140px;
}

.room-3 .vault-panel {
    top: 20%;
    left: 12%;
    width: 130px;
    height: 110px;
}

.room-3 .crystal {
    top: 50%;
    left: 35%;
    width: 110px;
    height: 100px;
}

.room-3 .final-mechanism {
    top: 35%;
    left: 58%;
    width: 130px;
    height: 110px;
}

.room-3 .door-final {
    top: 30%;
    right: 10%;
    width: 120px;
    height: 160px;
}

.lock-indicator {
    position: absolute;
    bottom: 10px;
    font-size: 1.5rem;
}

.door-next.unlocked .lock-indicator,
.door-final.unlocked .lock-indicator {
    display: none;
}

.door-next.unlocked,
.door-final.unlocked {
    border-color: var(--success);
    animation: doorGlow 1s ease-in-out infinite;
}

@keyframes doorGlow {

    0%,
    100% {
        box-shadow: 0 0 20px var(--success-glow);
    }

    50% {
        box-shadow: 0 0 40px var(--success-glow);
    }
}

/* ===== Code Tracker ===== */
.code-tracker {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1rem 2rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.code-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.code-display {
    display: flex;
    gap: 0.5rem;
}

.code-digit {
    width: 36px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    background: var(--primary);
    border: 2px solid var(--accent);
    border-radius: 8px;
    transition: all var(--transition-medium);
}

.code-digit.locked {
    color: var(--text-muted);
    border-color: var(--glass-border);
}

.code-digit.revealed {
    color: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
    animation: codeReveal 0.5s ease;
}

@keyframes codeReveal {
    0% {
        transform: scale(1.3);
    }

    50% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

/* ===== Modal Styles ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, #1a0f0f, #0a0a0f);
    border: 2px solid var(--accent);
    border-radius: 24px;
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(139, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--accent), transparent, var(--accent));
}

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

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* Problem Modal */
.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.problem-number {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent);
}

.problem-difficulty {
    font-size: 1.1rem;
    color: var(--warning);
}

.problem-text {
    font-size: 1.1rem;
    line-height: 2;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.problem-text p {
    margin-bottom: 1rem;
}

.problem-text .katex {
    font-size: 1.2em;
}

.answer-section {
    margin-top: 1.5rem;
}

.answer-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.answer-input-container {
    display: flex;
    gap: 1rem;
}

.answer-input {
    flex: 1;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-family: var(--font-main);
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    outline: none;
    transition: all var(--transition-fast);
}

.answer-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.answer-input::placeholder {
    color: var(--text-muted);
}

.btn-submit {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 700;
    font-family: var(--font-main);
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent), #ff6b8a);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-submit:hover {
    transform: scale(1.02);
    box-shadow: 0 0 20px var(--accent-glow);
}

.answer-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.75rem;
    font-style: italic;
}

.feedback-area {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 12px;
    display: none;
}

.feedback-area.show {
    display: block;
}

.feedback-area.correct {
    background: rgba(78, 204, 163, 0.2);
    border: 1px solid var(--success);
    color: var(--success);
}

.feedback-area.wrong {
    background: rgba(233, 69, 96, 0.2);
    border: 1px solid var(--accent);
    color: var(--accent);
}

/* Success Modal */
.success-modal-content {
    text-align: center;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: bounce 0.5s ease;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

.success-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 1rem;
}

.success-message {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.code-reveal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.revealed-code {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
    text-shadow: 0 0 15px var(--success-glow);
}

/* Hint Modal */
.hint-modal-content {
    max-width: 500px;
}

.hint-header {
    margin-bottom: 1.5rem;
}

.hint-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning);
}

.hint-text {
    padding: 1.5rem;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.btn-use-hint {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-main);
    color: var(--primary);
    background: var(--warning);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-use-hint:hover {
    background: #ffcd39;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5);
}

/* Wrong Answer Modal */
.wrong-modal-content {
    text-align: center;
    max-width: 400px;
}

.wrong-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: shake 0.5s ease;
}

@keyframes shake {

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

    20%,
    60% {
        transform: translateX(-10px);
    }

    40%,
    80% {
        transform: translateX(10px);
    }
}

.wrong-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 1rem;
}

.wrong-message {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.attempts-left {
    color: var(--warning);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Solution Modal */
.solution-modal-content {
    max-width: 650px;
}

.solution-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.solution-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--success);
}

.solution-text {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    line-height: 2;
}

.solution-text .katex {
    font-size: 1.1em;
}

/* Escape Modal */
.escape-modal-content {
    text-align: center;
    max-width: 500px;
    position: relative;
    overflow: hidden;
}

.escape-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: trophy 1s ease infinite;
}

@keyframes trophy {

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

    25% {
        transform: scale(1.1) rotate(-5deg);
    }

    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

.escape-title {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(90deg, var(--success), #7fffcc, var(--warning));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1rem;
}

.escape-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.8;
}

.escape-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.final-code {
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    margin-bottom: 2rem;
}

.final-code-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.final-code-display {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
}

.final-code-display .code-digit {
    background: var(--success);
    color: var(--primary);
    border: none;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .game-title {
        font-size: 2.5rem;
    }

    .title-escape {
        font-size: 1.8rem;
    }

    .game-header {
        flex-wrap: wrap;
        gap: 1rem;
        padding: 1rem;
    }

    .header-center {
        order: 3;
        width: 100%;
    }

    .progress-bar {
        flex: 1;
    }

    .room-visual {
        height: 350px;
    }

    .object {
        padding: 0.75rem;
    }

    .object-label {
        font-size: 0.75rem;
    }

    .code-tracker {
        flex-direction: column;
        gap: 1rem;
    }

    .code-digit {
        width: 28px;
        height: 36px;
        font-size: 1rem;
    }

    .answer-input-container {
        flex-direction: column;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .escape-stats {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 2rem;
    }

    .room-visual {
        height: 300px;
    }

    .object {
        width: 80px !important;
        height: 70px !important;
        padding: 0.5rem;
    }

    .room-1 .door-next,
    .room-2 .door-next,
    .room-3 .door-final {
        height: 100px !important;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--primary);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ===== Problem Actions ===== */
.problem-actions {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-end;
}

.btn-hint-ingame {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--warning);
    background: transparent;
    border: 1px solid var(--warning);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-hint-ingame:hover {
    background: rgba(255, 193, 7, 0.1);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.2);
}

/* ===== Root Button ===== */
.btn-root {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, #4a3b6b, #2d2540);
    border: 2px solid #6b5b8b;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-root:hover {
    background: linear-gradient(135deg, #5b4b7b, #3d3550);
    border-color: #8b7bab;
    box-shadow: 0 0 15px rgba(107, 91, 139, 0.4);
    transform: scale(1.05);
}

.btn-root:active {
    transform: scale(0.95);
}

/* ===== Mute Button ===== */
.mute-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 500;
}

.mute-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: var(--accent);
    transform: scale(1.1);
}

.mute-btn .mute-icon {
    font-size: 1.5rem;
}

.mute-btn.muted {
    border-color: var(--text-muted);
    opacity: 0.7;
}

.mute-btn.muted:hover {
    opacity: 1;
    border-color: var(--accent);
}

@media (max-width: 768px) {
    .mute-btn {
        width: 44px;
        height: 44px;
        bottom: 15px;
        right: 15px;
    }

    .mute-btn .mute-icon {
        font-size: 1.2rem;
    }

    .btn-root {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }
}

/* ===== Hint System ===== */
.hint-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hint-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    transition: all var(--transition-fast);
}

.hint-item.unlocked {
    background: rgba(45, 90, 39, 0.1);
    border-color: var(--success);
}

.hint-item.locked {
    background: rgba(0, 0, 0, 0.5);
    border-style: dashed;
}

.hint-level-badge {
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--secondary);
    border: 1px solid var(--glass-border);
    padding: 0.2rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.hint-item.unlocked .hint-level-badge {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.hint-content {
    margin-top: 0.5rem;
    font-size: 1.1rem;
    line-height: 1.6;
}

.btn-unlock-hint {
    width: 100%;
    padding: 1rem;
    background: var(--warning);
    color: var(--primary);
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-unlock-hint:hover {
    background: #ffdb4d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.3);
}

.btn-unlock-hint.disabled {
    background: var(--glass-bg);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.hint-locked-msg {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem;
}