/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #fafafa;
    color: #2d3748;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.container {
    width: 95%;
    max-width: 1400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    height: 95vh;
    display: flex;
    flex-direction: column;
}

.screen {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* 🎯 새로운 메인 로그인 화면 디자인 */

/* Login Screen */
#login-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 배경 애니메이션 효과 */
#login-screen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* 메인 로그인 컨테이너 */
.login-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 48px;
    box-shadow: 
        0 32px 64px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    max-width: 480px;
    width: 90%;
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* 게임 타이틀 새 디자인 */
.game-title {
    text-align: center;
    margin-bottom: 40px;
}

.game-title h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: -0.02em;
}

.game-title p {
    font-size: 1.125rem;
    color: #64748b;
    margin-bottom: 24px;
    font-weight: 500;
}

/* 새로운 기능 배지 디자인 */
.feature-badges {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}

.badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* 새로운 로그인 폼 디자인 */
.login-form {
    max-width: 100%;
    margin: 0;
}

.input-group {
    position: relative;
    margin-bottom: 24px;
}

.input-group .input-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 18px;
    z-index: 2;
}

#player-name {
    width: 100%;
    padding: 20px 20px 20px 60px;
    font-size: 16px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    font-weight: 500;
    color: #1e293b;
}

#player-name:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: white;
    transform: translateY(-2px);
}

#player-name::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* 새로운 게임 참여 버튼 */
#join-game-btn {
    width: 100%;
    padding: 20px;
    font-size: 18px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
    margin-bottom: 24px;
}

#join-game-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
}

#join-game-btn:active {
    transform: translateY(-1px);
}

#join-game-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 버튼 내부 글로우 효과 */
#join-game-btn::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: left 0.5s;
}

#join-game-btn:hover::before {
    left: 100%;
}

/* 새로운 연결 상태 디자인 */
.connection-status {
    text-align: center;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 12px;
    border: 1px solid rgba(226, 232, 240, 0.5);
    backdrop-filter: blur(5px);
}

.connection-status #connection-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse-status 2s infinite;
}

@keyframes pulse-status {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

#connection-text {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

/* 연결 상태별 색상 */
.connection-status.connected #connection-indicator {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2);
}

.connection-status.connecting #connection-indicator {
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
}

.connection-status.disconnected #connection-indicator {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
}

/* 새로운 사이트 정보 디자인 */
.site-info {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    position: relative;
    overflow: hidden;
}

.site-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.site-info small {
    display: block;
    color: #475569;
    font-weight: 500;
    line-height: 1.6;
}

.site-info small:first-child {
    font-size: 15px;
    margin-bottom: 8px;
    color: #1e293b;
}

.site-info small:last-child {
    font-size: 13px;
    color: #64748b;
}

#current-site {
    font-weight: 700;
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
}

/* 추가 시각적 개선 */
.decorative-elements {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
}

.decorative-elements::before,
.decorative-elements::after {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
}

.decorative-elements::before {
    top: -100px;
    right: -100px;
    animation: float-reverse 8s ease-in-out infinite;
}

.decorative-elements::after {
    bottom: -100px;
    left: -100px;
    animation: float 10s ease-in-out infinite;
}

@keyframes float-reverse {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(20px) rotate(180deg); }
}

/* 타이핑 애니메이션 효과 */
.typing-animation {
    display: inline-block;
    margin-left: 4px;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* 🎯 게임 화면 그리드 레이아웃 */
#game-screen {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr; /* 좌측(1), 중앙(2), 우측(1) 비율 */
    grid-template-rows: auto 1fr; /* 헤더 자동, 나머지 영역 1fr */
    gap: 0;
    height: 100%;
}

/* Game Header - 전체 너비 */
.game-header {
    grid-column: 1 / -1;  /* 전체 너비 차지 */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8f9fa;
}

.game-header h2 {
    margin: 0;
    color: #2d3748;
    font-size: 1.5rem;
}

.game-info {
    display: flex;
    gap: 24px;
    font-size: 14px;
    color: #718096;
}

