/* TP-052: 번호를 앞세운 홈과 결과. 번호·입력·저장 방식은 기존 것을 재사용한다. */
#home-dashboard { padding-top:0; gap:16px; }
#weekly-main { display:grid; grid-template-columns:minmax(0,1fr); padding:20px; position:relative; isolation:isolate; }
#weekly-main > * { position:relative; z-index:1; }
#weekly-main h1 { font-size:clamp(1.875rem,7.7vw,2rem); line-height:1.18; margin:0 0 8px; }
#weekly-main h1 .title-accent { color:var(--primary); }
#weekly-main #engine-facts { margin:0; min-height:0; }
/* 계산 배지 4개는 칩이 아니라 제목 아래 작은 보조 줄(가운뎃점 구분) */
#weekly-main #weekly-badges { min-height:1.5em; margin:6px 0 4px; gap:0; display:flex; flex-wrap:wrap; font-size:.8125rem; line-height:1.5; color:var(--text-sub); }
/* 항목 중간에서 끊기지 않게 항목마다 줄바꿈 금지, 항목 사이에서만 다음 줄로 */
#weekly-main #weekly-badges span { display:inline; border:0; padding:0; font-size:inherit; white-space:nowrap; }
#weekly-main #weekly-badges span:not(:last-child)::after { content:'·'; margin:0 .4em; }
#weekly-main #home-weekly-round { min-height:3.2em; margin:4px 0 0; font-size:.875rem; }
#weekly-main #weekly-next-release { min-height:1.6em; margin:4px 0; }
#weekly-main #engine-facts { font-size:.875rem; line-height:1.6; min-height:3.2em; }
#weekly-main #home-combos-container { margin-top:8px; min-height:290px; }
#weekly-main .home-preview { grid-template-columns:minmax(0,1fr); align-content:start; }
#weekly-main .home-preview .combo-row { padding:10px 0; }
#weekly-main .home-preview .combo-left { gap:8px; }
#weekly-main .home-preview .combo-meta { flex:0 0 auto; min-width:24px; }
#weekly-main .home-preview .combo-tag { font-size:.875rem; }
#weekly-main .home-preview .balls-group { gap:6px; }
#weekly-main .home-preview .lotto-ball { width:34px; height:34px; flex:0 0 34px; font-size:1rem; }
#weekly-main > .home-shortcuts { min-height:0; margin:12px 0 0; display:flex; flex-wrap:wrap; gap:8px; }
.home-shortcuts .btn-action { flex:1 1 125px; font-size:.9375rem; }
#weekly-guide { display:flex; align-items:center; justify-content:center; gap:8px; min-height:148px; padding:8px 0; }
#weekly-guide-art { width:132px; height:132px; object-fit:contain; flex-shrink:0; }
#weekly-guide p { font-size:1rem; line-height:1.5; margin:6px 0 0; }
.guide-badge { font-size:.8125rem; color:var(--primary); font-weight:700; }
#weekly-guide-name { margin-left:6px; font-size:.875rem; }
/* 수묵은 카드 상단에서 번호 시작 직전까지만 펼친다. 높이는 실제 번호 위치에 맞춘다. */
#weekly-main.has-ink-mobile::before { content:''; position:absolute; z-index:0; inset:0 0 auto; height:var(--ink-height,0px); pointer-events:none; border-radius:inherit; background:linear-gradient(rgba(251,248,241,.55),rgba(251,248,241,.55)),url('./bg/ink_mobile.webp') right 72%/cover no-repeat; mask-image:linear-gradient(#000 0%,#000 84%,transparent 100%); }
/* 어두운 화면은 그림 위에 어두운 막을 유지한다. */
[data-theme="dark"] #weekly-main.has-ink-mobile::before { background-image:linear-gradient(rgba(23,20,17,.86),rgba(23,20,17,.86)),url('./bg/ink_mobile.webp'); }
@media (min-width:1000px) {
 .layout-pc #weekly-main { grid-template-columns:minmax(0,1.5fr) minmax(0,1fr); column-gap:36px; padding:28px; }
 .layout-pc #weekly-main h1 { font-size:2.75rem; }
 .layout-pc #weekly-main > * { grid-column:1; }
 .layout-pc #weekly-guide { grid-column:2; grid-row:1 / span 5; align-self:start; min-height:224px; }
 .layout-pc #weekly-guide-art { width:200px; height:200px; }
 .layout-pc #weekly-main > .home-shortcuts { grid-column:2; grid-row:6 / span 2; align-self:start; flex-direction:column; }
 .layout-pc .home-shortcuts .btn-action { flex:auto; }
 .layout-pc #weekly-main .home-preview .lotto-ball { width:44px; height:44px; flex-basis:44px; font-size:1.125rem; }
 .layout-pc #weekly-main #home-combos-container { min-height:340px; }
 .layout-pc #weekly-main .home-preview .combo-row { padding:12px 0; }
 .layout-pc #weekly-main.has-ink-mobile::before { content:none; }
 .layout-pc #weekly-main.has-ink-pc::before { content:''; position:absolute; z-index:0; inset:0 0 auto; height:var(--ink-height,0px); pointer-events:none; border-radius:inherit; background:linear-gradient(rgba(251,248,241,.5),rgba(251,248,241,.5)),url('./bg/ink_pc.webp') right 38%/auto 680px no-repeat; mask-image:linear-gradient(#000 0%,#000 84%,transparent 100%); }
 [data-theme="dark"].layout-pc #weekly-main.has-ink-pc::before { background-image:linear-gradient(rgba(23,20,17,.86),rgba(23,20,17,.86)),url('./bg/ink_pc.webp'); }
 .layout-pc #weekly-main.has-ink-mobile.has-ink-pc::before { background-image:linear-gradient(rgba(251,248,241,.55),rgba(251,248,241,.55)),url('./bg/ink_pc.webp'),url('./bg/ink_mobile.webp'); background-position:center,right 38%,center 65%; background-size:auto,auto 680px,cover; background-repeat:no-repeat; }
 [data-theme="dark"].layout-pc #weekly-main.has-ink-mobile.has-ink-pc::before { background-image:linear-gradient(rgba(23,20,17,.86),rgba(23,20,17,.86)),url('./bg/ink_pc.webp'),url('./bg/ink_mobile.webp'); }
}
/* 결과 DOM: 번호 → 입력 확인 → 한 줄 → 저장/공유 → 접힌 근거 → 운세. */
#saju-res-box,#lifetime-after { scroll-margin-top:88px; }
#saju-res-box .result-layout,#lifetime-after { display:grid; grid-template-columns:minmax(0,1fr); gap:16px; }
#saju-res-box .result-layout > *,#lifetime-after > * { min-width:0; margin:0; }
.result-input-summary { display:flex; flex-wrap:wrap; align-items:center; gap:8px 16px; }
.result-input-summary p { flex:1 1 220px; overflow-wrap:anywhere; }
.result-one-line p { line-height:1.7; margin:8px 0 0; }
/* TP-055-3: 자동 최소 너비가 잠금 공 6개 너비를 따라가던 홈 격자를 줄인다. */
#curiosity-block { grid-template-columns:minmax(0,1fr); }
#curiosity-block > * { min-width:0; }
@media (max-width:374px) {
 #curiosity-block .locked-row { gap:4px; }
 #curiosity-block .question-ball { width:24px; height:24px; }
 /* 공식 번호 6개와 보너스 묶음은 좁으면 묶음 단위로 다음 줄로 보낸다. */
 #latest-winning-balls { flex-wrap:wrap; }
}
#weekly-main .tool-actions { flex-wrap:wrap; }
#lifetime-after .lifetime-actions { flex-wrap:wrap; }
#lifetime-after .lifetime-actions .btn-action { min-width:0; white-space:normal; }
@media (min-width:1000px) {
 .layout-pc #curiosity-block { grid-template-columns:minmax(0,1fr) minmax(0,1fr); }
}
.result-evidence > summary { cursor:pointer; font-weight:700; padding:8px 0; }
.result-evidence .app-card { margin:16px 0 0; }
#saju-res-box .saju-details-column { display:block; }
#saju-res-box .result-games { position:static; }
.result-games { scroll-margin-top:88px; }
#saju-res-box .result-footer { margin:0; }
#saju-res-box .result-footer .button-row { flex-wrap:wrap; }
#saju-res-box .result-footer .button-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
#saju-res-box .result-save .btn-action { min-width:0; flex-wrap:wrap; word-break:normal; white-space:normal; }
#lifetime-after .lifetime-reasons { list-style:none; padding:0; }
#lifetime-after .lifetime-reasons li { margin:12px 0; }
#lifetime-after .lifetime-top h2 { margin:0 0 14px; }
#lifetime-after .lifetime-top .lifetime-balls { margin:14px 0; }
.result-tail { margin-top:16px; }
@media (min-width:1000px) {
 .layout-pc #saju-res-box .result-layout,.layout-pc #lifetime-after { grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); align-items:start; }
 /* 오른쪽(입력 확인·근거·운세)은 번호 카드 옆에 붙여 쌓고, 한 줄·저장은 번호 아래로. 오른쪽 사이 빈칸이 커지지 않게 함 */
 .layout-pc .result-games,.layout-pc .lifetime-top { grid-column:1; grid-row:1 / span 3; }
 .layout-pc .result-input-summary { grid-column:2; grid-row:1; }
 .layout-pc .result-one-line { grid-column:1; grid-row:4; }
 .layout-pc .result-save { grid-column:1; grid-row:5; }
 .layout-pc .result-evidence { grid-column:2; grid-row:2; }
 .layout-pc .result-fortune { grid-column:2; grid-row:3; }
 .layout-pc #gunghap-reading { grid-column:2; grid-row:2; }
 .layout-pc .result-tail { grid-column:1 / -1; }
}
@media (max-width:374px) {
 #weekly-main { padding:12px; }
 #weekly-main .home-preview .balls-group { gap:4px; }
 #weekly-main .home-preview .lotto-ball { width:30px; height:30px; flex-basis:30px; }
 #weekly-main .home-preview .combo-left { gap:4px; }
}
/* 6개 공은 어떤 폭에서도 한 줄. 공 지름을 번호 칸 너비(컨테이너)에 맞춰 계산한다(최대 2.125rem).
   빼는 값 = 조합 이름(대체 글꼴 포함 약 2.4rem) + 이름-공 간격 8 + 동작 단추 28 + 여유 6 + 공 사이 간격×5. 글자 확대 때는 이름이 커지는 만큼 공이 줄어든다. */
