/* 픽랩 홈(뽑기) 재구성 — 2026-11.
   styles.css(공용, 하우스 페이지도 싣는다)는 그대로 두고 index.html 에서만 이 파일을 덧싣는다.
   색은 styles.css 의 테마 토큰(--bg·--panel·--text …) 위에서만 고르고, 여기서 새로 정의하는 건
   광원·입자·무대 표면처럼 홈에만 있는 값뿐이다. */

:root {
  --stage-surface: rgba(22, 22, 26, 0.72);
  --stage-line: rgba(255, 255, 255, 0.08);
  --segment-bg: rgba(255, 255, 255, 0.05);
  --segment-active: rgba(255, 255, 255, 0.14);
  --focus-ring: #8cc8ff;
  --skeleton: rgba(255, 255, 255, 0.08);
  --skeleton-shine: rgba(255, 255, 255, 0.16);
  --slot-line: rgba(255, 255, 255, 0.16);
  --glow-a: rgba(90, 169, 230, 0.2);
  --glow-b: rgba(184, 146, 255, 0.16);
  --glow-c: rgba(240, 113, 103, 0.09);
  --glow-d: rgba(244, 201, 93, 0.08);
  --grain-opacity: 0.07;
  --ball-shadow: rgba(0, 0, 0, 0.45);
  --ico-tile: rgba(255, 255, 255, 0.06);
  --ico-ring: #1b1b1f;
}

body[data-theme="lightblue"] {
  --ico-tile: #f1f3f6;
  --ico-ring: #f1f3f6;
  --stage-surface: rgba(255, 255, 255, 0.8);
  --stage-line: rgba(23, 37, 54, 0.1);
  --segment-bg: rgba(23, 37, 54, 0.05);
  --segment-active: #ffffff;
  --focus-ring: #1f5f8f;
  --skeleton: rgba(23, 37, 54, 0.08);
  --skeleton-shine: rgba(23, 37, 54, 0.14);
  --slot-line: rgba(23, 37, 54, 0.2);
  --glow-a: rgba(90, 169, 230, 0.22);
  --glow-b: rgba(184, 146, 255, 0.16);
  --glow-c: rgba(240, 113, 103, 0.1);
  --glow-d: rgba(244, 201, 93, 0.16);
  --grain-opacity: 0.05;
  --ball-shadow: rgba(23, 37, 54, 0.22);
}

/* ------------------------------------------------------------ 밝은 테마의 어두운 히어로 띠 */
/* 띠 위(헤더·고지·히어로)는 다크 토큰을 그대로 다시 깐다 — 자식들이 같은 변수를 읽으므로 규칙 하나로 끝난다 */
.hero-band {
  display: none;
}

body[data-theme="lightblue"] .hero-band {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 70% at 12% 0%, rgba(90, 169, 230, 0.22), transparent 70%),
    radial-gradient(36% 70% at 88% 10%, rgba(184, 146, 255, 0.18), transparent 70%),
    #0c0d10;
}

body.view-my .hero-band {
  display: none !important;
}

body[data-theme="lightblue"]:not(.view-my) :is(.app-topbar, .disclaimer-line, .home-hero) {
  color-scheme: dark;
  --bg: #0e0e0e;
  --panel: #151515;
  --control: #171717;
  --button: #2b2b2b;
  --line: #777;
  --soft-line: #242424;
  --text: #f7f7f7;
  --muted: #c9c9c9;
  --accent: #ffffff;
  --stage-line: rgba(255, 255, 255, 0.08);
  --segment-bg: rgba(255, 255, 255, 0.05);
  --segment-active: rgba(255, 255, 255, 0.14);
  --focus-ring: #8cc8ff;
  --skeleton: rgba(255, 255, 255, 0.08);
  --skeleton-shine: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

/* ------------------------------------------------------------ 배경 광원 + 입자 */
/* 둘 다 정적이다(애니메이션 없음). body 기준으로 깔려 스크롤과 함께 움직이고 다시 그릴 게 없다 */
body {
  position: relative;
}

body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  /* 짧은 화면(내 번호)에서 문서를 늘리지 않게 body 높이를 넘지 않는다 */
  height: min(960px, 100%);
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 42% at 14% 12%, var(--glow-a), transparent 72%),
    radial-gradient(34% 40% at 88% 6%, var(--glow-b), transparent 72%),
    radial-gradient(30% 34% at 70% 52%, var(--glow-c), transparent 72%),
    radial-gradient(26% 30% at 34% 46%, var(--glow-d), transparent 72%);
}