/* 📌 새로운 좌측 사이드바 스타일 */
.left-sidebar {
    grid-column: 1; /* 첫 번째 열 */
    grid-row: 2;    /* 두 번째 행 */
    background: #f8f9fa;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px; /* 내부 요소에 패딩 적용 */
    /* overflow-y: auto; /* 우측 사이드바 전체 스크롤바 제거 */ */
    gap: 20px;
}

/* 📌 중앙 메인 게임 콘텐츠 영역 스타일 */
.main-game-content {
    grid-column: 1;  /* 첫 번째 열 */
    grid-column: 2;  /* 두 번째 열 (중앙) */
    grid-row: 2;     /* 두 번째 행 */
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    background: white;
}

/* 게임 상태 */
.game-status {
    text-align: center;
}

#waiting-message {
    font-size: 16px;
    color: #718096;
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

#start-game-section {
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.start-game-instructions {
    margin-top: 10px;
    font-size: 14px;
    color: #666;
}

#countdown {
    font-size: 36px;
    font-weight: 600;
    color: #e53e3e;
    padding: 20px;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* 🎯 게임 텍스트 - 타자 예문 */
#game-text {
    font-size: 22px;
    line-height: 1.8;
    padding: 24px;
    background: #f7fafc;
    border-radius: 8px;
    min-height: 100px;
    border: 2px solid #4299e1;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    white-space: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.2);
}

/* 🎯 타자 입력창 - 좌측 메인 영역의 핵심! */
.typing-area {
    background: #f0fff4;
    padding: 24px;
    border-radius: 12px;
    border: 3px solid #48bb78;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.2);
}

#typing-input {
    width: 100%;
    padding: 20px;
    font-size: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 16px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    transition: all 0.2s;
    background: white;
}

#typing-input:focus {
    outline: none;
    border-color: #48bb78;
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.1);
}

.progress-container {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: #48bb78;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-stats {
    display: flex;
    justify-content: space-around;
    font-size: 16px;
    color: #2d3748;
    font-weight: 600;
}

/* 게임 결과 */
#game-result {
    background: #f7fafc;
    padding: 24px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
}

