@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=Black+Han+Sans&family=Orbitron:wght@400;700;900&family=Exo+2:wght@400;700&display=block');
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=VT323&display=swap');

@font-face {
    font-family: 'DOSGothic';
    src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_eight@1.0/DOSGothic.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent !important;
}

html {
    background-color: #050508;
    height: 100%;
}

body {
    background-color: #050508;
    height: 100%;
    margin: 0;
    padding: 0;
}

:root {
    /* ==== FONT SWAPPING SYSTEM ==== */
    /* Available Korean Fonts (from font_preview.html): 
       'Inter', 'Noto Serif KR', 'Gowun Dodum', 'Jua', 'Black Han Sans', 'Do Hyeon'
       Change these variables to easily swap fonts across the entire game.
       User requested Font #6: 'Do Hyeon'
    */
    --main-font: 'Do Hyeon', sans-serif;
    --title-font: 'Do Hyeon', sans-serif;
    --number-font: 'Do Hyeon', sans-serif;

    --bg-dark: #050508;
    --panel-bg: rgba(15, 15, 20, 0.95);
    --neon-gold: #ffcc00;
    --neon-blue: #00f3ff;
    --neon-cyan: #00e5ff;
    --neon-red: #ff0055;
    --neon-green: #00ff66;
    --text-main: #ffffff;
    --border-glass: rgba(255, 255, 255, 0.15);
}

    body,
    html {
        margin: 0;
        padding: 0;
        width: 100vw;
        /* [V3 ?축 버그 ?치] 100lvh?무시?는 ?질 ?체 브라????비해, JS가 박아주는 ?? Pixel 값을 ?용?여 찌그?짐???구 차단. */
        height: calc(var(--vh, 1vh) * 100) !important;
        position: fixed;
        top: 0;
        left: 0;
        background-color: #050508;
        /* [Video Fix] Fallback dark background preventing white area leak */
        color: var(--text-main);
        font-family: var(--main-font, 'Pretendard', sans-serif);
        overflow: hidden;
        overscroll-behavior: none;
        /* ?크?밀?강제 방? */
        user-select: none;
        display: flex;
        justify-content: center;
        align-items: center;
        /* [Notch Fix] iOS/Android 펀치홀·노치 영역 배경색 채움 */
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }

    #game-container {
        width: 100%;
        height: 100%;
        overflow: hidden;
    }

    /* Ensure views scroll */
    #menu-view,
    #game-view,
    .view {
        width: 100%;
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #bg-grid {
        display: none !important;
    }

    @keyframes gridMove {
        0% {
            transform: perspective(1000px) rotateX(60deg) translateY(0);
        }

        100% {
            transform: perspective(1000px) rotateX(60deg) translateY(80px);
        }
    }

    #bg-video {
        position: fixed;
        top: 50%;
        left: 50%;
        min-width: 100%;
        min-height: 100%;
        width: auto;
        height: auto;
        transform: translate(-50%, -50%);
        z-index: 0;
        /* [Video Fix] Changed from -10 to 0 (Above body bg) */
        object-fit: cover;
        pointer-events: none;
    }

    #vignette {
        position: fixed;
        inset: 0;
        pointer-events: none;
        z-index: -1;
        background: radial-gradient(circle, transparent 30%, #000 95%);
        display: none !important;
        /* [User Feedback] Remove blur/darkening effect */
    }

    .loader {
        width: 48px;
        height: 48px;
        border: 5px solid #FFF;
        border-bottom-color: var(--neon-gold);
        border-radius: 50%;
        display: inline-block;
        box-sizing: border-box;
        animation: rotation 1s linear infinite;
        box-shadow: 0 0 10px var(--neon-gold);
    }

    @keyframes rotation {
        0% {
            transform: rotate(0deg);
        }

        100% {
            transform: rotate(360deg);
        }
    }

    #game-container {
        width: 100%;
        height: 100%;
        position: fixed;
        inset: 0;
        background: rgba(15, 15, 20, 0.2);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateZ(0);
        margin: auto;
        border-radius: 0;
        border: none;
    }

    /* [Layout Refinement] Force 95% Width & Centering */
    /* Using vw ensures it's relative to screen, not parent container */
    #game-header-bar,
    #game-footer-bar,
    .main-area,
    #main-container {
        width: 100% !important;
        max-width: 500px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .footer-btn-label {
        color: rgba(255, 255, 255, 0.7);
        font-size: 13px;
        font-weight: bold;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    }

    #main-container {
        height: calc(var(--vh, 1vh) * 100) !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transform: translateZ(0);
    }

    /* Ensure #game-body allows centering but doesn't double-pad */
    #game-body {
        width: 100vw !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        display: flex;
        flex-direction: column;
        align-items: center;
    }


    /* [Final Layout Styles - From User Request] */
    /* Replaces previous wireframe styles */

    .phone-container {
        width: 100%;
        /* ?�려???�라지???�단 메뉴 강제 부????�� (?�히???�이?�웃 겹침 ?�러 ?�발) */
        display: flex;
        flex-direction: column;
        gap: 10px;
        padding: 0;
        background: transparent !important;
        /* [Video Fix] Force transparency */
    }

    /* Common Box Style */
    .layout-box {
        border: 1px solid var(--border-glass);
        display: flex;
        justify-content: center;
        align-items: center;
        font-weight: bold;
        font-size: 12px;
        white-space: nowrap;
        background: rgba(0, 0, 0, 0.2);
        /* Slight visibility */
        color: #fff;
        position: relative;
        cursor: pointer;
        /* Interaction hint */
    }

    /* Circle Style */
    .layout-circle {
        border-radius: 50%;
        aspect-ratio: 1 / 1;
    }

    /* Header Area */
    .header-top {
        display: flex;
        align-items: center;
        gap: 5px;
        width: 100%;
    }

    .profile-btn {
        width: 70px;
        flex-shrink: 0;
    }

    .settings-btn {
        width: 45px;
        flex-shrink: 0;
    }

    .info-row {
        flex: 1;
        display: flex;
        gap: 4px;
        height: 35px;
    }

    .info-item {
        flex: 1;
        height: 100%;
        padding: 0 2px;
        font-size: 11px;
        /* Fit text */
    }

    /* Music Player */
    #menu-music-player.layout-box {
        width: 100%;
        height: 30px;
    }

    /* Specific button styles override default .layout-box size */
    #menu-profile-box {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
        border: none !important;
        /* Remove red/glass border */
        background: transparent !important;
        /* Clean look */
        border-radius: 50% !important;
        /* Circular */
    }

    #menu-profile-img {
        border-radius: 50% !important;
    }

    /* Specific button styles override default .layout-box size */
    .game-title-box {
        width: 100%;
        /* [Mobile Layout Fix] Reduce fixed height, use flex to fill available space */
        height: auto;
        flex: 1;
        /* Allow it to shrink/grow */
        min-height: 200px;
        /* Minimum size */
        max-height: 350px;
        /* Maximum size */
        font-size: 20px;
        color: var(--neon-gold);
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .menu-btn-box {
        width: 100%;
        height: 60px;
        font-size: 18px;
    }

    .footer-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 10px;
        /* [Mobile Fix] Safe area padding for bottom */
        padding-bottom: calc(5px + env(safe-area-inset-bottom));
        flex-shrink: 0;
    }

    .footer-item {
        width: 60px;
        /* Adjusted from 85px which might be too wide for mobile screens with 4 items */
        font-size: 10px;
        text-align: center;
        padding: 5px;
        word-break: keep-all;
        line-height: 1.2;
    }

    #header {
        display: flex;
        flex-direction: column !important;
        align-items: stretch;
        background: rgba(0, 0, 0, 0.4);
        border-bottom: 1px solid var(--border-glass);
        flex-shrink: 0;
        padding: 10px 15px 10px 15px !important;
        gap: 10px !important;
    }

    .header-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    #user-info {
        font-family: var(--number-font, 'Orbitron');
        font-weight: 700;
        color: var(--neon-blue) !important;
        letter-spacing: 1px;
        white-space: nowrap;
        display: block !important;
        min-width: 60px !important;
        width: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 9999 !important;
        position: relative;
        margin-left: 5px !important;
        font-size: 14px !important;
        /* From backup */
    }

    #user-wrapper {
        display: flex;
        align-items: center;
        min-width: 130px !important;
    }

    #lives {
        white-space: nowrap !important;
        margin-right: 5px !important;
        letter-spacing: -2px;
        font-size: 14px !important;
    }

    .control-btn-group {
        display: flex;
        gap: 12px !important;
        align-items: center;
    }

    .icon-btn {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid var(--border-glass);
        color: #ccc;
        width: 40px !important;
        height: 40px !important;
        border-radius: 6px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: 0.2s;
        font-size: 20px !important;
    }

    .icon-btn.active {
        background: var(--neon-gold);
        color: #000;
        border-color: var(--neon-gold);
        box-shadow: 0 0 10px var(--neon-gold);
    }

    /* [New] Edu Mode Specific Yellow Style */
    .icon-btn.active#btn-edu {
        background: #ffea00 !important;
        color: #000 !important;
        border-color: #ffea00 !important;
        box-shadow: 0 0 15px #ffea00 !important;
    }

    .icon-btn.off {
        opacity: 0.3;
        filter: grayscale(100%);
    }

    .btn {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-glass);
        color: #aaa;
        padding: 12px 16px !important;
        /* Mobile Fix from backup */
        border-radius: 6px;
        font-size: 14px !important;
        /* From backup */
        font-weight: 700;
        cursor: pointer;
        transition: 0.1s;
        font-family: var(--main-font, 'Pretendard');
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 48px !important;
        /* From backup */
    }

    .btn.selected {
        background: #fff !important;
        color: #000 !important;
        border-color: #fff !important;
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
        z-index: 10;
    }

    #install-btn {
        background: linear-gradient(45deg, #00f3ff, #0066ff);
        color: #fff;
        border: none;
        display: none;
    }

    #timer-box {
        width: 100%;
        height: 4px;
        background: rgba(255, 255, 255, 0.1);
        visibility: hidden;
    }

    #timer-bar {
        width: 100%;
        height: 100%;
        background: var(--neon-blue);
        box-shadow: 0 0 10px var(--neon-blue);
        transition: width 0.1s linear;
    }

    .view {
        display: none;
        flex: 1;
        flex-direction: column;
        width: 100%;
        height: 100%;
        overflow-x: hidden;
        overflow-y: auto !important;
        position: absolute;
        top: 0;
        left: 0;
        -webkit-overflow-scrolling: touch;

        /* [Final UI Polish] Hide scrollbar visually but allow scrolling */
        -ms-overflow-style: none;
        /* IE and Edge */
        scrollbar-width: none;
        /* Firefox */
    }

    /* Hide scrollbar for Chrome, Safari and Opera */
    .view::-webkit-scrollbar {
        display: none;
    }

    .view.active {
        display: flex;
        background: transparent !important;
        /* [Video Fix] Force transparency */
    }

    #menu-view {
        align-items: center;
        justify-content: flex-start;
        /* [Fixed] Changed from center to prevent top clipping */
        text-align: center;
        position: relative;
        padding-top: 10px;
        /* Slight buffer from header */
    }

    .menu-center {
        z-index: 10;
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        max-width: 400px;
        padding: 20px;
        /* Reduced top padding as margin:auto handles spacing */
        margin: auto 0;
        /* [Fixed] Safe centering: centers if space exists, aligns top if overflows */
    }

    .side-panel {
        display: none !important;
    }

    #main-title {
        font-family: var(--title-font, 'Black Han Sans');
        font-size: 2.5rem !important;
        /* [Compaction] Reduced from 3rem */
        color: #fff;
        text-shadow: 0 0 30px rgba(255, 204, 0, 0.5);
        background: linear-gradient(to bottom, #fff, #ffcc00);
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-bottom: 10px;
        /* [Compaction] Tight margin */

        /* [Final Fix] Massive padding to contain ascenders + glow */
        padding-top: 50px !important;
        padding-bottom: 10px !important;
        line-height: 1.2;
        margin-top: 0;
        display: block;
    }

    #sub-title {
        font-family: var(--number-font, 'Orbitron');
        font-size: 1.2rem !important;
        color: var(--neon-blue);
        letter-spacing: 6px;
        margin-bottom: 5px;
        font-weight: 900;
        opacity: 0.9;
        display: none !important;
        /* Hidden to save space */
    }

    #tag-line {
        font-family: var(--number-font, 'Orbitron');
        font-size: 10px !important;
        color: rgba(255, 255, 255, 0.5);
        letter-spacing: 4px;
        margin-bottom: 15px;
        /* Aggressively reduced from 25px */
        font-weight: 700;
    }

    .panel {
        width: 100%;
        background: rgba(0, 0, 0, 0.4);
        padding: 10px !important;
        /* Aggressively reduced from 15px */
        border-radius: 12px;
        border: 1px solid var(--border-glass);
        display: flex;
        flex-direction: column;
        gap: 8px;
        /* Aggressively reduced from 12px */
        margin-bottom: 15px;
        /* Aggressively reduced from 20px */
    }

    .input-area {
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-glass);
        border-radius: 6px;
        padding: 5px;
        transition: 0.3s;
    }

    .nick-input {
        width: 100%;
        background: transparent;
        border: none;
        color: #fff;
        padding: 10px;
        font-size: 18px;
        text-align: center;
        outline: none;
    }

    .menu-items {
        display: flex;
        flex-direction: column;
        gap: 4px;
        /* [Final Compaction] Minimum gap */
        width: 100%;
    }

    .start-btn {
        background: var(--neon-blue);
        color: #000;
        border: none;
        font-family: var(--main-font, 'Pretendard', sans-serif);
        font-weight: 800;
        font-size: 18px;
        /* Slightly reduced */
        padding: 10px;
        letter-spacing: 0px !important;
        /* Fixed from backup */
        border-radius: 8px;
        /* Fixed from backup */
        min-height: 48px !important;
        /* Keep start buttons slightly larger for touch */
    }

    #game-body {
        display: flex;
        flex: 1;
        flex-direction: column;
        padding: 25px 0 5px 0 !important;
        /* [Layout Fix] 0 side padding */
        gap: 10px !important;
        overflow: hidden;
    }

    .main-area {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* Changed from center */
        padding-top: 20px;
        /* Added some top cushioning */
        position: relative;
        transition: opacity 0.3s ease, transform 0.3s ease;
    }

    #q-category {
        font-family: var(--number-font, 'Orbitron');
        color: var(--neon-gold);
        font-size: 16px !important;
        margin-bottom: 8px !important;
        letter-spacing: 3px;
        text-transform: uppercase;
        opacity: 1;
        text-align: center;
        font-weight: 800;
        text-shadow: none !important;
        /* [User Feedback] Remove glow/blur */
    }

    #question-area {
        width: 100%;
        font-size: clamp(1.05rem, 4.5vw, 1.45rem) !important;
        font-weight: 800;
        line-height: 1.3 !important;
        margin-bottom: 10px !important;
        color: #fff;
        text-align: center;
        text-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
        word-break: keep-all;
        /* [Layout Fix] Fixed height - prevents box from expanding on long questions */
        height: 90px;
        max-height: 90px;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 5px;
    }

    #options {
        width: 100%;
        /* [Layout Fix] Force full width */
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px !important;
    }

    .option-card {
        height: 60px !important;
        /* [UI Fix] Fixed height */
        display: flex;
        align-items: center;
        padding: 0 15px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border-glass);
        padding: 0 20px !important;
        /* Slightly more side padding */
        border-radius: 10px;
        /* Slightly rounder */
        font-size: 17px !important;
        /* Slightly larger font */
        font-weight: 700;
        color: #ddd;
        text-align: left;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        height: 64px !important;
        /* Increased from 56px */
        display: flex;
        align-items: center;
        width: 100%;
        margin: 0 auto;
        position: relative;
        /* Anchor for explain-text */
    }

    .option-card .option-text {
        flex: 1;
    }

    .explain-text {
        position: absolute;
        bottom: -45px;
        left: 0;
        width: 100%;
        text-align: center;
        font-size: 14px;
        color: var(--neon-gold);
        font-weight: 700;
        opacity: 0;
        transition: 0.3s;
        text-shadow: 0 2px 4px #000;
        pointer-events: none;
        word-break: keep-all;
        z-index: 10;
    }

    .option-card.selected {
        background: rgba(255, 204, 0, 0.1) !important;
        border: 1px solid var(--neon-gold) !important;
        color: #fff !important;
        box-shadow: 0 0 15px rgba(255, 204, 0, 0.3);
    }

    .key-badge {
        background: rgba(255, 204, 0, 0.15);
        border: 1px solid var(--neon-gold);
        color: var(--neon-gold);
        min-width: 28px;
        height: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 6px;
        margin-right: 15px;
        font-size: 13px;
        font-family: var(--number-font, 'Orbitron');
        font-weight: 900;
        flex-shrink: 0;
    }

    .option-card.correct {
        background: var(--neon-green) !important;
        color: #000 !important;
        border-color: var(--neon-green) !important;
        box-shadow: 0 0 25px var(--neon-green);
        transform: scale(1.02);
        z-index: 20;
    }

    .option-card.wrong {
        background: var(--neon-red) !important;
        color: #fff !important;
        border-color: var(--neon-red) !important;
        opacity: 1 !important;
        /* [Fix] Make it clearly visible */
        box-shadow: 0 0 15px var(--neon-red);
        /* Added glow */
    }

    /* [Restored] Original Sidebar Styles + Blur Fix */
    .sidebar {
        width: 100% !important;
        background: transparent !important;
        border: none !important;
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        padding: 5px !important;
        /* Reverted padding */
        gap: 0 !important;
        align-items: center;
        text-align: center;
        order: -1;
        margin-bottom: 0px !important;
        z-index: 9999 !important;
        /* Keep high Z-index to avoid overlay overlap */
        position: relative;
        /* Clarity fixes kept */
        filter: none !important;
        backdrop-filter: none !important;
        mask: none !important;
        -webkit-mask: none !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .sb-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }

    .sb-label {
        /* Restored Original Look */
        font-size: 9px !important;
        color: #888 !important;
        /* Back to original grey */
        margin-bottom: 0 !important;
        font-family: var(--number-font, 'Orbitron', sans-serif) !important;
        /* Back to Orbitron */
        letter-spacing: 1px;
        opacity: 1 !important;
        font-weight: 700 !important;
        text-shadow: none !important;
        /* Keep shadow off for clarity */
        transform: none !important;
    }

    .sb-value {
        /* Restored Original Look */
        font-size: 16px !important;
        font-weight: 900;
        font-family: var(--number-font, 'Orbitron', sans-serif) !important;
        /* Back to Orbitron */
        color: #fff;
        /* [Fixed] Removed !important to allow inline specific colors */
        transition: transform 0.2s;
        /* Re-enable transition if desired, or keep off for max sharpness. User said 'original style', usually implies animation too. */
        text-shadow: none !important;
        /* Keep shadow off for clarity */
        opacity: 1 !important;
        transform: none !important;
    }

    .modal-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.95);
        z-index: 2000;
        display: none;
        justify-content: center;
        align-items: center;
    }

    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 30px;
        text-align: center;
        background: #111;
        border: 1px solid var(--border-glass);
        border-radius: 16px;
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.9);
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .key-hint {
        position: fixed;
        bottom: 15px;
        left: 0;
        width: 100%;
        color: rgba(255, 255, 255, 0.3);
        font-size: 10px;
        display: flex;
        justify-content: center;
        gap: 10px;
        pointer-events: none;
        z-index: 10;
    }

    .bgm-scroll-mask {
        width: 100px;
        overflow: hidden;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        mask-image: linear-gradient(90deg, transparent, white 10%, white 90%, transparent);
        -webkit-mask-image: linear-gradient(90deg, transparent, white 10%, white 90%, transparent);
    }

    .bgm-scroll-text {
        display: inline-block;
        animation: marquee 8s linear infinite;
        padding-left: 0;
    }

    @keyframes marquee {
        0% {
            transform: translateX(100%);
        }

        100% {
            transform: translateX(-100%);
        }
    }

    .music-visualizer,
    .waveform-icon {
        display: flex;
        gap: 2px;
        align-items: flex-end;
        height: 15px;
        margin-right: 10px;
    }

    .music-visualizer .bar,
    .waveform-icon .bar {
        width: 3px;
        background: var(--neon-blue);
        animation: equalize 0.8s infinite ease-in-out alternate;
    }

    .music-visualizer .bar:nth-child(1),
    .waveform-icon .bar:nth-child(1) {
        animation-delay: -0.4s;
        animation-duration: 0.6s;
    }

    .music-visualizer .bar:nth-child(2),
    .waveform-icon .bar:nth-child(2) {
        animation-delay: -0.2s;
        animation-duration: 0.8s;
    }

    .music-visualizer .bar:nth-child(3),
    .waveform-icon .bar:nth-child(3) {
        animation-delay: -0.7s;
        animation-duration: 0.7s;
    }

    .music-visualizer .bar:nth-child(4),
    .waveform-icon .bar:nth-child(4) {
        animation-delay: -0.5s;
        animation-duration: 0.9s;
    }

    @keyframes equalize {
        0% {
            height: 3px;
        }

        50% {
            height: 12px;
        }

        100% {
            height: 8px;
        }
    }

    .music-visualizer.paused .bar,
    .waveform-icon.paused .bar {
        animation: none !important;
        height: 3px !important;
    }

    /* Update Toast Animation */
    #update-toast.show {
        opacity: 1 !important;
        transform: translate(-50%, 0) !important;
    }

    /* Leaderboard Styles */
    .lb-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        gap: 0 !important;
        align-items: center;
        text-align: center;
        order: -1;
        margin-bottom: 0px !important;
        z-index: 9999 !important;
        /* Keep high Z-index to avoid overlay overlap */
        position: relative;
        /* Clarity fixes kept */
        filter: none !important;
        backdrop-filter: none !important;
        mask: none !important;
        -webkit-mask: none !important;
        transform: none !important;
        box-shadow: none !important;
    }

    .sb-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        position: relative;
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }

    .sb-label {
        /* Restored Original Look */
        font-size: 9px !important;
        color: #888 !important;
        /* Back to original grey */
        margin-bottom: 0 !important;
        font-family: var(--number-font, 'Orbitron', sans-serif) !important;
        /* Back to Orbitron */
        letter-spacing: 1px;
        opacity: 1 !important;
        font-weight: 700 !important;
        text-shadow: none !important;
        /* Keep shadow off for clarity */
        transform: none !important;
    }

    .sb-value {
        /* Restored Original Look */
        font-size: 16px !important;
        font-weight: 900;
        font-family: var(--number-font, 'Orbitron', sans-serif) !important;
        /* Back to Orbitron */
        color: #fff;
        /* [Fixed] Removed !important to allow inline specific colors */
        transition: transform 0.2s;
        /* Re-enable transition if desired, or keep off for max sharpness. User said 'original style', usually implies animation too. */
        text-shadow: none !important;
        /* Keep shadow off for clarity */
        opacity: 1 !important;
        transform: none !important;
    }

    .modal-overlay {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.95);
        z-index: 2000;
        display: none;
        justify-content: center;
        align-items: center;
    }

    .modal-content {
        width: 95%;
        max-width: 500px;
        padding: 30px;
        text-align: center;
        background: #111;
        border: 1px solid var(--border-glass);
        border-radius: 16px;
        box-shadow: 0 0 80px rgba(0, 0, 0, 0.9);
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .key-hint {
        position: fixed;
        bottom: 15px;
        left: 0;
        width: 100%;
        color: rgba(255, 255, 255, 0.3);
        font-size: 10px;
        display: flex;
        justify-content: center;
        gap: 10px;
        pointer-events: none;
        z-index: 10;
    }

    .bgm-scroll-mask {
        width: 100px;
        overflow: hidden;
        white-space: nowrap;
        display: inline-block;
        vertical-align: middle;
        mask-image: linear-gradient(90deg, transparent, white 10%, white 90%, transparent);
        -webkit-mask-image: linear-gradient(90deg, transparent, white 10%, white 90%, transparent);
    }

    .bgm-scroll-text {
        display: inline-block;
        animation: marquee 8s linear infinite;
        padding-left: 0;
    }

    @keyframes marquee {
        0% {
            transform: translateX(100%);
        }

        100% {
            transform: translateX(-100%);
        }
    }

    .music-visualizer,
    .waveform-icon {
        display: flex;
        gap: 2px;
        align-items: flex-end;
        height: 15px;
        margin-right: 10px;
    }

    .music-visualizer .bar,
    .waveform-icon .bar {
        width: 3px;
        background: var(--neon-blue);
        animation: equalize 0.8s infinite ease-in-out alternate;
    }

    .music-visualizer .bar:nth-child(1),
    .waveform-icon .bar:nth-child(1) {
        animation-delay: -0.4s;
        animation-duration: 0.6s;
    }

    .music-visualizer .bar:nth-child(2),
    .waveform-icon .bar:nth-child(2) {
        animation-delay: -0.2s;
        animation-duration: 0.8s;
    }

    .music-visualizer .bar:nth-child(3),
    .waveform-icon .bar:nth-child(3) {
        animation-delay: -0.7s;
        animation-duration: 0.7s;
    }

    .music-visualizer .bar:nth-child(4),
    .waveform-icon .bar:nth-child(4) {
        animation-delay: -0.5s;
        animation-duration: 0.9s;
    }

    @keyframes equalize {
        0% {
            height: 3px;
        }

        50% {
            height: 12px;
        }

        100% {
            height: 8px;
        }
    }

    .music-visualizer.paused .bar,
    .waveform-icon.paused .bar {
        animation: none !important;
        height: 3px !important;
    }

    /* Update Toast Animation */
    #update-toast.show {
        opacity: 1 !important;
        transform: translate(-50%, 0) !important;
    }

    /* Leaderboard Styles */
    .lb-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 15px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-size: 14px;
        transition: background 0.2s;
    }

    .lb-rank {
        font-family: var(--number-font, 'Orbitron');
        font-weight: 900;
        width: 30px;
        margin-right: 15px;
        text-align: center;
        font-size: 16px;
    }

    /* =========================================
   [NEW] 시네마틱 포스터 테마 모바일 기본 레이아웃 (Overlap & Clipping Prevention)
   ========================================= */
    .poster-viewport {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important; /* Top align to prevent vertical shift on height changes */
        align-items: center !important;
        height: 100% !important;
        box-sizing: border-box !important;
        padding-top: 15px !important; /* Optimized top padding (no longer pushed down) */
        padding-bottom: 40px !important; /* Safety padding above bottom buttons */
    }

    /* Cinematic Poster height expander override for mobile height constraint */
    #stat-carousel {
        height: 100% !important;
        max-height: none !important;
    }

    /* 반응형 구조를 해치지 않으면서 타이틀과 명언 영역을 고정할 스페이서 */
    .poster-spacer-top {
        flex: 0 0 2vh !important;
        max-height: 15px !important;
        min-height: 5px !important;
        width: 100%;
        pointer-events: none;
    }

    .poster-spacer-middle {
        flex: 0 0 5vh !important;
        max-height: 45px !important;
        min-height: 25px !important;
        width: 100%;
        pointer-events: none;
    }

    .poster-spacer-bottom {
        flex: 1 1 auto !important; /* 남는 모든 세로 여백을 다 받아내서 명언 길이 변화에 대처함 */
        min-height: 20px !important;
        width: 100%;
        pointer-events: none;
    }

    .poster-title-area {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        width: 100% !important;
        text-align: center !important;
        position: relative !important;
        z-index: 2 !important;
    }

    .poster-present {
        font-family: 'Cinzel', serif !important;
        font-size: 7px !important;
        color: #fbbf24 !important;
        letter-spacing: 5px !important;
        margin: 0 0 8px 0 !important;
        text-transform: uppercase !important;
        opacity: 0.8 !important;
        text-shadow: 0 1px 2px #000 !important;
        text-align: center !important;
        position: relative !important;
        z-index: 2 !important;
    }

    .poster-cast {
        font-family: 'Cinzel', serif !important;
        font-size: 8px !important;
        color: #f5e6d3 !important;
        letter-spacing: 4px !important;
        margin: 0 0 12px 0 !important;
        text-transform: uppercase !important;
        opacity: 0.9 !important;
        text-shadow: 0 1px 3px #000 !important;
        text-align: center !important;
        font-weight: 700 !important;
        position: relative !important;
        z-index: 2 !important;
    }

    .poster-large-title {
        font-family: 'Cinzel', serif !important;
        line-height: 1.25 !important;
        position: relative !important;
        z-index: 2 !important;
        margin: 0 !important;
    }

    .poster-title-babel {
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        text-shadow: 1px 1px 0px rgba(0,0,0,1), 2px 2px 0px rgba(0,0,0,1), 3px 3px 0px rgba(0,0,0,1), 5px 5px 15px rgba(0,0,0,0.95), 0 0 20px rgba(251, 191, 36, 0.25) !important;
        font-size: 32px !important; /* Mobile font size */
        letter-spacing: 4px !important;
        text-indent: 4px !important;
        font-weight: 900 !important;
        display: inline-block !important;
    }

    .poster-title-tower {
        font-size: 14px !important; /* Mobile font size */
        letter-spacing: 3px !important;
        font-weight: 700 !important;
        display: block !important;
        margin-top: 8px !important;
        color: #ffd54f !important;
        -webkit-text-fill-color: #ffd54f !important;
        text-shadow: 1px 1px 0px rgba(0,0,0,1), 2px 2px 0px rgba(0,0,0,1), 3px 3px 0px rgba(0,0,0,1), 5px 5px 15px rgba(0,0,0,0.95), 0 0 20px rgba(251, 191, 36, 0.35) !important;
    }

    .poster-subtitle {
        margin: 12px 0 0 0 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
        text-shadow: 1px 1px 0px rgba(0,0,0,1), 2px 2px 0px rgba(0,0,0,1), 3px 3px 0px rgba(0,0,0,1), 5px 5px 15px rgba(0,0,0,0.95), 0 0 20px rgba(251, 191, 36, 0.25) !important;
        font-size: 14px !important;
        letter-spacing: 2px !important;
        font-weight: 800 !important;
    }

    .poster-center-frame {
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 10 !important;
    }

    .poster-headline-quote {
        margin: 0 auto !important;
        font-size: 16px !important;
        line-height: 1.6 !important;
        max-width: 90% !important;
        text-align: center !important;
        font-weight: 800 !important;
        color: #ffffff !important;
        letter-spacing: 1.5px !important;
        text-shadow: 1px 1px 0px rgba(0,0,0,1), 2px 2px 0px rgba(0,0,0,1), 4px 4px 10px rgba(0,0,0,0.9), 0 0 15px rgba(251, 191, 36, 0.3) !important;
    }

    .poster-headline-quote span {
        font-size: 13px !important;
        font-weight: 800 !important;
        color: #ffd54f !important;
        display: block !important;
        margin-top: 10px !important;
        font-style: normal !important;
        text-shadow: 1px 1px 0px rgba(0,0,0,1), 2px 2px 5px rgba(0,0,0,0.9), 0 0 8px rgba(251, 191, 36, 0.3) !important;
    }

    /* 로딩화면 스타일 및 반응형 (Loading Screen Styling) */
    .loading-inner-wrap {
        position: relative !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 500px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important; /* Bottom-align to prevent overlap with centered background logo */
        align-items: center !important;
        z-index: 2 !important;
        background: url('../assets/imgs/로딩_밤.webp') no-repeat center center/cover !important; /* 시작=밤. 낮 레이어(#loading-day-layer)가 위에서 페이드인 */
        box-shadow: 0 0 50px rgba(0,0,0,0.8) !important;
        padding-bottom: 110px !important; /* Visual spacing from the bottom of the viewport on mobile */
    }

    .loading-bar-container {
        position: relative !important; z-index: 3 !important; /* 낮 레이어 위에 유지 */
        margin-top: 14px !important; /* 로딩 텍스트 아래 슬림 라인 */
        width: 300px !important;
        max-width: 76% !important;
        height: 3px !important;
        background: rgba(255,255,255,0.14) !important; /* 은은한 트랙 */
        border-radius: 2px !important;
        overflow: hidden !important;
        box-shadow: 0 1px 2px rgba(0,0,0,0.55) !important;
    }

    #loading-text {
        position: relative !important; z-index: 3 !important; /* 낮 레이어 위에 유지 */
        color: rgba(255,220,100,0.85) !important;
        font-family: var(--main-font, 'Montserrat', sans-serif) !important;
        font-size: 11px !important;
        margin-top: 12px !important;
        letter-spacing: 3px !important;
        text-transform: uppercase !important;
        text-shadow: 0 0 8px rgba(255,200,0,0.6) !important;
        animation: blink 1.5s infinite !important;
    }

    /* =========================================
   [NEW] 반응형 듀얼 레이어 배경 시스템
   ========================================= */
    #ambient-blur-background {
        position: fixed !important;
        inset: 0 !important;
        width: 100vw !important;
        height: 100% !important;
        z-index: -11 !important;
        background-size: cover !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        filter: blur(25px) brightness(0.35) !important;
        transform: scale(1.05) !important;
        /* 블러 경계면 하얗게 들뜨는 현상 방지 */
        pointer-events: none !important;
        transition: background-image 0.5s ease, opacity 0.5s ease !important;
    }

    #game-background-img {
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 100% !important;
        max-width: 500px !important;
        /* #main-container 가로폭과 정확히 매칭 */
        height: 100% !important;
        z-index: -10 !important;
        background-size: cover !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        pointer-events: none !important;
        transition: background-image 0.5s ease, opacity 0.5s ease !important;
    }

    /* =========================================
   [NEW] 전역 모바일 뷰포트 압축 방지 가드 (Aspect Ratio & Flex Shrink Guard)
   ========================================= */

    /* 1. 모든 헤더 및 푸터 영역의 세로 찌그러짐 방지 */
    .lobby-header-divine,
    .ingame-header-container,
    .ingame-header-layout,
    #header,
    .footer-row,
    .divine-footer-dock,
    #game-header-bar,
    #game-footer-bar {
        flex-shrink: 0 !important;
    }

    /* 2. 푸터 도크 버튼 및 프로필 아바타 원형 완벽 보존 */
    .dock-btn,
    .divine-footer-dock .footer-icon-frame,
    .divine-footer-dock .notif-bg-frame,
    .avatar-container-divine,
    #menu-profile-box {
        flex-shrink: 0 !important;
        aspect-ratio: 1 / 1 !important;
    }

    /* 푸터 도크 버튼 및 프레임 크기 강제 (헤더 알림 종 버튼과 격리) */
    .divine-footer-dock .dock-btn,
    .divine-footer-dock .footer-icon-frame,
    .divine-footer-dock .notif-bg-frame {
        width: 45px !important;
        height: 45px !important;
        min-width: 45px !important;
        min-height: 45px !important;
        box-sizing: border-box !important;
    }

    /* 3. 로비 프로필 줌 영역 내의 아바타 컨테이너 크기 정밀 제어 */
    #menu-profile-box {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
    }

    .avatar-container-divine {
        width: 3.5rem !important;
        height: 3.5rem !important;
        min-width: 3.5rem !important;
        min-height: 3.5rem !important;
    }

    /* 4. 세로 해상도가 낮은 모바일 기기에서의 푸터 도크 버튼 크기 자동 축소 및 원형 유지 */
    @media (max-height: 680px) {

        .divine-footer-dock .dock-btn,
        .divine-footer-dock .footer-icon-frame,
        .divine-footer-dock .notif-bg-frame {
            width: 38px !important;
            height: 38px !important;
            min-width: 38px !important;
            min-height: 38px !important;
        }
    }

    /* 로그인 패널 위치 반응형 조정 (구글 로그인 버튼 위치 최적화) */
    #login-panel {
        bottom: 180px !important;
    }
    @media (max-height: 740px) {
        #login-panel {
            bottom: 140px !important;
        }
    }
    @media (max-height: 640px) {
        #login-panel {
            bottom: 110px !important;
        }
    }

    /* =========================================
    [NEW] 태블릿 및 넓은 화면 반응형 최적화 (Tablet Responsive Overrides)
    ========================================= */
    @media (min-width: 600px) and (max-width: 1023px) {
        #game-header-bar,
        #game-footer-bar,
        .main-area,
        #main-container,
        #game-background-img {
            max-width: 100% !important; /* 좌우 검은 여백을 완벽히 제거하기 위해 100%로 확장 */
            width: 100% !important;
        }

        #main-container {
            height: 100vh !important; /* 상하 여백 제거를 위해 100vh 강제 */
            top: 0 !important;
            bottom: 0 !important;
        }

        /* 2. 헤더 영역 크기 및 비율 밸런싱 (가운데 버튼 영역인 680px 가로폭에 매칭 및 중앙 정렬) */
        .lobby-header-divine {
            padding: 20px 30px !important;
            max-width: 680px !important;
            margin-left: auto !important;
            margin-right: auto !important;
            width: 100% !important;
            box-sizing: border-box !important;
        }
        
        .profile-group-divine,
        .header-right-col-divine {
            zoom: 1.0 !important; /* 태블릿에서는 프로필과 재화를 더욱 시원하게 100% 스케일로 지정 */
        }

        /* 3. 명언 및 타이틀 영역 위치 조정 (위로 쏠림 방지 및 세로 밸런싱) */
        .stat-carousel-container {
            max-width: 80% !important;
            margin-left: auto !important;
            margin-right: auto !important;
        }

        /* [Fix] 태블릿/PC에서 타이틀 및 명언 영역이 위로 쏠리는 현상 해결을 위해 Flex 중앙 정렬 적용 */
        .poster-viewport {
            display: flex !important;
            flex-direction: column !important;
            justify-content: flex-start !important; /* Top align on desktop to prevent shifting */
            align-items: center !important;
            height: 100% !important;
            box-sizing: border-box !important;
            padding-top: 15px !important; /* Reduced from 25px to bring it closer to the profile tab */
            padding-bottom: 40px !important; /* Safety padding above bottom buttons */
        }

        .poster-spacer-top {
            flex: 0 0 12vh !important;
            max-height: 150px !important;
            min-height: 40px !important;
        }

        .poster-spacer-middle {
            flex: 0 0 14vh !important;
            max-height: 180px !important;
            min-height: 50px !important;
        }

        .poster-spacer-bottom {
            flex: 1.5 1 auto !important;
            min-height: 40px !important;
        }
 
        .poster-title-area {
            margin-top: 0 !important;
            margin-bottom: 0 !important;
        }
        
        .poster-present {
            font-size: 11px !important;
            letter-spacing: 6px !important;
            margin-bottom: 10px !important;
        }

        .poster-cast {
            font-size: 13px !important;
            letter-spacing: 5px !important;
            margin-bottom: 18px !important;
        }

        .poster-title-babel {
            font-size: 72px !important;
            letter-spacing: 10px !important;
            text-indent: 10px !important;
        }

        .poster-title-tower {
            font-size: 30px !important;
            letter-spacing: 6px !important;
            margin-top: 14px !important;
        }
        
        .poster-subtitle {
            font-size: 24px !important;
            margin-top: 20px !important;
            letter-spacing: 5px !important;
        }
 
        /* 명언 텍스트 및 저자 텍스트 크기 및 세로 마진 증가 */
        .poster-center-frame {
            top: 0 !important; /* flex 중앙정렬을 위해 고정 탑 제거 */
            max-width: none !important; /* 부모 프레임의 max-width를 해제하여 좌우 쏠림 현상 방지 */
            width: 100% !important;
            margin: 0 !important;
            display: flex !important;
            justify-content: center !important;
        }
        
        .poster-headline-quote {
            font-size: 24px !important; /* Increased for tablet readability */
            line-height: 1.6 !important;
            max-width: 600px !important; /* 명언 텍스트 자체의 최대 가로폭을 아래 버튼 영역과 매칭 */
            width: 90% !important;
            margin-left: auto !important;
            margin-right: auto !important;
            text-align: center !important;
        }
        .poster-headline-quote span {
            font-size: 17px !important; /* Increased for tablet */
            margin-top: 15px !important; /* Increased for better visual gap */
            display: block !important;
        }

        /* 로그인 패널 가로폭 조절 (메인 버튼들과 가로폭 통일) */
        #login-panel {
            max-width: 680px !important;
            margin-left: auto !important;
            margin-right: auto !important;
            box-sizing: border-box !important;
        }

        /* 4. 메인 버튼 컨테이너 및 버튼 최적화 */
        .menu-buttons-container {
            max-width: 680px !important;
            margin-left: auto !important;
            margin-right: auto !important;
            gap: 24px !important;
            top: -20px !important; /* 하단 버튼군이 너무 처지지 않게 보정 */
            padding-bottom: 30px !important;
        }

        /* 푸터 도크 정렬 (버튼 가로폭 680px과 매칭 및 중앙 배치) */
        .divine-footer-dock {
            max-width: 680px !important;
            margin-left: auto !important;
            margin-right: auto !important;
            width: 100% !important;
            box-sizing: border-box !important;
        }

        /* 메인 버튼 내부 텍스트 및 패딩 키우기 */
        .divine-menu-btn {
            height: 68px !important;
        }
        
        .divine-menu-btn > div:first-child {
            flex: 0 0 68px !important;
            height: 100% !important;
        }
        
        .divine-menu-btn svg {
            width: 32px !important;
            height: 32px !important;
        }

        .divine-menu-btn span {
            font-size: 1.35rem !important;
        }
        
        .divine-menu-btn div[style*="margin-top"] span, 
        .divine-menu-btn span[style*="color: #ffeb3b"],
        .divine-menu-btn span[style*="color:#ffeb3b"] {
            font-size: 0.85rem !important;
        }

        /* 로딩 화면 배경 이미지 반응형 제어 (태블릿 세로에서는 100% 꽉 채우고, PC/가로화면에서는 500px 중앙 열로 제한하여 로고 과확대/잘림 방지) */
        #loading-screen > div:not(#loading-ambient-blur) {
            width: 100% !important;
            margin-left: auto !important;
            margin-right: auto !important;
            padding-bottom: 170px !important; /* Increased space from the bottom on tablet */
        }

        /* 로딩화면 구성요소 태블릿 최적화 */
        .loading-bar-container {
            margin-top: 16px !important; /* Align to bottom padding structure */
            width: 380px !important;
            height: 4px !important;
        }

        #loading-text {
            font-size: 15px !important;
            margin-top: 18px !important;
            letter-spacing: 4px !important;
        }
    }

    /* 태블릿/PC 반응형 로딩 레이아웃 가로/세로 오버라이드 */
    @media (min-width: 600px) and (max-width: 1023px) and (orientation: portrait) {
        #loading-screen > div:not(#loading-ambient-blur) {
            max-width: 100% !important;
        }
    }

    @media (min-width: 600px) and (max-width: 1023px) and (orientation: landscape) {
        #loading-screen > div:not(#loading-ambient-blur) {
            max-width: 500px !important;
        }
    }

    /* =========================================
       PC 반응형: 게임을 폰 사이즈로 중앙 고정 (≥1024px)
       모바일 기본 스타일(작은 스페이서, 작은 폰트)이 그대로 적용됨
    ========================================= */
    @media (min-width: 1024px) {
        #game-container {
            left: 50% !important;
            right: auto !important;
            width: 430px !important;
            max-width: 430px !important;
            transform: translateX(-50%) translateZ(0) !important;
        }

        #main-container {
            left: 50% !important;
            right: auto !important;
            width: 430px !important;
            max-width: 430px !important;
            transform: translateX(-50%) translateZ(0) !important;
        }

        #game-background-img {
            max-width: 430px !important;
        }
    }