/* =========================================================
   불주먹 복싱 체육관 (Fire Fist Boxing Club) - Style CSS
   ========================================================= */

:root {
    --bg-dark: #121316;
    --wood-floor: #2a1e17;
    --ring-blue: #1d4ed8;
    --ring-red: #dc2626;
    --gold: #f59e0b;
    --neon-yellow: #facc15;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --panel-bg: rgba(24, 25, 29, 0.88);
    --panel-border: rgba(255, 255, 255, 0.12);
    --accent-red: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    font-family: 'Noto Sans KR', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #181412;
}

/* 메인 캔버스 */
#gymCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* =========================================================
   상단 헤더 UI
   ========================================================= */
#ui-header {
    position: absolute;
    top: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 20;
    gap: 12px;
}

#ui-header > * {
    pointer-events: auto;
}

.logo-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    padding: 10px 18px;
    border-radius: 14px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 8px rgba(239, 68, 68, 0.5));
}

.logo-text h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 20px;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff 0%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text .sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}

/* =========================================================
   공식 전광판 (라운드 타이머 + 아래 순위 일체형)
   ========================================================= */
.timer-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(15, 23, 42, 0.96);
    backdrop-filter: blur(12px);
    padding: 8px 20px 8px 20px;
    border-radius: 14px;
    border: 1.5px solid #f59e0b;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 16px rgba(245, 158, 11, 0.2);
    min-width: 360px;
    max-width: 580px;
    user-select: none;
}

.timer-main-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.phase-indicator {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 10px;
    border-radius: 12px;
    margin-bottom: 2px;
    letter-spacing: 0.5px;
    text-align: center;
}

.phase-indicator.fight {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.phase-indicator.rest {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.timer-display {
    font-family: 'Black Han Sans', monospace;
    font-size: 28px;
    color: #facc15;
    letter-spacing: 2px;
    line-height: 1.1;
    text-shadow: 0 0 12px rgba(250, 204, 21, 0.7);
}

.timer-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
}

.round-badge {
    font-size: 11px;
    font-weight: 800;
    color: #f87171;
    background: rgba(239, 68, 68, 0.15);
    padding: 2px 8px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* 전광판 아래 순위 표시 (PC) */
.timer-rank-strip {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(245, 158, 11, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 11px;
    width: 100%;
    color: #cbd5e1;
    white-space: nowrap;
}

.rank-strip-title {
    font-weight: 800;
    color: #facc15;
    font-size: 11px;
}

.rank-item.gold {
    color: #fef08a;
    font-weight: 700;
}

.rank-item.my {
    color: #fbbf24;
    font-weight: 800;
    background: rgba(245, 158, 11, 0.18);
    padding: 1px 7px;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.rank-item.bronze {
    color: #94a3b8;
}

.bell-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
    font-weight: 800;
}

.bell-btn:hover {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    transform: scale(1.05);
}

/* 우측 상단 프로필 및 사운드 */
.top-right-bar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    padding: 8px 14px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
}

.invite-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.3);
}

