/* ================================================
   미르니 전리품 상자 시뮬레이터 — style.css
   ================================================ */

/* ── Google Fonts ──────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap');

/* ── 디자인 토큰 (Design Tokens) ──────────────── */
:root {
    --bg:          #0f0f18;
    --panel:       #1a1a2e;
    --card:        #22223a;
    --inner:       #131322;
    --text:        #e2e2f0;
    --muted:       #9494b8;
    --accent:      #f0b429;
    --accent-dim:  #a87820;
    --border:      #2d2d50;
    --border-soft: #25253d;
    --success:     #4cee70;
    --alt:         #ffb74d;
    --pity-color:  #ce93d8;
    --pity-fill:   #5c6bc0;
    --pity-warn:   #e53935;
    --dud:         #444;
    --shadow:      0 4px 24px rgba(0,0,0,.55);
    --r-lg: 14px;
    --r-md: 9px;
    --r-sm: 5px;

    --pity-track-bg: #1a1a30;

    --badge-great-bg: rgba(76,238,112,.18);
    --badge-great-text: #4cee70;
    --badge-great-border: rgba(76,238,112,.4);
    --badge-good-bg: rgba(100,210,255,.15);
    --badge-good-text: #64d2ff;
    --badge-good-border: rgba(100,210,255,.35);
    --badge-avg-bg: rgba(255,214,0,.12);
    --badge-avg-text: #ffd600;
    --badge-avg-border: rgba(255,214,0,.3);
    --badge-bad-bg: rgba(229,57,53,.14);
    --badge-bad-text: #ef9a9a;
    --badge-bad-border: rgba(229,57,53,.35);

    --tag-new-bg: rgba(76,238,112,.1);
    --tag-new-border: rgba(76,238,112,.35);
    --tag-pity-bg: rgba(206,147,216,.12);
    --tag-pity-border: rgba(206,147,216,.4);
    --tag-alt-bg: rgba(255,183,77,.1);
    --tag-alt-border: rgba(255,183,77,.3);

    --btn-reset-text: #ef9a9a;
    --btn-reset-border: #c62828;
    --btn-reset-hover-bg: #c62828;
    
    --text-btn-hover: #e57373;
    
    --box-header-bg: rgba(240,180,41,0.03);
    --inv-badge-bg: rgba(240,180,41,.12);
    --inv-badge-border: rgba(240,180,41,.3);
    
    --meter-great: linear-gradient(90deg, #1a5f2a, #4cee70);
    --meter-good: linear-gradient(90deg, #1a3a5f, #64d2ff);
    --meter-avg: linear-gradient(90deg, #5f4d1a, #ffd600);
    --meter-bad: linear-gradient(90deg, #5f1a1a, #ef9a9a);
    
    --log-item-border: var(--inner);
    --log-item-text: #d1d1e0;
    --log-item-name: #e2e2f0;
    
    --box-shard: #6ec6ff;
    --box-piece: #b39ddb;
    --box-core: #ffcc80;
    
    --shop-buy-bg: var(--accent);
    --shop-buy-text: #111;
    --shop-buy-hover: #ffd54f;
    --shop-buy-disabled-bg: #444;
    --shop-buy-disabled-text: #666;
}

:root.light-theme {
    --bg:          #f4f5f8;
    --panel:       #ffffff;
    --card:        #f8f9fb;
    --inner:       #eceff4;
    --text:        #2e3440;
    --muted:       #5c6b7f;
    --accent:      #3b82f6;
    --accent-dim:  #2563eb;
    --border:      #d8dee9;
    --border-soft: #e5e9f0;
    --success:     #10b981;
    --alt:         #f59e0b;
    --pity-color:  #9c27b0;
    --pity-fill:   #3f51b5;
    --pity-warn:   #d32f2f;
    --dud:         #9e9e9e;
    --shadow:      0 4px 16px rgba(0,0,0,.08);

    --pity-track-bg: #e2e8f0;

    --badge-great-bg: rgba(16, 185, 129, 0.15);
    --badge-great-text: #059669;
    --badge-great-border: rgba(16, 185, 129, 0.4);
    --badge-good-bg: rgba(59, 130, 246, 0.15);
    --badge-good-text: #2563eb;
    --badge-good-border: rgba(59, 130, 246, 0.4);
    --badge-avg-bg: rgba(245, 158, 11, 0.15);
    --badge-avg-text: #d97706;
    --badge-avg-border: rgba(245, 158, 11, 0.4);
    --badge-bad-bg: rgba(239, 68, 68, 0.15);
    --badge-bad-text: #dc2626;
    --badge-bad-border: rgba(239, 68, 68, 0.4);

    --tag-new-bg: rgba(16, 185, 129, 0.1);
    --tag-new-border: rgba(16, 185, 129, 0.35);
    --tag-pity-bg: rgba(156, 39, 176, 0.1);
    --tag-pity-border: rgba(156, 39, 176, 0.35);
    --tag-alt-bg: rgba(245, 158, 11, 0.1);
    --tag-alt-border: rgba(245, 158, 11, 0.35);

    --btn-reset-text: #dc2626;
    --btn-reset-border: #dc2626;
    --btn-reset-hover-bg: #dc2626;
    
    --text-btn-hover: #dc2626;
    
    --box-header-bg: rgba(59, 130, 246, 0.05);
    --inv-badge-bg: rgba(59, 130, 246, 0.1);
    --inv-badge-border: rgba(59, 130, 246, 0.3);

    --meter-great: linear-gradient(90deg, #a7f3d0, #10b981);
    --meter-good: linear-gradient(90deg, #bfdbfe, #3b82f6);
    --meter-avg: linear-gradient(90deg, #fde68a, #f59e0b);
    --meter-bad: linear-gradient(90deg, #fecaca, #ef4444);

    --log-item-border: var(--border-soft);
    --log-item-text: #374151;
    --log-item-name: #1f2937;
    
    --box-shard: #0284c7;
    --box-piece: #7c3aed;
    --box-core: #d97706;
    
    --shop-buy-bg: var(--accent);
    --shop-buy-text: #fff;
    --shop-buy-hover: var(--accent-dim);
    --shop-buy-disabled-bg: #e5e7eb;
    --shop-buy-disabled-text: #9ca3af;
}

/* ── 리셋 ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 스크롤바 ──────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--inner); }
::-webkit-scrollbar-thumb { background: #3a3a60; border-radius: 3px; }

/* ── 전체 레이아웃 ─────────────────────────────── */
body {
    font-family: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── 데스크탑 최상단 헤더 ──────────────────────── */
.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}
.theme-icon {
    font-size: 14px;
    user-select: none;
}
.theme-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--border);
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text);
    transition: .4s;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:focus + .slider {
    box-shadow: 0 0 1px var(--accent);
}
input:checked + .slider:before {
    transform: translateX(20px);
    background-color: #111;
}
.slider.round {
    border-radius: 24px;
}
.slider.round:before {
    border-radius: 50%;
}

/* ── 모바일 헤더 (기본 숨김, 모바일에서 표시) ──── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 200;
}
.mobile-title { font-size: 14px; font-weight: 700; color: var(--accent); }
.mobile-only  { display: none !important; }

/* ── 아이콘 버튼 ───────────────────────────────── */
.icon-btn {
    width: 36px; height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: 16px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.icon-btn:hover { background: var(--card); }
.shop-icon-btn  { color: var(--accent); border-color: var(--accent-dim); }

/* ── 사이드바 오버레이 ─────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 299;
}

/* ── 사이드바 ──────────────────────────────────── */
.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-head h2 { font-size: 15px; color: var(--accent); }
.sidebar-close-btn { display: none; }  /* 데스크탑에서는 닫기 버튼 숨김 */
.sidebar-hint { 
    font-size: 14px; 
    color: var(--muted); 
    line-height: 1.6;
    background: var(--card);
    padding: 10px;
    border-radius: var(--r-sm);
    border-left: 3px solid var(--border);
}

.checklist-section {
    background: var(--inner);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 12px;
}
.checklist-section h3 {
    font-size: 14px; font-weight: 700;
    color: var(--accent); text-transform: uppercase;
    letter-spacing: .08em; margin-bottom: 10px;
    opacity: 0.9;
}
.box-section-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    padding: 10px 10px 6px;
    opacity: 0.9;
    letter-spacing: 0.03em;
    background: var(--box-header-bg);
    margin-top: 4px;
}
.checklist-item {
    display: flex; 
    align-items: center; 
    gap: 10px; 
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}
.checklist-item:hover {
    background: rgba(240, 180, 41, 0.08);
}
.checklist-item input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--accent); cursor: pointer; flex-shrink: 0;
}
.checklist-item label  { 
    font-size: 14px; 
    cursor: pointer; 
    user-select: none; 
    line-height: 1.4;
    flex: 1;
}
.checklist-item.owned label { text-decoration: line-through; color: var(--muted); }

/* ── 메인 콘텐츠 ───────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    overflow: hidden;
    min-width: 0;
}

/* ── 상자 개봉 영역 ────────────────────────────── */
.box-container {
    display: flex;
    gap: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}
.box-group {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 12px;
    display: flex; flex-direction: column; gap: 9px;
    transition: border-color .2s;
}
.box-group:hover { border-color: var(--accent-dim); }

.box-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.box-group-title h3 { font-size: 15px; color: var(--accent); }

.inv-badge {
    font-size: 13px; font-weight: 700;
    color: var(--accent);
    background: var(--inv-badge-bg);
    border: 1px solid var(--inv-badge-border);
    border-radius: 4px;
    padding: 2px 7px;
    white-space: nowrap;
}

.btn-row { display: flex; gap: 7px; flex-wrap: wrap; }

/* 열기 버튼 */
.box-btn {
    flex: 1;
    min-width: 85px;
    padding: 10px 8px;
    font-size: 14px; font-weight: 700; font-family: inherit;
    background: var(--inner); color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background .15s, color .15s, transform .1s, box-shadow .15s;
}
.box-btn:hover:not(:disabled) {
    background: var(--accent); color: #111;
    border-color: var(--accent); 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 180, 41, 0.3);
}
.box-btn:active:not(:disabled) { 
    transform: translateY(0); 
    box-shadow: 0 2px 6px rgba(240, 180, 41, 0.2);
}
.box-btn:disabled {
    opacity: .3; cursor: not-allowed;
    background: var(--inner) !important;
    color: var(--muted) !important;
    border-color: var(--border) !important;
}

/* 모두 열기 버튼 강조 */
.box-open-all-btn:not(:disabled) {
    background: linear-gradient(135deg, var(--accent-dim), var(--accent));
    color: #111;
    border-color: var(--accent);
    font-weight: 800;
    position: relative;
    overflow: hidden;
}
.box-open-all-btn:not(:disabled)::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}
.box-open-all-btn:not(:disabled):hover::before {
    left: 100%;
}
.box-open-all-btn:not(:disabled):hover {
    background: linear-gradient(135deg, var(--accent), #ffd54f);
    box-shadow: 0 0 15px rgba(240, 180, 41, 0.5);
}


/* 천장 프로그레스 바 */
.pity-bar-wrap { display: flex; flex-direction: column; gap: 3px; }
.pity-label-row {
    display: flex; justify-content: space-between;
    font-size: 12px; color: var(--muted);
}
.pity-title { color: var(--pity-color); font-weight: 600; }
.pity-track { height: 4px; background: var(--pity-track-bg); border-radius: 2px; overflow: hidden; }
.pity-fill {
    height: 100%; width: 0%;
    background: var(--pity-fill);
    border-radius: 2px;
    transition: width .3s ease, background .3s;
}
.pity-fill.pity-warn { background: var(--pity-warn); box-shadow: 0 0 6px rgba(229,57,53,.5); }

/* ── 상점 패널 (데스크탑) ──────────────────────── */
.shop-panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 11px 14px;
    display: flex; flex-direction: column; gap: 10px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}
.shop-header {
    display: flex; align-items: center;
    justify-content: space-between; gap: 12px;
}
.shop-title { font-size: 15px; font-weight: 700; color: var(--accent); }
.shop-meta  { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.shop-meta strong { color: var(--accent); }
.total-cost-display { color: var(--accent); }

.shop-packages { display: flex; gap: 8px; flex-wrap: wrap; }
.shop-pkg {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 10px 12px; min-width: 84px;
    transition: border-color .2s;
}
.shop-pkg:hover { border-color: var(--accent-dim); }
.shop-pkg-count { font-size: 15px; font-weight: 700; }
.shop-pkg-price { font-size: 13px; color: var(--accent); font-weight: 600; }
.shop-buy-btn {
    font-size: 14px; font-weight: 700; font-family: inherit;
    padding: 6px 16px; margin-top: 4px;
    background: var(--shop-buy-bg); color: var(--shop-buy-text);
    border: none; border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
}
.shop-buy-btn:hover { 
    background: var(--shop-buy-hover); 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 180, 41, 0.4);
}
.shop-buy-btn:disabled { 
    background: var(--shop-buy-disabled-bg); 
    color: var(--shop-buy-disabled-text); 
    cursor: not-allowed; 
    transform: none;
    box-shadow: none;
}

/* ── 결과 영역 ─────────────────────────────────── */
.results-area {
    display: flex; gap: 12px;
    flex: 1; overflow: hidden; min-height: 0;
}
.log-panel, .summary-panel {
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px;
    display: flex; flex-direction: column; gap: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    min-width: 0;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-soft); padding-bottom: 8px;
}
.panel-header h2 { 
    font-size: 16px; 
    color: var(--accent); 
    letter-spacing: .04em; 
    font-weight: 700;
}

.text-btn {
    font-size: 13px; font-family: inherit;
    padding: 5px 11px;
    background: transparent; color: var(--muted);
    border: 1px solid var(--border); border-radius: 5px;
    cursor: pointer; 
    transition: all .15s;
    font-weight: 600;
}
.text-btn:hover { 
    color: var(--text-btn-hover); 
    border-color: var(--text-btn-hover);
    background: rgba(239, 115, 115, 0.1);
    transform: translateY(-1px);
}

.reset-all-btn {
    font-size: 13px; font-family: inherit;
    padding: 6px 14px;
    background: transparent; color: var(--btn-reset-text);
    border: 1px solid var(--btn-reset-border); border-radius: 5px;
    cursor: pointer; 
    transition: all .15s;
    white-space: nowrap;
    font-weight: 600;
}
.reset-all-btn:hover { 
    background: var(--btn-reset-hover-bg); 
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(198, 40, 40, 0.3);
}

.stats-bar {
    display: flex; gap: 12px;
    font-size: 13px; color: var(--muted);
    flex-shrink: 0;
}
.stats-bar strong { color: var(--accent); }

.scroll-area {
    flex: 1; overflow-y: auto;
    background: var(--inner);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-sm);
    padding: 9px;
}

