/* ================================
   테트리스 챌린지 스타일 - 챌린지 공통 톤
================================ */

.tetris-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tetris-container h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.tetris-container .page-desc {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.tetris-main-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

.tetris-game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tetris-game-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.tetris-game-card h3 {
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: var(--text-primary);
    text-align: center;
}

.tetris-game-desc {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
    text-align: center;
}

/* 탭: 싱글 / 멀티 */
.tetris-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.tetris-tab-btn {
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.tetris-tab-btn:hover {
    color: var(--text-primary);
}

.tetris-tab-btn.active {
    color: var(--gold-primary);
    border-bottom-color: var(--gold-primary);
}

.tetris-tab-content {
    margin-bottom: 14px;
}

.tetris-tab-content.hidden {
    display: none !important;
}

.tetris-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.tetris-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.tetris-btn-start {
    background: linear-gradient(135deg, var(--gold-primary), var(--gold-light));
    color: #000;
}

.tetris-btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.tetris-btn-start:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 스탯 바: 그리드 + 횟수/회복 행 */
.tetris-status-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.tetris-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.tetris-stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 8px;
    background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    min-height: 52px;
}

.tetris-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.tetris-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.tetris-stat-pill.tetris-score .tetris-stat-value { color: var(--gold-primary); }
.tetris-stat-pill.tetris-combo .tetris-stat-value { color: #7dd3fc; }

.tetris-count-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.tetris-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: linear-gradient(145deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.tetris-count-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tetris-count-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tetris-count-value strong { color: var(--gold-primary); }

.tetris-count-sep {
    margin: 0 4px;
    color: var(--text-secondary);
    font-weight: 500;
}

.tetris-regen-inline {
    margin-left: 6px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.85rem;
    font-weight: 500;
    color: #86efac;
    white-space: nowrap;
}

.regen-timer.hidden { display: none; }

/* 모바일 터치 안내 (데스크톱에서는 숨김) */
.tetris-touch-hint {
    display: none;
    margin: 0 0 10px 0;
    padding: 6px 10px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

/* 플레이 영역: 보드 + Next */
.tetris-play-area {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    justify-content: center;
    margin: 12px 0;
}

.tetris-board-wrap {
    position: relative;
    background: #1a1a2e;
    border-radius: 8px;
    border: 2px solid rgba(212, 175, 55, 0.3);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.tetris-canvas {
    display: block;
    border-radius: 6px;
}

.tetris-pause-overlay,
.tetris-gameover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
}

.tetris-pause-overlay p,
.tetris-gameover-overlay p {
    margin: 8px 0 0;
    font-size: 0.9rem;
    font-weight: 400;
    opacity: 0.9;
}

.tetris-gameover-overlay .tetris-final-score {
    font-size: 1.4rem;
    color: var(--gold-primary);
}

.tetris-next-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tetris-next-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* NEXT 영역 고정 크기 (블록 크기와 관계없이 레이아웃 유지) */
.tetris-next-canvas {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 56px;  /* 4 * 14px 고정 */
    min-width: 56px;
}

.tetris-next-piece {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 28px;
    min-width: 56px;
    min-height: 28px;
    flex-shrink: 0;
}

.tetris-next-piece canvas,
.tetris-next-piece-canvas {
    display: block;
    width: 56px;
    height: 28px;
}

/* 하단 가상 버튼 (모바일) */
.tetris-bottom-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 10px 0;
}

.tetris-bottom-buttons.hidden { display: none; }

.tetris-ctrl-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tetris-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

/* 순위 사이드바 - 챌린지 공통 톤 */
.tetris-ranking-sidebar {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 18px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tetris-ranking-sidebar h4 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.tetris-ranking-list {
    max-height: 280px;
    overflow-y: auto;
}

.tetris-ranking-list .loading,
.tetris-ranking-list .empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px 0;
}

.tetris-ranking-list .ranking-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
}

.tetris-ranking-list .ranking-item:last-child { border-bottom: none; }

.tetris-ranking-list .rank {
    min-width: 28px;
    font-weight: 700;
    color: var(--gold-primary);
    flex-shrink: 0;
}

.tetris-ranking-list .ranking-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.tetris-ranking-list .ranking-avatar.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.tetris-ranking-list .name {
    flex: 1;
    min-width: 0;
    max-width: 85px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tetris-ranking-list .score {
    color: var(--gold-primary);
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 4px;
}

/* 명예의 전당 */
.tetris-ranking-sidebar .hall-of-fame-title {
    font-size: 1rem;
    margin-top: 18px;
    margin-bottom: 12px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.tetris-hall-of-fame-list {
    max-height: 160px;
    overflow-y: auto;
}

.tetris-hall-of-fame-list .empty {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px 0;
}

.tetris-hall-of-fame-list .ranking-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.9rem;
}

.tetris-hall-of-fame-list .ranking-item:last-child { border-bottom: none; }

.tetris-hall-of-fame-list .ranking-avatar {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.tetris-hall-of-fame-list .ranking-avatar.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.8rem;
}

.tetris-hall-of-fame-list .rank {
    min-width: 28px;
    font-weight: 700;
    color: var(--gold-primary);
    flex-shrink: 0;
}

.tetris-hall-of-fame-list .name {
    flex: 1;
    min-width: 0;
    max-width: 85px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tetris-hall-of-fame-list .score {
    color: var(--gold-primary);
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 4px;
}

/* 테트리스 멀티플레이 (최대 6인) */
.tetris-multi-panel {
    margin-bottom: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tetris-multi-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.tetris-multi-actions.hidden {
    display: none !important;
}

.tetris-room-list-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.tetris-room-list-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.tetris-room-list {
    width: 100%;
    margin-top: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.tetris-room-list-empty {
    padding: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tetris-room-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.tetris-room-item-code {
    font-weight: 600;
    letter-spacing: 0.1em;
    color: var(--gold-primary);
    min-width: 72px;
}

.tetris-room-item-host {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.tetris-room-item-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tetris-btn-multi {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tetris-btn-multi:hover {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.1));
}

.tetris-join-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tetris-room-code-input {
    width: 90px;
    padding: 8px 10px;
    font-size: 0.95rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-primary);
}

.tetris-room-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tetris-room-info > .tetris-room-label,
.tetris-room-info > strong,
.tetris-room-info > .tetris-btn-small {
    display: inline;
}

.tetris-room-info-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.tetris-lobby-players {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tetris-lobby-player {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 0.9rem;
}

.tetris-lobby-player.tetris-lobby-me {
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.tetris-lobby-player-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tetris-lobby-host-badge {
    margin-left: 6px;
    font-size: 0.75rem;
    color: var(--gold-primary);
}

.tetris-lobby-ready-badge {
    font-size: 0.8rem;
    color: #4caf50;
}

.tetris-lobby-wait-badge {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.tetris-ready-btn.hidden,
.tetris-host-start-btn.hidden {
    display: none !important;
}

.tetris-room-info.hidden {
    display: none !important;
}

.tetris-room-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tetris-room-info strong {
    color: var(--gold-primary);
    letter-spacing: 0.15em;
}

.tetris-btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    cursor: pointer;
}

.tetris-btn-small:hover {
    background: rgba(255, 255, 255, 0.15);
}

.tetris-other-boards {
    margin-top: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tetris-other-boards.hidden {
    display: none !important;
}

.tetris-other-boards-title {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.tetris-other-slots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.tetris-other-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.tetris-other-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tetris-other-score {
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.9;
    white-space: nowrap;
    text-align: center;
}

.tetris-other-canvas {
    width: 100px;
    height: 200px;
    max-width: 100%;
    background: #1a1a2e;
    border-radius: 4px;
    display: block;
}

/* 반응형 */
@media (max-width: 1024px) {
    .tetris-main-layout {
        grid-template-columns: 1fr;
    }

    .tetris-ranking-sidebar {
        order: 2;
        margin-top: 16px;
    }

    .tetris-game-area {
        order: 1;
    }
}

@media (max-width: 768px) {
    .tetris-touch-hint { display: block; }

    .tetris-container {
        padding: 16px;
    }

    .tetris-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tetris-stat-pill {
        min-height: 48px;
        padding: 8px 6px;
    }

    .tetris-stat-value {
        font-size: 1.05rem;
    }

    .tetris-count-row {
        flex-direction: column;
        align-items: stretch;
    }


    .tetris-play-area {
        flex-direction: column;
        align-items: center;
    }

    .tetris-canvas {
        max-width: 100%;
        height: auto;
    }

    .tetris-bottom-buttons {
        padding: 12px 0;
    }

    .tetris-ctrl-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .tetris-other-slots {
        grid-template-columns: repeat(3, 1fr);
    }

    .tetris-other-canvas {
        width: 80px;
        height: 160px;
    }
}

.tetris-pause-overlay.hidden,
.tetris-gameover-overlay.hidden {
    display: none !important;
}
