* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-primary: #141517;
    --bg-secondary: #1f2123;
    --bg-tertiary: #2a2c2e;
    --bg-hover: #3a3c3e;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #6b6b6b;
    --accent-green: #00ffa3;
    --accent-purple: #a970ff;
    --accent-blue: #00c8ff;
    --accent-orange: #ff9500;
    --accent-red: #ff4d4d;
    --accent-pink: #ff6b9d;
    --border-color: #3a3c3e;
    --card-bg: rgba(31, 33, 35, 0.95);
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    color: var(--text-primary);
    overflow: hidden;
    transition: background 0.3s;
}

/* ========== 라이트모드 ========== */
body.light-mode {
    --accent-green: #00e892;
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --card-bg: rgba(255, 255, 255, 0.98);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-attachment: fixed;
}

body.light-mode .login-box,
body.light-mode .setup-box {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
}

body.light-mode .top-controls,
body.light-mode .toolbar {
    background: rgba(255, 255, 255, 0.92);
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

body.light-mode .panel,
body.light-mode .shortcut-sidebar {
    background: rgba(255, 255, 255, 0.88);
    border: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

body.light-mode .top-btn,
body.light-mode .tool-btn {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body.light-mode .top-btn:hover,
body.light-mode .tool-btn:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

body.light-mode .tool-btn.active {
    background: linear-gradient(135deg, var(--accent-green), #00e693);
    color: #000;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(0, 255, 163, 0.3);
}

body.light-mode .top-btn.btn-skip:hover { background: var(--accent-green); color: #000; }
body.light-mode .top-btn.btn-change:hover { background: var(--accent-orange); color: #000; }
body.light-mode .top-btn.btn-reset:hover { background: var(--accent-red); color: white; }
body.light-mode .top-btn.btn-full-reset:hover { background: var(--accent-purple); color: white; }
body.light-mode .top-btn.btn-chat-toggle:hover { background: var(--accent-blue); color: #000; }

body.light-mode .ranking-tab {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

body.light-mode .ranking-tab.active {
    background: linear-gradient(135deg, var(--accent-purple), #c084fc);
    color: white;
    box-shadow: 0 4px 12px rgba(169, 112, 255, 0.3);
}

body.light-mode .ranking-item,
body.light-mode .chat-message,
body.light-mode .bgm-item,
body.light-mode .stage-rank-item {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.light-mode .chat-message {
    border-left: 3px solid var(--accent-purple);
}

body.light-mode .bgm-item:hover,
body.light-mode .stage-rank-item:hover {
    background: var(--bg-hover);
}

body.light-mode .bgm-item.active {
    background: linear-gradient(135deg, var(--accent-purple), #c084fc);
    color: white;
}

body.light-mode .shortcut-item .key {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

body.light-mode .canvas-wrapper {
    border: 3px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

body.light-mode .canvas-wrapper::before {
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 15px,
        #7c3aed 15px,
        #7c3aed 18px,
        transparent 18px,
        transparent 20px,
        #8b5cf6 20px,
        #8b5cf6 30px,
        #7c3aed 30px,
        #7c3aed 33px,
        transparent 33px,
        transparent 48px
    );
}

body.light-mode .start-overlay,
body.light-mode .countdown-overlay {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
}

body.light-mode .countdown-number {
    color: var(--accent-purple);
    text-shadow: 0 0 60px rgba(169, 112, 255, 0.6);
}

body.light-mode .popup-overlay {
    background: rgba(102, 126, 234, 0.85);
    backdrop-filter: blur(10px);
}

body.light-mode .popup-content {
    background: rgba(255, 255, 255, 0.98);
    border: none;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
}

body.light-mode .popup-content.correct-popup {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 3px solid var(--accent-green);
}

body.light-mode .popup-content.correct-popup .winner-name {
    color: #065f46;
    text-shadow: none;
}

body.light-mode .popup-content.timeout-popup {
    background: linear-gradient(135deg, #fef2f2, #fecaca);
    border: 3px solid var(--accent-red);
}

body.light-mode .interview-chat-display {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.light-mode .setup-group select,
body.light-mode .setup-group input[type="number"],
body.light-mode .setup-group textarea {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

body.light-mode .setup-group select:focus,
body.light-mode .setup-group input:focus,
body.light-mode .setup-group textarea:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(169, 112, 255, 0.15);
}

body.light-mode input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, var(--accent-green) 0%, var(--accent-green) var(--value-percent, 50%), #cbd5e1 var(--value-percent, 50%), #cbd5e1 100%);
}

body.light-mode .color-btn {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

body.light-mode .bg-banner .banner-text {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

body.light-mode .theme-toggle {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .toggle-track {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
}

body.light-mode .toggle-track::before {
    content: '☁️';
    left: 6px;
    right: auto;
}

body.light-mode .toggle-thumb {
    left: 26px;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.5);
}

/* ========== 공통 스타일 ========== */

/* 사이드 배너 */
.left-banners {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    align-self: center;
}

.bg-banner {
    display: block;
    text-decoration: none;
    width: 150px;
}

.bg-banner .banner-text {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    padding: 18px 14px;
    border-radius: 12px;
    text-align: center;
    transition: transform 0.2s, opacity 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.bg-banner .banner-text:hover {
    transform: scale(1.03);
    opacity: 0.9;
}

.bg-banner .banner-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin-bottom: 6px;
}

.bg-banner .banner-desc {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

@media (max-width: 1850px) {
    .left-banners { display: none; }
}

/* 로그인 화면 */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-box {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.login-box h1 {
    color: var(--accent-green);
    margin-bottom: 10px;
    font-weight: 700;
}

.login-box p {
    color: var(--text-secondary);
    margin: 20px 0;
}

.login-logo {
    width: 250px;
    height: auto;
    margin-bottom: 20px;
}

.login-btn {
    padding: 15px 40px;
    font-size: 16px;
    background: var(--accent-green);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.2s;
}

.login-btn:hover {
    background: #00e693;
    transform: scale(1.02);
}

/* 설정 화면 */
.setup-screen {
    display: none;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.setup-box {
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border-color);
    max-width: 700px;
    width: 95%;
}

.setup-title {
    font-size: 24px;
    margin-bottom: 24px;
    color: var(--text-primary);
    font-weight: 700;
}

.setup-group {
    margin-bottom: 16px;
    text-align: left;
}

.setup-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.setup-group select,
.setup-group input[type="number"],
.setup-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s;
}

.setup-group select:focus,
.setup-group input:focus,
.setup-group textarea:focus {
    border-color: var(--accent-green);
    outline: none;
}

.setup-group input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 3px;
    cursor: pointer;
}

.setup-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-green);
    border-radius: 50%;
    cursor: pointer;
}

.setup-row {
    display: flex;
    gap: 12px;
}

.setup-row .setup-group {
    flex: 1;
    min-width: 0;
}

.setup-row .setup-group.wide {
    flex: 1.5;
}

.setup-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 700;
    background: var(--accent-green);
    color: var(--bg-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    margin-top: 16px;
    transition: all 0.2s;
}

.setup-btn:hover {
    background: #00e693;
    transform: scale(1.01);
}

/* 게임 화면 */
.container {
    display: none;
    gap: 10px;
    width: 100%;
    height: 98vh;
}

.container.active {
    display: flex;
    justify-content: center;
}

.canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

/* 상단 컨트롤 */
.top-controls {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: wrap;
    transition: all 0.3s;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.control-group input[type="range"] {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 2px;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent-green);
    border-radius: 50%;
}

.control-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
}

.top-btn {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.top-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-green);
}

.top-btn.btn-skip { border-color: var(--accent-green); }
.top-btn.btn-change { border-color: var(--accent-orange); }
.top-btn.btn-reset { border-color: var(--accent-red); }
.top-btn.btn-full-reset { border-color: var(--accent-purple); }
.top-btn.btn-chat-toggle { border-color: var(--accent-blue); }

.top-btn.btn-skip:hover { background: var(--accent-green); color: var(--bg-primary); }
.top-btn.btn-change:hover { background: var(--accent-orange); color: var(--bg-primary); }
.top-btn.btn-reset:hover { background: var(--accent-red); color: white; }
.top-btn.btn-full-reset:hover { background: var(--accent-purple); color: white; }
.top-btn.btn-chat-toggle:hover { background: var(--accent-blue); color: var(--bg-primary); }

.top-btn svg {
    width: 18px;
    height: 18px;
}

.top-logo-icon {
    width: 140px;
    height: 70px;
    object-fit: contain;
}

.top-logo-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-green);
    margin-right: 8px;
}

/* 캔버스 영역 */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    gap: 8px;
    min-height: 0;
    min-width: 0;
}

/* 단축키 사이드바 */
.shortcut-sidebar {
    width: 150px;
    min-width: 150px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    flex-shrink: 0;
    transition: all 0.3s;
}

.shortcut-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    text-align: center;
}

.shortcut-item {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.shortcut-item .key {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    min-width: 24px;
    text-align: center;
}

.shortcut-divider {
    height: 1px;
    background: var(--border-color);
    margin: 6px 0;
}

/* 캔버스 */
.canvas-wrapper {
    flex: 1;
    position: relative;
    background: #f5f5dc;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    margin-top: 30px;
    min-width: 0;
    transition: all 0.3s;
}

.canvas-wrapper::before {
    content: '';
    position: absolute;
    top: -25px;
    left: 20px;
    right: 20px;
    height: 30px;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 15px,
        #888 15px,
        #888 18px,
        transparent 18px,
        transparent 20px,
        #666 20px,
        #666 30px,
        #888 30px,
        #888 33px,
        transparent 33px,
        transparent 48px
    );
    background-size: 48px 30px;
    z-index: 10;
}

.canvas-wrapper .spring-holes {
    position: absolute;
    top: -5px;
    left: 20px;
    right: 20px;
    height: 10px;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 18px,
        #f5f5dc 18px,
        #f5f5dc 30px,
        transparent 30px,
        transparent 48px
    );
    background-size: 48px 10px;
    z-index: 11;
}

.canvas-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 450px;
    height: auto;
    opacity: 0.2;
    pointer-events: none;
    z-index: 1;
}

.canvas-wrapper::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, transparent 50%, #e8e8c8 50%, #d8d8b8 100%);
    box-shadow: -2px -2px 5px rgba(0,0,0,0.1);
    z-index: 5;
}

.notebook-lines {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: repeating-linear-gradient(
        transparent, transparent 29px,
        #e0e0e0 29px, #e0e0e0 30px
    );
    pointer-events: none;
    z-index: 1;
}

#canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    cursor: crosshair;
    z-index: 2;
}

#previewCanvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 3;
}

/* 캔버스 상태 배지 */
.canvas-status {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 10px;
    z-index: 5;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.canvas-badge {
    padding: 10px 18px;
    border-radius: 25px;
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 6px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.badge-stage {
    background: rgba(169, 112, 255, 0.95);
    color: white;
}

.badge-round {
    background: rgba(0, 200, 255, 0.95);
    color: white;
}

.badge-timer {
    background: rgba(255, 149, 0, 0.95);
    color: white;
    min-width: 120px;
    justify-content: center;
}

.badge-timer.warning {
    background: rgba(255, 77, 77, 0.98);
    animation: pulse 0.5s ease-in-out infinite;
}

.badge-addtime {
    background: rgba(0, 200, 100, 0.95);
    color: white;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.badge-addtime:hover {
    background: rgba(0, 230, 120, 1);
    transform: scale(1.05);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* 시작 오버레이 */
.start-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(20, 21, 23, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    transition: background 0.3s;
}

.start-overlay.hidden { display: none; }

.start-btn {
    padding: 24px 64px;
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-green);
    color: var(--bg-primary);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 163, 0.4);
}

/* 카운트다운 */
.countdown-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(20, 21, 23, 0.95);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 15;
    transition: background 0.3s;
}

.countdown-overlay.active { display: flex; }

.countdown-number {
    font-size: 160px;
    font-weight: 900;
    color: var(--accent-green);
    text-shadow: 0 0 60px rgba(0, 255, 163, 0.5);
    animation: countPulse 0.8s ease-out;
}

@keyframes countPulse {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* 도구바 */
.toolbar {
    display: flex;
    gap: 8px;
    background: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    transition: all 0.3s;
}

.tool-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: var(--accent-green);
    background: var(--bg-hover);
}

.tool-btn.active {
    border-color: var(--accent-green);
    background: var(--accent-green);
    color: var(--bg-primary);
}

.tool-btn svg {
    width: 24px;
    height: 24px;
}

.toolbar-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    margin: 0 4px;
    flex-shrink: 0;
}

.brush-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.brush-control-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brush-control-row span {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 45px;
}

.brush-control-row input[type="range"] {
    width: 80px;
    height: 8px;
}

.brush-control-row .value-display {
    font-size: 12px;
    color: var(--text-primary);
    min-width: 30px;
    text-align: right;
}

.color-palette {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.color-btn {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.color-btn:hover {
    transform: scale(1.15);
    border-color: var(--text-primary);
}

.color-btn.active {
    border-color: var(--text-primary);
    box-shadow: 0 0 6px rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.custom-color-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

.custom-color-btn {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    background: conic-gradient(
        hsl(0, 100%, 50%),
        hsl(60, 100%, 50%),
        hsl(120, 100%, 50%),
        hsl(180, 100%, 50%),
        hsl(240, 100%, 50%),
        hsl(300, 100%, 50%),
        hsl(360, 100%, 50%)
    );
    transition: all 0.2s;
}

.custom-color-btn:hover {
    transform: scale(1.15);
    border-color: var(--text-primary);
}

.custom-color-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    opacity: 0;
    cursor: pointer;
}

.toolbar-spacer {
    flex: 1;
}

.contact-text {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* 사이드바 */
.sidebar {
    width: 420px;
    min-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.panel {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.panel-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 랭킹 */
.ranking-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.ranking-tab {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.ranking-tab.active {
    background: var(--accent-purple);
    color: white;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 12px;
    transition: all 0.2s;
}

.ranking-item.empty {
    color: var(--text-muted);
}

.rank-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
    margin-right: 10px;
    color: var(--bg-primary);
}

.rank-1 { background: linear-gradient(135deg, #ffd700, #ffec8b); }
.rank-2 { background: linear-gradient(135deg, #c0c0c0, #e8e8e8); }
.rank-3 { background: linear-gradient(135deg, #cd7f32, #daa06d); }
.rank-4, .rank-5 { background: var(--bg-hover); color: var(--text-primary); }

.rank-name {
    flex: 1;
    color: var(--text-primary);
}

.rank-score {
    font-weight: 700;
    color: var(--accent-green);
}

/* 채팅 */
.chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.chat-message {
    padding: 6px 10px;
    margin-bottom: 3px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 15px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.chat-message .nickname {
    font-weight: 700;
}

/* 정답 영역 */
.answer-panel {
    padding: 8px;
    flex-shrink: 0;
}

.answer-area-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    overflow: hidden;
    border-radius: 8px;
}

.answer-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-green), #00e693);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.answer-hint {
    font-size: 12px;
    color: rgba(0,0,0,0.5);
    margin-bottom: 8px;
    font-weight: 500;
}

.answer-text {
    font-size: 36px;
    font-weight: 900;
    color: var(--bg-primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.answer-cover-hint {
    font-size: 11px;
    color: rgba(0,0,0,0.4);
    margin-top: 8px;
}

/* 팝업 공통 */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(20, 21, 23, 0.95);
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: background 0.3s;
}

.popup-overlay.active { display: flex; }

.popup-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    max-width: 600px;
    width: 90%;
    border: 1px solid var(--border-color);
    animation: popupIn 0.3s ease-out;
    transition: all 0.3s;
}

@keyframes popupIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 정답 팝업 */
.popup-content.correct-popup {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid var(--accent-green);
    box-shadow: 0 0 40px rgba(0, 255, 163, 0.3);
    overflow: hidden;
    position: relative;
}

.correct-popup::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, rgba(0, 255, 163, 0.1), transparent 30%);
    animation: rotate 4s linear infinite;
    z-index: 0;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

.winner-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-green), #00e693);
    color: var(--bg-primary);
    padding: 8px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.winner-name {
    font-size: 32px;
    font-weight: 900;
    color: white;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(0, 255, 163, 0.5);
    position: relative;
    z-index: 1;
}

.winner-name.interviewing {
    animation: glow 1s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 10px var(--accent-green); }
    to { text-shadow: 0 0 30px var(--accent-green), 0 0 50px var(--accent-purple); }
}

.winner-message {
    font-size: 18px;
    color: var(--accent-green);
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.winner-score {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}

.winner-drawing {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 300px;
    border-radius: 12px;
    margin-bottom: 12px;
    background: #f5f5dc;
    object-fit: contain;
    border: 3px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    position: relative;
    z-index: 1;
}

.interview-chat-display {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: 40px;
    font-size: 14px;
    color: var(--text-primary);
    display: none;
    border: 2px solid var(--accent-purple);
    position: relative;
    z-index: 1;
}

.interview-chat-display.active { display: block; }

.popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.popup-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    transition: all 0.3s;
}

.popup-btn:hover {
    transform: translateY(-2px);
}

.btn-interview {
    background: linear-gradient(135deg, var(--accent-purple), #c084fc);
    color: white;
    box-shadow: 0 4px 15px rgba(169, 112, 255, 0.4);
}

.btn-interview:hover {
    box-shadow: 0 6px 20px rgba(169, 112, 255, 0.6);
}

.btn-continue {
    background: linear-gradient(135deg, var(--accent-green), #00e693);
    color: var(--bg-primary);
    box-shadow: 0 4px 15px rgba(0, 255, 163, 0.4);
}

.btn-continue:hover {
    box-shadow: 0 6px 20px rgba(0, 255, 163, 0.6);
}

/* 시간초과 팝업 */
.popup-content.timeout-popup {
    background: linear-gradient(135deg, #2d1f1f, #1a1a2e);
    border: 3px solid var(--accent-red);
    box-shadow: 0 0 40px rgba(255, 77, 77, 0.3);
}

.timeout-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--accent-red), #ff6b6b);
    color: white;
    padding: 8px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.timeout-title {
    font-size: 28px;
    font-weight: 900;
    color: var(--accent-red);
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(255, 77, 77, 0.5);
}

.timeout-message {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.answer-reveal {
    background: rgba(255, 77, 77, 0.15);
    border: 2px solid var(--accent-red);
    border-radius: 12px;
    padding: 16px 32px;
    margin: 16px 0;
}

.answer-reveal-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.answer-reveal-text {
    font-size: 28px;
    font-weight: 900;
    color: var(--accent-red);
}

/* 스테이지 종료 팝업 */
.stage-end-content {
    max-width: 600px;
}

.stage-end-title {
    font-size: 28px;
    font-weight: 900;
    color: var(--accent-green);
    margin-bottom: 16px;
}

.rankings-container {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.rankings-column {
    flex: 1;
}

.rankings-column-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.stage-end-rankings {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 250px;
    overflow-y: auto;
}

.stage-rank-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
}

.stage-rank-item:hover {
    background: var(--bg-hover);
}

.stage-rank-item.interviewing {
    background: var(--accent-purple);
    color: white;
}

.stage-rank-item.interviewing .rank-score {
    color: white;
}

/* BGM 팝업 */
.bgm-popup-content {
    max-width: 400px;
}

.bgm-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.bgm-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.bgm-item:hover {
    background: var(--bg-hover);
}

.bgm-item.active {
    background: var(--accent-purple);
    color: white;
}

.bgm-item-name {
    flex: 1;
}

.bgm-item-icon {
    margin-right: 8px;
}

/* 확인 팝업 */
.confirm-popup-content {
    max-width: 400px;
}

.confirm-title {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent-orange);
    margin-bottom: 12px;
}

.confirm-message {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-confirm {
    background: var(--accent-red);
    color: white;
}

/* 테마 토글 스위치 */
.theme-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s;
    user-select: none;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent-orange);
}

.toggle-track {
    width: 52px;
    height: 28px;
    background: linear-gradient(135deg, #1e293b, #334155);
    border-radius: 14px;
    position: relative;
    transition: all 0.4s;
    overflow: hidden;
}

.toggle-track::before {
    content: '✨';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.7;
}

.toggle-thumb {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #1e1e2e, #2d2d44);
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 슬라이더 */
input[type="range"] {
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: 4px;
    position: relative;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, var(--accent-green) 0%, var(--accent-green) var(--value-percent, 50%), var(--bg-tertiary) var(--value-percent, 50%), var(--bg-tertiary) 100%);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    margin-top: -4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

body.light-mode .canvas-wrapper {
    margin-top: 0;
    padding-top: 35px;
    border-radius: 12px;
}

body.light-mode .canvas-wrapper::before {
    top: 5px;
    z-index: 4;
}

body.light-mode .canvas-wrapper .spring-holes {
    top: 25px;
    z-index: 4;
}

body.light-mode .canvas-status {
    z-index: 10;
}


/* 유틸리티 */
.hidden { display: none !important; }

/* 버튼 클릭 효과 */
.top-btn:active,
.tool-btn:active,
.popup-btn:active,
.login-btn:active,
.setup-btn:active {
    transform: scale(0.95);
}

/* 채팅 메시지 슬라이드 */
.chat-message {
    animation: msgIn 0.2s ease-out;
}

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

/* 팝업 등장 */
@keyframes popupIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 시작 버튼 글로우 */
.start-btn {
    animation: btnGlow 2s ease-in-out infinite;
}

@keyframes btnGlow {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 255, 163, 0.3); }
    50% { box-shadow: 0 0 35px rgba(0, 255, 163, 0.5); }
}

/* 스크롤바 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-purple);
    border-radius: 3px;
}

/* 선택 영역 */
::selection {
    background: var(--accent-purple);
    color: white;
}

body:not(.light-mode) .canvas-wrapper {
    margin-top: 0;
    padding-top: 35px;
    border-radius: 12px;
}

body:not(.light-mode) .canvas-wrapper::before {
    top: 5px;
    z-index: 4;
}

body:not(.light-mode) .canvas-wrapper .spring-holes {
    top: 25px;
    z-index: 4;
}

body:not(.light-mode) .canvas-status {
    z-index: 10;
}

.bgm-notice {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
}


/* 정답 수정 */
.answer-edit-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.answer-edit-btn {
    background: rgba(0, 0, 0, 0.3);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-edit-btn:hover {
    background: rgba(0, 0, 0, 0.5);
    transform: scale(1.1);
}

.answer-input {
    font-size: 28px;
    font-weight: 900;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    border: 3px solid var(--accent-green);
    border-radius: 12px;
    padding: 10px 20px;
    color: #1a1a1a;
    outline: none;
    width: 80%;
    max-width: 300px;
}

.answer-input:focus {
    box-shadow: 0 0 15px rgba(0, 255, 163, 0.5);
}

.winner-answer {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-orange);
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.stage-end-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* 직접 입력 오버레이 */
.answer-input-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    z-index: 10;
    border-radius: 8px;
}

.input-waiting-text {
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.custom-answer-input {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid white;
    border-radius: 12px;
    padding: 12px 24px;
    color: #1a1a1a;
    outline: none;
    width: 80%;
    max-width: 280px;
}

.custom-answer-input:focus {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.input-hint {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
}

/* 시작 오버레이에 대기 메시지 */
.start-overlay.waiting .start-btn {
    display: none;
}

.start-overlay .waiting-message {
    display: none;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent-purple);
    text-align: center;
}

.start-overlay.waiting .waiting-message {
    display: block;
}

/* 유저 프로필 */
.user-profile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.profile-image {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-green);
}

.profile-image.default {
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.verified-mark {
    background: var(--accent-green);
    color: var(--bg-primary);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

body.light-mode .user-profile {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

/* 채팅 패널 헤더 */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-toggles {
    display: flex;
    gap: 10px;
}

.font-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-green);
}

.font-btn:active {
    transform: scale(0.95);
}

/* 라이트모드 */
body.light-mode .font-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .font-btn:hover {
    background: #ffffff;
    border-color: var(--accent-green);
}


/* 랭킹 헤더 프로필 */
.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 700;
    color: var(--text-primary);
    font-size: 13px;
}

.ranking-profile-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-green);
    flex-shrink: 0;
}

.ranking-profile-image.default {
    background: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.ranking-profile-name {
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.ranking-title-text {
    color: var(--text-primary);
    white-space: nowrap;
}

/* 채팅 숨김 상태 */
.chat-messages.hidden {
    visibility: hidden;
}

.chat-messages.hide-nickname .nickname,
.chat-messages.hide-nickname .nickname-separator {
    display: none !important;
}