@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Noto+Sans+KR:wght@400;700;900&display=swap');

/* ===== CSS 변수 (테마 시스템) ===== */
:root {
    --theme-primary: #667eea;
    --theme-secondary: #764ba2;
    --theme-accent: #ff6b6b;
    --theme-accent2: #feca57;
    --theme-success: #4CAF50;
    --theme-warning: #ffc107;
    --theme-danger: #dc3545;
    --theme-text: #333;
    --theme-textLight: #666;
    --theme-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --theme-headerBg: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    --theme-cardBg: rgba(255,255,255,0.9);
    --theme-buttonBg: linear-gradient(135deg, #ff6b6b, #feca57);
    
    /* 추가 공통 변수 */
    --border-radius-sm: 10px;
    --border-radius-md: 15px;
    --border-radius-lg: 20px;
    --border-radius-xl: 25px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    --shadow-sm: 0 2px 10px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --blur-sm: blur(5px);
    --blur-md: blur(10px);
    --blur-lg: blur(15px);
}

/* ===== 기본 리셋 및 전역 스타일 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--theme-background);
    min-height: 100vh;
    color: var(--theme-text);
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== 테마 시스템 ===== */
.theme-dropdown {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1051;
}

.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 12px 20px;
    border-radius: var(--border-radius-xl);
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    backdrop-filter: var(--blur-md);
    transition: var(--transition-normal);
    color: white;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.dropdown-arrow {
    font-size: 0.8rem;
    transition: var(--transition-normal);
}

.theme-toggle-btn.active .dropdown-arrow {
    transform: rotate(180deg);
}

.theme-dropdown-menu {
    position: fixed;
    top: 60px;
    left: 0;
    z-index: 9999;
    background: var(--theme-cardBg);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: var(--blur-lg);
    border: 2px solid rgba(255, 255, 255, 0.2);
    min-width: 380px;
    max-height: 500px;
    overflow-y: auto;
    display: none;
    animation: dropdownSlideIn 0.4s ease-out;
}

@keyframes dropdownSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.theme-dropdown-header {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--theme-text);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.theme-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-md);
    padding: 15px;
    cursor: pointer;
    transition: var(--transition-normal);
    text-align: center;
    backdrop-filter: var(--blur-sm);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.theme-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: var(--transition-slow);
}

.theme-card:hover::before {
    left: 100%;
}