/* ── 로그 엔트리 ───────────────────────────────── */
.log-entry {
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--r-sm);
    padding: 8px 10px; margin-bottom: 7px;
    animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

.log-entry-title {
    font-size: 14px; font-weight: 700; color: var(--accent);
    display: flex; align-items: center; gap: 6px; margin-bottom: 5px;
}
.box-badge {
    font-size: 12px; padding: 2px 7px;
    border: 1px solid; border-radius: 4px;
}
.log-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 3px 0; font-size: 14px; color: var(--log-item-text);
    border-bottom: 1px solid var(--log-item-border);
}
.log-item:last-child { border: none; }
.log-slot-label { font-size: 13px; color: var(--muted); margin-right: 4px; font-weight: 600; }
.log-qty { font-size: 14px; color: var(--accent); margin-left: 8px; white-space: nowrap; font-weight: 700; }
.log-placeholder { color: var(--muted); text-align: center; margin-top: 40px; font-size: 15px; }

/* ── 태그 ──────────────────────────────────────── */
.tag-new  { font-size:12px;font-weight:700;color:var(--success);background:var(--tag-new-bg);border:1px solid var(--tag-new-border);border-radius:4px;padding:2px 6px;margin-left:4px; }
.tag-pity { font-size:12px;font-weight:700;color:var(--pity-color);background:var(--tag-pity-bg);border:1px solid var(--tag-pity-border);border-radius:4px;padding:2px 6px;margin-left:4px; }
.tag-alt  { font-size:12px;font-weight:600;color:var(--alt);background:var(--tag-alt-bg);border:1px solid var(--tag-alt-border);border-radius:4px;padding:2px 6px;margin-left:4px; }

