/* ════════════════════════════════════════════════════════════
   LOTTO DECODER — Futuristic Minimal Theme
   BG #0A0A0F · FG #F0F0F5 · Accent #00E5C7 (mint-cyan)
   ════════════════════════════════════════════════════════════ */

:root {
  /* Light Cyber — 흰 응모지 + 적색 액센트 + 모노 + 격자 */
  --bg: #F2F3F5;
  --bg-panel: #FFFFFF;
  --bg-ticket: #FFFFFF;
  --bg-cell: #F7F7FA;
  --bg-cell-hi: #EDEEF1;

  --fg: #18181B;
  --fg-dim: #52525B;
  --fg-mute: #8B8B92;
  --fg-faint: #C4C4CB;

  --line: #E5E5EA;
  --line-strong: #D1D1D6;

  --accent: #E63946;          /* 실제 로또 응모지의 빨강 톤 */
  --accent-glow: rgba(230, 57, 70, 0.25);
  --accent-soft: #FFF1F2;

  /* 축 색상 (라이트 환경 가시성 ↑) */
  --a1: #00B894;  /* 회차 — mint (어둡게) */
  --a2: #E67E22;  /* 날짜 — orange */
  --a3: #8E44AD;  /* 변수 — purple */
  --a4: #2980B9;  /* 지난회차 — blue */

  /* 폰트 스택 */
  --sans: 'Inter', 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --display: 'Space Grotesk', 'Inter', 'Pretendard', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ──────────── APP GRID ──────────── */
.app {
  display: grid;
  grid-template-columns: 380px 1fr;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 600px 400px at 85% 15%, rgba(230, 57, 70, 0.04), transparent 70%),
    radial-gradient(ellipse 800px 600px at 15% 85%, rgba(0, 122, 255, 0.03), transparent 70%),
    var(--bg);
}

/* ════════════════════════════════════════════
   좌측 패널 — 단서 입력
   ════════════════════════════════════════════ */
.panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--line);
  padding: 32px 30px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 10px;
  color: var(--accent);
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-name {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
}
.brand-sub {
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.brand-tag {
  font-size: 14px;
  color: var(--fg-dim);
  line-height: 1.6;
}

/* form */
.form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.field label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg);
}
.opt {
  margin-left: auto;
  font-size: 11px;
  color: var(--fg-mute);
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
}

.axis-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.axis-dot.a1 { background: var(--a1); box-shadow: 0 0 6px var(--a1); }
.axis-dot.a2 { background: var(--a2); box-shadow: 0 0 6px var(--a2); }
.axis-dot.a3 { background: var(--a3); box-shadow: 0 0 6px var(--a3); }
.axis-dot.a4 { background: var(--a4); box-shadow: 0 0 6px var(--a4); }

input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  background: var(--bg-cell);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 13px 16px;
  font-family: var(--mono);
  font-size: 16px;
  border-radius: 6px;
  outline: none;
  transition: border 0.15s, box-shadow 0.15s;
}
input[type="date"] { color-scheme: dark; font-family: var(--sans); }
textarea { resize: vertical; min-height: 78px; font-family: var(--sans); font-size: 15px; }
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.10);
}
input::placeholder, textarea::placeholder { color: var(--fg-mute); }

.hint {
  font-size: 13px;
  color: var(--fg-mute);
}

/* 회차 ± 컨트롤 */
.round-control {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 6px;
}
.round-control input {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}
.step {
  background: var(--bg-cell);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 6px;
  font-size: 22px;
  line-height: 1;
  transition: all 0.15s;
}
.step:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* 지난 회차 collapse */
.field-collapse {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-cell);
}
.field-collapse summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.field-collapse summary::-webkit-details-marker { display: none; }
.field-collapse summary::after {
  content: '+';
  margin-left: auto;
  color: var(--fg-mute);
  font-size: 16px;
  font-weight: 300;
  transition: transform 0.2s;
}
.field-collapse[open] summary::after { content: '−'; }

