@font-face {
    font-family: 'DungGeunMo';
    src: url('fonts/DungGeunMo.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

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

:root {
    --matrix-green: #00ff41;
    --matrix-dark-green: #008f11;
    --matrix-bg: #0d0208;
    --glow: 0 0 10px #00ff41, 0 0 20px #00ff41, 0 0 30px #00ff41;
}

/* iOS Safari: glow 강도 완화 */
@supports (-webkit-touch-callout: none) {
    :root {
        --glow: 0 0 6px rgba(0, 255, 65, 0.7), 0 0 12px rgba(0, 255, 65, 0.35);
    }
}

body {
    font-family: 'DungGeunMo', monospace;
    background: #000;
    color: var(--matrix-green);
    margin: 0;
    padding: 0;
    /* 상태바/네비게이션바 영역까지 배경 확장 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
}

/* 16:9 Game Wrapper */
.game-wrapper {
    position: relative;
    width: 100vw;
    height: 56.25vw;
    max-height: 100vh;
    max-height: 100dvh;
    max-width: 177.78vh;
    background: transparent;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* Game Scaler - Fixed 1600x900 design */
.game-scaler {
    position: relative;
    width: 1600px;
    height: 900px;
    background: transparent;
    transform-origin: center center;
}

/* Matrix Rain Background (fullscreen) */
#matrix-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    opacity: 0.5;
}

/* Game Container */
.game-container {
    position: absolute;
    z-index: 1;
    width: 1200px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 20px 40px;
    display: none;
    flex-direction: column;
}

.game-container.active {
    display: flex;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 10px;
}

.level-display, .points-display {
    font-size: 32px;
    text-shadow: var(--glow);
    letter-spacing: 3px;
    font-weight: bold;
    position: relative;
}

.game-title {
    font-size: 36px;
    font-weight: 900;
    text-align: center;
    text-shadow: var(--glow);
    letter-spacing: 4px;
    animation: flicker 3s infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 1; }
    93% { opacity: 0.8; }
    94% { opacity: 1; }
    95% { opacity: 0.9; }
}

/* Control Buttons (positioned relative to wrapper, not scaler) */
.control-buttons {
    position: fixed;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    transform-origin: right center;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
}

/* 팝업이 열렸을 때 컨트롤 버튼 숨기기 */
body:has(.info-overlay.show) .control-buttons,
body:has(.ranking-overlay.show) .control-buttons,
body:has(.modal-overlay.show) .control-buttons,
body:has(.confirm-overlay.show) .control-buttons,
body:has(.level-complete-overlay.show) .control-buttons,
body:has(.game-clear-overlay.show) .control-buttons {
    display: none;
}

.ctrl-btn {
    width: 50px;
    height: 50px;
    border: 2px solid var(--matrix-green);
    background: rgba(0, 0, 0, 0.8);
    color: var(--matrix-green);
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:hover {
    background: var(--matrix-green);
    color: var(--matrix-bg);
    box-shadow: var(--glow);
}

.ctrl-btn.used {
    opacity: 0.3;
    pointer-events: none;
}

/* Question Area */
.question-area {
    text-align: center;
    margin: 5px 0 5px;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.progress-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--matrix-green);
    background: transparent;
    transition: all 0.3s;
}

/* 미진행 상태 */
.progress-dot.pending {
    background: transparent;
    opacity: 0.4;
}

/* 진행중 상태 */
.progress-dot.current {
    background: var(--matrix-green);
    box-shadow: var(--glow);
    animation: currentPulse 1s infinite;
}

@keyframes currentPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 완료 상태 */
.progress-dot.completed {
    background: var(--matrix-green);
    opacity: 1;
}

/* 패스 상태 */
.progress-dot.passed {
    background: #ff9900;
    border-color: #ff9900;
    opacity: 0.8;
}

/* 실패 상태 */
.progress-dot.failed {
    background: #ff0000;
    border-color: #ff0000;
    opacity: 0.8;
}

/* 광고 시청 후 정답 공개 상태 */
.progress-dot.revealed {
    background: #a78bfa;
    border-color: #a78bfa;
    opacity: 0.9;
}

.question-text {
    font-size: 42px;
    margin-bottom: 15px;
    font-family: 'DungGeunMo', sans-serif;
    font-weight: 700;
    line-height: 1.5;
}

.question-author {
    font-size: 12px;
    color: #ffd700;
    margin: -28px 0 10px 0;
    display: none;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
    padding: 10px 20px;
}

/* Answer Boxes */
.answer-boxes {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.answer-box {
    width: 95px;
    height: 85px;
    border: 3px solid var(--matrix-green);
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-family: 'DungGeunMo', sans-serif;
    font-weight: 700;
    color: var(--matrix-green);
    text-shadow: var(--glow);
    transition: all 0.3s;
}

.answer-box.filled {
    background: rgba(0, 255, 65, 0.15);
    cursor: pointer;
}

.answer-box.hint {
    color: #005a0a;
    font-size: 38px;
    text-shadow: none;
}

.answer-box.correct {
    background: rgba(0, 255, 65, 0.4);
    animation: correctFlash 0.5s;
}

.answer-box.wrong {
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.3);
    animation: shake 0.5s;
}

.answer-box.space-after {
    margin-right: 20px;
}

/* 현재 입력 대기 칸 커서 */
.answer-box.active {
    animation: cursorGlow 0.75s ease-in-out infinite;
}

/* 한글 조합 중인 칸 */
.answer-box.composing {
    border-color: var(--matrix-green);
}

/* 조합 중인 글자만 반전 깜빡임 */
.composing-char {
    display: inline-block;
    padding: 0 3px;
    border-radius: 3px;
    animation: composingBlink 0.5s step-end infinite;
}

@keyframes composingBlink {
    0%, 100% {
        color: var(--matrix-green);
        background: transparent;
        text-shadow: var(--glow);
    }
    50% {
        color: #000;
        background: var(--matrix-green);
        text-shadow: none;
    }
}

.answer-box.active:not(.filled):not(.hint)::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 50%;
    background: var(--matrix-green);
    box-shadow: 0 0 6px var(--matrix-green);
    animation: blinkCaret 0.7s step-end infinite;
}

@keyframes cursorGlow {
    0%, 100% {
        border-color: #00ff41;
        box-shadow: 0 0 14px var(--matrix-green), 0 0 28px rgba(0, 255, 65, 0.35);
    }
    50% {
        border-color: rgba(0, 255, 65, 0.4);
        box-shadow: 0 0 3px var(--matrix-green);
    }
}

@keyframes blinkCaret {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* 모든 칸 입력 완료 시 나타나는 엔터 버튼 */
.enter-submit-btn {
    width: 95px;
    height: 85px;
    border: 3px solid var(--matrix-green);
    background: rgba(0, 255, 65, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--matrix-green);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    animation: enterPulse 0.9s ease-in-out infinite;
    flex-shrink: 0;
}

.enter-submit-btn:hover {
    background: rgba(0, 255, 65, 0.3);
    transform: scale(1.07);
}

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

.enter-submit-btn svg {
    width: 38px;
    height: 38px;
    stroke-width: 2.5;
}

@keyframes enterPulse {
    0%, 100% {
        box-shadow: 0 0 8px var(--matrix-green), 0 0 18px rgba(0, 255, 65, 0.3);
    }
    50% {
        box-shadow: 0 0 3px var(--matrix-green);
    }
}

@keyframes correctFlash {
    0%, 100% { background: rgba(0, 255, 65, 0.4); }
    50% { background: rgba(0, 255, 65, 0.7); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

/* Hidden Input */
#hidden-input {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

/* Stats Row */
.stats-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 80px;
    margin: 20px 0 0;
    padding: 0 10px;
    font-size: 22px;
}

.warning-text {
    position: fixed;
    left: 50%;
    bottom: 15%;
    transform: translateX(-50%);
    color: #ff4444;
    font-size: 28px;
    font-weight: bold;
    text-shadow: 0 0 20px #ff4444, 0 0 40px #ff4444;
    text-align: center;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #ff4444;
    border-radius: 10px;
    z-index: 1000;
    opacity: 0;
    white-space: nowrap;
    max-width: 90vw;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

.warning-text.show {
    opacity: 1;
    visibility: visible;
    animation: warningPop 0.3s ease-out;
}

@keyframes warningPop {
    0% { transform: translateX(-50%) scale(0.8); }
    50% { transform: translateX(-50%) scale(1.1); }
    100% { transform: translateX(-50%) scale(1); }
}

/* Virtual Keyboard */
.keyboard {
    padding: 40px 0;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.key {
    min-width: 95px;
    height: 85px;
    border: 2px solid var(--matrix-green);
    background: rgba(0, 0, 0, 0.7);
    color: var(--matrix-green);
    font-size: 40px;
    font-family: 'DungGeunMo', sans-serif;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key:hover {
    background: rgba(0, 255, 65, 0.2);
}

.key:active, .key.pressed {
    background: var(--matrix-green);
    color: var(--matrix-bg);
    transform: scale(0.95);
    box-shadow: var(--glow);
}

.key.special {
    min-width: 105px;
    font-size: 44px;
}

.key.wide {
    min-width: 160px;
    font-size: 28px;
    font-family: 'DungGeunMo', monospace;
}

.key.action-key {
    min-width: 80px;
    font-size: 22px;
    font-family: 'DungGeunMo', sans-serif;
    color: #ffcc00;
    border-color: #ffcc00;
    white-space: nowrap;
}

.key.action-key:hover {
    background: rgba(255, 204, 0, 0.2);
}

.key.action-key:active, .key.action-key.pressed {
    background: #ffcc00;
    color: var(--matrix-bg);
    box-shadow: 0 0 20px #ffcc00;
}

#hint-btn.used,
#pass-btn.disabled, #pass-btn-alt.disabled {
    opacity: 0.4;
    pointer-events: none;
    border-color: #666;
    color: #666;
}

/* Stats Display */
.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    opacity: 0.7;
}

.stat-value {
    text-shadow: var(--glow);
    font-weight: bold;
    font-size: 26px;
}

/* Timer Bar */
.timer-container {
    width: 100%;
    max-width: 500px;
    margin: 10px auto;
    height: 20px;
    min-height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

.timer-bar {
    height: 100%;
    min-height: 16px;
    background: linear-gradient(90deg, var(--matrix-dark-green), var(--matrix-green));
    width: 100%;
    transition: width 0.1s linear;
    box-shadow: var(--glow);
}

.timer-bar.warning {
    background: linear-gradient(90deg, #ff6600, #ff9900);
    box-shadow: 0 0 10px #ff9900, 0 0 20px #ff9900, 0 0 30px #ff9900;
}

.timer-bar.danger {
    background: linear-gradient(90deg, #cc0000, #ff0000);
    box-shadow: 0 0 10px #ff0000, 0 0 20px #ff0000, 0 0 30px #ff0000;
    animation: dangerPulse 0.5s infinite;
}

@keyframes dangerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}


/* Result Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 400;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show, .confirm-overlay.show {
    display: flex;
}

.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 400;
    justify-content: center;
    align-items: center;
}

.confirm-overlay .modal-title {
    font-size: 32px;
    margin-bottom: 15px;
}

.confirm-overlay .modal-message {
    font-size: 18px;
    margin-bottom: 12px;
    line-height: 1.5;
}

.confirm-overlay .modal-message strong {
    font-size: 20px;
}

.confirm-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: nowrap;
}

.confirm-buttons .modal-btn {
    white-space: nowrap;
}

.modal-content {
    background: var(--matrix-bg);
    border: 3px solid var(--matrix-green);
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    box-shadow: var(--glow);
    max-width: 500px;
    width: 90%;
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-title {
    font-size: 48px;
    margin-bottom: 20px;
    text-shadow: var(--glow);
}

.modal-message {
    font-size: 24px;
    margin-bottom: 15px;
    font-family: 'DungGeunMo', sans-serif;
}

.modal-message strong {
    color: #fff;
    font-size: 28px;
}

.reveal-question {
    font-size: 20px;
    color: #aaa;
    margin-bottom: 10px;
    line-height: 1.5;
    word-break: keep-all;
}

.reveal-answer {
    font-size: 22px;
    margin-top: 6px;
}

.reveal-answer strong {
    color: #a78bfa;
    font-size: 28px;
}

.modal-score {
    font-size: 36px;
    margin: 30px 0;
    text-shadow: var(--glow);
}

.modal-btn {
    padding: 11px 28px;
    font-size: 18px;
    border: 2px solid var(--matrix-green);
    background: transparent;
    color: var(--matrix-green);
    cursor: pointer;
    border-radius: 10px;
    margin: 10px;
    transition: all 0.3s;
    font-family: 'DungGeunMo', monospace;
}

.modal-btn:hover {
    background: var(--matrix-green);
    color: var(--matrix-bg);
    box-shadow: var(--glow);
}

/* Info Overlay */
/* ===== 규칙 팝업 ===== */
.info-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 400;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.info-overlay.show {
    display: flex;
}

.info-panel {
    max-width: 500px;
    width: 100%;
    max-height: 88vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 255, 65, 0.3);
    background: #0d1010;
    box-shadow: 0 0 50px rgba(0, 255, 65, 0.1), 0 24px 60px rgba(0, 0, 0, 0.9);
    animation: modalPop 0.3s ease-out;
}

/* 헤더 */
.info-header {
    position: relative;
    background: linear-gradient(160deg, rgba(0, 255, 65, 0.1) 0%, rgba(0, 80, 17, 0.06) 100%);
    border-bottom: 1px solid rgba(0, 255, 65, 0.18);
    padding: 28px 28px 22px;
    text-align: center;
    flex-shrink: 0;
}

.info-x-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    font-family: monospace;
}

.info-x-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ccc;
}

.info-header-icon {
    font-size: 44px;
    display: block;
    margin-bottom: 8px;
    animation: floatIcon 3.2s ease-in-out infinite;
}

.info-panel h2 {
    font-size: 28px;
    color: var(--matrix-green);
    letter-spacing: 3px;
    text-shadow: 0 0 12px rgba(0, 255, 65, 0.5);
    margin: 0 0 6px;
    text-align: center;
}

.info-subtitle {
    color: #7a9980;
    font-size: 12px;
    font-family: 'DungGeunMo', sans-serif;
    margin: 0;
}

.privacy-policy-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 0;
    background: none;
    border: none;
    color: rgba(0, 255, 65, 0.35);
    font-size: 11px;
    font-family: 'DungGeunMo', sans-serif;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.privacy-policy-btn:hover,
.privacy-policy-btn:active {
    color: rgba(0, 255, 65, 0.7);
}

/* 콘텐츠 영역 */
.info-content {
    overflow-y: auto;
    flex: 1;
    padding: 20px 22px 24px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.info-content::-webkit-scrollbar {
    display: none;
}

/* 섹션 */
.info-section {
    margin-bottom: 14px;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border-left: 3px solid rgba(0, 255, 65, 0.4);
}

.info-section h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #ffcc00;
    text-shadow: 0 0 8px rgba(255, 204, 0, 0.4);
    letter-spacing: 1px;
}

.info-section p {
    font-size: 14px;
    margin-bottom: 6px;
    color: #889988;
    font-family: 'DungGeunMo', sans-serif;
    line-height: 1.6;
    text-align: left;
    padding-left: 4px;
}

.info-section p strong {
    color: #cceecc;
}

.info-section p:last-child {
    margin-bottom: 0;
}

.info-close-btn {
    display: block;
    margin: 16px auto 0;
    padding: 10px 40px;
}

/* Difficulty Selection */
.difficulty-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--matrix-bg);
    border: 3px solid var(--matrix-green);
    border-radius: 20px;
    padding: 50px;
    z-index: 100;
    text-align: center;
    box-shadow: var(--glow);
}

.difficulty-panel.show {
    display: block;
}

.difficulty-panel h2 {
    font-size: 36px;
    margin-bottom: 35px;
    text-shadow: var(--glow);
}

.difficulty-btn {
    display: block;
    width: 100%;
    padding: 20px 70px;
    font-size: 28px;
    margin: 15px 0;
    border: 2px solid var(--matrix-green);
    background: transparent;
    color: var(--matrix-green);
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s;
    font-family: 'DungGeunMo', monospace;
}

.difficulty-btn:hover {
    background: var(--matrix-green);
    color: var(--matrix-bg);
    box-shadow: var(--glow);
    transform: scale(1.02);
}


/* Score Popup Animation */
.score-popup {
    position: absolute;
    font-size: 48px;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    animation: scoreFloat 1s ease-out forwards;
    font-family: 'DungGeunMo', monospace;
    white-space: nowrap;
}

.score-popup.positive {
    color: var(--matrix-green);
    text-shadow: var(--glow);
}

.score-popup.negative {
    color: #ff0000;
    text-shadow: 0 0 10px #ff0000;
}

@keyframes scoreFloat {
    0% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1.3);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -60px) scale(1);
    }
}