.result-header h3 {
    margin-bottom: 8px;
    color: #2d3748;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* 📌 새로운 우측 사이드바 스타일 (채팅 및 실시간 정보) */
.right-sidebar {
    grid-column: 3;  /* 세 번째 열 */
    grid-row: 2;     /* 두 번째 행 */
    background: #f8f9fa;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto; /* 우측 사이드바 전체 스크롤바 활성화 */
    gap: 20px;
}

/* 기존 .game-sidebar 스타일은 left-sidebar 또는 right-sidebar로 필요에 따라 이동/병합 */
/* 예를 들어, .room-limits, .players-section 등은 .left-sidebar 내부로 이동했으므로,
   해당 스타일 선택자를 .left-sidebar .room-limits 등으로 조정하거나,
   .left-sidebar 자체에 패딩 등을 적용하여 내부 요소들이 잘 보이도록 합니다. */
/* 방 제한 정보 */
.room-limits {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.limit-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.limit-icon {
    font-size: 14px;
}

.limit-label {
    font-weight: 500;
    color: #4a5568;
    flex: 1;
    font-size: 13px;
}

.limit-value {
    color: #4299e1;
    font-weight: 600;
    font-size: 13px;
}

/* 플레이어 목록 */
.players-section {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.players-section h3 {
    margin-bottom: 12px;
    color: #2d3748;
    font-size: 15px;
}

#players-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.player-item {
    background: #f7fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-status {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #48bb78;
}

.player-number {
    background: #4299e1;
    color: white;
    padding: 2px 6px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

.player-name {
    font-weight: 500;
    font-size: 13px;
}

.player-progress {
    font-weight: 600;
    color: #4299e1;
    font-size: 12px;
}

/* 실시간 진행률 - 우측 사이드바 */
.live-progress-section {
    background: #f0fff4;
    padding: 16px;
    border-radius: 8px;
    border: 3px solid #48bb78;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.2);
    flex: 1;  /* 사이드바에서 가장 많은 공간 차지 */
    min-height: 200px; /* 최소 높이 확보 */
}

.live-progress-section h4 {
    margin-bottom: 12px;
    color: #48bb78;
    font-size: 16px;
    font-weight: 600;
}

.live-progress-container {
    /* max-height: 300px;  채팅창과 공간을 나눠야 하므로 조절 */
    overflow-y: auto;
}

.live-rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    transition: all 0.2s;
}

.live-rank-item:hover {
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.live-rank-item.first-place {
    background: #fef5e7;
    border-color: #ed8936;
    font-weight: 600;
}

.rank {
    font-weight: 600;
    color: #48bb78;
    min-width: 24px;
}

.name {
    flex: 1;
    text-align: left;
    margin: 0 8px;
    color: #2d3748;
}

.progress {
    font-weight: 600;
    color: #48bb78;
}

/* 실시간 순위 */
.leaderboard {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.leaderboard h3 {
    margin-bottom: 12px;
    color: #2d3748;
    font-size: 15px;
}

#leaderboard-list {
    /* max-height: 150px; 채팅창과 공간을 나눠야 하므로 조절 */
    overflow-y: auto;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
}

/* Character Highlighting */
.completed-char, .current-char, .error-char, .normal-char {
    display: inline-block;
    min-width: 1ch;
    text-align: center;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
}

.completed-char {
    background: #c6f6d5;
    color: #22543d;
}

.current-char {
    background: #fef5e7;
    color: #744210;
    box-shadow: 0 0 0 2px #ed8936;
}

.error-char {
    background: #fed7d7;
    color: #742a2a;
}

.normal-char {
    background: transparent;
    color: #4a5568;
}

/* 버튼 스타일 */
button {
    background: #4299e1;
    color: white;
    border: none;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: 500;
}

button:hover:not(:disabled) {
    background: #3182ce;
}

button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
}

.primary-btn {
    background: #4299e1;
}

.secondary-btn {
    background: #718096;
}

.no-data {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 20px;
    font-size: 13px;
}

/* Player State Variants */
.player-item.playing {
    border-color: #48bb78;
    background: #f0fff4;
}

.player-item.waiting {
    border-color: #ed8936;
    background: #fef5e7;
    opacity: 0.9;
}

/* 🎯 모바일 최적화 */
@media (max-width: 768px) {
    /* 로그인 화면 모바일 */
    .login-container {
        padding: 32px 24px;
        margin: 16px;
    }
    
    .game-title h1 {
        font-size: 2rem;
    }
    
    .feature-badges {
        flex-direction: column;
        align-items: center;
    }
    
    .badge {
        width: 100%;
        text-align: center;
        padding: 16px 20px;
    }
    
    #player-name {
        padding: 18px 18px 18px 55px;
    }
    
    #join-game-btn {
        padding: 18px;
        font-size: 16px;
    }
    
    /* 게임 화면 모바일 */
    #game-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        /* 모바일에서는 좌측 사이드바, 메인, 우측 사이드바 순으로 세로 정렬 */
    }
    
    .left-sidebar {
        grid-column: 1;
        grid-row: 2; /* 헤더 다음 */
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 200px; /* 높이 제한 및 스크롤 */
    }
    
    .main-game-content {
        grid-column: 1;
        grid-row: 3; /* 좌측 사이드바 다음 */
    }
    
    .right-sidebar {
        grid-column: 1;
        grid-row: 4; /* 메인 콘텐츠 다음 */
        border-left: none;
        border-top: 1px solid #e2e8f0;
        max-height: 250px;
        flex-direction: row;
        overflow-x: auto;
        gap: 15px;
    }
    
    .left-sidebar > div,
    .right-sidebar > div {
        min-width: 250px;
    }
}

@media (max-width: 480px) {
    /* 로그인 화면 작은 모바일 */
    .login-container {
        padding: 24px 20px;
    }
    
    .game-title h1 {
        font-size: 1.75rem;
    }
    
    .game-title p {
        font-size: 1rem;
    }
}

