:root {
    --bg-main: #000000;
    --text-main: #ffffff;
    --font: 'Outfit', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-touch-callout: none; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    background: var(--bg-main);
    font-family: var(--font), sans-serif; color: var(--text-main);
    touch-action: none; margin: 0; padding: 0;
    overscroll-behavior-y: contain;
}

.game-container {
    position: relative; width: 100%; height: 100%; max-width: 600px; margin: 0 auto;
    background: var(--bg-main);
    overflow: hidden; display: flex; flex-direction: column;
}

#webgl-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }

.ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 10; display: flex; flex-direction: column;
}

.header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; pointer-events: none;
    position: relative;
    background: rgba(255, 255, 255, 0.1); 
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.best-score-container {
    display: flex; flex-direction: column; align-items: flex-start;
}

.best-score-container .label {
    font-size: 1rem; font-weight: 900; color: #ffeb3b;
    margin-bottom: -5px; text-shadow: 1px 1px 2px #000;
}

.best-score-container .value {
    font-size: 1.5rem; font-weight: 900; color: #fff; text-shadow: 1px 1px 2px #000;
    transition: transform 0.1s;
}

.score-container { text-align: center; }

.value { 
    font-size: 2.5rem; font-weight: 900; color: #fff; 
    text-shadow: 0 0 10px rgba(255,255,255,0.5);
    display: inline-block; transition: transform 0.1s; 
}

.timer-badge {
    font-weight: 900; font-size: 1.8rem; color: #ff3b30;
    text-shadow: 0 0 10px rgba(255,59,48,0.5);
    pointer-events: none; display: flex; align-items: center; gap: 5px;
}
.timer-badge::before { content: '⏱️'; font-size: 1.2rem; }

.combo-badge {
    position: absolute; top: 100px; left: 50%; transform: translateX(-50%);
    font-weight: 900; font-size: 3rem; color: #ffeb3b; 
    text-shadow: 0 0 30px #ff9800, 3px 3px 0 #000;
    pointer-events: none; opacity: 1;
    z-index: 50; white-space: nowrap;
}

.combo-badge.hidden { display: none; }

@keyframes comboAnim { 
    0% { transform: translate(-50%, 0) scale(0.8); opacity: 0; } 
    10% { transform: translate(-50%, 0) scale(1.2); opacity: 1; }
    90% { transform: translate(-50%, 0) scale(1); opacity: 1; }
    100% { transform: translate(-50%, 0) scale(1); opacity: 1; }
}

.overlay-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(15px);
    z-index: 30; pointer-events: none; transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#startScreen {
    background: linear-gradient(-45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3);
    background-size: 400% 400%;
    animation: rainbowAnim 8s ease infinite;
}

@keyframes rainbowAnim {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.overlay-screen.active { opacity: 1; pointer-events: auto; }
.overlay-screen.hidden { display: none; }

.modal { 
    text-align: center; background: rgba(255, 255, 255, 0.1); 
    padding: 40px; border-radius: 30px; border: 1.5px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4); width: 90%; max-width: 450px;
}

.modal h1 { font-size: 2.8rem; font-weight: 900; margin-bottom: 20px; color: #fff; text-shadow: 0 0 20px rgba(255,255,255,0.3); }

.btn-primary {
    background: #fff; border: none; color: #000;
    padding: 15px 30px; border-radius: 50px; font-family: var(--font);
    font-size: 1.5rem; font-weight: 900; cursor: pointer; 
    transition: transform 0.1s; width: 100%;
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.2); border: 1.5px solid rgba(255, 255, 255, 0.4); 
    color: #fff; padding: 12px 30px; border-radius: 50px; font-family: var(--font);
    font-size: 1.2rem; font-weight: 800; cursor: pointer; 
    transition: transform 0.1s; width: 100%; margin-top: 5px;
}
.btn-primary:active, .btn-secondary:active { transform: scale(0.95); }