/* 미세한 입자 — SVG 노이즈 한 장을 타일로. 콘텐츠 뒤에 깔려 글자 대비를 건드리지 않는다 */
body::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

body[data-theme="lightblue"]::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.09  0 0 0 0 0.14  0 0 0 0 0.21  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ------------------------------------------------------------ 공통 손질 */
/* 키보드 포커스는 어디서든 보인다 */
.home-stage :focus-visible,
.app-topbar :focus-visible,
.advanced-options :focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.app-topbar {
  padding-top: 20px;
}

.nav-button,
.icon-button {
  background: var(--segment-bg);
  border-color: var(--stage-line);
}

.nav-button.active {
  background: var(--segment-active);
  border-color: var(--stage-line);
}

/* 상단 고지 — 내용은 그대로, 경고색 아이콘 + 흐린 한 줄로 무게만 덜었다 */
.disclaimer-line {
  margin-bottom: 0;
  font-size: 11.5px;
}

/* 한 칸 세로 흐름 — 히어로 · 무대 · 성적표 · 고급 옵션 */
.page-shell {
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding-top: 20px;
}

.main-slot.home-stage {
  display: grid;
  gap: 16px;
  width: 100%;
}

/* ------------------------------------------------------------ 히어로 */
.home-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 240px;
  padding: 4px 4px 4px;
}

/* 공 볼텍스 — 히어로 뒤에 깔리는 장식. 글자·버튼은 그 위에 */
.hero-vortex {
  position: absolute;
  inset: -12px -24px;
  width: calc(100% + 48px);
  height: calc(100% + 24px);
  pointer-events: none;
}

.home-hero > :not(.hero-vortex) {
  position: relative;
}