/* ── 종합 패널 ─────────────────────────────────── */
.summary-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 7px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 14px;
    transition: background .12s;
}
.summary-item:hover { background: rgba(240,180,41,.05); }
.summary-item:last-child { border: none; }
.summary-item.category-header {
    font-size: 13px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .08em;
    background: var(--inner); pointer-events: none;
}
.summary-item-count { color: var(--accent); font-weight: 700; }

/* ── 모달 (상점 모달) ──────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.7);
    z-index: 500;
    align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    max-width: 480px; width: 92%;
    max-height: 85dvh;
    display: flex; flex-direction: column; gap: 14px;
    box-shadow: var(--shadow);
    overflow-y: auto;
}
.modal-lg { max-width: 1800px; width: 96%; }
.modal-overlay.scroll-overlay {
    align-items: flex-start !important;
    overflow-y: auto;
    padding: 30px 10px;
}
.modal-content.modal-full-height {
    max-height: none !important;
    overflow-y: visible !important;
    margin: auto;
}

/* 크게 보기 모달 내부 다단(Column) 레이아웃 */
#modal-summary-content {
    display: block; /* .modal-body의 flex 덮어쓰기 */
    column-width: 300px;
    column-gap: 32px;
    column-rule: 1px solid var(--border-soft);
}
#modal-summary-content > div {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 6px;
}
#modal-summary-content .category-header {
    margin-top: 10px;
}
#modal-summary-content .luck-card {
    margin-top: 0;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-soft); padding-bottom: 10px;
}
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 15px; color: var(--text);
    border-top: 1px solid var(--border-soft); padding-top: 10px;
}
.modal-footer strong { color: var(--accent); }