.login-modal h1 { margin-bottom: 5px; }
.login-modal .subtitle { font-size: 1.1rem; color: #eee; margin-bottom: 30px; opacity: 0.8; }

.input-field {
    width: 100%; padding: 18px; border-radius: 15px; border: 1.5px solid rgba(255,255,255,0.2);
    font-size: 1.3rem; margin-bottom: 20px; font-family: var(--font);
    text-align: center; background: rgba(255,255,255,0.9); color: #222;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); transition: all 0.3s;
    pointer-events: auto;
}
.input-field:focus { outline: none; background: #fff; transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.2); border-color: #fff; }

.social-btn-container {
    display: flex; flex-direction: row; justify-content: space-around; align-items: center;
    gap: 15px; margin-top: 30px;
}

.social-btn {
    width: 65px; height: 65px; border-radius: 18px; border: none;
    cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #fff; pointer-events: auto;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}
.social-btn:hover { transform: translateY(-5px); box-shadow: 0 12px 25px rgba(0,0,0,0.3); }
.social-btn:active { transform: scale(0.9); }
.social-btn svg { width: 32px; height: 32px; flex-shrink: 0; }

.social-btn.google { background: #ffffff; border: 1px solid #ddd; }
.social-btn.naver { background: #03c75a; }
.social-btn.kakao { background: #fee500; }
.social-btn.facebook { background: #1877f2; }

/* Turn Timer & Point Dashboard */
.turn-timer {
    position: absolute; bottom: 170px; left: 50%; transform: translateX(-50%);
    font-size: 3rem; font-weight: 900; color: #ffeb3b;
    text-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(5px);
    width: 80px; height: 80px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 3px solid #ffeb3b; z-index: 60;
}
.turn-timer.warning { 
    color: #ff3b30; border-color: #ff3b30; 
    animation: timerPanic 0.5s infinite alternate;
}
@keyframes timerPanic {
    0% { transform: translateX(-50%) scale(1); opacity: 1; }
    100% { transform: translateX(-50%) scale(1.2); opacity: 0.8; }
}

.point-display {
    position: absolute; top: 120px; left: 50%; transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.3); backdrop-filter: blur(10px);
    padding: 10px 25px; border-radius: 30px; border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex; align-items: center; gap: 15px; font-weight: 900; font-size: 1.2rem;
    color: #fff; z-index: 40;
}
.vs { color: #ff3b30; font-weight: 400; font-style: italic; }

/* Mode Selection */
.mode-modal { max-width: 600px; padding: 40px; background: rgba(0, 0, 0, 0.4); backdrop-filter: blur(25px); border: 2px solid rgba(255,255,255,0.1); border-radius: 40px; animation: modalEnter 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes modalEnter { 0% { transform: scale(0.8); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.mode-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 30px; }
@media (min-width: 500px) { .mode-grid { grid-template-columns: 1fr 1fr 1fr; } }

.mode-card {
    background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.1);
    border-radius: 30px; padding: 30px 20px; cursor: pointer; transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; align-items: center; text-align: center;
    position: relative; overflow: hidden;
}
.mode-card:hover { 
    background: rgba(255, 255, 255, 0.15); 
    transform: translateY(-10px) scale(1.05); 
    box-shadow: 0 15px 45px rgba(0,0,0,0.4);
}

.mode-card[data-mode="AI_BATTLE"]:hover { border-color: #ff3b30; box-shadow: 0 0 30px rgba(255, 59, 48, 0.3); }

.mode-settings {
    margin-top: 15px; display: flex; gap: 10px; font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.2); padding: 5px 10px; border-radius: 15px;
}
.mode-settings label { cursor: pointer; display: flex; align-items: center; gap: 4px; }

.mode-card[data-mode="SINGLE"]:hover { border-color: #007AFF; box-shadow: 0 0 30px rgba(0, 122, 255, 0.3); }
.mode-card[data-mode="MULTI"]:hover { border-color: #34C759; box-shadow: 0 0 30px rgba(52, 199, 89, 0.3); }

.mode-card .icon { font-size: 3.5rem; margin-bottom: 15px; filter: drop-shadow(0 0 10px rgba(255,255,255,0.3)); }
.mode-card h3 { font-size: 1.4rem; margin-bottom: 8px; color: #fff; font-weight: 900; }
.mode-card p { font-size: 0.9rem; opacity: 0.6; color: #eee; font-weight: 500; }

/* Lobby Screen Decoration */
#generatedCode {
    font-family: 'Courier New', Courier, monospace;
    font-size: 4rem !important; font-weight: 900;
    color: #ffeb3b; text-shadow: 0 0 20px rgba(255, 235, 59, 0.8), 0 0 40px rgba(255, 235, 59, 0.4);
    letter-spacing: 15px; padding-left: 15px; margin: 25px 0 !important;
}

#lobbyScreen .btn-primary { 
    background: linear-gradient(135deg, #34C759, #28a745); color: #fff; 
    box-shadow: 0 10px 20px rgba(40, 167, 69, 0.3);
}
#lobbyScreen .btn-secondary { 
    background: rgba(255, 255, 255, 0.1); border: 1.5px solid rgba(255, 255, 255, 0.3);
}

/* Turn Indicator Decoration */
.turn-indicator {
    position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(15px);
    padding: 12px 40px; border-radius: 60px; font-weight: 900; font-size: 1.6rem;
    color: #fff; border: 2px solid rgba(255, 255, 255, 0.3); z-index: 60;
    pointer-events: none; animation: turnPulse 2s infinite ease-in-out;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); 
    white-space: nowrap;
}
@keyframes turnPulse {
    0% { transform: translateX(-50%) scale(1); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
    50% { transform: translateX(-50%) scale(1.05); box-shadow: 0 15px 40px rgba(255,255,255,0.2); }
    100% { transform: translateX(-50%) scale(1); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
}

#roomHostView.hidden, #roomJoinView.hidden { display: none; }