/* Penalty Indicator (next to potential score) */
.penalty-indicator {
    display: inline-block;
    margin-left: 10px;
    color: #ff4444;
    font-size: 26px;
    font-weight: bold;
    text-shadow: 0 0 10px #ff4444, 0 0 20px #ff4444;
    opacity: 0;
    pointer-events: none;
}

.penalty-indicator.show {
    animation: penaltyFlash 0.8s ease-out forwards;
}

@keyframes penaltyFlash {
    0% { 
        opacity: 0;
        transform: scale(0.5);
    }
    20% { 
        opacity: 1;
        transform: scale(1.3);
    }
    40% { 
        opacity: 1;
        transform: scale(1);
    }
    80% {
        opacity: 1;
        transform: scale(1);
    }
    100% { 
        opacity: 0;
        transform: scale(0.8);
    }
}

/* Start Screen */
.start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--matrix-bg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.start-screen.hidden {
    display: none;
}

.start-title {
    font-size: 64px;
    text-shadow: var(--glow);
    margin-bottom: 20px;
    animation: flicker 2s infinite;
    text-align: center;
}

.start-subtitle {
    font-size: 24px;
    margin-bottom: 50px;
    opacity: 0.8;
    font-family: 'DungGeunMo', sans-serif;
}

.start-btn {
    padding: 25px 80px;
    font-size: 36px;
    border: 3px solid var(--matrix-green);
    background: transparent;
    color: var(--matrix-green);
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.3s;
    font-family: 'DungGeunMo', monospace;
    animation: pulse 2s infinite;
}