/* ── 영구 보유 모달 개선 ───────────────────────── */
/* 데스크탑: 다단 컬럼 레이아웃 */
#preowned-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* 데스크탑에서 체크리스트를 2단 컬럼으로 */
@media (min-width: 769px) {
    #preowned-modal .modal-content {
        max-width: 900px;
    }
    
    #pre-tanks-list,
    #pre-cosmetics-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px 16px;
    }
    
    /* 상자별 섹션 헤더는 전체 너비 */
    #pre-tanks-list .box-section-header,
    #pre-cosmetics-list .box-section-header {
        grid-column: 1 / -1;
    }
}

/* 체크리스트 아이템 가시성 개선 */
.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 4px;
    transition: background 0.15s;
    cursor: pointer;
    user-select: none;
}

.checklist-item:hover {
    background: rgba(240, 180, 41, 0.08);
}

.checklist-item:focus-within,
.checklist-item:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-item label {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    line-height: 1.4;
    flex: 1;
}

/* 영구 보유 모달 힌트 강조 */
#preowned-modal .sidebar-hint {
    background: var(--card);
    border-left: 3px solid var(--accent);
    padding: 12px;
    border-radius: var(--r-sm);
    font-size: 14px;
    line-height: 1.6;
}

/* 영구 보유 모달 섹션 타이틀 강조 */
#preowned-modal .checklist-section h3 {
    font-size: 15px;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}