.home-headline {
  display: grid;
  margin: 0;
  color: var(--text);
  font-size: clamp(36px, 4.4vw, 56px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

/* 라틴 글자는 한글보다 자간이 덜 필요하다 */
html:lang(en) .home-headline {
  letter-spacing: -0.03em;
}

/* "이안랩과 함께하는" 은 작게, "픽랩" 은 크게 */
.home-headline span:first-child {
  color: var(--muted);
  font-size: 0.42em;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.home-draw {
  display: grid;
  justify-items: end;
  gap: 6px;
  min-width: 180px;
  text-align: right;
}

.home-draw-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.home-draw-round {
  color: var(--text);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.home-draw-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.next-draw-line {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.home-dday {
  padding: 3px 9px;
  border: 1px solid var(--stage-line);
  border-radius: 999px;
  background: var(--segment-bg);
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.home-dday:empty {
  display: none;
}

/* 회차를 불러오는 동안 자리만 잡는다 — 문장은 스크린리더에만 */
.home-draw[data-state="loading"] .home-draw-round,
.home-draw[data-state="loading"] .home-draw-meta::before {
  content: "";
  display: block;
  width: 108px;
  height: 30px;
  border-radius: 8px;
  background: var(--skeleton);
}

.home-draw[data-state="loading"] .home-draw-meta::before {
  width: 132px;
  height: 16px;
}

.home-draw[data-state="loading"] .next-draw-line {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.home-draw[data-state="error"] .home-draw-round {
  display: none;
}

/* ------------------------------------------------------------ 무대(결과 + 조작) */
.home-stage-card {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--stage-line);
  border-radius: 22px;
  background: var(--stage-surface);
  box-shadow: 0 24px 60px -32px rgba(0, 0, 0, 0.6);
}

.home-stage-card .result-card,
.home-stage-card .control-card {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.home-stage-card .result-card {
  gap: 16px;
  padding: 20px 24px 22px;
  /* 공 뒤 은은한 스포트라이트 — 정적 그라데이션 한 장 */
  background: radial-gradient(60% 90% at 50% 100%, var(--segment-bg), transparent 70%);
}

.home-stage-card .control-card {
  gap: 12px;
  padding: 18px 24px 20px;
  border-top: 1px solid var(--stage-line);
}

.table-panel {
  min-width: 0;
  container-type: inline-size;
}

.table-body {
  gap: 10px;
}

/* 공 행 — 줄 이름(A~J) · 공 6개 · 점수 칩 · 다시 뽑기. 공은 칸을 채우되 52px 를 넘지 않는다 */
.home-stage .game-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 352px) auto 34px;
  justify-content: center;
  align-items: center;
  gap: clamp(6px, 2.2cqi, 12px);
}

.home-stage .game-balls {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 52px));
  gap: clamp(5px, 1.8cqi, 10px);
}

/* 랜덤 결과엔 칩이 없다 — 칩 칸을 비워 다시 뽑기 버튼이 공 옆에 붙게 */
.home-stage .game-row:not(.has-score) {
  grid-template-columns: 18px minmax(0, 352px) 34px;
}

.home-stage .game-score {
  padding: 4px 8px;
  border: 1px solid var(--stage-line);
  border-radius: 999px;
  background: var(--segment-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.home-stage .game-score.is-high {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

.home-stage .game-reroll {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--stage-line);
  border-radius: 10px;
  background: var(--segment-bg);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.home-stage .game-reroll:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 35%, transparent);
}

.home-stage .game-reroll:active {
  transform: rotate(-30deg);
}

.home-stage .game-reroll:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* 10게임은 넓은 화면에서 두 단으로 — 조작부가 화면 밖으로 밀리지 않게 */
@media (min-width: 900px) {
  .home-stage .table-body[data-count="10"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* 1~5 왼쪽, 6~10 오른쪽 — 번호 순서대로 읽힌다 */
    grid-template-rows: repeat(5, auto);
    grid-auto-flow: column;
    column-gap: 24px;
  }
}

.home-stage .game-index {
  width: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.home-stage .result-ball {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  /* 광택 한 점 + 아래쪽 그늘 — 색 공이 화면의 주인공 */
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 46%),
    var(--ball-color);
  box-shadow:
    inset 0 -3px 6px rgba(0, 0, 0, 0.16),
    0 6px 14px -6px var(--ball-shadow);
  color: #0e0e0e;
  font-size: clamp(14px, 4.4cqi, 20px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* 굴러오기 — 왼쪽에서 한 바퀴 돌며 들어와 살짝 튄다. transform·opacity 만 움직인다 */
.home-stage .game-row.is-rolling .result-ball {
  animation: ball-roll-in var(--roll-ms, 360ms) cubic-bezier(0.22, 0.8, 0.32, 1) both;
  animation-delay: calc(var(--row, 0) * var(--row-gap, 0ms) + var(--i, 0) * var(--roll-step, 55ms));
}

@keyframes ball-roll-in {
  0% {
    opacity: 0;
    transform: translateX(-40px) rotate(-300deg) scale(0.72);
  }
  55% {
    opacity: 1;
    transform: translateX(3px) translateY(-5px) rotate(10deg) scale(1.04);
  }
  78% {
    transform: translateX(-1px) translateY(1px) rotate(-3deg) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-stage .game-row.is-rolling .result-ball {
    animation: none;
  }
}

/* 뽑기 전 — 공 6칸 자리 + 안내 */
.home-stage .table-empty {
  max-width: none;
  min-height: 0;
  grid-column: 1 / -1;
  padding: 8px 0;
  font-size: 13px;
}

.home-stage .table-empty.is-slots {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.table-empty-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 52px));
  justify-content: center;
  gap: clamp(6px, 2.2cqi, 12px);
  width: 100%;
}

.table-empty-slots i {
  aspect-ratio: 1;
  border: 1.5px dashed var(--slot-line);
  border-radius: 50%;
}

/* ------------------------------------------------------------ 조작부 */
.control-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 14px 24px;
}

.control-row .button-control {
  flex: 1 1 280px;
  max-width: 420px;
}

.control-row .button-control:last-child {
  margin-left: auto;
}

/* 게임 수 · 방식 = 세그먼트 컨트롤 */
.home-stage .preset-panel,
.home-stage .method-buttons {
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--stage-line);
  border-radius: 12px;
  background: var(--segment-bg);
}

.home-stage .method-button,
.home-stage .preset-button {
  height: 38px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.home-stage .method-button:hover,
.home-stage .preset-button:hover {
  color: var(--text);
}

.home-stage .method-button.active,
.home-stage .preset-button.active {
  background: var(--segment-active);
  color: var(--text);
  outline: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.home-stage .method-button:focus-visible,
.home-stage .preset-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.home-stage .method-hint {
  font-size: 12.5px;
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.home-stage .generate-button {
  height: 56px;
  border-radius: 14px;
  font-size: 17px;
  letter-spacing: -0.01em;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.home-stage .generate-button:hover {
  filter: brightness(0.94);
}

.home-stage .generate-button:active {
  transform: scale(0.985);
}

.home-stage .save-week-button {
  height: 56px;
  padding: 0 20px;
  border-color: var(--stage-line);
  border-radius: 14px;
  background: var(--segment-bg);
  font-size: 13px;
}

/* 고른 줄 — 옅은 띠로 표시. 줄을 누르면 아래 '어디쯤' 패널이 그 줄로 바뀐다 */
.home-stage .game-row {
  border-radius: 12px;
  cursor: pointer;
}

.home-stage .game-row.is-selected {
  background: var(--segment-bg);
  box-shadow: 0 0 0 6px var(--segment-bg);
}

.home-stage .game-balls:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: 999px;
}

/* ------------------------------------------------------------ 번호판 (꼭 넣기 · 빼기) */
.number-board {
  padding: 16px 24px;
  border-bottom: 1px solid var(--stage-line);
}

.number-board summary {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding-right: 22px;
  cursor: pointer;
  list-style: none;
}

.number-board summary::-webkit-details-marker {
  display: none;
}

.number-board summary::after,
.where-panel summary::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}

.number-board[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.board-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.board-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 40px));
  justify-content: start;
  gap: 8px;
  margin-top: 14px;
}

.board-ball {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--stage-line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.12s ease;
}

.board-ball:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--text) 35%, transparent);
}

