/* ==========================================
   🕵️‍♂️ 모던 클래스룸 마피아 디자인 시스템
   ========================================== */

/* 1. 디자인 시스템 토큰 정의 */
:root {
    /* 심해와 밤하늘을 머금은 깊은 다크 테마 컬러 */
    --bg-gradient: linear-gradient(135deg, #0d0d12 0%, #161622 100%);
    --panel-bg: rgba(28, 28, 40, 0.75);
    --panel-border: rgba(255, 255, 255, 0.07);
    --panel-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    
    /* 텍스트 컬러 */
    --text-primary: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;

    /* 역할군 브랜딩 색상 */
    --color-mafia: #ef4444;      /* 크림슨 레드 */
    --color-citizen: #10b981;    /* 에메랄드 그린 */
    --color-police: #3b82f6;     /* 로열 블루 */
    --color-doctor: #ec4899;     /* 핫 핑크 */
    --color-gondal: #f59e0b;     /* 마리골드 골드 */
    --color-terror: #f97316;     /* 오렌지 번 */
    --color-gija: #06b6d4;       /* 사이언 */
    --color-youngmae: #8b5cf6;   /* 라벤더 퍼플 */
    --color-sungjik: #14b8a6;    /* 민트 */
    --color-politician: #eab308; /* 정치적 옐로우 */
    --color-soldier: #64748b;    /* 슬레이트 그레이 */
    --color-rat: #a855f7;        /* 쥐인간 퍼플 */

    /* 전역 기능적 컬러 */
    --accent-gold: #fbbf24;      /* 화려한 골드 */
    --btn-hover-scale: scale(1.02);
    --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. 전역 스타일링 및 리셋 */
* {
    box-sizing: border-box;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    letter-spacing: -0.02em;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* 3. 모던 글래스모피즘 메인 컨테이너 */
.container {
    width: 100%;
    max-width: 580px;
    margin: 20px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    box-shadow: var(--panel-shadow);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 35px 30px;
    position: relative;
    overflow: hidden;
    transition: max-width 0.3s ease-in-out;
}

/* 교사용 넓은 대시보드 화면용 가로폭 확장 */
.container.wide-container {
    max-width: 1000px;
}

/* 장식용 은은한 글로우 레이어 */
.container::before {
    content: '';
    position: absolute;
    top: -150px;
    left: -150px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0) 70%);
    z-index: 0;
    pointer-events: none;
}

/* 4. 화면 제어 및 전환 */
.screen {
    position: relative;
    z-index: 1;
    animation: fadeIn 0.4s ease-out forwards;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 5. 타이틀 및 헤더 */
h1, h2, h3, h4 {
    margin-top: 0;
    font-weight: 800;
    color: #ffffff;
}

h1 {
    font-size: 2.2rem;
    background: linear-gradient(120deg, #ffffff 40%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 5px;
    text-align: center;
}

h2 {
    font-size: 1.6rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
    margin-bottom: 20px;
    text-align: center;
}

h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.maker-tag {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-align: center;
    letter-spacing: 0.1em;
    margin-bottom: 30px;
    text-transform: uppercase;
}

/* 6. 입력창 및 입력그룹 */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 4px;
}

input[type="text"], input[type="number"], select {
    background: rgba(17, 17, 27, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    width: 100%;
    outline: none;
    transition: var(--transition-smooth);
}

input[type="text"]:focus, input[type="number"]:focus, select:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
    background: rgba(17, 17, 27, 0.85);
}

/* 7. 버튼 시스템 */
button, .btn-primary, .btn-secondary, .btn-danger {
    padding: 15px 20px;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* 메인 프라이머리 버튼 (골드 광채 테마) */
.btn-primary {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: var(--text-dark);
}

.btn-primary:hover:not(:disabled) {
    transform: var(--btn-hover-scale);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.35);
}

/* 보조 버튼 (다크 그레이 / 실버 느낌) */
.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: var(--btn-hover-scale);
}

/* 위험 및 공격성 버튼 (크림슨 레드) */
.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    transform: var(--btn-hover-scale);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 8. 교실 코드 렌더링 박스 */
.room-code-box {
    background: rgba(251, 191, 36, 0.08);
    border: 2px dashed rgba(251, 191, 36, 0.3);
    padding: 16px;
    border-radius: 16px;
    margin: 20px 0;
    text-align: center;
    animation: pulseGlow 3s infinite ease-in-out;
}

#display-room-code {
    font-size: 3.2rem;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--accent-gold);
    text-shadow: 0 0 16px rgba(251, 191, 36, 0.3);
}

@keyframes pulseGlow {
    0%, 100% { border-color: rgba(251, 191, 36, 0.3); box-shadow: 0 0 0 rgba(251, 191, 36, 0); }
    50% { border-color: rgba(251, 191, 36, 0.6); box-shadow: 0 0 15px rgba(251, 191, 36, 0.15); }
}

/* 9. 교실 인원 설정 그리드 */
.role-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    background: rgba(17, 17, 27, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 25px;
    max-height: 280px;
    overflow-y: auto;
}

