/* ============================================================
   worldcup.css — worldcup play page
   Split from static/style.css (refactor 2026-07).
   2026-07 redesign: settings-tab diet, match toolbar (순서 업데이트),
   flattened base+override duplicates. Tokens/values unchanged.
   ============================================================ */

/* ===== LAYOUT ===== */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-h));
    width: 100vw;
}

/* Left Panel (Sidebar) */
.ranking-panel {
    width: var(--side-w);
    background: var(--surface-base);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width 0.1s;
    flex-shrink: 0;
}

.panel-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-base);
}

.panel-title {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}

.panel-range-display {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.panel-empty-note {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.mobile-header-spacer {
    width: 44px;
}

/* Right Panel (Main Content) */
.worldcup-panel {
    flex: 1;
    background: var(--surface-canvas);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.resize-handle {
    width: 4px;
    cursor: col-resize;
    background-color: transparent;
    transition: background-color var(--transition-fast);
    z-index: 100;
    margin-left: -2px;
    /* Overlap border */
}

.resize-handle:hover,
.resize-handle:active {
    background-color: var(--accent-primary);
}

.mode-hidden {
    display: none !important;
}

.input-label {
    color: var(--text-secondary);
    font-size: var(--fs-12);
    font-weight: 600;
}

/* card 라이트 보정 (사이드 안의 카드들) */
body.worldcup-page .card {
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

body.worldcup-page .card-header {
    background: var(--surface-base);
    border-bottom: 1px solid var(--border-subtle);
}

/* ===== LIST ITEMS (Ranking) ===== */
.list-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
    transition: background-color var(--transition-fast);
    font-size: 0.9rem;
    min-width: 0;
}

.list-item:hover {
    background-color: var(--bg-tertiary);
}

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

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-strong);
    flex-shrink: 0;
    min-width: 28px;
    height: 22px;
    padding: 0 6px;
    border-radius: var(--r-sm);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    font-size: var(--fs-12);
    text-align: center;
}

.item-content {
    flex: 1;
    min-width: 0;
}

.item-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-subtitle {
    font-size: 0.76rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.elo-badge {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--accent-primary);
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

.item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.match-count-badge {
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
}

.item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.list-item:hover .item-actions {
    opacity: 1;
}

/* ===== MATCH AREA ===== */
.match-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* safe center: 콘텐츠가 들어가면 세로 중앙, 넘치면 상단부터 정렬.
       그냥 center면 25곡 티어처럼 긴 콘텐츠의 위쪽(제목·S·A)이 넘쳐 잘리고
       스크롤로도 닿을 수 없다(flexbox overflow 함정). */
    justify-content: safe center;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 40px;
    gap: 24px;
}

.match-header {
    text-align: center;
    margin-bottom: 0;
}

.match-title {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: -0.015em;
    margin-bottom: 6px;
}

.match-subtitle {
    font-size: var(--fs-13);
    color: var(--text-secondary);
}

.match-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 32px;
    align-items: stretch;
    max-width: 1100px;
    width: 100%;
}

/* Match toolbar — 플레이의 보상 액션 (순서 업데이트) */
.match-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 40px 0;
    padding: 12px 16px;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.match-toolbar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.match-toolbar-info strong {
    font-size: var(--fs-13);
    color: var(--text-strong);
}

.match-toolbar-hint {
    font-size: var(--fs-12);
    color: var(--text-muted);
}

.match-toolbar .btn {
    flex-shrink: 0;
}

/* Match state cards (loading / login / empty / error) */
.match-state-card {
    text-align: center;
    padding: 2.5rem 1.5rem;
    max-width: 420px;
    width: 100%;
}

.match-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.match-state-card h3 {
    margin-bottom: 0.5rem;
    color: var(--text-strong);
}

.match-state-desc {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.match-state-card .btn {
    min-width: 160px;
}

/* Versus divider — 원형 VS 알약 */
.versus-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    align-self: center;
    position: relative;
}

.versus-line {
    display: none;
}

.versus-circle {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: var(--accent-fg);
    border: 1px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--fs-14);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Song cards (2곡 대결) */