.start-btn:hover {
    background: var(--matrix-green);
    color: var(--matrix-bg);
    box-shadow: var(--glow);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* Nickname Input Area */
.nickname-input-area {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.nickname-input {
    padding: 15px 60px 15px 25px;
    font-size: 24px;
    font-family: 'DungGeunMo', sans-serif;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--matrix-green);
    border-radius: 10px;
    color: var(--matrix-green);
    text-align: center;
    width: 320px;
    outline: none;
    transition: all 0.3s;
}

.nickname-input:focus {
    box-shadow: var(--glow);
    background: rgba(0, 255, 65, 0.1);
}

.nickname-input::placeholder {
    color: rgba(0, 255, 65, 0.4);
}

.random-nick-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    font-size: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.random-nick-btn:hover {
    transform: translateY(-50%) rotate(180deg) scale(1.15);
    filter: drop-shadow(0 0 8px var(--matrix-green));
}

.nickname-hint {
    font-size: 16px;
    color: rgba(0, 255, 65, 0.5);
    margin-bottom: 30px;
    font-family: 'DungGeunMo', sans-serif;
}

.ranking-btn {
    padding: 18px 50px;
    font-size: 24px;
    border: 2px solid #ffcc00;
    background: transparent;
    color: #ffcc00;
    cursor: pointer;
    border-radius: 12px;
    margin-top: 20px;
    transition: all 0.3s;
    font-family: 'DungGeunMo', monospace;
}

.ranking-btn:hover {
    background: #ffcc00;
    color: var(--matrix-bg);
    box-shadow: 0 0 20px #ffcc00;
}

/* Ranking Overlay */
/* ===== 랭킹 팝업 ===== */
.ranking-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 400;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    padding: 20px;
}

.ranking-overlay.show {
    display: flex;
}

.ranking-panel {
    max-width: 540px;
    width: 100%;
    max-height: 88vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 200, 0, 0.28);
    background: #0d1010;
    box-shadow: 0 0 50px rgba(255, 200, 0, 0.07), 0 24px 60px rgba(0, 0, 0, 0.9);
    animation: modalPop 0.3s ease-out;
}

/* 헤더 */
.ranking-header {
    position: relative;
    background: linear-gradient(160deg, rgba(255, 200, 0, 0.1) 0%, rgba(180, 100, 0, 0.06) 100%);
    border-bottom: 1px solid rgba(255, 200, 0, 0.16);
    padding: 28px 28px 20px;
    text-align: center;
    flex-shrink: 0;
}

