/* Tetra Ars — extracted from index.html for CSP */
        @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&family=Orbitron:wght@500;700&display=swap');

        @keyframes gradientBg {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        @keyframes titleGlow {
            0% { text-shadow: 0 0 10px #0DC2FF, 0 0 20px #0DC2FF; }
            50% { text-shadow: 0 0 20px #0DC2FF, 0 0 30px #0DC2FF, 0 0 40px #0DC2FF; }
            100% { text-shadow: 0 0 10px #0DC2FF, 0 0 20px #0DC2FF; }
        }

        body { 
            background: linear-gradient(-45deg, #1a1a2e, #16213e, #0f3460, #0d0d14);
            background-size: 400% 400%;
            animation: gradientBg 15s ease infinite;
            color: #f0f0f0; 
            font-family: 'Noto Sans KR', sans-serif;
            text-align: center; 
            margin: 0; 
            padding: 20px;
            min-height: 100vh;
        }
        .header-controls {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            max-width: 900px;
            margin: 0 auto 30px auto;
            padding: 15px 25px;
            background: rgba(20, 20, 30, 0.6);
            backdrop-filter: blur(15px);
            border-radius: 15px;
            border: 1px solid rgba(13, 194, 255, 0.2);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), inset 0 0 10px rgba(13, 194, 255, 0.1);
            box-sizing: border-box;
        }
        #main-title {
            font-family: 'Orbitron', sans-serif;
            color: #fff;
            text-shadow: 0 0 10px #0DC2FF, 0 0 20px #0DC2FF;
            animation: titleGlow 2s ease-in-out infinite;
            margin: 0;
            font-size: 1.8rem;
        }
        .game-container {
            display: flex;
            justify-content: center;
            align-items: flex-start;
            gap: 40px;
        }
        .player-area {
            display: flex;
            flex-direction: column;
            align-items: center;
            background: rgba(10, 10, 20, 0.65);
            backdrop-filter: blur(12px);
            padding: 20px;
            border-radius: 16px;
            border: 1px solid rgba(255, 255, 255, 0.1);
            box-shadow: 0 8px 32px rgba(0,0,0,0.6), inset 0 0 20px rgba(0,0,0,0.5);
        }
        #p1-name { color: #0DFF72; font-size: 1.4rem; margin: 0 0 10px 0; text-shadow: 0 0 8px rgba(13,255,114,0.5); }
        #p2-name { color: #FF0D72; font-size: 1.4rem; margin: 0 0 10px 0; text-shadow: 0 0 8px rgba(255,13,114,0.5); }
        canvas { 
            border-radius: 8px;
            background-color: #050505; 
            margin-top: 10px;
        }
        #tetris { border: 2px solid #0DFF72; box-shadow: 0 0 20px rgba(13, 255, 114, 0.4), inset 0 0 10px rgba(13, 255, 114, 0.2); }
        #opponent-tetris { border: 2px solid #FF0D72; box-shadow: 0 0 20px rgba(255, 13, 114, 0.4), inset 0 0 10px rgba(255, 13, 114, 0.2); max-width: 100%; height: auto; object-fit: contain; }
        .hold-block, .next-block { width: 25%; max-width: 80px; flex-shrink: 0; }
        .hold-block canvas, .next-block canvas { width: 100%; height: auto; aspect-ratio: 1 / 1; display: block; object-fit: contain; }
        .score {
            font-family: 'Orbitron', sans-serif;
            font-size: 1.5rem;
            font-weight: 700;
            margin-bottom: 5px;
        }
        .lines-info { font-family: 'Orbitron', sans-serif; font-size: 1rem; margin-bottom: 2px; color: #aaa; }
        .bottom-panel {
            display: flex;
            flex-direction: column;
            margin-top: 20px;
            width: 100%;
            max-width: 560px;
        }
        
        #chat-container {
            width: 100%;
            margin: 0;
            background: rgba(0,0,0,0.4);
            padding: 15px;
            border-radius: 15px;
            border: 1px solid #333;
            box-sizing: border-box;
            position: relative;
            z-index: 1001;
            display: flex;
            flex-direction: column;
            flex: 1;
        }
        #chat-box {
            flex: none;
            height: 150px;
            max-height: 150px;
            background: rgba(0, 0, 0, 0.8);
            border: 1px solid #444;
            border-radius: 8px;
            overflow-y: auto;
            text-align: left;
            padding: 10px;
            margin-bottom: 10px;
            font-size: 0.85rem;
            line-height: 1.5;
            word-break: break-all;
        }
        .chat-input-wrapper { display: flex; flex-direction: column; gap: 8px; }
        #chat-input {
            flex: 1;
            padding: 10px 15px;
            border-radius: 8px;
            border: 1px solid #555;
            background: #1a1a24;
            color: #fff;
            outline: none;
            font-family: inherit;
            transition: border-color 0.2s;
        }
        #chat-input:focus { border-color: #0DC2FF; }
        
        button {
            background: linear-gradient(135deg, #0DC2FF, #3877FF);
            color: #fff !important;
            border: none !important;
            padding: 8px 16px;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 700;
            transition: transform 0.1s, box-shadow 0.2s;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            border: 1px solid rgba(255,255,255,0.1) !important;
            white-space: nowrap;
        }
        button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(13, 194, 255, 0.6); filter: brightness(1.1); }
        
        select, #room-input {
            padding: 8px 12px;
            background: #2a2a35;
            color: #fff;
            border: 1px solid #555;
            border-radius: 6px;
            outline: none;
        }
        select:hover, #room-input:focus { border-color: #0DC2FF; }
        
        #help-btn { background: #0DC2FF; color: #111 !important; }
        
        /* 도움말 모달 스타일 */
        #help-modal {
            display: none; position: fixed; z-index: 1005; left: 0; top: 0; 
            width: 100%; height: 100%; background-color: rgba(0,0,0,0.8); 
        }
        .modal-content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: #1a1a2e;
            padding: 25px;
            border: 2px solid #0DC2FF;
            width: 90%;
            max-width: 450px;
            max-height: 80vh;
            overflow-y: auto;
            box-sizing: border-box;
            border-radius: 15px;
            text-align: left;
            line-height: 1.6;
            box-shadow: 0 0 30px rgba(13, 194, 255, 0.3);
        }
        .close-btn { float: right; color: #aaa; font-size: 28px; font-weight: bold; cursor: pointer; }
        .close-btn:hover { color: #fff; }

        #game-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.85);
            z-index: 2000;
            display: none;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            border-radius: 16px;
        }

        .lobby-box {
            background: rgba(0, 0, 0, 0.6);
            padding: 40px;
            border-radius: 15px;
            border: 1px solid #0DC2FF;
            box-shadow: 0 0 30px rgba(13, 194, 255, 0.3);
        }
        
        /* 밝은 테마 (Light Theme) 스타일 */
        body.light-theme {
            background: linear-gradient(-45deg, #f4f7f6, #e0e6ed, #d1dce5, #eaeff2);
            background-size: 400% 400%;
            animation: gradientBg 15s ease infinite;
            color: #222;
        }
        body.light-theme .header-controls,
        body.light-theme .player-area,
        body.light-theme #chat-container,
        body.light-theme .lobby-box,
        body.light-theme #game-overlay {
            background: rgba(255, 255, 255, 0.9);
            border: 1px solid rgba(0, 0, 0, 0.1);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
        }
        
        /* 설정 그리드 UI 스타일 */
        .settings-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 25px;
            background: rgba(0, 0, 0, 0.6);
            padding: 30px;
            border-radius: 15px;
            border: 1px solid #333;
            width: 100%;
            box-sizing: border-box;
        }
        .setting-item {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 8px;
            text-align: left;
        }
        .setting-label {
            color: #0DC2FF;
            font-size: 1.1rem;
            font-weight: bold;
        }
        body.light-theme .settings-grid {
            background: rgba(255, 255, 255, 0.9);
            border: 1px solid #ccc;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
        }
        body.beige-theme .settings-grid {
            background: rgba(250, 240, 230, 0.95);
            border: 1px solid #d2b48c;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        }
        body.light-theme #opponent-level-ui {
            background: rgba(255, 255, 255, 0.9);
            border: 1px solid #ccc !important;
        }
        body.light-theme #main-title {
            color: #0DC2FF;
            text-shadow: 0 0 10px rgba(13, 194, 255, 0.3);
        }
        body.light-theme #game-time-display {
            color: #0b80d6 !important;
            text-shadow: none !important;
        }
        body.light-theme canvas {
            background-color: #ffffff !important;
            border-color: #bbb !important;
            box-shadow: none !important;
        }
        body.light-theme,
        body.light-theme .lines-info, 
        body.light-theme label, 
        body.light-theme #game-over-stats, 
        body.light-theme #opponent-level-ui, 
        body.light-theme #modal-text,
        body.light-theme #controls-dynamic-list div span,
        body.light-theme #help-controls-list div span,
        body.light-theme #keymap-list span {
            color: #222 !important;
        }
        body.light-theme #controls-dynamic-list div span:last-child,
        body.light-theme #help-controls-list div span:last-child {
            color: #0b80d6 !important; /* 밝은 테마용 단축키 색상 */
        }
        body.light-theme #chat-box, body.light-theme #chat-input, body.light-theme select, body.light-theme input {
            background-color: #eef2f5; /* 테마에 맞는 입력/드롭다운 배경색 */
            color: #222 !important;
            border: 1px solid #bbb;
        }
        body.light-theme #chat-input:focus, body.light-theme input:focus, body.light-theme select:focus { border-color: #0DC2FF; }
        body.light-theme .modal-content {
            background-color: #fcfcfc;
            border-color: #ccc;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }
        body.light-theme .lobby-input {
            background: #eef2f5;
            color: #222;
            border-color: #bbb;
        }
        body.light-theme #room-input {
            background: #eef2f5;
            color: #222;
            border-color: #bbb;
        }

        /* 베이지 테마 (Beige Theme) 스타일 */
        body.beige-theme {
            background: linear-gradient(-45deg, #fdfbf7, #f5f5dc, #e8e4c9, #f0ebd8);
            background-size: 400% 400%;
            animation: gradientBg 15s ease infinite;
            color: #5d4037; /* 어두운 갈색 텍스트 */
        }
        body.beige-theme .header-controls,
        body.beige-theme .player-area,
        body.beige-theme #chat-container,
        body.beige-theme .lobby-box,
        body.beige-theme #game-overlay {
            background: rgba(250, 240, 230, 0.85); /* 리넨(Linen) 느낌의 반투명 배경 */
            border: 1px solid #d2b48c; /* 황갈색(Tan) 테두리 */
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        }
        body.beige-theme #main-title {
            color: #c79c6e;
            text-shadow: 0 0 8px rgba(199, 156, 110, 0.5);
        }
        body.beige-theme canvas {
            background-color: #faf5ef !important; /* 캔버스 배경 */
            border-color: #c79c6e !important;
            box-shadow: none !important;
        }
        body.beige-theme,
        body.beige-theme .lines-info, 
        body.beige-theme label, 
        body.beige-theme #game-over-stats, 
        body.beige-theme #opponent-level-ui, 
        body.beige-theme #modal-text,
        body.beige-theme #controls-dynamic-list div span,
        body.beige-theme #help-controls-list div span,
        body.beige-theme #keymap-list span {
            color: #5d4037 !important;
        }
        body.beige-theme #controls-dynamic-list div span:last-child,
        body.beige-theme #help-controls-list div span:last-child {
            color: #8c6d46 !important;
        }
        body.beige-theme #chat-box, body.beige-theme #chat-input, body.beige-theme select, body.beige-theme input {
            background-color: #fdfaf5;
            color: #5d4037 !important;
            border: 1px solid #d2b48c;
        }
        body.beige-theme #chat-input:focus, body.beige-theme input:focus, body.beige-theme select:focus { border-color: #c79c6e; }
        body.beige-theme .modal-content {
            background-color: #fdfdf5;
            border-color: #d2b48c;
            box-shadow: 0 0 20px rgba(0,0,0,0.1);
        }
        body.beige-theme .lobby-input {
            background: #fdfaf5;
            color: #5d4037;
            border-color: #d2b48c;
        }
        body.beige-theme #room-input {
            background: #fdfaf5;
            color: #5d4037;
            border-color: #d2b48c;
        }
        body.beige-theme #game-time-display {
            color: #8c6d46 !important;
            text-shadow: none !important;
        }

        /* 숫자 입력 화살표 숨김 */
        input[type="number"]::-webkit-inner-spin-button,
        input[type="number"]::-webkit-outer-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }
        input[type="number"] { 
            -moz-appearance: textfield;
            appearance: textfield;
        }

        /* 로비 화면 스타일 */
        .lobby-input {
            display: block; width: 220px; padding: 10px; margin-bottom: 20px;
            background: #1a1a24; color: #fff; border: 1px solid #555; border-radius: 6px; text-align: center; font-size: 1rem;
        }
        .lobby-input:focus { border-color: #0DC2FF; outline: none; }

        /* 모바일 컨트롤 UI 스타일 */
        #mobile-controls {
            display: none; /* PC에서는 숨김 */
            position: fixed;
            bottom: 20px;
            left: 0;
            width: 100%;
            justify-content: space-between;
            padding: 0 10px;
            box-sizing: border-box;
            z-index: 3000;
            pointer-events: none; /* 컨테이너는 클릭 비활성화 */
        }
        .mobile-control-group {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        .mobile-btn {
            pointer-events: auto; /* 버튼은 다시 클릭 활성화 */
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: rgba(13, 194, 255, 0.2) !important;
            border: 2px solid #0DC2FF !important;
            color: #fff !important;
            font-size: 20px;
            font-weight: bold;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            user-select: none;
            touch-action: none; /* 화면 더블탭 확대 방지 */
            box-shadow: 0 0 10px rgba(13, 194, 255, 0.3) !important;
            line-height: 1.2;
            padding: 4px !important;
            text-align: center;
            word-break: keep-all; /* 단어 단위로 깔끔하게 줄바꿈 */
            white-space: pre-wrap; /* 띄어쓰기 시 자동 줄바꿈 허용 */
            box-sizing: border-box; /* 패딩 영역을 포함하여 크기 유지 */
            overflow: hidden; /* 버튼 밖으로 튀어나감 방지 */
        }
        .mobile-btn:active {
            background: rgba(13, 194, 255, 0.6) !important;
            transform: scale(0.9);
        }