.prev-rounds {
  padding: 0 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.prev-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.prev-label {
  font-size: 11px;
  color: var(--fg-mute);
  min-width: 44px;
  letter-spacing: 0.05em;
}
.prev-cells {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  flex: 1;
}
.prev-cells input {
  text-align: center;
  padding: 8px 2px !important;
  font-size: 14px !important;
  -moz-appearance: textfield;
}
.prev-cells input::-webkit-outer-spin-button,
.prev-cells input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-collapse .hint { padding: 0 14px 12px; margin-top: -4px; }

/* 재해독 버튼 */
.reshuffle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: all 0.15s;
  margin-top: 4px;
}
.reshuffle svg { width: 16px; height: 16px; }
.reshuffle:hover {
  background: var(--fg);
  box-shadow: 0 0 32px var(--accent-glow);
  transform: translateY(-1px);
}

.panel-foot {
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 0.05em;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* ════════════════════════════════════════════
   좌측 위젯들 (당첨번호 조회 · 방문자)
   ════════════════════════════════════════════ */
.widget {
  padding: 16px 16px;
  background: var(--bg-cell);
  border: 1px solid var(--line);
  border-radius: 10px;
}

/* 당첨번호 위젯 */
.widget-result {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.widget-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.widget-head h3 {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
}
.widget-round {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-dim);
}
.widget-round-num strong {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin: 0 2px;
}
.widget-step {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: all 0.12s;
}
.widget-step:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.widget-date {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 0.03em;
}

/* 로또 ball — 실제 색상(5구간) */
.result-balls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding-top: 2px;
}
.result-ball {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.15);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.08);
}
.result-ball.r-1 { background: #FBC400; } /* 1~10 노랑 */
.result-ball.r-2 { background: #69C8F2; } /* 11~20 파랑 */
.result-ball.r-3 { background: #FF7272; } /* 21~30 빨강 */
.result-ball.r-4 { background: #AAAAAA; } /* 31~40 회색 */
.result-ball.r-5 { background: #B0D840; } /* 41~45 초록 */
.ball-plus {
  margin: 0 2px;
  color: var(--fg-mute);
  font-size: 16px;
  font-weight: 300;
}
.ball-skel {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--bg-cell-hi);
  display: inline-block;
}
.result-balls.error {
  font-size: 12px;
  color: var(--fg-mute);
  font-style: italic;
  padding: 4px 0;
}

/* 방문자 카운터 */
.widget-visit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  padding: 0;
  background: var(--line);
  overflow: hidden;
}
.visit-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 12px;
  background: var(--bg-cell);
}
.visit-label {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.18em;
}
.visit-cell strong {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1;
}

/* ════════════════════════════════════════════
   우측 — 응모지 결과
   ════════════════════════════════════════════ */
.ticket-wrap {
  padding: 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  min-height: 100vh;
}

.ticket {
  background: var(--bg-ticket);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
  /* 실제 응모지 격자 — 미세한 줄 */
  background-image:
    repeating-linear-gradient(0deg, transparent 0 26px, rgba(0,0,0,0.015) 26px 27px);
}

/* 응모지 좌측 perforation — 절취선 같은 점 */
.ticket::before {
  content: '';
  position: absolute;
  top: 12px; bottom: 12px;
  left: 0;
  width: 4px;
  background-image: radial-gradient(circle, var(--bg) 1.2px, transparent 1.5px);
  background-size: 4px 8px;
  background-repeat: repeat-y;
  pointer-events: none;
}
/* 응모지 우측 perforation */
.ticket::after {
  content: '';
  position: absolute;
  top: 12px; bottom: 12px;
  right: 0;
  width: 4px;
  background-image: radial-gradient(circle, var(--bg) 1.2px, transparent 1.5px);
  background-size: 4px 8px;
  background-repeat: repeat-y;
  pointer-events: none;
}

/* 헤더 — 실제 응모지 모사: 좌측 로고 + 우측 회차 */
.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 8px;
}
.ticket-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 22px;
  color: var(--fg);
}
.logo-dot {
  display: inline-grid;
  place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
}
.logo-dot::before { content: '⌬'; line-height: 1; }
.logo-text { font-size: 20px; }
.logo-text strong {
  color: var(--accent);
  font-weight: 700;
}
.ticket-round {
  text-align: right;
  font-family: var(--display);
  font-size: 13px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}
.ticket-round strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
  font-family: var(--display);
  letter-spacing: -0.01em;
}

/* 메타 — 실제 응모지의 좌측 정렬 라벨/값 */
.ticket-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-cell {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: baseline;
  gap: 10px;
  padding: 2px 0;
  font-size: 13px;
}
.meta-label {
  font-size: 12px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
  font-weight: 500;
}
.meta-cell strong {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.02em;
}
.meta-serial strong {
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.1em;
}