.ranking-x-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    font-family: 'DungGeunMo', monospace;
}

.ranking-x-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ccc;
}

.ranking-trophy {
    font-size: 46px;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 16px rgba(255, 200, 0, 0.7));
    animation: floatIcon 3.2s ease-in-out infinite;
}

.ranking-panel h2 {
    font-family: 'DungGeunMo', monospace;
    font-size: 30px;
    color: #ffcc00;
    letter-spacing: 3px;
    text-shadow: 0 0 14px rgba(255, 200, 0, 0.5);
    margin: 0 0 5px;
    text-align: center;
}

.ranking-subtitle {
    color: #6a5e28;
    font-size: 12px;
    font-family: 'DungGeunMo', sans-serif;
    margin: 0;
}

/* 바디 (스크롤) */
.ranking-body {
    overflow-y: auto;
    flex: 1;
    padding: 20px 22px 24px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ranking-body::-webkit-scrollbar {
    display: none;
}

/* 내 기록 카드 */
.ranking-my-record {
    margin-bottom: 18px;
}

.my-record-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(255, 200, 0, 0.1) 0%, rgba(200, 100, 0, 0.06) 100%);
    border: 1px solid rgba(255, 200, 0, 0.28);
    border-radius: 12px;
}

.my-rank-badge {
    background: linear-gradient(135deg, #ffcc00, #e08800);
    color: #1a0e00;
    font-family: 'DungGeunMo', monospace;
    font-size: 19px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 8px;
    min-width: 48px;
    text-align: center;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(255, 200, 0, 0.25);
    line-height: 1.2;
}

.my-record-info {
    flex: 1;
    min-width: 0;
}

.my-record-label {
    font-family: 'DungGeunMo', sans-serif;
    font-size: 10px;
    color: #6a5a28;
    letter-spacing: 1px;
    margin-bottom: 3px;
}

.my-nick {
    color: #fff;
    font-family: 'DungGeunMo', sans-serif;
    font-size: 15px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.my-score-block {
    text-align: right;
    flex-shrink: 0;
}

.my-score-label {
    font-family: 'DungGeunMo', sans-serif;
    font-size: 10px;
    color: #6a5a28;
    display: block;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
}

.my-score {
    color: #ffcc00;
    font-family: 'DungGeunMo', monospace;
    font-size: 22px;
    line-height: 1;
}

.no-record {
    text-align: center;
    color: rgba(255, 200, 0, 0.28);
    font-family: 'DungGeunMo', sans-serif;
    font-size: 13px;
    padding: 16px;
    background: rgba(255, 200, 0, 0.04);
    border: 1px solid rgba(255, 200, 0, 0.1);
    border-radius: 10px;
}

/* 랭킹 테이블 */
.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'DungGeunMo', sans-serif;
    margin-bottom: 16px;
}

.ranking-table thead tr {
    background: rgba(0, 0, 0, 0.35);
}

.ranking-table th {
    color: #445544;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 9px 8px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ranking-table td {
    padding: 11px 8px;
    text-align: center;
    font-size: 14px;
    color: #889988;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background 0.15s;
}

.ranking-table tbody tr:last-child td {
    border-bottom: none;
}

.ranking-table td:first-child {
    font-size: 18px;
    width: 44px;
}

/* Top 3 강조 */
.ranking-table tr.rank-1st {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.12) 0%, transparent 80%);
}
.ranking-table tr.rank-1st td {
    color: #ffd700;
    font-weight: 700;
    font-size: 15px;
}

.ranking-table tr.rank-2nd {
    background: linear-gradient(90deg, rgba(192, 210, 220, 0.08) 0%, transparent 80%);
}
.ranking-table tr.rank-2nd td {
    color: #c0d2dc;
    font-weight: 600;
    font-size: 14px;
}

.ranking-table tr.rank-3rd {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.1) 0%, transparent 80%);
}
.ranking-table tr.rank-3rd td {
    color: #cd8040;
    font-weight: 600;
}

.ranking-table tbody tr:not(.rank-1st):not(.rank-2nd):not(.rank-3rd):hover td {
    background: rgba(0, 255, 65, 0.04);
}

.no-rankings {
    text-align: center;
    color: rgba(0, 255, 65, 0.3);
    font-size: 14px;
    font-family: 'DungGeunMo', sans-serif;
    padding: 30px 20px;
}

.ranking-close-btn {
    display: block;
    margin: 0 auto;
    padding: 10px 40px;
}

/* Rank Result in Modal */
.rank-result {
    font-size: 28px;
    color: #ffcc00;
    display: block;
    margin-top: 10px;
}