/* 접근성 향상 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 다크모드 지원 */
@media (prefers-color-scheme: dark) {
    .login-container {
        background: rgba(15, 23, 42, 0.95);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .game-title p {
        color: #94a3b8;
    }
    
    #player-name {
        background: rgba(30, 41, 59, 0.9);
        border-color: #334155;
        color: #f1f5f9;
    }
    
    #player-name::placeholder {
        color: #64748b;
    }
    
    .connection-status {
        background: rgba(30, 41, 59, 0.8);
        border-color: rgba(51, 65, 85, 0.5);
    }
    
    #connection-text {
        color: #94a3b8;
    }
    
    .site-info {
        background: linear-gradient(135deg, #1e293b, #334155);
        border-color: rgba(51, 65, 85, 0.8);
    }
    
    .site-info small {
        color: #94a3b8;
    }
    
    .site-info small:first-child {
        color: #f1f5f9;
    }
}

/* Focus States */
button:focus,
input:focus {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Smooth Transitions */
* {
    transition: color 0.2s, background-color 0.2s, border-color 0.2s;
}

/* Scrollbar 커스터마이징 */
#game-text::-webkit-scrollbar {
    height: 4px;
}

#game-text::-webkit-scrollbar-track {
    background: #e2e8f0;
    border-radius: 2px;
}

#game-text::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

/* 🎯 채팅창 스타일 (우측 사이드바 내부) */
.chat-section {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* flex-shrink: 0; /* 채팅창 크기 유지 - 제거 또는 flex-shrink: 1; 로 변경 */
    flex-grow: 1; /* .right-sidebar 내에서 사용 가능한 공간을 차지하도록 함 */
    min-height: 0; /* 자식 요소의 overflow가 올바르게 작동하도록 함 */
}


.chat-section h4 {
    margin-bottom: 8px;
    color: #2d3748;
    font-size: 15px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}
/* 채팅 입력 영역 컨테이너 */
.chat-input-container {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: white;
  border-top: 1px solid #e2e8f0;
  border-radius: 0 0 8px 8px;
}

/* 채팅 입력창 래퍼 */
.chat-input-wrapper {
  flex: 1;
  position: relative;
  background: #ffffff;
  border: 2px solid #cbd5e0; /* 명확한 회색 테두리 */
  border-radius: 8px; /* 둥근 모서리 */
  transition: all 0.3s ease;
  overflow: hidden;
}

.chat-input-wrapper:focus-within {
  border-color: #4299e1; /* 포커스 시 파란색 테두리 */
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
  background: #ffffff;
}

#chat-input {
  width: 100%;
  border: none;
  outline: none;
  padding: 12px 16px;
  font-size: 14px;
  background: transparent;
  resize: none;
  font-family: inherit;
  color: #2d3748;
  line-height: 1.4;
  min-height: 20px;
  max-height: 80px;
  overflow-y: auto;
}

#chat-input::placeholder {
  color: #a0aec0;
  font-weight: 400;
}

/* 전송 버튼 */
#send-chat-btn {
  width: auto;
  min-width: 60px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px; /* 동그라미에서 둥근 사각형으로 변경 */
  border: none;
  background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  margin-left: auto;
}

#send-chat-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(66, 153, 225, 0.4);
  background: linear-gradient(135deg, #3182ce 0%, #2c5aa0 100%);
}

#send-chat-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(66, 153, 225, 0.3);
}

#send-chat-btn:disabled {
  background: #cbd5e0;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  color: #718096;
}

/* 전송 버튼 텍스트 */
#send-chat-btn::before {
  content: "전송";
  font-size: 14px;
  font-weight: 600;
}

/* 입력 상태에 따른 스타일 변화 */
.chat-input-wrapper.has-text {
  border-color: #4299e1;
  background: #ffffff;
}

/* 추가 시각적 개선 */
.chat-input-wrapper:hover {
  border-color: #a0aec0;
}