#home-combos-container { container-type:inline-size; }
:root:not(.layout-pc) #weekly-main .home-preview .combo-left { flex:0 1 auto; min-width:0; }
:root:not(.layout-pc) #weekly-main .home-preview .balls-group { --gap:6px; flex-wrap:nowrap; gap:var(--gap); }
@media (max-width:374px) { :root:not(.layout-pc) #weekly-main .home-preview .balls-group { --gap:4px; } }
:root:not(.layout-pc) #weekly-main .home-preview .lotto-ball { --ball:clamp(20px, calc((100cqi - 2.4rem - 42px - 5 * var(--gap, 6px)) / 6), 2.125rem); width:var(--ball); height:var(--ball); flex:0 0 var(--ball); font-size:max(13px, min(1rem, calc(var(--ball) * .4706))); }
#saju-res-box .personal-number-line { align-items:center; }
#saju-res-box .saju-number-row { flex-wrap:wrap; min-width:0; }
#saju-res-box .personal-number-line .lotto-ball { width:2.25rem; height:2.25rem; flex-basis:2.25rem; font-size:1.0625rem; }
#lifetime-after .lifetime-balls { flex-wrap:wrap; justify-content:flex-start; gap:8px; }
#lifetime-after .lifetime-balls .lotto-ball { width:2.5rem; height:2.5rem; flex:0 0 2.5rem; font-size:1.1875rem; }
#saju-res-box .result-input-summary,#lifetime-after .result-input-summary { font-size:.875rem; }
#saju-res-box .reading-card h2 { flex-wrap:wrap; }
.result-evidence { overflow-wrap:anywhere; }
.result-evidence { container-type:inline-size; }
#weekly-main :is(.caption,.selection-policy),#saju-res-box :is(.caption,.number-sub),#lifetime-after :is(.caption,.lifetime-note) { font-size:.8125rem; }
#saju-res-box,#lifetime-after { font-size:1rem; }
:is(#saju-res-box,#lifetime-after) :is(h2,h3) { font-size:1.3125rem; }
:is(#saju-res-box,#lifetime-after) :is(.who,.number-meta,.btn-action,.btn-text,.lack,.details-body) { font-size:.875rem; }
#saju-res-box .lock { font-size:.8125rem; white-space:normal; }
#saju-res-box .ilju,#lifetime-after .ilju { font-size:.9375rem; }
#saju-res-box .ilju strong,#lifetime-after .ilju strong { font-size:1.1875rem; }
#saju-res-box .pillars :is(.h,.rl),#lifetime-after .pillars :is(.h,.rl),#saju-res-box .pillar-cell small,#lifetime-after .pillar-cell small,#saju-res-box .reading-card h2 small,#lifetime-after .reading-card h2 small { font-size:.8125rem; white-space:normal; }
#saju-res-box .pillar-cell b,#lifetime-after .pillar-cell b { font-size:2.25rem; }
#saju-res-box .element-count,#lifetime-after .element-count { font-size:.875rem; }
/* 좁은 폭·큰 글자에서는 표를 세로로 읽어 한자가 이웃 칸과 겹치지 않게 한다. */
@container (max-width:16em) {
 #saju-res-box .pillars,#lifetime-after .pillars { grid-template-columns:3em repeat(2,minmax(0,1fr)); }
 #saju-res-box .pillars .rl,#lifetime-after .pillars .rl { writing-mode:horizontal-tb; letter-spacing:normal; }
 .pillars > [role="row"]:nth-child(1) > :nth-child(1) { grid-area:1 / 1; }
 .pillars > [role="row"]:nth-child(1) > :nth-child(2) { grid-area:2 / 1; }
 .pillars > [role="row"]:nth-child(1) > :nth-child(3) { grid-area:3 / 1; }
 .pillars > [role="row"]:nth-child(1) > :nth-child(4) { grid-area:4 / 1; }
 .pillars > [role="row"]:nth-child(1) > :nth-child(5) { grid-area:5 / 1; }
 .pillars > [role="row"]:nth-child(2) > :nth-child(1) { grid-area:1 / 2; }
 .pillars > [role="row"]:nth-child(2) > :nth-child(2) { grid-area:2 / 2; }
 .pillars > [role="row"]:nth-child(2) > :nth-child(3) { grid-area:3 / 2; }
 .pillars > [role="row"]:nth-child(2) > :nth-child(4) { grid-area:4 / 2; }
 .pillars > [role="row"]:nth-child(2) > :nth-child(5) { grid-area:5 / 2; }
 .pillars > [role="row"]:nth-child(3) > :nth-child(1) { grid-area:1 / 3; }
 .pillars > [role="row"]:nth-child(3) > :nth-child(2) { grid-area:2 / 3; }
 .pillars > [role="row"]:nth-child(3) > :nth-child(3) { grid-area:3 / 3; }
 .pillars > [role="row"]:nth-child(3) > :nth-child(4) { grid-area:4 / 3; }
 .pillars > [role="row"]:nth-child(3) > :nth-child(5) { grid-area:5 / 3; }
}
@media (min-width:1000px) {
 .layout-pc #weekly-main .home-preview .lotto-ball { width:2.75rem; height:2.75rem; flex-basis:2.75rem; }
 .layout-pc #saju-res-box .personal-number-line .lotto-ball { width:2.5rem; height:2.5rem; flex-basis:2.5rem; }
}
@media (max-width:374px) {
 #weekly-main .home-preview .lotto-ball { width:1.875rem; height:1.875rem; flex-basis:1.875rem; }
}
/* 결과 데이터와 카드가 함께 정해진 뒤 홈과 기록을 표시한다. */
#tp058-home:empty,#tp058-record:empty { display:none; }
@media (min-width:1000px) {
 .layout-pc #weekly-main:has(#tp058-home:not(:empty)) #weekly-guide { grid-column:1 / -1; grid-row:1; justify-content:flex-end; }
 .layout-pc #weekly-main:has(#tp058-home:not(:empty)) #tp058-home { grid-column:1 / -1; grid-row:2; }
 .layout-pc #weekly-main:has(#tp058-home:not(:empty)) > .home-shortcuts { grid-row:auto; }
}
.tp058-card { min-width:0; margin:0 0 20px; padding:18px; border:1px solid var(--border); border-radius:16px; background:var(--surface-2); }
#tp058-record .tp058-card { background:var(--surface); }
.tp058-card h2 { font-size:1.375rem; line-height:1.35; margin:0 0 4px; }
.tp058-card .caption { margin:0 0 12px; }
.tp058-winning { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-bottom:18px; }
.tp058-winning .bonus-ball { display:inline-flex; align-items:center; gap:6px; margin-left:0; }
.tp058-label { font-size:.875rem; font-weight:700; margin:0 0 5px; }
.tp058-game { display:grid; grid-template-columns:18px minmax(0,1fr) auto; align-items:center; gap:8px; padding:8px 0; border-top:1px solid var(--border); }
.tp058-id { color:var(--text-sub); font-size:.875rem; }
.tp058-balls { display:flex; flex-wrap:wrap; gap:4px; min-width:0; }
.tp058-card .tp058-balls .lotto-ball { width:32px; height:32px; flex:0 0 32px; font-size:.875rem; }
.tp058-card .record-miss { opacity:.58; }
.tp058-card .record-hit { box-shadow:0 0 0 2px var(--primary); }
.tp058-count { display:flex; align-items:center; flex-wrap:wrap; justify-content:flex-end; gap:4px; font-size:.8125rem; white-space:nowrap; }
.tp058-check { margin-top:14px; }
@media (max-width:430px) {
 .tp058-game { grid-template-columns:16px minmax(0,1fr); }
 .tp058-count { grid-column:2; justify-content:flex-start; }
}
@media (prefers-reduced-motion:reduce) {
 *,*::before,*::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; }
}
/* 홈 첫 방문 추첨 연출(약 1.75초): 번호 위에 무대 칸을 끼우지 않고 번호 칸 안에서 '?'가 번호로 바뀐다.
   진행 상태 문구는 화면 낭독기용으로만 남기고, 무대·건너뛰기 단추는 보이지 않게 해 레이아웃이 밀리지 않게 함. */
#home-combos-container .draw-stage { position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
#home-combos-container .draw-skip { display:none; }
#home-combos-container .draw-results { display:grid; grid-template-columns:minmax(0,1fr); gap:inherit; }
/* 홈 공 크기 규칙이 '?' 상태(.draw-pending)의 글자 숨김보다 앞서지 않게 */
#weekly-main #home-combos-container .lotto-ball.draw-pending { font-size:0; }

/* 평생 5줄도 홈과 같은 공 크기·간격을 사용한다. */
#lifetime-after #lifetime-balls { display:block; container-type:inline-size; }
.lifetime-combo { padding:10px 0; border-bottom:1px solid var(--border); }
.lifetime-number-line { display:flex; align-items:center; gap:8px; min-width:0; }
.lifetime-number-line .combo-tag { min-width:24px; padding:0; background:none; font-size:.875rem; }
#lifetime-balls .balls-group { --gap:6px; display:flex; flex-wrap:nowrap; gap:var(--gap); }
#lifetime-after #lifetime-balls .lotto-ball { --ball:clamp(20px, calc((100cqi - 2.4rem - 42px - 5 * var(--gap, 6px)) / 6), 2.125rem); width:var(--ball); height:var(--ball); flex:0 0 var(--ball); font-size:max(13px, min(1rem, calc(var(--ball) * .4706))); }
.lifetime-basis { margin:8px 0 0; color:var(--text-sub); }
#lifetime-representative-reasons { margin-top:8px; }
#lifetime-representative-reasons > summary { min-height:32px; cursor:pointer; font-size:.875rem; }
#lifetime-after .lifetime-actions { flex-wrap:wrap; }
#lifetime-after .lifetime-actions .btn-action { flex:1 1 42%; }
@media (min-width:1000px) {
 .layout-pc #lifetime-after #lifetime-balls .lotto-ball { width:2.75rem; height:2.75rem; flex-basis:2.75rem; font-size:1.125rem; }
 .layout-pc .lifetime-combo { padding:12px 0; }
}
@media (max-width:374px) { #lifetime-balls .balls-group { --gap:4px; } }