/* 영구 보유 모달 저장 버튼 강조 */
#preowned-modal .modal-footer button {
    font-size: 15px;
    padding: 12px 20px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(76, 238, 112, 0.3);
    transition: all 0.2s;
}

#preowned-modal .modal-footer button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 238, 112, 0.4);
}

/* ── 접근성 개선 ───────────────────────────────── */
/* 포커스 표시 강화 */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 버튼 호버/포커스 상태 */
button:focus-visible {
    box-shadow: 0 0 0 3px rgba(240, 180, 41, 0.3);
}

/* 체크박스 포커스 */
input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* 스크린 리더 전용 텍스트 */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ── 반응형: 모바일 (≤ 768px) ─────────────────── */
@media (max-width: 768px) {
    /* 전체 레이아웃 */
    body {
        flex-direction: column;
        overflow: auto;
        height: auto; min-height: 100dvh;
    }

    /* 모바일 헤더 표시 */
    .mobile-header { display: flex; }
    .mobile-only   { display: flex !important; }
    .desktop-only  { display: none !important; }

    /* 사이드바 → 슬라이드 드로어 */
    .sidebar {
        position: fixed;
        top: 0; left: -260px;
        width: 250px; height: 100dvh;
        z-index: 300;
        transition: left .25s ease;
        padding-top: 14px;
    }
    .sidebar.open { left: 0; }
    .sidebar-overlay.open { display: block; }
    .sidebar-close-btn { display: flex; }   /* 모바일에서 닫기 버튼 표시 */

    /* 메인: 상단 패딩으로 헤더 공간 확보 */
    .main-content {
        padding: 62px 10px 12px;
        overflow: auto;
        height: auto;
    }

    /* .app-container도 모바일에서는 flex-direction 해제 필요 시 처리 */
    .app-container {
        flex-direction: column;
        overflow: visible;
    }

    /* 상자: 가로 스크롤 */
    .box-container { overflow-x: auto; }
    .box-group     { min-width: 140px; }

    /* 결과: 세로 스택 */
    .results-area  { flex-direction: column; overflow: visible; }
    .log-panel, .summary-panel { min-height: 280px; flex: none; }
    .scroll-area   { max-height: 260px; }

    /* 상점 모달: 하단 시트 */
    .modal-overlay { align-items: flex-end; }
    .modal-content {
        border-radius: var(--r-lg) var(--r-lg) 0 0;
        max-width: 100%; width: 100%;
        max-height: 70dvh;
    }
    
    /* 모바일: 영구 보유 모달 단일 컬럼 */
    #preowned-modal .modal-content {
        max-height: 85dvh;
    }
    
    #pre-tanks-list,
    #pre-cosmetics-list {
        display: flex;
        flex-direction: column;
    }
    
    /* 모바일: 체크박스 터치 영역 확대 */
    .checklist-item {
        padding: 10px 8px;
        min-height: 44px;
    }
    
    .checklist-item input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    .checklist-item label {
        font-size: 15px;
    }
}