/* ===== Portrait Mode (세로모드) ===== */
@media (orientation: portrait) {
    /* 가로폭을 뷰포트에 꽉 채움 */
    .game-wrapper {
        width: var(--viewport-width, 100vw);
        height: var(--viewport-height, 100vh);
        max-width: none;
        max-height: none;
        overflow: visible;
    }
    
    /* Portrait scaler - 540x960 design */
    .game-scaler {
        width: 540px;
        height: 960px;
        position: absolute;
        left: 50%;
        top: 0;
        margin-left: -270px;
        transform-origin: top center;
    }
    
    /* Control buttons at bottom horizontal */
    .control-buttons {
        position: fixed;
        right: auto;
        left: 50%;
        top: auto;
        bottom: 10px;
        transform: translateX(-50%);
        transform-origin: center bottom;
        flex-direction: row;
        gap: 15px;
    }
    
    .ctrl-btn {
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    
    /* Game Container adjustments */
    .game-container {
        width: 100%;
        padding: 24px 24px 15px;
        justify-content: flex-start;
    }
    
    /* Header */
    .game-header {
        padding: 12px 0;
        margin-bottom: 8px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .level-display, .points-display {
        font-size: 26px;
        letter-spacing: 2px;
    }
    
    .game-title {
        font-size: 28px;
        letter-spacing: 3px;
        width: 100%;
        order: -1;
        margin-bottom: 8px;
    }
    
    /* Question Area */
    .question-area {
        margin: 10px 0;
    }
    
    .progress-dots {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .progress-dot {
        width: 18px;
        height: 18px;
    }
    
    .question-text {
        font-size: 32px;
        margin-bottom: 15px;
        padding: 10px 15px;
        line-height: 1.5;
    }
    
    /* Answer boxes bigger */
    .answer-boxes {
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .answer-box {
        width: 60px;
        height: 60px;
        font-size: 32px;
        border-width: 2px;
    }
    
    
    .enter-submit-btn {
        width: 60px;
        height: 60px;
        border-width: 2px;
    }
    
    .enter-submit-btn svg {
        width: 28px;
        height: 28px;
    }
    
    .answer-box.hint {
        font-size: 28px;
    }
    
    /* Stats row */
    .stats-row {
        gap: 40px;
        margin: 15px 0 0;
        font-size: 20px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    /* Timer */
    .timer-container {
        max-width: 350px;
        height: 18px;
        min-height: 18px;
        margin: 12px auto;
    }
    
    .timer-bar {
        min-height: 16px;
    }
    
    /* Keyboard much smaller */
    .keyboard {
        padding: 10px 0 55px;
    }
    
    .keyboard-row {
        gap: 3px;
        margin-bottom: 3px;
    }
    
    .key {
        min-width: 36px;
        height: 40px;
        font-size: 20px;
        border-width: 1px;
        border-radius: 5px;
    }
    
    .key.special {
        min-width: 40px;
        font-size: 22px;
    }
    
    .key.wide {
        min-width: 58px;
        font-size: 14px;
    }
    
    .key.action-key {
        min-width: 38px;
        font-size: 13px;
        padding: 0 4px;
        white-space: nowrap;
    }
    
    /* Start screen bigger */
    .start-title {
        font-size: 44px;
        margin-bottom: 20px;
    }
    
    .start-subtitle {
        font-size: 22px;
        margin-bottom: 40px;
    }
    
    .start-btn {
        padding: 22px 60px;
        font-size: 30px;
    }
    
    /* Modals bigger */
    .modal-content {
        padding: 35px;
        max-width: 90%;
    }
    
    .modal-title {
        font-size: 38px;
    }
    
    .modal-message {
        font-size: 22px;
    }
    
    .modal-score {
        font-size: 30px;
        margin: 25px 0;
    }
    
    .modal-btn {
        padding: 11px 25px;
        font-size: 18px;
    }
    
    /* Info panel */
    .info-panel {
        max-width: 95%;
        max-height: 88%;
    }
    
    /* Warning text */
    .warning-text {
        font-size: 20px;
        padding: 10px 20px;
    }
    
    /* Score popup */
    .score-popup {
        font-size: 50px;
    }
    
    /* Nickname Input */
    .nickname-input-area {
        margin-bottom: 8px;
    }
    
    .nickname-input {
        padding: 12px 50px 12px 18px;
        font-size: 18px;
        width: 260px;
    }
    
    .random-nick-btn {
        right: 8px;
        width: 38px;
        height: 38px;
        font-size: 26px;
    }
    
    .nickname-hint {
        font-size: 14px;
        margin-bottom: 25px;
    }
    
    .ranking-btn {
        padding: 14px 35px;
        font-size: 20px;
        margin-top: 15px;
    }
    
    /* Ranking Panel */
    .ranking-panel {
        max-width: 95%;
        max-height: 88%;
    }
    
    .ranking-table th,
    .ranking-table td {
        padding: 10px 5px;
        font-size: 13px;
    }
    
    .rank-result {
        font-size: 22px;
    }
    
    /* 포트레잇 모드 - 확인/이어서하기 팝업 */
    .confirm-overlay .modal-content {
        padding: 30px 25px;
    }
    
    .confirm-overlay .modal-title {
        font-size: 32px;
    }
    
    .confirm-overlay .modal-message {
        font-size: 20px;
    }
    
    .confirm-overlay .confirm-score {
        font-size: 26px;
        margin: 20px 0;
    }
    
    .confirm-overlay .confirm-buttons {
        gap: 15px;
    }
    
    .confirm-overlay .modal-btn {
        padding: 10px 22px;
        font-size: 17px;
    }
}

/* ===== 네이티브 키보드 열림 (Capacitor 앱) ===== */
/* 네이티브 키보드 열림: 비주얼 뷰포트 크기로 고정 */
body.native-keyboard-open .game-wrapper {
    width: var(--viewport-width, 100vw) !important;
    height: var(--viewport-height, 100vh) !important;
    max-width: none !important;
    max-height: none !important;
    align-items: flex-start !important;
    overflow: visible !important;
}



/* hidden-input focus 시 HTML 키보드 숨기고 action 버튼만 표시 */
body.native-keyboard-open .keyboard {
    display: none !important;
}


body.native-keyboard-open .keyboard-actions {
    display: flex !important;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

body.native-keyboard-open .keyboard-actions .action-btn {
    padding: 10px 18px;
    font-size: 15px;
    border: 2px solid #ffcc00;
    background: transparent;
    color: #ffcc00;
    cursor: pointer;
    border-radius: 10px;
    font-family: 'DungGeunMo', sans-serif;
    white-space: nowrap;
    transition: all 0.3s;
}

body.native-keyboard-open .keyboard-actions .action-btn:active {
    background: rgba(255, 204, 0, 0.2);
}

body.native-keyboard-open .keyboard-actions .action-btn.used {
    opacity: 0.4;
    pointer-events: none;
    border-color: #666;
    color: #666;
}

/* ===== 정사각형 모드 (mode-square) ===== */
/* 화면 비율이 0.8~1.25 사이일 때 (시스템 키보드 올라온 상태 포함) */

/* 기본: keyboard-actions 숨김 */
.keyboard-actions {
    display: none;
}

/* 정사각형 모드 - UI 키보드 숨기고 중앙 정렬 */
body.mode-square .keyboard {
    display: none !important;
}

/* 정사각형 모드 - 하단 컨트롤 버튼 */
body.mode-square .control-buttons {
    position: fixed;
    right: auto;
    left: 50%;
    top: auto;
    bottom: 10px;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 12px;
}

body.mode-square .ctrl-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
}

body.mode-square {
    align-items: flex-start;
}

body.mode-square .game-wrapper {
    width: var(--viewport-width, 100vw);
    height: var(--viewport-height, 100vh);
    max-width: none;
    max-height: none;
    align-items: flex-start;
}

body.mode-square .game-scaler {
    width: 540px;
    height: 540px;
    position: absolute;
    left: 50%;
    top: 0;
    margin-left: -270px;
    transform-origin: top center;
}

body.mode-square .game-container {
    width: 100%;
    padding: 24px 24px 15px;
    justify-content: flex-start;
    height: 100%;
}

/* 헤더 - 한 줄로 */
body.mode-square .game-header {
    padding: 8px 0;
    margin-bottom: 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
}

body.mode-square .game-title {
    font-size: 24px;
    letter-spacing: 2px;
    width: auto;
    order: 0;
    margin-bottom: 0;
}

body.mode-square .level-display,
body.mode-square .points-display {
    font-size: 20px;
    letter-spacing: 1px;
}

/* 진행 상태 */
body.mode-square .progress-dots {
    gap: 6px;
    margin-bottom: 12px;
}

body.mode-square .progress-dot {
    width: 14px;
    height: 14px;
}

/* 질문 텍스트 */
body.mode-square .question-text {
    font-size: 30px;
    margin-bottom: 15px;
    padding: 8px 12px;
    line-height: 1.4;
}

/* 정답 박스 */
body.mode-square .answer-boxes {
    gap: 10px;
    margin-bottom: 15px;
}

body.mode-square .answer-box {
    width: 55px;
    height: 55px;
    font-size: 28px;
}

body.mode-square .answer-box.hint {
    font-size: 24px;
}


body.mode-square .enter-submit-btn {
    width: 55px;
    height: 55px;
}

body.mode-square .enter-submit-btn svg {
    width: 26px;
    height: 26px;
}

/* 타이머 */
body.mode-square .timer-container {
    max-width: 320px;
    height: 14px;
    min-height: 14px;
    margin: 10px auto;
}

/* Stats row */
body.mode-square .stats-row {
    gap: 35px;
    margin: 12px 0 0;
    font-size: 18px;
}

body.mode-square .stat-value {
    font-size: 20px;
}

/* 정사각형 모드에서 힌트/패스 버튼 표시 */
body.mode-square .keyboard-actions {
    display: flex !important;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
}

body.mode-square .keyboard-actions .action-btn {
    padding: 10px 18px;
    font-size: 15px;
    border: 2px solid #ffcc00;
    background: transparent;
    color: #ffcc00;
    cursor: pointer;
    border-radius: 10px;
    font-family: 'DungGeunMo', sans-serif;
    transition: all 0.3s;
    white-space: nowrap;
}

body.mode-square .keyboard-actions .action-btn:hover,
body.mode-square .keyboard-actions .action-btn:active {
    background: rgba(255, 204, 0, 0.2);
}

body.mode-square .keyboard-actions .action-btn.used {
    opacity: 0.4;
    pointer-events: none;
    border-color: #666;
    color: #666;
}

body.mode-square .question-area {
    margin: 8px 0;
}

/* ===== 정사각형 모드 - 시작 화면 ===== */
body.mode-square .start-screen {
    padding: 20px;
    justify-content: flex-start;
    padding-top: 40px;
}

body.mode-square .start-title {
    font-size: 38px;
    margin-bottom: 15px;
}

body.mode-square .start-subtitle {
    font-size: 18px;
    margin-bottom: 25px;
}

body.mode-square .nickname-input-area {
    margin-bottom: 8px;
}

body.mode-square .nickname-input {
    padding: 12px 45px 12px 18px;
    font-size: 18px;
    width: 240px;
}

body.mode-square .random-nick-btn {
    right: 8px;
    width: 35px;
    height: 35px;
    font-size: 22px;
}

body.mode-square .nickname-hint {
    font-size: 13px;
    margin-bottom: 20px;
}

body.mode-square .start-btn {
    padding: 18px 50px;
    font-size: 26px;
}

body.mode-square .ranking-btn {
    padding: 12px 30px;
    font-size: 18px;
    margin-top: 15px;
}

/* ===== 정사각형 모드 - 모달/패널 ===== */
body.mode-square .modal-content {
    padding: 20px 22px;
    max-width: 85%;
}

body.mode-square .modal-title {
    font-size: 28px;
    margin-bottom: 12px;
}

body.mode-square .modal-message {
    font-size: 16px;
    margin-bottom: 10px;
}

body.mode-square .modal-message strong {
    font-size: 20px;
}

body.mode-square .reveal-question {
    font-size: 15px;
}

body.mode-square .reveal-answer {
    font-size: 17px;
}

body.mode-square .reveal-answer strong {
    font-size: 21px;
}

body.mode-square .modal-score {
    font-size: 22px;
    margin: 15px 0;
}

body.mode-square .modal-btn {
    padding: 10px 26px;
    font-size: 18px;
    margin: 6px;
}

body.mode-square .ranking-panel {
    max-width: 90%;
    max-height: 88vh;
}

body.mode-square .ranking-header {
    padding: 20px 20px 16px;
}

body.mode-square .ranking-trophy {
    font-size: 34px;
    margin-bottom: 6px;
}

body.mode-square .ranking-panel h2 {
    font-size: 24px;
}

body.mode-square .ranking-body {
    padding: 14px 16px 18px;
}

body.mode-square .ranking-table th {
    font-size: 9px;
    padding: 7px 4px;
}

body.mode-square .ranking-table td {
    padding: 9px 4px;
    font-size: 12px;
}

body.mode-square .ranking-table tr.rank-1st td {
    font-size: 13px;
}

body.mode-square .my-record-card {
    padding: 10px 14px;
    gap: 10px;
}

body.mode-square .my-nick {
    font-size: 13px;
}

body.mode-square .my-score {
    font-size: 18px;
}

body.mode-square .ranking-my-record {
    margin-bottom: 12px;
}

body.mode-square .ranking-close-btn {
    padding: 8px 30px;
}

body.mode-square .info-panel {
    max-width: 90%;
    max-height: 88vh;
}

body.mode-square .info-header {
    padding: 20px 20px 16px;
}

body.mode-square .info-header-icon {
    font-size: 34px;
    margin-bottom: 6px;
}

body.mode-square .info-panel h2 {
    font-size: 22px;
}

body.mode-square .info-content {
    padding: 14px 16px 18px;
}

body.mode-square .info-section {
    margin-bottom: 10px;
    padding: 10px 12px;
}

body.mode-square .info-section h3 {
    font-size: 14px;
    margin-bottom: 7px;
}

body.mode-square .info-section p {
    font-size: 12px;
    margin-bottom: 4px;
}

body.mode-square .info-close-btn {
    padding: 8px 30px;
    margin-top: 10px;
}

/* ===== 정사각형 모드 - 종료/이어서하기 확인 팝업 ===== */
body.mode-square .confirm-overlay .modal-content {
    padding: 18px 20px;
    max-width: 88%;
}

body.mode-square .confirm-overlay .modal-title {
    font-size: 24px;
    margin-bottom: 10px;
}

body.mode-square .confirm-overlay .modal-message {
    font-size: 15px;
    margin-bottom: 8px;
    line-height: 1.4;
}

body.mode-square .confirm-overlay .modal-message strong {
    font-size: 17px;
}

body.mode-square .confirm-overlay .confirm-score {
    font-size: 18px;
    margin: 12px 0;
}

body.mode-square .confirm-overlay .confirm-buttons {
    gap: 10px;
    flex-wrap: nowrap;
}

body.mode-square .confirm-overlay .modal-btn {
    padding: 10px 20px;
    font-size: 16px;
    margin: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ===== Countdown Overlay ===== */
.countdown-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    z-index: 250;
    justify-content: center;
    align-items: center;
}

.countdown-overlay.show {
    display: flex;
}

.countdown-number {
    font-size: 200px;
    font-weight: 900;
    color: var(--matrix-green);
    text-shadow: 0 0 10px var(--matrix-green), 0 0 20px rgba(0, 255, 65, 0.5);
    animation: countdownPop 0.8s ease-out;
    font-family: 'DungGeunMo', monospace;
}

@keyframes countdownPop {
    0% {
        transform: scale(2);
        opacity: 0;
    }
    30% {
        transform: scale(0.9);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 포트레잇 모드 카운트다운 */
@media (orientation: portrait) {
    .countdown-number {
        font-size: 140px;
    }
}

/* 정사각형 모드 카운트다운 */
body.mode-square .countdown-number {
    font-size: 120px;
}

/* ===== Level Complete Modal ===== */
.level-complete-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    z-index: 400;
    justify-content: center;
    align-items: center;
}

.level-complete-overlay.show {
    display: flex;
}

.level-complete-title {
    font-size: 42px;
    color: #ffcc00;
    text-shadow: 0 0 20px #ffcc00, 0 0 40px #ffcc00;
    margin-bottom: 30px;
}

.level-stats {
    background: rgba(0, 255, 65, 0.08);
    border: 2px solid var(--matrix-green);
    border-radius: 15px;
    padding: 25px 35px;
    margin-bottom: 30px;
}

.level-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 24px;
    font-family: 'DungGeunMo', sans-serif;
    border-bottom: 1px solid rgba(0, 255, 65, 0.2);
}

.level-stat-row:last-child {
    border-bottom: none;
}

.level-stat-row.bonus {
    color: #ffcc00;
}

.level-stat-row.bonus span:last-child {
    text-shadow: 0 0 10px #ffcc00;
    animation: bonusPulse 1s infinite;
}

@keyframes bonusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.level-stat-row.total {
    font-size: 28px;
    font-weight: bold;
    padding-top: 18px;
    margin-top: 8px;
    border-top: 2px solid var(--matrix-green);
}

.level-stat-row.total span:last-child {
    color: #fff;
    text-shadow: var(--glow);
}

/* 포트레잇 모드 레벨 완료 */
@media (orientation: portrait) {
    .level-complete-title {
        font-size: 34px;
    }
    
    .level-stats {
        padding: 20px 25px;
    }
    
    .level-stat-row {
        font-size: 20px;
        padding: 10px 0;
    }
    
    .level-stat-row.total {
        font-size: 24px;
    }
}

/* 정사각형 모드 레벨 완료 */
body.mode-square .level-complete-overlay .modal-content {
    padding: 20px 25px;
    max-width: 85%;
}

body.mode-square .level-complete-title {
    font-size: 26px;
    margin-bottom: 15px;
}

body.mode-square .level-stats {
    padding: 12px 16px;
    margin-bottom: 15px;
}

body.mode-square .level-stat-row {
    font-size: 15px;
    padding: 6px 0;
}

body.mode-square .level-stat-row.total {
    font-size: 18px;
    padding-top: 10px;
    margin-top: 5px;
}

body.mode-square .level-complete-overlay .modal-btn {
    padding: 10px 28px;
    font-size: 18px;
}

/* ===== Game Clear Modal (전체 클리어) ===== */
.game-clear-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.98);
    z-index: 500;
    justify-content: center;
    align-items: center;
}

.game-clear-overlay.show {
    display: flex;
}

#confetti-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
}

.game-clear-modal {
    position: relative;
    z-index: 2;
    max-width: 520px;
    animation: clearModalPop 0.6s ease-out;
}

@keyframes clearModalPop {
    0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(2deg); }
    70% { transform: scale(0.95) rotate(-1deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.clear-badge {
    font-size: 32px;
    margin-bottom: 15px;
    animation: badgeBounce 1s infinite;
}

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.clear-title {
    color: #ffcc00 !important;
    text-shadow: 0 0 20px #ffcc00, 0 0 40px #ffcc00 !important;
    font-size: 52px !important;
    margin-bottom: 10px !important;
}

.game-clear-modal .modal-message {
    font-size: 22px;
    color: #fff;
    margin-bottom: 25px;
}

.clear-stats {
    background: rgba(0, 255, 65, 0.08);
    border: 2px solid var(--matrix-green);
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 20px;
}

.clear-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    font-size: 22px;
    font-family: 'DungGeunMo', sans-serif;
    border-bottom: 1px solid rgba(0, 255, 65, 0.2);
}

.clear-stat-row:last-child {
    border-bottom: none;
}

.clear-stat-row.final-score {
    font-size: 28px;
    font-weight: bold;
    padding-top: 18px;
    margin-top: 8px;
    border-top: 2px solid var(--matrix-green);
    border-bottom: none;
}

.clear-stat-row.final-score span:last-child {
    color: #ffcc00;
    text-shadow: 0 0 15px #ffcc00, 0 0 30px #ffcc00;
    animation: scoreGlow 1.5s infinite alternate;
}

@keyframes scoreGlow {
    0% { text-shadow: 0 0 15px #ffcc00, 0 0 30px #ffcc00; }
    100% { text-shadow: 0 0 25px #ffcc00, 0 0 50px #ffcc00, 0 0 70px #ff9900; }
}

.clear-rank-box {
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.2), rgba(255, 153, 0, 0.2));
    border: 2px solid #ffcc00;
    border-radius: 15px;
    padding: 20px 30px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 0 20px rgba(255, 204, 0, 0.3);
}

.clear-rank-label {
    font-size: 24px;
    font-family: 'DungGeunMo', sans-serif;
    color: #ffcc00;
}

.clear-rank-value {
    font-size: 42px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #ffcc00;
    animation: rankPulse 1s infinite;
}

@keyframes rankPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

#clear-restart-btn {
    font-size: 28px;
    padding: 18px 50px;
    background: linear-gradient(135deg, var(--matrix-dark-green), var(--matrix-green));
    border: none;
    color: var(--matrix-bg);
    font-weight: bold;
    box-shadow: var(--glow);
}

#clear-restart-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px var(--matrix-green), 0 0 50px var(--matrix-green);
}

/* 포트레잇 모드 게임 클리어 */
@media (orientation: portrait) {
    .game-clear-modal {
        max-width: 95%;
        padding: 30px;
    }
    
    .clear-badge {
        font-size: 26px;
    }
    
    .clear-title {
        font-size: 40px !important;
    }
    
    .game-clear-modal .modal-message {
        font-size: 18px;
        margin-bottom: 20px;
    }
    
    .clear-stats {
        padding: 15px 20px;
    }
    
    .clear-stat-row {
        font-size: 18px;
        padding: 10px 0;
    }
    
    .clear-stat-row.final-score {
        font-size: 24px;
    }
    
    .clear-rank-box {
        padding: 15px 20px;
    }
    
    .clear-rank-label {
        font-size: 20px;
    }
    
    .clear-rank-value {
        font-size: 34px;
    }
    
    #clear-restart-btn {
        font-size: 24px;
        padding: 15px 40px;
    }
    
    #confetti-canvas {
        width: 400px;
        height: 600px;
    }
}