.theme-card:hover {
    transform: translateY(-5px) scale(1.05);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.theme-card.active {
    border-color: #ffd700;
    background: rgba(255, 215, 0, 0.2);
    transform: scale(1.05);
}

.theme-card.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffd700;
    color: #333;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

.theme-preview-large {
    width: 100%;
    height: 50px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: var(--transition-normal);
}

.theme-card:hover .theme-preview-large {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.theme-name {
    display: block;
    font-weight: bold;
    font-size: 1rem;
    color: var(--theme-text);
    margin-bottom: 5px;
}

.theme-description {
    font-size: 0.8rem;
    color: var(--theme-textLight);
    opacity: 0.8;
}

/* 테마 미리보기 색상 */
.default-theme { background: linear-gradient(135deg, #667eea, #764ba2); }
.dark-theme { background: linear-gradient(135deg, #2c3e50, #34495e); }
.pink-theme { background: linear-gradient(135deg, #ff6b9d, #ffeaa7); }
.green-theme { background: linear-gradient(135deg, #00b894, #55a3ff); }
.orange-theme { background: linear-gradient(135deg, #ff7675, #fdcb6e); }
.blue-theme { background: linear-gradient(135deg, #74b9ff, #0984e3); }
.red-theme { background: linear-gradient(135deg, #e17055, #fdcb6e); }
.purple-theme { background: linear-gradient(135deg, #6c5ce7, #a29bfe); }

.theme-notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--theme-cardBg);
    color: var(--theme-text);
    padding: 20px 30px;
    border-radius: 30px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: var(--blur-lg);
    border: 2px solid var(--theme-primary);
    z-index: 2000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-weight: bold;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-notification::before {
    content: '🎨';
    font-size: 1.5rem;
    animation: spin 2s ease-in-out;
}

.theme-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== 공통 애니메이션 ===== */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes moveStripes {
    0% { transform: translateX(0); }
    100% { transform: translateX(30px); }
}

@keyframes textGlow {
    from { text-shadow: 3px 3px 6px rgba(0,0,0,0.5), 0 0 20px rgba(255,255,255,0.3); }
    to { text-shadow: 3px 3px 6px rgba(0,0,0,0.5), 0 0 30px rgba(255,255,255,0.6); }
}

@keyframes avatarBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.05); }
}

@keyframes selectedGlow {
    from { box-shadow: 0 0 20px #ffd700; }
    to { box-shadow: 0 0 30px #ffd700, 0 0 40px #ffd700; }
}

@keyframes expGlow {
    from { box-shadow: 0 0 5px #4CAF50; }
    to { box-shadow: 0 0 15px #4CAF50, 0 0 25px #4CAF50; }
}

@keyframes wordPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes hintReveal {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
        box-shadow: 0 4px 15px rgba(52, 152, 219, 0.1);
    }
    50% {
        transform: scale(1.02);
        opacity: 1;
        box-shadow: 0 8px 25px rgba(52, 152, 219, 0.3);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes correctAnswer {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes wrongAnswer {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes hintBlink {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.7; transform: translateY(-50%) scale(1.1); }
}

@keyframes pulseWarning {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes particle {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0) translateY(-50px);
    }
}

/* ===== 배경 애니메이션 ===== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.floating-icon {
    position: absolute;
    font-size: 2rem;
    opacity: 0.1;
    animation: float 6s ease-in-out infinite;
}

/* ===== 컨테이너 및 레이아웃 ===== */
.container {
    overflow: visible; 
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--theme-cardBg);
    box-shadow: 0 0 50px rgba(0,0,0,0.2);
    backdrop-filter: var(--blur-md);
}

.screen {
    display: none;
    padding: 30px;
    min-height: calc(100vh - 120px);
    animation: fadeInUp 0.6s ease-out;
}

.screen.active {
    display: block;
}

/* ===== 헤더 스타일 ===== */
.header {
    background: var(--theme-headerBg);
    background-size: 400% 400%;
    animation: gradientShift 4s ease infinite;
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255,255,255,0.1) 10px,
        rgba(255,255,255,0.1) 20px
    );
    animation: moveStripes 3s linear infinite;
}

.header h1 {
    font-family: 'Orbitron', sans-serif;
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    position: relative;
    z-index: 2;
    animation: textGlow 2s ease-in-out infinite alternate;
}

.user-info {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255,255,255,0.2);
    padding: 10px 15px;
    border-radius: var(--border-radius-xl);
    backdrop-filter: var(--blur-md);
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== 캐릭터 시스템 ===== */
.character-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    color: white;
    margin: 0 auto 15px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    animation: avatarBounce 2s ease-in-out infinite;
}

.character-selection {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin: 20px 0;
    max-width: 400px;
}

.character-option {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    position: relative;
    overflow: hidden;
}

.character-option:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.character-option.selected {
    border-color: #ffd700;
    animation: selectedGlow 1s ease-in-out infinite alternate;
}

/* ===== 버튼 스타일 ===== */
.btn {
    background: var(--theme-buttonBg);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: 0 8px 25px rgba(255,107,107,0.4);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: var(--transition-slow);
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(255,107,107,0.6);
}

.btn:active {
    transform: translateY(-1px) scale(1.02);
}

.btn-secondary {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: #333;
    box-shadow: 0 8px 25px rgba(168,237,234,0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff9a9e, #fecfef);
    box-shadow: 0 8px 25px rgba(255,154,158,0.4);
}

.btn-sm {
    padding: 8px 15px;
    font-size: 14px;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-google {
    background: #ffffff;
    color: #333;
    border: 2px solid #ddd;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: var(--transition-normal);
}

.btn-exit {
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-normal);
    backdrop-filter: var(--blur-md);
}

.btn-exit:hover {
    background: rgba(231, 76, 60, 1);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

/* ===== 인증 화면 ===== */
.auth-container {
    max-width: 400px;
    margin: 50px auto;
    background: var(--theme-cardBg);
    padding: 40px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    backdrop-filter: var(--blur-md);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--theme-accent);
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
}

.auth-divider {
    margin: 20px 0;
    text-align: center;
    position: relative;
}

/* ===== 폼 스타일 ===== */
.form-group {
    margin: 20px 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input, 
.form-group select {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid transparent;
    border-radius: var(--border-radius-md);
    font-size: 16px;
    transition: var(--transition-normal);
    background: rgba(255,255,255,0.9);
    backdrop-filter: var(--blur-md);
}

.form-group input:focus, 
.form-group select:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 20px rgba(255,107,107,0.3);
    transform: translateY(-2px);
}

/* ===== 카드 스타일 ===== */
.card {
    background: var(--theme-cardBg);
    padding: 25px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    transition: var(--transition-normal);
    backdrop-filter: var(--blur-md);
    border: 1px solid rgba(255,255,255,0.2);
}

.card:hover {
    transform: translateY(-10px) rotateX(5deg);
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
}

.card h3 {
    color: var(--theme-accent);
    margin-bottom: 20px;
    font-size: 1.5em;
    font-family: 'Orbitron', sans-serif;
}

/* ===== 대시보드 그리드 ===== */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.profile-card {
    text-align: center;
}

/* ===== 레벨 시스템 ===== */
.level-display {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
    padding: 5px 12px;
    border-radius: var(--border-radius-lg);
    font-size: 0.9em;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(255,215,0,0.4);
    display: inline-block;
    margin: 5px 0;
}

.exp-bar {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 5px 0;
}

.exp-fill {
    height: 100%;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    border-radius: 4px;
    transition: width 0.5s ease;
    animation: expGlow 2s ease-in-out infinite alternate;
}

.stats-item {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

/* ===== 랭킹 ===== */
.ranking-list {
    max-height: 300px;
    overflow-y: auto;
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: white;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
}

.rank-position {
    font-size: 1.2em;
    font-weight: bold;
    margin-right: 15px;
    min-width: 30px;
}

.rank-position.top3 {
    color: #FFD700;
}

.player-character {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    color: white;
    margin-right: 10px;
}

/* ===== 방 목록 ===== */
.rooms-container {
    max-height: 400px;
    overflow-y: auto;
}

.room-item {
    background: white;
    padding: 15px;
    margin: 10px 0;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.room-info h4 {
    color: var(--theme-accent);
    margin-bottom: 5px;
}

.room-status {
    font-size: 0.9em;
    color: var(--theme-textLight);
}

/* ===== 게임 화면 스타일 ===== */
#gameScreen.active ~ .header,
body:has(#gameScreen.active) .header {
    display: none !important;
    opacity: 0;
    transform: translateY(-100%);
    transition: var(--transition-normal);
}

#gameScreen.active {
    padding-top: 0;
    height: 100vh;
    overflow: hidden;
    background: var(--theme-background);
    position: relative;
}

.game-screen {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
    overflow: hidden;
}

.game-top-info {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--blur-md);
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
    padding: 12px 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-top: none;
    flex-shrink: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.game-progress {
    display: flex;
    align-items: center;
    gap: 15px;
}

.question-number {
    font-size: 1.1em;
    color: var(--theme-textLight);
    font-weight: bold;
}

.category-badge {
    background: var(--theme-accent);
    color: white;
    padding: 6px 16px;
    border-radius: var(--border-radius-lg);
    font-size: 0.85em;
    font-weight: bold;
}

.game-top-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.game-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    padding-bottom: 100px; /* 모바일 입력창 공간 확보 */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.game-content-area::-webkit-scrollbar {
    display: none;
}

.game-main-area {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--blur-md);
    border-radius: var(--border-radius-lg);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.word-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 3rem;
    font-weight: bold;
    color: #2c3e50;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(45deg, #f093fb 0%, #f5576c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    word-break: keep-all;
    line-height: 1.2;
    animation: wordPulse 2s ease-in-out infinite;
}

.hint-display {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15), rgba(155, 89, 182, 0.15));
    border: 2px solid #3498db;
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.2);
    backdrop-filter: var(--blur-sm);
}

.hint-label {
    color: #2980b9;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#hintDisplay {
    color: #2c3e50;
    font-size: 1.05rem;
    line-height: 1.4;
    font-weight: 500;
    text-align: left;
}

.game-input-section {
    position: relative; /* 기본값을 relative로 변경 */
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: var(--blur-lg);
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom: none;
    z-index: 1000;
    transition: var(--transition-normal);
}

/* 모바일 전용 추가 스타일 */
@media (max-width: 768px) {
    body #gameScreen.active .game-input-section,
    body .game-screen .game-input-section,
    .mobile-floating {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        margin: 0 !important;
        padding: 12px 15px !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(15px) !important;
        border-radius: 12px 12px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2) !important;
        z-index: 9999 !important;
        transform: translateZ(0) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        border-bottom: none !important;
    }
    
    body #gameScreen.active .game-content-area {
        padding: 10px !important;
        padding-bottom: 100px !important;
    }
    
    /* 키보드 열릴 때 */
    body #gameScreen.active .game-input-section.keyboard-open,
    body .mobile-floating.keyboard-open {
        position: fixed !important;
        bottom: 0 !important;
        z-index: 9999 !important;
        background: rgba(255, 255, 255, 0.99) !important;
        box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.3) !important;
    }
    
    .keyboard-open + .game-content-area,
    .keyboard-open ~ .game-content-area {
        padding-bottom: 120px !important;
    }
}

.input-header {
    text-align: center;
    margin-bottom: 8px;
}

.input-title {
    font-size: 0.9rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 0;
}

.chat-input {
    width: 100%;
    padding: 12px 18px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius-lg);
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.9);
    transition: var(--transition-normal);
    outline: none;
    box-sizing: border-box;
}

.chat-input:focus {
    border-color: var(--theme-primary);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
    background: rgba(255, 255, 255, 1);
}

.game-bottom-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 0;
}

.players-panel, 
.chat-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--blur-md);
    border-radius: var(--border-radius-md);
    padding: 15px;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.players-panel h4 {
    margin-bottom: 10px;
    color: var(--theme-accent);
    font-size: 1em;
    font-family: 'Orbitron', sans-serif;
}

.player-item {
    background: rgba(255,255,255,0.9);
    padding: 12px 15px;
    margin: 8px 0;
    border-radius: var(--border-radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: var(--transition-normal);
    border-left: 4px solid var(--theme-accent);
}

.player-item:hover {
    transform: translateX(5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.player-name {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-score {
    background: var(--theme-accent);
    color: white;
    padding: 5px 12px;
    border-radius: var(--border-radius-lg);
    font-size: 0.9em;
    font-weight: bold;
}

.chat-container {
    max-height: 280px;
    display: flex;
    flex-direction: column;
}

.chat-header {
    background: var(--theme-accent);
    color: white;
    padding: 10px;
    border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
    text-align: center;
    font-weight: bold;
    font-size: 0.9em;
}

.chat-messages {
    flex: 1;
    padding: 10px;
    overflow-y: auto;
    font-size: 0.85em;
    max-height: 230px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.chat-message {
    margin: 6px 0;
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    background: rgba(255,255,255,0.8);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    animation: messageSlideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
}

.chat-message.correct {
    background: linear-gradient(135deg, #d4edda, #c3e6cb);
    border-left: 4px solid #28a745;
    animation: correctAnswer 0.5s ease-out;
}

.chat-message.wrong {
    background: linear-gradient(135deg, #f8d7da, #f1c2c7);
    border-left: 4px solid #dc3545;
    animation: wrongAnswer 0.3s ease-out;
}

.chat-message.system {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border-left: 4px solid #ffc107;
    font-weight: bold;
    position: relative;
}

.chat-message.system::before {
    content: '💡';
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    background: #ffc107;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: hintBlink 2s ease-in-out infinite;
}

.timer-display {
    font-family: 'Orbitron', sans-serif;
    font-size: 2rem;
    font-weight: bold;
    color: #27ae60;
    text-shadow: 0 2px 10px rgba(39, 174, 96, 0.3);
    transition: var(--transition-normal);
}

.timer-display.warning {
    color: #e74c3c;
    text-shadow: 0 2px 10px rgba(231, 76, 60, 0.5);
    animation: pulseWarning 1s infinite;
}

/* ===== 로딩 애니메이션 ===== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid transparent;
    border-top: 4px solid var(--theme-accent);
    border-right: 4px solid var(--theme-accent2);
    border-bottom: 4px solid #48dbfb;
    border-left: 4px solid #ff9ff3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== 모달 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1050;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius-md);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

/* ===== 결과 화면 ===== */
.results-screen {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.winner-announcement {
    font-size: 3em;
    color: var(--theme-accent);
    margin: 30px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    font-family: 'Orbitron', sans-serif;
}

.final-scores {
    background: var(--theme-cardBg);
    padding: 30px;
    border-radius: var(--border-radius-md);
    margin: 30px 0;
    backdrop-filter: var(--blur-md);
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin: 10px 0;
    background: white;
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-sm);
}

.score-item.winner {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 2px solid #ffc107;
}

/* ===== 특수 효과 ===== */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    animation: particle 1s ease-out forwards;
}

/* ===== 키보드 상태 ===== */
.game-input-section.keyboard-open {
    background: rgba(255, 255, 255, 0.99);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.2);
}

.game-input-section.keyboard-open .chat-input {
    transform: scale(1.01);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

/* iOS Safari 대응 */
@supports (-webkit-touch-callout: none) {
    .game-input-section {
        position: fixed !important;
        bottom: max(0px, env(safe-area-inset-bottom)) !important;
    }
    
    .game-input-section.keyboard-open {
        /* iOS에서 키보드 높이 감지 시 위로 이동 */
        transform: translateY(-env(keyboard-inset-height, 0px)) !important;
    }
}

/* ===== 반응형 디자인 ===== */
@media (max-width: 1024px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .word-display {
        font-size: 2.5em;
        letter-spacing: 6px;
    }

    .game-bottom-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .chat-container {
        max-height: 150px;
    }
}

/* 모바일 전용 클래스 */
.mobile-floating {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 9999 !important;
}


@media (max-width: 768px) {

 .mobile-floating {
        width: 100vw !important;
        margin: 0 !important;
    }
    .screen {
        padding: 10px;
    }

    .container {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .header {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }

    .user-info {
        position: static;
        background: rgba(255,255,255,0.3);
        margin-top: 8px;
        text-align: center;
        flex-direction: column;
        padding: 8px 12px;
        border-radius: var(--border-radius-md);
        gap: 5px;
    }

    /* 게임 화면 모바일 최적화 */
    .game-top-info {
        padding: 8px 15px;
        border-radius: 0 0 var(--border-radius-sm) var(--border-radius-sm);
    }
    
    .game-content-area {
        padding: 10px;
        padding-bottom: 100px; /* 모바일 입력창 높이 */
    }
    
    .game-main-area {
        padding: 20px 15px;
        margin-bottom: 15px;
    }
    
    .word-display {
        font-size: 2rem;
        padding: 15px 10px;
        margin-bottom: 15px;
    }
    
    .hint-display {
        padding: 15px;
        margin-top: 15px;
    }
    
    .hint-label {
        font-size: 1rem;
    }
    
    #hintDisplay {
        font-size: 1rem;
    }
    
    .game-bottom-info {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .players-panel, .chat-container {
        padding: 12px;
    }
    
    .chat-container {
        max-height: 180px;
    }
    
    .chat-messages {
        max-height: 130px;
    }
    
    .timer-display {
        font-size: 1.8rem;
    }

	#gameScreen.active .game-input-section {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        margin: 0 !important;
        padding: 12px 15px !important;
        background: rgba(255, 255, 255, 0.98) !important;
        backdrop-filter: blur(15px) !important;
        border-radius: 12px 12px 0 0 !important;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.2) !important;
        z-index: 9999 !important;
        transform: translateZ(0) !important;
    }
    
    #gameScreen.active .game-content-area {
        padding-bottom: 100px !important;
    }
    
    /* 키보드 열릴 때 */
    #gameScreen.active .game-input-section.keyboard-open {
        position: fixed !important;
        z-index: 9999 !important;
    }
    
    .keyboard-open .game-content-area {
        padding-bottom: 120px !important;
        /* 키보드 높이만큼 추가 여백 */
        margin-bottom: env(keyboard-inset-height, 0px) !important;
    }
    
    
    .input-title {
        font-size: 0.85rem;
    }
    
    .chat-input {
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    /* 기타 모바일 최적화 */
    .character-selection {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    
    .character-option {
        width: 60px;
        height: 60px;
        font-size: 2em;
        border-width: 2px;
    }

    .auth-container {
        margin: 20px auto;
        padding: 25px;
        border-radius: var(--border-radius-md);
    }

    .btn {
        padding: 12px 20px;
        font-size: 14px;
        border-radius: var(--border-radius-xl);
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }

    .modal-content {
        padding: 20px;
        border-radius: var(--border-radius-sm);
        margin: 10px;
    }

    .winner-announcement {
        font-size: 1.8em;
        margin: 15px 0;
    }

    .final-scores {
        padding: 20px;
        margin: 15px 0;
        border-radius: var(--border-radius-sm);
    }

    .form-group input, 
    .form-group select {
        padding: 12px 16px;
        font-size: 16px;
        border-radius: var(--border-radius-sm);
    }

    .player-item {
        padding: 6px 8px;
        margin: 3px 0;
        border-radius: 8px;
        border-left-width: 2px;
    }

    .player-character {
        width: 20px;
        height: 20px;
        font-size: 0.9em;
        margin-right: 6px;
    }

    .player-name {
        font-size: 0.8em;
        gap: 6px;
    }

    .player-score {
        padding: 2px 6px;
        font-size: 0.7em;
    }

    .chat-header {
        padding: 6px;
        font-size: 0.7em;
        border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
    }

    .chat-messages {
        padding: 6px;
        font-size: 0.7em;
    }

    .chat-message {
        margin: 3px 0;
        padding: 6px 8px;
        border-radius: 8px;
        border-left-width: 2px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.5em;
    }

    .word-display {
        font-size: 1.8rem;
        padding: 12px 8px;
    }
    
    .game-main-area {
        padding: 15px 10px;
    }
    
    .hint-display {
        padding: 12px;
    }
    
    .game-input-section {
        padding: 8px 10px;
    }
    
    .chat-input {
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    .input-title {
        font-size: 0.8rem;
    }

    .timer-display {
        font-size: 1.5em;
    }
}

/* 키보드가 올라왔을 때 감지 */
@media (max-height: 500px) and (orientation: portrait) {
    .game-content-area {
        padding-bottom: 80px;
    }
    
    .game-main-area {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .word-display {
        font-size: 1.6rem;
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .hint-display {
        padding: 10px;
        margin-top: 10px;
    }
    
    .game-bottom-info {
        display: none;
    }
    
    .game-input-section {
        padding: 6px 8px;
    }
    
    .input-title {
        font-size: 0.75rem;
    }
    
    .chat-input {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* 가로 모드 대응 */
@media (orientation: landscape) and (max-height: 500px) {
    .game-top-info {
        padding: 6px 15px;
    }
    
    .game-content-area {
        padding: 6px;
        padding-bottom: 80px;
    }
    
    .game-main-area {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .word-display {
        font-size: 1.6rem;
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .hint-display {
        padding: 8px 12px;
        margin-top: 8px;
    }
    
    .game-bottom-info {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .players-panel, .chat-container {
        padding: 8px;
    }
    
    .chat-container {
        max-height: 120px;
    }
    
    .chat-messages {
        max-height: 80px;
    }
    
    .game-input-section {
        padding: 6px 8px;
    }
}