.board-ball:active {
  transform: scale(0.92);
}

.board-ball:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* 넣기 = 그 번호 공 색으로 채움 */
.board-ball.is-in {
  border-color: transparent;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 46%),
    var(--ball-color);
  color: #0e0e0e;
}

/* 빼기 = 흐리게 + 사선 */
.board-ball.is-out {
  border-style: dashed;
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  background: linear-gradient(135deg, transparent 48%, color-mix(in srgb, var(--muted) 70%, transparent) 48% 52%, transparent 52%);
}

.board-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.board-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.board-clear {
  flex-shrink: 0;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--stage-line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.board-clear:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ------------------------------------------------------------ 역대 기록에서 어디쯤? */
.where-panel {
  border-top: 1px solid var(--stage-line);
  padding-top: 14px;
}

.where-panel summary {
  position: relative;
  padding-right: 22px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  cursor: pointer;
  list-style: none;
}

.where-panel summary::-webkit-details-marker {
  display: none;
}

.where-panel[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.where-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.where-sub {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.where-body {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.where-row-head {
  display: grid;
  gap: 2px;
  margin-bottom: 8px;
}

.where-row-head b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.where-row-head b span {
  color: var(--text);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.where-row-head small {
  color: var(--muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* 막대는 무채색만 — 빨강·초록은 "좋은 칸"처럼 읽힌다 */
.where-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 44px;
}

.where-bars i {
  flex: 1;
  min-width: 0;
  border-radius: 3px 3px 0 0;
  background: color-mix(in srgb, var(--muted) 30%, transparent);
}

.where-bars i.is-mine {
  background: var(--text);
}

.where-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
}

/* 복사 · 이미지 저장 — 뽑은 뒤에만 켜진다 */
.share-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.home-stage .share-button {
  height: 44px;
  border: 1px solid var(--stage-line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.home-stage .share-button:hover:not(:disabled) {
  background: var(--segment-bg);
}

.home-stage .share-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.home-stage .share-button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.home-stage .generate-status {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

/* ------------------------------------------------------------ 실험실 카드 */
.lab-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.lab-card {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 4px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--stage-line);
  border-radius: 16px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.lab-card:hover {
  border-color: color-mix(in srgb, var(--text) 30%, transparent);
}

.lab-card.is-active {
  border-color: var(--text);
  background: var(--segment-bg);
}

.lab-card:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.lab-card-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  border-radius: 13px;
  background: var(--ico-tile);
  color: var(--text);
}

.lab-card-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 900;
}

.lab-card-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

/* ------------------------------------------------------------ 성적표 보드 (홈 메인) */
.house-board {
  display: grid;
  gap: 16px;
  padding: 20px 24px;
  border: 1px solid var(--stage-line);
  border-radius: 22px;
  background: var(--stage-surface);
}

.hb-lead {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hb-lead b {
  color: var(--text);
  font-weight: 900;
}

.hb-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hb-stat {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--segment-bg);
}

.hb-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

/* 손익도 같은 글자색 — 빨강·초록은 "잘 된다"로 읽힌다 */
.hb-stat strong {
  color: var(--text);
  font-size: clamp(20px, 2.6vw, 28px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.hb-stat small {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.hb-lines {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.hb-lines b {
  color: var(--text);
}

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

.hb-button {
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--stage-line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.hb-button.is-primary {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
}

.hb-button:focus-visible,
.hb-link:focus-visible,
.hb-row:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.hb-link {
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.hb-link:hover {
  color: var(--text);
}

/* 전체 기록 — 줄을 누르면 그 회차 100세트가 펼쳐진 성적표로 간다 */
.hb-history {
  display: grid;
  gap: 2px;
  border-top: 1px solid var(--stage-line);
  padding-top: 12px;
}

.hb-row {
  display: grid;
  grid-template-columns: 112px 64px minmax(0, 1fr) 96px 96px 16px;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}

a.hb-row:hover {
  background: var(--segment-bg);
}

.hb-row > :nth-child(4),
.hb-row > :nth-child(5) {
  text-align: right;
}

.hb-row.is-head {
  padding-top: 0;
  padding-bottom: 6px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}

.hb-row.is-total {
  border-top: 1px solid var(--stage-line);
  border-radius: 0;
  font-weight: 900;
}

.hb-row .hb-muted {
  color: var(--muted);
}

.hb-ver {
  display: inline-block;
  font-style: normal;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--stage-line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.hb-chev {
  color: var(--muted);
}

.hb-versions {
  display: grid;
  gap: 3px;
  margin: 10px 0 0;
  padding: 0 8px;
  list-style: none;
  color: var(--muted);
  font-size: 12px;
}

.hb-versions b {
  color: var(--text);
}

.house-board[data-state="loading"] .hb-stat strong {
  width: 70%;
  height: 28px;
  border-radius: 8px;
  background: var(--skeleton);
  color: transparent;
}

.house-board[data-state="error"] .hb-lead,
.house-board[data-state="empty"] .hb-lead {
  color: var(--text);
}

/* 스켈레톤 반짝임 — 작은 면적만, 동작 줄이기면 멈춘다 */
@media (prefers-reduced-motion: no-preference) {
  .home-draw[data-state="loading"] .home-draw-round,
  .home-draw[data-state="loading"] .home-draw-meta::before,
  .house-board[data-state="loading"] .hb-stat strong {
    background: linear-gradient(90deg, var(--skeleton) 30%, var(--skeleton-shine) 50%, var(--skeleton) 70%) 0 0 / 300% 100%;
    animation: skeleton-shine 1.4s ease-in-out infinite;
  }
}

@keyframes skeleton-shine {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: 0 0;
  }
}

/* ------------------------------------------------------------ 고급 옵션 · 푸터 (위치만 정돈) */
.advanced-options {
  border-color: var(--stage-line);
  border-radius: 16px;
  background: var(--stage-surface);
}

body.view-my .advanced-options {
  background: transparent;
}

.app-footer {
  border-top-color: var(--stage-line);
}

/* ------------------------------------------------------------ 좁은 화면 */
@media (max-width: 580px) {
  .page-shell {
    gap: 16px;
    padding-top: 12px;
  }

  .home-hero {
    display: grid;
    gap: 14px;
    padding: 8px 2px 4px;
  }

  .home-headline {
    font-size: clamp(32px, 9.4vw, 40px);
  }

  /* 회차는 헤드라인 아래 한 줄로 */
  .home-draw {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-items: start;
    gap: 6px 8px;
    min-width: 0;
    text-align: left;
  }

  .home-draw-round {
    font-size: 18px;
  }

  .home-draw[data-state="loading"] .home-draw-round {
    width: 64px;
    height: 20px;
  }

  .home-stage-card {
    border-radius: 18px;
  }

  .home-stage-card .result-card {
    padding: 18px 14px 20px;
  }

  .home-stage-card .control-card {
    padding: 16px 14px 18px;
  }

  .where-body {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .number-board {
    padding: 14px;
  }

  .home-hero {
    min-height: 0;
  }

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

  .lab-card {
    min-height: 100px;
    padding: 12px;
  }

  .board-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 6px;
  }

  .board-foot {
    align-items: flex-start;
  }

  /* 좁은 화면 — 점수 칩은 공 아래 줄로 내린다 */
  .home-stage .game-row,
  .home-stage .game-row:not(.has-score) {
    grid-template-columns: 14px minmax(0, 1fr) 30px;
    row-gap: 4px;
  }

  .home-stage .game-score {
    grid-row: 2;
    grid-column: 2;
    justify-self: start;
    padding: 2px 7px;
    font-size: 11px;
  }

  .home-stage .game-reroll {
    grid-row: 1;
    grid-column: 3;
    width: 30px;
    height: 30px;
  }

  .home-stage .result-card-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .control-row .button-control {
    flex-basis: 100%;
    max-width: none;
  }

  .home-stage .save-week-button {
    padding: 0 14px;
  }

  .house-board {
    gap: 14px;
    padding: 16px 14px;
    border-radius: 18px;
  }

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

  /* 현재 손익은 한 줄 통째로 */
  .hb-stat:last-child {
    grid-column: 1 / -1;
  }

  .hb-stat {
    padding: 12px;
  }

  .hb-actions .hb-button {
    flex: 1;
  }

  .hb-link {
    flex-basis: 100%;
    margin-left: 0;
    text-align: center;
  }

  /* 추첨일은 접고 회차·결과·금액만 */
  .hb-row {
    grid-template-columns: 88px minmax(0, 1fr) 72px 64px 12px;
    gap: 6px;
    padding: 10px 4px;
    font-size: 12px;
  }

  .hb-row > :nth-child(2) {
    display: none;
  }
}