.invite-btn:hover {
    background: linear-gradient(135deg, #34d399, #10b981);
    transform: translateY(-1px);
}

.record-tag {
    font-size: 11px;
    font-weight: 800;
    background: rgba(245, 158, 11, 0.2);
    color: #facc15;
    padding: 2px 7px;
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.meter-track {
    width: 90px;
    height: 10px;
    background: #2b2f3a;
    border-radius: 5px;
    overflow: hidden;
    margin: 0 4px;
}

.meter-fill {
    height: 100%;
    transition: width 0.15s ease-out;
}

.hp-fill {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.stamina-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.stamina-fill.tired {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.stamina-fill.exhausted {
    background: linear-gradient(90deg, #ef4444, #991b1b);
}

.meter-text {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 700;
    min-width: 45px;
}

.rank-tag.online {
    background: #065f46;
    color: #34d399;
    border: 1px solid rgba(52, 211, 153, 0.4);
}

.rank-tag {
    font-size: 10px;
    font-weight: 800;
    background: #374151;
    color: #93c5fd;
    padding: 2px 6px;
    border-radius: 4px;
}

.username {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
}

#btnEditName {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#btnEditName:hover {
    opacity: 1;
}

.audio-controls {
    display: flex;
    gap: 6px;
}

.ui-btn {
    background: #262930;
    border: 1px solid var(--panel-border);
    color: #e5e7eb;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.ui-btn:hover {
    background: #374151;
    color: #fff;
}

.sound-btn.active {
    border-color: #3b82f6;
    color: #60a5fa;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

/* =========================================================
   하단 통계 및 펀치 바
   ========================================================= */
#stats-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    padding: 10px 24px;
    border-radius: 16px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

.stat-card {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 24px;
    color: #fff;
}

.stat-unit {
    font-size: 12px;
    color: var(--text-muted);
}

.stat-value.highlight {
    color: #f97316;
    text-shadow: 0 0 8px rgba(249, 115, 22, 0.5);
}

.stamina-track {
    width: 90px;
    height: 10px;
    background: #2b2f3a;
    border-radius: 5px;
    overflow: hidden;
    margin-left: 4px;
}

.stamina-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981, #059669);
    transition: width 0.15s ease-out;
}

/* =========================================================
   키 안내 가이드 (우측 하단)
   ========================================================= */
#key-guide {
    position: absolute;
    bottom: 24px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(18, 19, 22, 0.7);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    pointer-events: none;
    z-index: 10;
}

#key-guide b {
    color: #e5e7eb;
}

/* =========================================================
   인터랙션 안내 및 말풍선
   ========================================================= */
#interaction-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -100px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #f59e0b;
    padding: 8px 16px;
    border-radius: 30px;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    pointer-events: none;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(245, 158, 11, 0.4);
    animation: bounce 1.2s infinite ease-in-out;
    z-index: 25;
}

@keyframes bounce {
    0%, 100% { transform: translate(-50%, -100px); }
    50% { transform: translate(-50%, -108px); }
}

.key-badge {
    background: #f59e0b;
    color: #000;
    font-weight: 800;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 6px;
}

/* 관장님 응원 말풍선 */
#coach-bubble {
    position: absolute;
    top: 90px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(20, 21, 26, 0.95);
    border-left: 4px solid #ef4444;
    padding: 12px 18px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 20;
    max-width: 380px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.coach-avatar {
    font-size: 26px;
}

.coach-msg {
    font-size: 13px;
    font-weight: 600;
    color: #f3f4f6;
    line-height: 1.4;
}

/* =========================================================
   모달 창 스타일 (방명록 & 닉네임)
   ========================================================= */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-window {
    width: 90%;
    max-width: 520px;
    background: #1e2026;
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-window.small-modal {
    max-width: 360px;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #17181c;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: #f9fafb;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: #fff;
}

.modal-body {
    padding: 20px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 14px;
    line-height: 1.5;
}

.board-input-box {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.board-input-box input, .small-modal input {
    flex: 1;
    background: #121316;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
    outline: none;
}

.board-input-box input:focus, .small-modal input:focus {
    border-color: #f59e0b;
}

.primary-btn {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.15s;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.sticky-notes-container {
    max-height: 260px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding-right: 4px;
}

.sticky-note {
    background: #fef3c7;
    color: #78350f;
    padding: 12px;
    border-radius: 8px;
    font-size: 12px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 70px;
    transform: rotate(calc(-2deg + 4deg * var(--rand, 0.5)));
    position: relative;
}

.sticky-note .note-author {
    font-size: 10px;
    font-weight: 700;
    color: #92400e;
    margin-top: 6px;
    text-align: right;
}

.btn-group {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

/* =========================================================
   모바일 가상 패드 (왼쪽 엄지: 조이스틱 + 원 / 오른쪽 엄지: 투 + 행동)
   ========================================================= */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 18px;
    left: 0;
    right: 0;
    padding: 0 16px;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 40;
}

#left-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
}

#right-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    pointer-events: auto;
}

#joystick-zone {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    position: relative;
    pointer-events: auto;
    touch-action: none;
}

#joystick-knob {
    width: 38px;
    height: 38px;
    background: #ef4444;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.m-action-btn {
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* 왼쪽 엄지 펀치: 원 (잽) */
.action-one {
    width: 64px;
    height: 64px;
    font-size: 13px;
    background: linear-gradient(135deg, #f97316, #ea580c);
    border: 3px solid rgba(255, 255, 255, 0.35);
}

.action-one:active {
    transform: scale(0.92);
    background: #c2410c;
}

/* 오른쪽 엄지 펀치: 투 (스트레이트/훅) */
.action-two {
    width: 72px;
    height: 72px;
    font-size: 15px;
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    border: 3px solid rgba(255, 255, 255, 0.4);
}

.action-two:active {
    transform: scale(0.92);
    background: #991b1b;
}

.action-interact {
    width: 52px;
    height: 52px;
    font-size: 12px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.action-interact:active {
    transform: scale(0.92);
}

.hidden {
    display: none !important;
}

/* =========================================================
   모바일 최적화 미디어 쿼리 (화면 폭 840px 이하)
   ========================================================= */
@media (max-width: 840px) {
    #mobile-controls {
        display: flex;
    }

    #key-guide {
        display: none;
    }

    .key-badge {
        display: none !important;
    }

    /* 상단 헤더: 깔끔한 가로 단일 바 */
    #ui-header {
        top: 8px;
        left: 8px;
        right: 8px;
        gap: 6px;
    }

    .logo-box {
        padding: 5px 10px;
        border-radius: 10px;
        gap: 6px;
    }

    .logo-icon {
        font-size: 20px;
    }

    .logo-text h1 {
        font-size: 14px;
    }

    .logo-text .sub {
        display: none;
    }

    .timer-box {
        padding: 4px 8px;
        border-radius: 10px;
        min-width: auto;
        border-width: 1px;
    }

    .timer-rank-strip {
        display: none;
    }

    .phase-indicator {
        font-size: 9px;
        padding: 1px 6px;
    }

    .timer-display {
        font-size: 18px;
    }

    .round-badge {
        display: none;
    }

    .bell-btn {
        padding: 4px 8px;
        font-size: 11px;
    }

    #btnTimerToggle {
        display: none;
    }

    .top-right-bar {
        gap: 4px;
    }

    .invite-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .user-badge {
        padding: 5px 8px;
        gap: 4px;
    }

    .username {
        font-size: 12px;
        max-width: 65px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #btnEditName {
        display: none;
    }

    .audio-controls {
        display: none;
    }

    /* 하단에 거슬리던 상태바를 상단 헤더 바로 아래의 슬림 HUD로 이동 */
    #stats-bar {
        position: absolute;
        top: 56px;
        left: 8px;
        right: 8px;
        bottom: auto;
        transform: none;
        width: auto;
        padding: 4px 10px;
        gap: 8px;
        border-radius: 10px;
        justify-content: space-around;
        background: rgba(18, 19, 22, 0.85);
        z-index: 15;
    }

    .stat-card {
        gap: 4px;
    }

    .stat-label {
        font-size: 10px;
    }

    .meter-track {
        width: 50px;
        height: 7px;
    }

    .meter-text {
        font-size: 9px;
        min-width: auto;
    }

    .stat-value {
        font-size: 13px;
    }

    .streak-card {
        display: none;
    }
}