/* 정사각형 모드 게임 클리어 */
body.mode-square .game-clear-modal {
    max-width: 85%;
    padding: 18px 22px;
}

body.mode-square .clear-badge {
    font-size: 18px;
    margin-bottom: 6px;
}

body.mode-square .clear-title {
    font-size: 28px !important;
    margin-bottom: 5px !important;
}

body.mode-square .game-clear-modal .modal-message {
    font-size: 14px;
    margin-bottom: 12px;
}

body.mode-square .clear-stats {
    padding: 10px 14px;
    margin-bottom: 12px;
}

body.mode-square .clear-stat-row {
    font-size: 14px;
    padding: 5px 0;
}

body.mode-square .clear-stat-row.final-score {
    font-size: 17px;
    padding-top: 10px;
    margin-top: 5px;
}

body.mode-square .clear-rank-box {
    padding: 10px 14px;
    margin-bottom: 12px;
}

body.mode-square .clear-rank-label {
    font-size: 15px;
}

body.mode-square .clear-rank-value {
    font-size: 24px;
}

body.mode-square #clear-restart-btn {
    font-size: 18px;
    padding: 10px 30px;
}

body.mode-square #confetti-canvas {
    width: 300px;
    height: 380px;
}

/* ===== 문제 출제 신청 모달 ===== */
.submit-gag-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.88);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.submit-gag-overlay.active {
    display: flex;
}