.song-card {
    flex: 1;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--t-base), border-color var(--t-base), box-shadow var(--t-base);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.song-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.song-thumbnail-container {
    padding: 0;
    position: relative;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    background: var(--surface-sunken);
}

.song-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity var(--transition-fast);
}

.song-info {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

.song-title-large {
    font-size: var(--fs-16);
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.4;
    color: var(--text-strong);
}

.song-meta {
    font-size: var(--fs-13);
    color: var(--text-secondary);
}

.select-btn-area {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-subtle);
    background: var(--surface-base);
}

.song-card .rank-badge {
    background: var(--accent-soft) !important;
    color: var(--accent);
    border-radius: var(--r-pill);
    padding: 3px 10px;
    font-size: var(--fs-12);
    font-weight: 600;
}

.song-card .elo-badge {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
}

.song-card .match-count-badge {
    background: var(--surface-sunken);
    border-color: var(--border-subtle);
    color: var(--text-muted);
}

/* song-card 매치 화면의 메타 row 정렬 */
.song-card-meta-row {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.song-card-meta-row .elo-badge {
    font-size: var(--fs-13);
    color: var(--accent);
    font-weight: 700;
    padding: 2px 8px;
    background: var(--accent-soft);
    border-radius: var(--r-pill);
}

/* ===== FAST ELO / BATCH ===== */
.fast-elo-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(100%, 800px);
    max-width: 100%;
}

.fast-elo-card {
    background: var(--surface-raised);
    border: 2px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    width: 100%;
    max-width: 100%;
}

.fast-elo-card:hover {
    border-color: var(--border-default);
    box-shadow: var(--shadow-sm);
}

.fast-elo-card.selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.12);
}

.fast-elo-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
}

.fast-elo-thumb-wrap {
    position: relative;
    flex-shrink: 0;
}

.fast-elo-thumb-preview {
    display: none;
}

.fast-elo-thumbnail {
    width: 80px;
    height: 45px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    display: block;
}

.fast-elo-content {
    flex: 1;
    min-width: 0;
}

.fast-elo-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.fast-elo-title {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fast-elo-channel {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fast-elo-grid-title {
    display: none;
}

.fast-elo-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    flex-shrink: 0;
}

.fast-elo-rank {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--r-pill);
    background: var(--surface-sunken);
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--fs-12);
    border: 1px solid var(--border-subtle);
}

.fast-elo-rating {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: var(--fs-13);
}

.fast-elo-badge-slot {
    width: 32px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

/* fast-elo 카드 선택 시 표시되는 순위 배지 */
.fast-elo-pick-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--fs-13);
    box-shadow: var(--shadow-sm);
}

/* 선택 순서 칩 (구 inline style → class) */
.fast-elo-pick-chip {
    background: var(--accent);
    color: var(--accent-fg);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.fast-elo-progress {
    width: min(100%, 720px);
    max-width: 100%;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
}

.fast-elo-progress-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.fast-elo-progress-track {
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-sunken);
}

.fast-elo-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

.fast-elo-progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.fast-elo-selected {
    margin-bottom: 1rem;
    min-height: 36px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    width: min(100%, 720px);
    max-width: 100%;
}

.fast-elo-selected-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.fast-elo-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* match-header — FAST ELO 미니멀 라벨 톤 (카드 영역에 공간 양보) */
.fast-elo-match-header {
    margin-bottom: 0.4rem;
}

.fast-elo-match-header .match-title {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    font-style: normal;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    margin: 0;
}

.fast-elo-match-header .match-title em {
    color: var(--accent);
    font-style: normal;
}

.fast-elo-match-header .match-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== FULL TOURNAMENT BANNER ===== */
.ft-banner {
    margin: 16px 40px 0;
    padding: 16px;
    flex-shrink: 0;
    background: var(--accent-soft) !important;
    border-color: var(--accent) !important;
    color: var(--text-strong);
}

.ft-banner[hidden] {
    display: none;
}

.ft-banner strong {
    color: var(--accent);
}

.ft-banner-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.ft-banner-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== SESSION INSIGHTS ===== */
.session-insights-card {
    background: var(--surface-base);
}

.session-insights-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.session-mode-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    font-size: 0.72rem;
}