/* 메시지 카운터 스타일 개선 */
.message-counter {
  position: absolute;
  bottom: 4px;
  right: 12px;
  font-size: 11px;
  color: #a0aec0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 4px;
  border-radius: 3px;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  .chat-input-container {
    padding: 10px;
    gap: 6px;
  }
  
  #chat-input {
    padding: 10px 14px;
    font-size: 16px; /* iOS 줌 방지 */
  }
  
  #send-chat-btn {
    height: 36px;
    min-width: 50px;
    padding: 0 12px;
  }
  
  #send-chat-btn::before {
    content: "→"; /* 모바일에서는 화살표로 표시 */
    font-size: 16px;
  }
}

/* 접근성 개선 */
#send-chat-btn:focus {
  outline: 2px solid #4299e1;
  outline-offset: 2px;
}

/* 로딩 상태 (선택사항) */
#send-chat-btn.loading::before {
  content: "...";
  animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {
  0%, 20% { content: "."; }
  40% { content: ".."; }
  60%, 100% { content: "..."; }
}

/* 모바일 최적화 */
@media (max-width: 768px) {
  .chat-input-container {
    padding: 10px;
    gap: 6px;
  }
  
  #chat-input {
    padding: 10px 14px;
    font-size: 16px; /* iOS에서 줌 방지 */
  }
  
  #send-chat-btn {
    width: 36px;
    height: 36px;
  }
  
  #send-chat-btn::before {
    font-size: 14px;
  }
}

/* 접근성 향상 */
@media (prefers-reduced-motion: reduce) {
  #send-chat-btn,
  .chat-input-wrapper {
    transition: none;
  }
  
  .typing-animation {
    animation: none;
  }
}

/* 포커스 상태 개선 */
#chat-input:focus {
  outline: none;
}

#send-chat-btn:focus {
  outline: 2px solid #4299e1;
  outline-offset: 2px;
}

.chat-messages-container {
    flex-grow: 1; /* 가능한 많은 공간 차지 */
    min-height: 100px; /* 최소 높이 */
  max-height: clamp(100px, 25vh, 300px); /* 최소 100px, 이상적으로 뷰포트 높이의 25%, 최대 300px */
  overflow-y: auto; /* 내용이 최대 높이를 초과하면 스크롤바 표시 */    
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 6px;
    background: #f8f9fa;
}

/* 채팅창 내부 스크롤바 커스터마이징 (흰색) */
.chat-messages-container::-webkit-scrollbar {
    width: 8px; /* 스크롤바 너비 */
}

.chat-messages-container::-webkit-scrollbar-track {
    background: #f8f9fa; /* 트랙 배경색 (채팅창 배경과 유사하게) */
}

.chat-messages-container::-webkit-scrollbar-thumb {
    background: #ffffff; /* 스크롤바 색상 (흰색) */
    border: 1px solid #e2e8f0; /* 흰색 스크롤바가 잘 보이도록 테두리 추가 */
    border-radius: 4px; /* 스크롤바 모서리 둥글게 */
}
#player-name.readonly:focus {
    outline: none;
    border-color: #d1d5db; /* readonly 포커스 시 약간 더 어두운 회색 테두리 (선택 사항) 또는 #e2e8f0 유지 */
    box-shadow: none;      /* 일반 포커스의 그림자 효과 제거 */
    transform: none;       /* 일반 포커스의 transform 효과 제거 */
    background-color: #f0f0f0; /* readonly 상태의 배경색 유지 (일반 포커스의 흰색 배경 방지) */
    color: #555;           /* readonly 상태의 텍스트 색상 유지 */
    cursor: default;       /* 커서 모양을 기본값으로 유지 */
}
input.readonly {
    background-color: #f0f0f0; /* 연한 회색 배경 */
    cursor: default; /* 기본 커서 */
    color: #555; /* 텍스트 색상 약간 어둡게 */
}
/* 📌 본인 메시지 스타일 */
.chat-username.my-message {
    color: #48bb78 !important; /* 빨간색 */
    font-weight: 900;
}
/* 포인트 지급 알림 애니메이션 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* 현재 플레이어 순위 강조 */
.final-rank-item.current-player {
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    border: 2px solid #2f855a;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

.final-rank-item.current-player strong {
    color: #fff3cd;
}

/* 포인트 수상자 표시 */
.final-rank-item.current-player div:first-child::after {
    content: " 💰";
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}