.submit-gag-modal {
    max-width: 460px;
    width: 100%;
    max-height: 92vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 255, 65, 0.3);
    background: #0d1010;
    box-shadow: 0 0 50px rgba(0, 255, 65, 0.1), 0 24px 60px rgba(0, 0, 0, 0.9);
    animation: modalPop 0.3s ease-out;
}

/* 헤더 */
.submit-gag-header {
    position: relative;
    background: linear-gradient(160deg, rgba(0, 255, 65, 0.1) 0%, rgba(0, 80, 17, 0.06) 100%);
    border-bottom: 1px solid rgba(0, 255, 65, 0.18);
    padding: 30px 28px 24px;
    text-align: center;
    flex-shrink: 0;
}

.submit-x-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
    padding: 0;
    font-family: 'DungGeunMo', monospace;
}

.submit-x-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    color: #ccc;
}

.submit-gag-icon {
    font-size: 46px;
    display: block;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 14px rgba(255, 220, 0, 0.55));
    animation: floatIcon 3.2s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-6px) rotate(3deg); }
}

.submit-gag-title {
    font-family: 'DungGeunMo', monospace;
    font-size: 30px;
    color: var(--matrix-green);
    letter-spacing: 3px;
    text-shadow: 0 0 12px rgba(0, 255, 65, 0.5);
    margin: 0 0 8px;
}