.session-insights-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.session-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.session-stat-card {
    padding: 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-raised);
    min-width: 0;
}

.session-stat-label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.session-stat-value {
    display: block;
    margin-top: 4px;
    font-size: 0.92rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-stat-subtle {
    display: block;
    margin-top: 2px;
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.session-insights-summary {
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.session-history-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.session-history-heading {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.session-history-item {
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
}

.session-history-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    min-width: 0;
}

.session-history-title strong,
.session-history-title span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-history-arrow {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.session-history-meta {
    margin-top: 3px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.session-insights-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== RANKING SEARCH ===== */
.ranking-search-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ranking-search-row {
    display: flex;
    gap: 8px;
}

.ranking-search-row input {
    flex: 1;
}

.ranking-search-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ===== SETTINGS TAB (구 도구 탭 다이어트: 4개 그룹 플랫 패널) ===== */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.settings-btn-row {
    display: flex;
    gap: 4px;
}

.settings-btn-row .btn {
    flex: 1;
    white-space: nowrap;
    padding-left: 6px;
    padding-right: 6px;
}

.matching-mode-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
}

.settings-btn-row.matching-mode-options .btn {
    min-width: 0;
    min-height: 34px;
    padding: 6px 3px;
    border-radius: 7px;
    border-color: transparent;
    box-shadow: none;
    font-size: var(--fs-12);
    font-weight: 600;
    line-height: 1.15;
    letter-spacing: -0.025em;
}

.settings-btn-row.matching-mode-options .btn-secondary {
    background: transparent;
    color: var(--text-secondary);
}

.settings-btn-row.matching-mode-options .btn-secondary:hover {
    background: var(--surface-raised);
    border-color: transparent;
    color: var(--text-primary);
}

.settings-help {
    margin: 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.matching-mode-help {
    padding: 0 2px;
    font-size: 0.7rem;
    line-height: 1.45;
    letter-spacing: -0.01em;
}

.settings-select {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    background: var(--surface-base);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-13);
}

.playlist-io-row input {
    flex: 1;
    min-width: 0;
    padding: 8px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--surface-base);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--fs-13);
}

.playlist-io-row .btn {
    flex: 0 0 auto;
}

/* ===== YOUTUBE MUSIC PREVIEW BUTTON ===== */
.ytm-preview-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(255, 0, 0, 0.15);
    color: #ff4444;
    font-size: 0.7rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    border: 1px solid rgba(255, 0, 0, 0.3);
}

.ytm-preview-btn:hover {
    background-color: rgba(255, 0, 0, 0.3);
    color: #ff6666;
    transform: scale(1.1);
}

.ytm-preview-btn-sm {
    width: 22px;
    height: 22px;
    font-size: 0.6rem;
}

/* ===== KEYBOARD SHORTCUTS INFO (PC) ===== */
.keyboard-shortcuts-info {
    position: fixed;
    top: 80px;
    right: 20px;
    background: var(--surface-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: 10px 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
    z-index: 100;
    opacity: 0.7;
    transition: opacity var(--t-fast);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-sm);
}

.keyboard-shortcuts-info[hidden] {
    display: none;
}

.keyboard-shortcuts-info:hover {
    opacity: 1;
}

.keyboard-shortcuts-info kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    background: var(--surface-sunken);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    color: var(--text-primary);
    margin-right: 4px;
    min-width: 16px;
    text-align: center;
}

/* ===== MODAL CLOSE BUTTON ===== */
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 2px 6px;
}

.modal-close-btn:hover {
    color: var(--text-strong);
}

/* =========================================================
   Worldcup 사이드바 — 세그먼트 탭 (모바일 [순위 | 설정])
   기존 디자인 토큰만 사용 — 라이트/다크 자동 호환
   ========================================================= */

/* ---------- 탭바 ---------- */
.panel-tabbar {
    display: flex;
    gap: 4px;
    padding: 12px 16px 0;
    background: var(--surface-base);
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.panel-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    margin-bottom: -1px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 140ms ease, border-color 140ms ease;
}

.panel-tab:hover {
    color: var(--text-secondary);
}

.panel-tab.is-active {
    color: var(--text-strong);
    border-bottom-color: var(--accent);
}