/* ── 반응형: 태블릿 (769~1024px) ──────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar   { width: 190px; }
    .box-group { padding: 10px; }
}

/* ── 전차 획득 상세 행 ──────────────────────────── */
.tank-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    padding: 7px 8px;
}
.tank-item.not-acquired { opacity: .55; }

.tank-name {
    font-size: 12px;
    font-weight: 700;
}
.tank-name.muted { color: var(--muted); }

.tank-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.tank-meta {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}
.tank-meta.muted { opacity: .7; }

/* ── 운 지표 배지 ──────────────────────────────── */
.luck-badge {
    font-size: 13px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: nowrap;
}
.luck-great { background: var(--badge-great-bg); color: var(--badge-great-text); border: 1px solid var(--badge-great-border); }
.luck-good  { background: var(--badge-good-bg); color: var(--badge-good-text); border: 1px solid var(--badge-good-border); }
.luck-avg   { background: var(--badge-avg-bg);  color: var(--badge-avg-text); border: 1px solid var(--badge-avg-border); }
.luck-bad   { background: var(--badge-bad-bg);  color: var(--badge-bad-text); border: 1px solid var(--badge-bad-border); }

/* ── 통계 섹션 ─────────────────────────────────── */
.stat-detail {
    font-size: 11px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
}
.muted { color: var(--muted); }

/* ── 종합 운 지수 카드 ──────────────────────────── */
.luck-card {
    background: var(--card);
    border: 1px solid var(--border-soft);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.luck-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.luck-card-badge-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.luck-badge-lg {
    font-size: 16px !important;
    padding: 6px 14px !important;
    border-radius: 20px !important;
}
.luck-card-detail {
    font-size: 15px;
    color: var(--text);
    font-weight: 600;
}
.luck-meter-wrap {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.luck-meter-track {
    height: 8px;
    background: var(--inner);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}
/* 가운데선 (평균 기준) */
.luck-meter-track::after {
    content: '';
    position: absolute;
    left: 50%; top: 0; bottom: 0;
    width: 1px;
    background: var(--border);
}
.luck-meter-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .5s ease;
}
.luck-meter-fill.luck-great { background: var(--meter-great); }
.luck-meter-fill.luck-good  { background: var(--meter-good); }
.luck-meter-fill.luck-avg   { background: var(--meter-avg); }
.luck-meter-fill.luck-bad   { background: var(--meter-bad); }
.luck-meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
}
.luck-card-note {
    font-size: 13px;
    color: var(--muted);
    opacity: .7;
}

/* ── 상자별 운 지수 행 ──────────────────────────── */
.luck-row {
    display: grid;
    grid-template-columns: 36px auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
.luck-row-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}
.luck-row-meter { min-width: 0; }

/* ── 전차별 운 배지 ──────────────────────────────── */
.tank-luck-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 4px;
    white-space: nowrap;
}
.tank-luck-badge.luck-good { background: var(--badge-good-bg); color: var(--badge-good-text); border: 1px solid var(--badge-good-border); }
.tank-luck-badge.luck-bad  { background: var(--badge-bad-bg);  color: var(--badge-bad-text); border: 1px solid var(--badge-bad-border); }
.tank-luck-badge.luck-avg  { background: var(--badge-avg-bg);  color: var(--badge-avg-text); border: 1px solid var(--badge-avg-border); }

.tank-expect-note {
    font-size: 10px;
    color: var(--muted);
    margin-left: 3px;
}

/* ── 상자 통계 운 색상 ──────────────────────────── */
.stat-luck-good { color: var(--badge-good-text); font-weight: 700; }
.stat-luck-bad  { color: var(--badge-bad-text); font-weight: 700; }
.stat-luck-avg  { color: var(--badge-avg-text); font-weight: 700; }