/* ─── Popover (셀 hover/tap 시 떠다니는 reason) ─── */
.popover {
  position: fixed;
  z-index: 1000;
  background: #FFFFFF;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 16px 18px;
  min-width: 240px;
  max-width: 320px;
  box-shadow:
    0 0 0 3px rgba(230, 57, 70, 0.08),
    0 12px 36px rgba(0, 0, 0, 0.16);
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  pointer-events: none;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.popover.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.popover.sticky { pointer-events: auto; }

.popover-num {
  font-family: var(--display);
  font-size: 44px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  min-width: 56px;
  text-align: center;
  flex-shrink: 0;
}
.popover-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popover-axes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.popover-axes span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.popover-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-dim);
}
.popover-list li {
  padding-left: 12px;
  position: relative;
}
.popover-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.games-hint {
  font-size: 12px;
  color: var(--fg-mute);
  font-style: italic;
  text-align: center;
  margin-top: -4px;
}

/* 게임 영역 — 실제 응모지 모사 */
.games {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.game {
  display: grid;
  grid-template-columns: 60px 1fr 24px;
  align-items: center;
  padding: 2px 0;
  gap: 6px;
  transition: background 0.15s;
}
.game:hover { background: rgba(0,0,0,0.02); }

.game-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.game-label-letter {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}
.game-label-mode {
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.5em;
  font-weight: 400;
  font-family: 'Pretendard', var(--sans);
}

.game-cells {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.cell {
  position: relative;
  background: #FFFFFF;
  border: 1.2px solid var(--fg);
  border-radius: 3px;
  padding: 7px 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.cell:hover, .cell.is-focused {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(230,57,70,0.18);
  z-index: 2;
}

.cell.ax-1 { --c: var(--a1); }
.cell.ax-2 { --c: var(--a2); }
.cell.ax-3 { --c: var(--a3); }
.cell.ax-4 { --c: var(--a4); }

/* 축 도트 — 셀 우상단 */
.cell[data-ax]:not([data-ax="0"])::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c, var(--fg-mute));
}

/* 하트 */
.game-heart {
  background: transparent;
  border: none;
  color: var(--fg-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  transition: color 0.15s;
}
.game-heart:hover, .game-heart.on {
  color: var(--accent);
}

/* compact 모드 (응모지 두 장이라 5게임씩만 보여서 거의 필요 X) */
.games.compact .cell { font-size: 16px; padding: 6px 0; }
.games.compact .game-label-letter { font-size: 16px; }

/* 푸터 — 금액 + 메타 */
.ticket-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px solid var(--fg);
  font-size: 13px;
  color: var(--fg);
}
.ticket-amount {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
}
.ticket-amount strong {
  color: var(--accent);
  font-weight: 700;
  margin-left: 2px;
}
.foot-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-mute);
  letter-spacing: 0.15em;
}

/* 응모지 외부 — 축 범례 (응모지 두 장 아래에 공통 1줄) */
.ticket-legend {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 8px 0 4px;
  font-size: 12px;
  color: var(--fg-mute);
}
.ticket-legend .legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ticket-legend .legend i {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ──────────── RESPONSIVE ──────────── */
@media (max-width: 1280px) {
  .app { grid-template-columns: 340px 1fr; }
  .panel { padding: 24px 22px 20px; }
  .ticket-wrap { padding: 22px; gap: 14px; }
  .ticket { padding: 20px 22px; }
  .cell { font-size: 15px; padding: 6px 0; }
}

@media (max-width: 1100px) {
  .ticket-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .panel {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 24px 20px 18px;
  }
  .ticket-wrap { padding: 16px; }
  .ticket { padding: 18px 16px; }
}

@media (max-width: 480px) {
  html, body { font-size: 15px; }
  .ticket { padding: 16px 14px; }
  .game { grid-template-columns: 52px 1fr 22px; padding: 2px 0; gap: 4px; }
  .game-label-letter { font-size: 16px; }
  .game-cells { gap: 3px; }
  .cell { font-size: 14px; padding: 7px 0; }
  .popover { max-width: calc(100vw - 32px); min-width: 200px; }
  .popover-num { font-size: 36px; min-width: 48px; }
}

/* ──────────── RESPONSIVE ──────────── */