.panel-tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.panel-tab-count {
    font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, monospace);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--text-secondary);
}

.panel-tab.is-active .panel-tab-count {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------- 탭 패널 (각 탭 컨테이너) ---------- */
.panel-tabpanel {
    flex: 1;
    min-height: 0;
    display: flex;
}

.panel-tabpanel.is-hidden,
.panel-tabpanel[hidden] {
    display: none;
}

/* ---------- 탭 안쪽 스크롤 영역 ---------- */
.panel-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
}

/* 부모(.panel-scroll)가 스크롤 — 자체 max-height/overflow 제거 */
.panel-tabpanel #current-ranking {
    max-height: none;
    overflow: visible;
    flex: none;
}

@media (min-width: 769px) {
    /* 데스크탑은 탭바를 숨기고 두 패널을 모두 표시 — 사이드바에 순위+설정 세로 배치 */
    .panel-tabbar {
        display: none;
    }

    .panel-tabpanel.is-hidden,
    .panel-tabpanel[hidden] {
        display: flex;
    }

    .panel-tabpanel + .panel-tabpanel {
        border-top: 1px solid var(--border-subtle);
    }
}

/* =========================================================
   MOBILE (≤768px)
   ========================================================= */
@media (max-width: 768px) {
    body.worldcup-page {
        overflow: hidden;
        height: 100vh;
        height: 100dvh;
    }

    /* === Main Layout === */
    .main-container {
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        min-height: 0;
    }

    /* === Sidebar / Ranking Panel === */
    .ranking-panel {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100dvh;
        z-index: 1000;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
        transition: left 0.3s ease;
        overflow: hidden;
    }

    .ranking-panel.mobile-open {
        left: 0;
    }

    /* === Worldcup Panel === */
    .worldcup-panel {
        width: 100%;
        height: 100%;
        min-height: 0;
        /* mobile-header 실제 높이(--header-h)와 정확히 맞춰 헤더가 콘텐츠를 가리지 않게.
           (예전엔 --header-height=50px라 mobile-header 56px보다 6px 짧아 겹쳤음) */
        padding-top: var(--header-h);
        /* 하단 탭바(공통 내비)가 매치 영역을 가리지 않게 */
        padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
        overflow: hidden;
    }

    /* === Match Area === */
    .match-area {
        flex: 1;
        min-height: 0;
        justify-content: flex-start;
        padding: 12px;
        gap: var(--spacing-md);
        overflow: hidden;
    }

    .match-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .match-toolbar {
        margin: 8px 10px 0;
        padding: 8px 10px;
    }

    .match-toolbar .btn {
        min-height: 34px;
        padding: 6px 12px;
        font-size: 0.82rem;
    }

    .ft-banner {
        margin: 8px 10px 0;
        padding: 8px 10px;
    }

    .ft-banner-desc {
        display: none;
    }

    .ft-banner .btn {
        min-height: 34px;
        padding: 6px 10px;
        font-size: 0.78rem;
    }

    .song-card {
        width: 100%;
        min-height: 200px;
    }

    .versus-divider {
        width: 100%;
        flex-direction: row;
    }

    .versus-circle {
        margin: 0 auto;
    }

    /* === Ranking list === */
    .list-item {
        gap: 6px;
        padding: 6px 8px;
        font-size: 0.82rem;
        cursor: pointer;
    }

    .list-item .item-actions {
        display: none;
    }

    .list-item.active {
        background-color: var(--bg-tertiary);
    }

    .list-item.active .item-actions {
        display: flex;
        opacity: 1;
    }

    .item-actions .btn-sm {
        padding: 2px 6px;
        font-size: 0.75rem;
    }

    .session-stats-grid {
        grid-template-columns: 1fr;
    }

    /* === Fast Elo === */
    .fast-elo-match-header {
        margin-bottom: 0.3rem;
    }

    .fast-elo-match-header .match-subtitle {
        display: none;
    }

    .fast-elo-list {
        flex: 1;
        min-height: 0;
        width: 100%;
        gap: 8px;
    }

    .fast-elo-list-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
        align-content: start;
    }

    .fast-elo-progress {
        gap: 8px;
        margin-bottom: 0.5rem;
    }

    .fast-elo-progress-label {
        display: none;
    }

    .fast-elo-progress-track {
        height: 10px;
    }

    .fast-elo-progress-text {
        font-size: 0.74rem;
    }

    .fast-elo-card {
        padding: 8px 10px !important;
        gap: 8px !important;
        border-radius: var(--radius-md);
    }

    .fast-elo-thumbnail {
        width: 60px !important;
        height: 34px !important;
    }

    .fast-elo-title {
        font-size: 0.82rem;
    }

    .fast-elo-channel,
    .fast-elo-rank,
    .fast-elo-rating {
        font-size: 0.72rem;
    }

    .fast-elo-badge-slot {
        width: 24px;
    }

    .fast-elo-list-grid .fast-elo-card {
        padding: 7px 8px !important;
        gap: 6px !important;
        align-items: stretch;
        flex-direction: column;
    }

    .fast-elo-list-grid .fast-elo-card-main {
        gap: 6px;
        align-items: flex-start;
    }

    .fast-elo-list-grid .fast-elo-channel {
        display: none;
    }

    .fast-elo-list-grid .fast-elo-content {
        display: none;
    }

    .fast-elo-list-grid .fast-elo-meta {
        margin-left: auto;
        align-items: flex-end;
        gap: 0;
    }

    .fast-elo-list-grid .fast-elo-grid-title {
        display: block;
        width: 100%;
        min-width: 0;
        font-size: 0.74rem;
        font-weight: 500;
        line-height: 1.25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .fast-elo-list-grid .fast-elo-thumb-preview {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        bottom: 2px;
        right: 2px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background-color: rgba(0, 0, 0, 0.65);
        color: #fff;
        font-size: 0.55rem;
        text-decoration: none;
        z-index: 2;
        border: 1px solid rgba(255, 255, 255, 0.3);
        transition: all var(--transition-fast);
    }

    .fast-elo-list-grid .fast-elo-thumb-preview:hover {
        background-color: rgba(255, 0, 0, 0.7);
        transform: scale(1.15);
    }

    .fast-elo-selected {
        display: none;
    }

    .fast-elo-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        padding: 8px 16px;
        gap: 8px;
        width: 100%;
        background: var(--bg-primary);
        border-top: 1px solid var(--border-color);
        z-index: 50;
        box-sizing: border-box;
    }

    .fast-elo-actions .btn {
        min-height: 38px;
        padding: 8px 12px;
        font-size: 0.9rem;
        flex: 1;
    }

    /* === Misc === */
    .keyboard-shortcuts-info {
        display: none;
    }

    /* worldcup은 .mobile-header가 있어 상단 우측이 비어있지 않으니 살짝 더 아래에 */
    body.worldcup-page .theme-toggle-mobile {
        top: calc(var(--header-h) + 8px + env(safe-area-inset-top));
    }

    /* 설정 탭 마지막 그룹 아래 추가 여유 */
    .panel-tabpanel[data-tabpanel="settings"] .panel-scroll {
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* =========================================================
   MOBILE SMALL (≤480px)
   ========================================================= */
@media (max-width: 480px) {
    .song-card {
        min-height: 160px;
    }

    .match-toolbar-hint {
        display: none;
    }

    .fast-elo-card {
        padding: 7px 8px !important;
        gap: 6px !important;
    }

    .fast-elo-progress {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 6px;
    }

    .fast-elo-list-grid {
        gap: 5px;
    }

    .fast-elo-title {
        font-size: 0.78rem;
    }

    .fast-elo-channel,
    .fast-elo-rank,
    .fast-elo-rating {
        font-size: 0.68rem;
    }

    .fast-elo-badge-slot {
        width: 22px;
    }

    .fast-elo-list-grid .fast-elo-rank,
    .fast-elo-list-grid .fast-elo-rating {
        font-size: 0.64rem;
    }

    .fast-elo-list-grid .fast-elo-grid-title {
        font-size: 0.7rem;
    }

    .fast-elo-actions .btn {
        min-height: 36px;
        padding: 7px 10px;
        font-size: 0.82rem;
    }
}