/* 역할 설정 개별 요소 */
.role-settings-grid div {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.role-settings-grid label {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

.role-settings-grid input {
    width: 52px;
    padding: 6px;
    text-align: center;
    border-radius: 8px;
    font-size: 14px;
}

/* 역할별 전용 아이콘 색상 설정 */
.text-mafia { color: var(--color-mafia); }
.text-citizen { color: var(--color-citizen); }
.text-police { color: var(--color-police); }
.text-doctor { color: var(--color-doctor); }
.text-gondal { color: var(--color-gondal); }
.text-terror { color: var(--color-terror); }
.text-gija { color: var(--color-gija); }
.text-youngmae { color: var(--color-youngmae); }
.text-sungjik { color: var(--color-sungjik); }
.text-politician { color: var(--color-politician); }
.text-soldier { color: var(--color-soldier); }
.text-rat { color: var(--color-rat); }

/* 10. 플레이어 배지 및 리스트 */
.player-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 30px;
}

.player-list li {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e5e7eb;
    transition: var(--transition-smooth);
}

.player-list li:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(1.05);
}

/* 11. 교사용 대시보드 리스트 (반응형 바둑판형 그리드 레이아웃) */
.player-list-full {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
}

/* 12. 역할 카드 대형 렌더링 */
.role-card {
    font-size: 2.4rem;
    padding: 30px;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.15) 0%, rgba(251, 191, 36, 0.04) 100%);
    border: 2px dashed var(--accent-gold);
    border-radius: 20px;
    margin: 25px 0;
    font-weight: 900;
    text-align: center;
    color: var(--accent-gold);
    text-shadow: 0 2px 10px rgba(251, 191, 36, 0.2);
    animation: cardPulse 3s infinite alternate;
}

.role-desc {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #cbd5e1;
    background: rgba(255, 255, 255, 0.03);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 25px;
}

@keyframes cardPulse {
    from { transform: scale(1); box-shadow: 0 0 10px rgba(251, 191, 36, 0.05); }
    to { transform: scale(1.02); box-shadow: 0 0 25px rgba(251, 191, 36, 0.18); }
}

/* 13. 알림 박스 (낮 결과 브리핑 등) */
.alert-box {
    background: rgba(254, 243, 199, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.2);
    padding: 18px;
    border-radius: 16px;
    text-align: left;
    margin-top: 20px;
    font-weight: 600;
    color: var(--accent-gold);
    font-size: 1rem;
    line-height: 1.6;
}

.vote-box {
    margin-top: 25px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    background: rgba(17, 17, 27, 0.4);
}

/* 14. 학생용 대기실 스피너 디자인 */
.student-lobby-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

.spinner {
    font-size: 3rem;
    color: var(--accent-gold);
    margin-bottom: 20px;
}

/* 15. 게임 로그 플로팅 버튼 */
#floating-log-btn {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    padding: 12px 20px !important;
    font-size: 0.95rem !important;
    font-weight: 700 !important;
    background: rgba(55, 65, 81, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    backdrop-filter: blur(8px) !important;
    border-radius: 50px !important;
    color: #ffffff !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3) !important;
    z-index: 9999 !important;
    display: none;
    transition: var(--transition-smooth) !important;
}

#floating-log-btn:hover {
    background: rgba(55, 65, 81, 1) !important;
    transform: scale(1.08) translateY(-2px) !important;
}

/* 16. 게임 로그 오버레이 모달 */
#log-modal-overlay {
    display: flex;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(8px);
    transition: var(--transition-smooth);
}

/* 17. 커스텀 스크롤바 */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 18. 게임 오버 뷰 및 뱃지 */
.game-over-title {
    font-size: 2.8rem;
    color: var(--color-mafia);
    font-weight: 900;
    text-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.winner-announcement {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--color-citizen);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 25px;
    text-align: center;
}

.game-over-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.game-over-list li {
    padding: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 1.05rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 실시간 학생 카드 및 상태 뱃지 컴팩트화 */
.player-status-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 14px;
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    border: 2px solid transparent;
    transition: var(--transition-smooth);
    background: rgba(255, 255, 255, 0.03);
    margin-bottom: 0;
}
.player-status-card:hover {
    transform: translateY(-2px);
}
.player-status-card.alive {
    background-color: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.2);
}
.player-status-card.dead {
    background-color: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
    opacity: 0.7;
}

/* 카드 내부 가로 행 (1단: 이름과 역할 / 2단: 생존여부와 실시간 행동 뱃지) */
.player-status-card .player-info-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

/* 카드 1단과 2단 사이의 은은한 구분선 추가 */
.player-status-card .player-info-main:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding-bottom: 6px;
}

/* 텍스트 크기 조절로 시각적 컴팩트함 강화 */
.player-nickname {
    color: #ffffff;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}
.player-role-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}
.player-life-text {
    font-weight: bold;
    font-size: 0.85rem;
}
.player-life-text.alive {
    color: var(--color-citizen);
}
.player-life-text.dead {
    color: var(--color-mafia);
}
.status-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 20px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.status-badge.done {
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
}
.status-badge.waiting {
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
}