:root {
    --bg-dark: #090c15;
    --card-bg: rgba(18, 24, 40, 0.85);
    --card-border: rgba(0, 229, 255, 0.2);
    --neon-cyan: #00e5ff;
    --neon-blue: #0070f3;
    --neon-purple: #bd00ff;
    --neon-yellow: #ffd600;
    --neon-green: #00e676;
    --neon-red: #ff1744;
    --neon-orange: #ff9100;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --font-main: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-digital: 'Orbitron', monospace;
    --font-timer: 'Teko', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background: radial-gradient(circle at center, #141b2d 0%, #060911 100%);
    font-family: var(--font-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* 전체 래퍼 */
.tetris-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    max-width: 900px;
    padding: 10px;
    position: relative;
}

/* 상단 헤더 */
.tetris-header {
    width: 100%;
    max-width: 580px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 6px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 229, 255, 0.1);
}

.game-logo {
    font-family: var(--font-digital);
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #00e5ff, #bd00ff, #ffd600);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
}

.quick-nav {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.icon-btn:hover {
    background: rgba(0, 229, 255, 0.2);
    border-color: var(--neon-cyan);
}

/* 메인 3단 레이아웃 (HOLD - BOARD - NEXT) */
.game-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 14px;
}

/* 사이드 패널 공통 */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 120px;
}

.hud-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.card-title {
    font-family: var(--font-digital);
    font-size: 11px;
    font-weight: 700;
    color: var(--neon-cyan);
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.preview-box {
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    height: 70px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.card-hint {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

.card-hint kbd {
    background: rgba(255, 255, 255, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
}

.stat-value {
    font-family: var(--font-digital);
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    padding: 4px 0;
}

.stat-value.highlight {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px rgba(255, 214, 0, 0.5);
}

.next-previews {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 6px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* 중앙 메인 보드 컨테이너 */
.board-container {
    position: relative;
    width: 300px;
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
    background: #0b0f19;
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.8);
}

canvas#tetrisCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* 액션 텍스트 팝업 (TETRIS, COMBO) */
.action-text {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-family: var(--font-digital);
    font-size: 32px;
    font-weight: 900;
    color: var(--neon-yellow);
    text-shadow: 0 0 20px rgba(255, 214, 0, 0.9);
    pointer-events: none;
    opacity: 0;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 15;
}

.action-text.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

/* 오버레이 화면 (일시정지, 게임오버) */
.overlay-screen {
    position: absolute;
    inset: 0;
    background: rgba(6, 10, 20, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 20;
    padding: 20px;
    text-align: center;
}

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

.overlay-screen h2 {
    font-family: var(--font-digital);
    font-size: 32px;
    color: var(--neon-cyan);
    text-shadow: 0 0 15px var(--neon-cyan);
}

.overlay-screen h2.danger-text {
    color: var(--neon-red);
    text-shadow: 0 0 15px var(--neon-red);
}

.final-score-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 24px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.final-score-box .score-num {
    font-family: var(--font-digital);
    font-size: 32px;
    color: var(--neon-yellow);
    margin-top: 4px;
}

/* 네온 버튼 */
.btn-neon {
    background: linear-gradient(135deg, #00e5ff, #0070f3);
    color: #000;
    font-family: var(--font-digital);
    font-size: 14px;
    font-weight: 900;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4);
    transition: all 0.15s ease;
}

.btn-neon:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 229, 255, 0.7);
}

.btn-glow {
    background: linear-gradient(135deg, #ffd600, #ff9100);
    box-shadow: 0 0 15px rgba(255, 214, 0, 0.5);
}

/* 하단 키 가이드 바 */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.ctrl-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
}

.key-tag {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 11px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.highlight-drop .key-tag {
    background: linear-gradient(135deg, #00e5ff, #0070f3);
    color: #000;
    border-color: #00e5ff;
}

/* 모바일 터치 컨트롤 */
.mobile-touch-controls {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
    max-width: 320px;
}

.touch-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.t-btn {
    flex: 1;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    touch-action: manipulation;
}

.t-rot { background: rgba(189, 0, 255, 0.3); border-color: var(--neon-purple); }
.t-drop { background: rgba(0, 229, 255, 0.3); border-color: var(--neon-cyan); }
.t-dir { font-size: 18px; }

/* 도움말 모달 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 12, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 100;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(160deg, #162035, #0a0f1c);
    border: 1px solid var(--neon-cyan);
    box-shadow: 0 0 30px rgba(0, 229, 255, 0.3);
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    padding: 24px;
}

.modal-header h2 {
    font-family: var(--font-digital);
    font-size: 20px;
    color: var(--neon-cyan);
    margin-bottom: 16px;
    text-align: center;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 13px;
}

.help-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    padding: 8px 12px;
    border-radius: 8px;
}

.key-label {
    min-width: 90px;
}

.key-label kbd {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-weight: 800;
    font-size: 11px;
}

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

/* 반응형 모바일 화면 */
@media (max-width: 540px) {
    .side-panel {
        width: 80px;
        gap: 6px;
    }
    .board-container {
        width: 200px;
        height: 400px;
    }
    .card-title {
        font-size: 9px;
    }
    .stat-value {
        font-size: 15px;
    }
    .controls-bar {
        display: none;
    }
    .mobile-touch-controls {
        display: flex;
    }
}