.submit-desc {
    color: #7a9980;
    font-size: 13px;
    font-family: 'DungGeunMo', sans-serif;
    margin: 0;
    line-height: 1.5;
}

/* 바디 (스크롤 영역) */
.submit-gag-body {
    overflow-y: auto;
    flex: 1;
    padding: 24px 26px 28px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.submit-gag-body::-webkit-scrollbar {
    display: none;
}

/* 입력 필드 */
.submit-field {
    margin-bottom: 18px;
}

.submit-field-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 7px;
}

.submit-field-header label {
    color: #b8c8b8;
    font-size: 13px;
    font-family: 'DungGeunMo', sans-serif;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.submit-field-header label .required {
    color: #ff7070;
    margin-left: 2px;
}

.char-count {
    font-family: 'DungGeunMo', monospace;
    font-size: 14px;
    color: #3a5040;
    transition: color 0.25s;
}

.char-count.near-limit {
    color: #cc8800;
}

.char-count.at-limit {
    color: #ff5555;
    font-weight: bold;
}

.submit-field input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(0, 255, 65, 0.18);
    border-radius: 10px;
    color: #d8edd8;
    font-size: 15px;
    font-family: 'DungGeunMo', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.submit-field input[type="text"]:focus {
    outline: none;
    border-color: var(--matrix-green);
    background: rgba(0, 255, 65, 0.05);
    box-shadow: 0 0 0 3px rgba(0, 255, 65, 0.1), 0 0 16px rgba(0, 255, 65, 0.08);
}

.submit-field input[type="text"]::placeholder {
    color: #2e4035;
    font-style: italic;
}

/* 토글 스위치 행 */
.submit-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 255, 65, 0.14);
    border-radius: 10px;
    margin-bottom: 16px;
    gap: 12px;
}

.toggle-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.toggle-title {
    color: #b8c8b8;
    font-size: 13px;
    font-family: 'DungGeunMo', sans-serif;
    font-weight: 700;
}

.toggle-desc {
    color: #4a6050;
    font-size: 11px;
    font-family: 'DungGeunMo', sans-serif;
    line-height: 1.4;
}

/* 토글 스위치 UI */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    transition: background 0.25s, border-color 0.25s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 22px;
    width: 22px;
    left: 2px;
    top: 2px;
    background: #555;
    border-radius: 50%;
    transition: transform 0.25s, background 0.25s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.toggle-switch input:checked + .toggle-slider {
    background: rgba(0, 255, 65, 0.22);
    border-color: rgba(0, 255, 65, 0.6);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: var(--matrix-green);
    box-shadow: 0 0 8px rgba(0, 255, 65, 0.6);
}

/* 안내 팁 */
.submit-tip {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 190, 0, 0.05);
    border: 1px solid rgba(255, 190, 0, 0.12);
    border-radius: 8px;
    margin-bottom: 20px;
    font-family: 'DungGeunMo', sans-serif;
    font-size: 11px;
    color: #7a6a40;
    line-height: 1.5;
}

.tip-icon {
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* 버튼 영역 */
.submit-buttons {
    display: flex;
    gap: 10px;
}

.submit-buttons .modal-btn {
    flex: 1;
    margin: 0;
}

.submit-cancel-btn {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: #666 !important;
}

.submit-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.25) !important;
    color: #aaa !important;
    box-shadow: none !important;
}

.submit-confirm-btn {
    background: linear-gradient(135deg, rgba(0, 255, 65, 0.85) 0%, rgba(0, 150, 30, 0.9) 100%) !important;
    border-color: rgba(0, 255, 65, 0.7) !important;
    color: #001a08 !important;
    font-weight: bold;
    letter-spacing: 1px;
}

.submit-confirm-btn:hover {
    background: linear-gradient(135deg, #00ff41 0%, #00c025 100%) !important;
    box-shadow: 0 0 22px rgba(0, 255, 65, 0.4), 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    transform: translateY(-1px);
}

/* 결과 메시지 */
.submit-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: 10px;
    text-align: center;
    font-family: 'DungGeunMo', sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.submit-result.success {
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid rgba(0, 255, 65, 0.35);
    color: #66ffaa;
}

.submit-result.error {
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 100, 100, 0.35);
    color: #ff8888;
}

/* ===== 정사각형 모드 - 문제 출제 모달 ===== */
body.mode-square .submit-gag-modal {
    max-width: 88%;
    max-height: 88vh;
}

body.mode-square .submit-gag-header {
    padding: 22px 22px 18px;
}

body.mode-square .submit-gag-icon {
    font-size: 36px;
    margin-bottom: 7px;
}

body.mode-square .submit-gag-title {
    font-size: 24px;
}

body.mode-square .submit-desc {
    font-size: 12px;
}

body.mode-square .submit-gag-body {
    padding: 18px 20px 22px;
}

body.mode-square .submit-field {
    margin-bottom: 14px;
}

body.mode-square .submit-field input[type="text"] {
    padding: 10px 14px;
    font-size: 14px;
}

body.mode-square .submit-toggle-row {
    padding: 10px 14px;
    margin-bottom: 12px;
}

body.mode-square .submit-tip {
    font-size: 10px;
    padding: 8px 12px;
    margin-bottom: 14px;
}

body.mode-square .submit-buttons .modal-btn {
    padding: 10px 18px;
    font-size: 16px;
}

/* 네이티브 앱에서 전체화면 버튼 숨김 (앱 자체가 전체화면) */
body.is-capacitor #fullscreen-btn {
    display: none;
}
