/* =========================================================
   Lotto-Ditto — visual layer
   Concept: Premium Analytical Hybrid (Gemini design pass)
   - Calm, financial-dashboard tone
   - Mobile-first card layout
   - Subtle elevation, restrained color
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  color-scheme: light;

  /* Theme */
  --page-bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f1f5f9;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #ef4444;
  --primary-strong: #dc2626;
  --primary-soft: #fff1f2;
  --primary-ring: rgba(239, 68, 68, 0.18);
  --shadow-soft: 0 1px 2px 0 rgb(15 23 42 / 0.05);
  --shadow-card: 0 4px 6px -1px rgb(15 23 42 / 0.1),
                 0 2px 4px -1px rgb(15 23 42 / 0.06);
  --shadow-lifted: 0 10px 15px -3px rgb(15 23 42 / 0.1),
                   0 4px 6px -2px rgb(15 23 42 / 0.05);
  --header-bg: rgba(255, 255, 255, 0.85);
  --ticket-bg: #fff7f7;
  --ticket-border: #fecaca;
  --ticket-inner-ring: #ffffff;
  --ticket-red: #ef4444;
  --ticket-red-soft: #f47b7b;
  --ticket-number: #ef6262;
  --ticket-selected-bg: #111827;
  --ticket-selected-text: #ffffff;
  --ticket-selected-hover: rgba(17, 24, 39, 0.08);
  --hero-glow: radial-gradient(120% 140% at 50% 0%, #fff1f2 0%, rgba(255,255,255,0) 70%);

  /* Surface & text */
  --color-bg: var(--page-bg);
  --color-surface: var(--surface);
  --color-surface-alt: var(--surface-soft);
  --color-text-main: var(--text-main);
  --color-text-muted: var(--text-muted);
  --color-border: var(--border);
  --color-border-strong: var(--border-strong);

  /* Brand */
  --color-primary: var(--primary);
  --color-primary-hover: var(--primary-strong);
  --color-primary-soft: var(--primary-soft);
  --color-primary-ring: var(--primary-ring);

  /* Status (Financial tone) */
  --status-success: #059669;
  --status-success-soft: #ecfdf5;
  --status-warning: #d97706;
  --status-warning-soft: #fffbeb;
  --status-danger: #dc2626;
  --status-danger-soft: #fef2f2;

  /* Lotto ball ranges (Analytical/Professional) */
  --ball-1-10: #f59e0b;   /* Amber-500 */
  --ball-11-20: #3b82f6;  /* Blue-500 */
  --ball-21-30: #ef4444;  /* Red-500 */
  --ball-31-40: #6b7280;  /* Gray-500 */
  --ball-41-45: #10b981;  /* Green-500 */

  /* Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 99px;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 48px;

  /* Elevation (Subtle & Clean) */
  --shadow-sm: var(--shadow-soft);
  --shadow-md: var(--shadow-card);
  --shadow-lg: var(--shadow-lifted);

  /* Layout */
  --container-max: 720px; /* More focused reading width */

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Pretendard",
    "Noto Sans KR", "Apple SD Gothic Neo", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --page-bg: #0f172a;
  --surface: #111827;
  --surface-soft: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #a8b4c7;
  --border: #334155;
  --border-strong: #475569;
  --primary: #f87171;
  --primary-strong: #fb7185;
  --primary-soft: rgba(248, 113, 113, 0.12);
  --primary-ring: rgba(248, 113, 113, 0.26);
  --shadow-soft: 0 1px 2px 0 rgb(0 0 0 / 0.28);
  --shadow-card: 0 10px 24px -14px rgb(0 0 0 / 0.72);
  --shadow-lifted: 0 18px 34px -20px rgb(0 0 0 / 0.82);
  --header-bg: rgba(15, 23, 42, 0.86);
  --ticket-bg: #1f1717;
  --ticket-border: #7f1d1d;
  --ticket-inner-ring: rgba(248, 113, 113, 0.12);
  --ticket-red: #ef4444;
  --ticket-red-soft: #7f1d1d;
  --ticket-number: #f87171;
  --ticket-selected-bg: #f8fafc;
  --ticket-selected-text: #0f172a;
  --ticket-selected-hover: rgba(248, 250, 252, 0.14);
  --hero-glow: radial-gradient(120% 140% at 50% 0%, rgba(248, 113, 113, 0.16) 0%, rgba(17, 24, 39, 0) 72%);

  --status-success: #34d399;
  --status-success-soft: rgba(16, 185, 129, 0.14);
  --status-warning: #fbbf24;
  --status-warning-soft: rgba(245, 158, 11, 0.16);
  --status-danger: #f87171;
  --status-danger-soft: rgba(239, 68, 68, 0.14);

  --ball-31-40: #9ca3af;
}

/* ---------- 2. Base reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  text-decoration: underline;
  color: var(--color-primary-hover);
}

button {
  font: inherit;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

input,
button {
  color: inherit;
}

/* Accessible focus ring */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- 3. Layout helpers ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-5);
}

.skip-link {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  z-index: 100;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 4. Header ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.site-header__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-width: 0;
  color: var(--color-text-main);
  white-space: nowrap;
  flex-wrap: nowrap;
  text-decoration: none;
}

.site-brand:hover {
  text-decoration: none;
}

.site-brand__logo {
  display: block;
  width: auto;
  height: auto;
  max-width: min(80vw, 280px);
  max-height: 42px;
  object-fit: contain;
  flex-shrink: 1;
}

.theme-toggle {
  position: absolute;
  right: var(--space-5);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-main);
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
}

.theme-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.theme-toggle__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  font-size: 1rem;
  line-height: 1;
}

/* ---------- 5. Sections ---------- */
.site-main {
  padding-bottom: var(--space-8);
}

.section {
  padding: var(--space-7) 0;
}

.section + .section {
  padding-top: var(--space-6);
}

.section__header {
  margin-bottom: var(--space-5);
}

.section__title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.section__title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--color-primary);
}

/* ---------- 6. Hero ---------- */
.hero {
  padding: var(--space-7) 0 var(--space-6);
}

.hero__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background:
    var(--hero-glow),
    var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px var(--space-3);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-primary-ring);
}

.hero__eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.hero__title {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
  letter-spacing: 0;
  color: var(--color-text-main);
}

.hero__actions {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 52px;
  padding: var(--space-2) var(--space-6);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn:active {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.btn:hover {
  text-decoration: none;
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  color: #fff;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.25);
}

.btn--ghost {
  background: var(--color-surface);
  color: var(--color-text-main);
  border-color: var(--color-border-strong);
}

.btn--ghost:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 8. Recommend form ---------- */
.recommend-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  background: var(--color-surface);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.mode-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mode-option {
  position: relative;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--space-3);
  row-gap: 4px;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.mode-option:hover {
  border-color: var(--color-border-strong);
  background: var(--color-surface-alt);
}

.mode-option[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.mode-option input[type="radio"] {
  grid-column: 1;
  grid-row: 1;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--color-primary);
}

.mode-option:has(input[type="radio"]:checked) {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.mode-option:has(input[type="radio"]:checked) .mode-option__title {
  color: var(--color-primary-hover);
}

.mode-option__title {
  grid-column: 2;
  grid-row: 1;
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
  margin: 0;
  letter-spacing: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.mode-option__desc {
  grid-column: 2;
  grid-row: 2;
  display: block;
  width: 100%;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.83rem;
  line-height: 1.5;
  word-break: keep-all;
  overflow-wrap: break-word;
  white-space: normal;
}

.form-help {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.recommend-form__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
}

/* ---------- 9. Result cards ---------- */
.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.empty-state {
  margin: 0;
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}

.microcopy {
  margin: var(--space-2) 0 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.result-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: clamp(14px, 3vw, var(--space-5));
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.result-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-strong);
  transform: translateY(-1px);
}

.result-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.result-card__label {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  font-weight: 700;
  letter-spacing: 0;
}

.result-card__balls {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(3px, 1.4vw, 7px);
  min-width: 0;
  max-width: 100%;
  margin: 0 0 var(--space-3);
  padding: var(--space-3) 0;
}

.result-card__balls .lotto-ball {
  width: 100%;
  max-width: 36px;
  height: auto;
  aspect-ratio: 1;
  min-width: 0;
  font-size: clamp(0.68rem, 2.7vw, 0.9rem);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1),
              0 1px 2px rgba(15, 23, 42, 0.06);
}

.result-card__details {
  margin-top: auto;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}

.result-card__details summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  list-style: none;
  user-select: none;
  padding: var(--space-1) 0;
}

.result-card__details summary:hover {
  color: var(--color-primary-hover);
}

.result-card__details summary::-webkit-details-marker {
  display: none;
}

.result-card__details summary::after {
  content: "▾";
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.result-card__details[open] summary::after {
  transform: rotate(180deg);
}

.result-card__detail-list {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: 0;
}

.result-card__detail-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-surface-alt);
}

.result-card__detail-list li:last-child {
  border-bottom: none;
}

.result-card__detail-list strong {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.result-card__detail-list span {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text-main);
  text-align: right;
  word-break: keep-all;
}

/* ---------- 10. Score badge ---------- */
.score-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 4px var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-surface-alt);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.score-badge__value {
  font-size: 0.95rem;
  line-height: 1;
}

.score-badge__suffix {
  font-weight: 600;
  opacity: 0.55;
}

.score-badge--good { background: var(--status-success-soft); color: var(--status-success); border-color: rgba(5, 150, 105, 0.18); }
.score-badge--mid { background: var(--status-warning-soft); color: var(--status-warning); border-color: rgba(217, 119, 6, 0.18); }
.score-badge--low { background: var(--status-danger-soft); color: var(--status-danger); border-color: rgba(220, 38, 38, 0.18); }

/* ---------- 11. Lotto ball ---------- */
.lotto-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
  background: var(--color-text-muted);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12),
              0 1px 2px rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.lotto-ball.ball-range-1 { background: var(--ball-1-10); color: #fff; }
.lotto-ball.ball-range-11 { background: var(--ball-11-20); color: #fff; }
.lotto-ball.ball-range-21 { background: var(--ball-21-30); color: #fff; }
.lotto-ball.ball-range-31 { background: var(--ball-31-40); color: #fff; }
.lotto-ball.ball-range-41 { background: var(--ball-41-45); color: #fff; }

/* ---------- 12. Analyzer form ---------- */
.analyzer-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  background: var(--color-surface);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.number-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.number-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.number-input label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  letter-spacing: 0;
}

.number-input input {
  min-height: 52px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  background: var(--color-surface-alt);
  font-variant-numeric: tabular-nums;
  color: var(--color-text-main);
}

.number-input input:focus {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.number-input input:not(:placeholder-shown),
.number-input input:valid:not(:invalid):not([value=""]) {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
}

/* Hide native number-input spinners (so labels/centered numbers stay clean) */
.number-input input::-webkit-outer-spin-button,
.number-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.number-input input[type="number"] {
  -moz-appearance: textfield;
}

.analyzer-form__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
}

.form-error {
  padding: var(--space-3);
  background: var(--status-danger-soft);
  color: var(--status-danger);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.form-error[hidden] {
  display: none;
}

.analyzer-workspace {
  margin-top: var(--space-4);
  display: grid;
  align-items: stretch;
  gap: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.lotto-ticket {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  max-width: 100%;
  padding: var(--space-3);
  background: var(--ticket-bg);
  border: 1px solid var(--ticket-border);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 2px var(--ticket-inner-ring);
  overflow: hidden;
}

.lotto-ticket__header {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  margin: -12px -12px 0;
  padding: 0 var(--space-3);
  background: var(--ticket-red);
  border-bottom: 2px solid var(--ticket-red-soft);
  overflow: hidden;
}

.lotto-ticket__header-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 86%;
  max-height: 34px;
  object-fit: contain;
}

.lotto-ticket__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(clamp(34px, 4.2vw, 44px), 1fr);
  row-gap: clamp(20px, 3vw, 28px);
  column-gap: clamp(8px, 1.4vw, 14px);
  align-content: center;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  padding: clamp(20px, 3vw, 28px) clamp(8px, 1.8vw, 16px) clamp(16px, 2.4vw, 22px);
}

.lotto-ticket__cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: clamp(34px, 4.2vw, 44px);
  aspect-ratio: 1 / 0.88;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ticket-number);
  cursor: pointer;
  font: inherit;
  font-size: clamp(0.88rem, 1.65vw, 1.05rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
  transition: color 0.15s ease, transform 0.12s ease, background-color 0.15s ease;
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}

.lotto-ticket__number {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  padding: 3px 6px;
  border-radius: 2px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lotto-ticket__corner {
  position: absolute;
  width: clamp(12px, 1.6vw, 16px);
  height: clamp(9px, 1.25vw, 13px);
  border-color: currentColor;
  pointer-events: none;
}

.lotto-ticket__corner--tl {
  top: 4px;
  left: 4px;
  border-top: 2px solid;
  border-left: 2px solid;
}

.lotto-ticket__corner--tr {
  top: 4px;
  right: 4px;
  border-top: 2px solid;
  border-right: 2px solid;
}

.lotto-ticket__corner--bl {
  bottom: 4px;
  left: 4px;
  border-bottom: 2px solid;
  border-left: 2px solid;
}

.lotto-ticket__corner--br {
  right: 4px;
  bottom: 4px;
  border-right: 2px solid;
  border-bottom: 2px solid;
}

@media (hover: hover) {
  .lotto-ticket__cell:hover {
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-primary-hover);
    transform: translateY(-1px);
  }

  .lotto-ticket__cell.is-selected:hover {
    background: var(--ticket-selected-hover);
    color: var(--ticket-selected-bg);
    transform: translateY(-1px);
  }
}

.lotto-ticket__cell:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  z-index: 1;
}

.lotto-ticket__cell:active {
  transform: scale(0.94);
}

.lotto-ticket__cell.is-selected {
  color: var(--ticket-selected-bg);
  font-weight: 800;
}

.lotto-ticket__cell.is-selected .lotto-ticket__number {
  background: var(--ticket-selected-bg);
  color: var(--ticket-selected-text);
  width: calc(100% - 12px);
  height: calc(100% - 10px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 2px;
}

.analyzer-result {
  min-width: 0;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-4);
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.analyzer-result__placeholder {
  margin: 0;
  padding: var(--space-5) var(--space-3);
  color: var(--color-text-muted);
  font-size: 0.88rem;
  line-height: 1.7;
  text-align: center;
  word-break: keep-all;
}

.analyzer-result__placeholder::before {
  content: "✦";
  display: block;
  margin: 0 auto var(--space-2);
  font-size: 1.4rem;
  color: var(--color-primary);
  opacity: 0.6;
}

.analyzer-result__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.analyzer-result__title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0;
}

.analyzer-result__balls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-4);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.analyzer-result__metrics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
}

.analyzer-result__metrics li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-surface-alt);
  font-size: 0.85rem;
}

.analyzer-result__metrics li:last-child {
  border-bottom: none;
}

.analyzer-result__metrics strong {
  font-weight: 500;
  color: var(--color-text-muted);
}

.analyzer-result__metrics span {
  font-weight: 700;
  text-align: right;
  word-break: keep-all;
}

.analyzer-result__note {
  margin: var(--space-3) 0 0;
  color: var(--color-text-muted);
  font-size: 0.83rem;
  line-height: 1.6;
  word-break: keep-all;
}

/* ---------- 14b. Site nav (under header) ---------- */
.site-nav {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.site-nav__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  justify-content: center;
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  padding: 6px var(--space-3);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.site-nav a:hover {
  color: var(--color-text-main);
  background: var(--color-surface-alt);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

/* ---------- 14c. Hero/section text helpers ---------- */
.hero__lede {
  margin: 0;
  max-width: 56ch;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  word-break: keep-all;
}

.section__lede {
  margin: var(--space-2) 0 0;
  color: var(--color-text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
  word-break: keep-all;
}

/* ---------- 14d. Notice banner ---------- */
.notice {
  margin: 0 0 var(--space-2);
}

.notice .container {
  padding: var(--space-4) var(--space-5);
  background: var(--status-warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius-md);
  color: var(--color-text-main);
}

.notice__title {
  margin: 0 0 var(--space-2);
  font-weight: 800;
  color: var(--status-warning);
  font-size: 0.92rem;
}

.notice__list {
  margin: 0;
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--color-text-main);
  word-break: keep-all;
}

.notice__list a {
  color: var(--status-warning);
  font-weight: 700;
}

/* ---------- 14e. Page hero (sub pages) ---------- */
.page-hero {
  padding: var(--space-7) 0 var(--space-5);
  background: var(--hero-glow), var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.page-hero__eyebrow {
  margin: 0 0 var(--space-2);
  display: inline-block;
  padding: 4px var(--space-3);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-primary-ring);
}

.page-hero__title {
  margin: 0 0 var(--space-3);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--color-text-main);
  word-break: keep-all;
}

.page-hero__lede {
  margin: 0 0 var(--space-3);
  max-width: 64ch;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
  word-break: keep-all;
}

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

/* ---------- 14f. Prose (article body) ---------- */
.prose {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6) var(--space-5);
  color: var(--color-text-main);
  font-size: 0.95rem;
  line-height: 1.75;
  word-break: keep-all;
}

.prose h2 {
  margin: var(--space-6) 0 var(--space-3);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text-main);
  letter-spacing: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose h3 {
  margin: var(--space-5) 0 var(--space-2);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-main);
}

.prose p {
  margin: 0 0 var(--space-3);
}

.prose ul,
.prose ol {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prose li::marker {
  color: var(--color-primary);
}

.prose code {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.prose strong {
  font-weight: 700;
  color: var(--color-text-main);
}

.prose a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.prose a:hover {
  color: var(--color-primary-hover);
}

.prose__note {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: -8px;
}

.prose__cta {
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
}

.prose__back {
  margin-top: var(--space-6);
  text-align: center;
  font-size: 0.9rem;
}

/* ---------- 14g. Tables ---------- */
.table-scroll {
  overflow-x: auto;
  margin: 0 0 var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 380px;
}

.data-table th,
.data-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: var(--color-surface-alt);
  font-weight: 700;
  color: var(--color-text-main);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

/* ---------- 14h. FAQ details ---------- */
.qa {
  margin: 0 0 var(--space-2);
  padding: 0;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.qa > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-3) var(--space-4);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  user-select: none;
}

.qa > summary::-webkit-details-marker {
  display: none;
}

.qa > summary::after {
  content: "+";
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.qa[open] > summary::after {
  content: "−";
}

.qa > p {
  margin: 0;
  padding: 0 var(--space-4) var(--space-4);
  font-size: 0.92rem;
  line-height: 1.75;
  color: var(--color-text-muted);
}

.qa > p a {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ---------- 14i. Contact-specific ---------- */
.contact-email {
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  padding: var(--space-4);
  background: var(--color-primary-soft);
  border: 1px dashed var(--color-primary);
  border-radius: var(--radius-md);
  margin: var(--space-3) 0 var(--space-4);
}

.contact-email a {
  color: var(--color-primary);
  text-decoration: none;
}

.notice-inline {
  margin: var(--space-5) 0 0;
  padding: var(--space-3) var(--space-4);
  background: var(--status-warning-soft);
  border-left: 3px solid var(--status-warning);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--color-text-main);
  line-height: 1.7;
}

/* ---------- 15. Footer ---------- */
.site-footer {
  padding: var(--space-7) 0 var(--space-5);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.site-footer__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-5);
  text-align: left;
  margin-bottom: var(--space-5);
}

.site-footer__col {
  min-width: 0;
}

.site-footer__brand {
  margin: 0 0 var(--space-2);
  font-size: 1rem;
  font-weight: 800;
  color: var(--color-text-main);
  letter-spacing: 0;
}

.site-footer__desc {
  margin: 0;
  font-size: 0.83rem;
  line-height: 1.7;
  color: var(--color-text-muted);
  word-break: keep-all;
}

.site-footer__heading {
  margin: 0 0 var(--space-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-main);
}

.site-footer__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-footer__list a {
  color: var(--color-text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
}

.site-footer__list a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.site-footer__copy {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin: 0;
  letter-spacing: 0;
  text-align: center;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  line-height: 1.7;
  word-break: keep-all;
}

/* ---------- 16. Responsive ---------- */

@media (max-width: 480px) {
  .container { padding: 0 var(--space-3); }
  .site-header__inner {
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .site-brand__logo {
    max-width: min(60vw, 240px);
    max-height: 36px;
  }
  .theme-toggle {
    right: var(--space-3);
    width: 34px;
    height: 34px;
  }
  .result-card { padding: var(--space-4); }
  .result-card__balls { gap: 4px; }
  .result-card__balls .lotto-ball {
    max-width: 34px;
    font-size: 0.78rem;
  }
  .lotto-ticket {
    padding: var(--space-3) var(--space-2) var(--space-3);
  }
  .analyzer-result {
    min-height: 300px;
  }
  .lotto-ticket__header {
    height: 46px;
    margin-right: -8px;
    margin-left: -8px;
    padding: 0 var(--space-2);
  }
  .lotto-ticket__header-logo {
    max-width: 88%;
    max-height: 30px;
  }
  .lotto-ticket__grid {
    grid-auto-rows: minmax(30px, 1fr);
    row-gap: 15px;
    column-gap: 6px;
    padding: 20px 6px 18px;
  }
  .lotto-ticket__cell {
    min-height: 30px;
    font-size: 0.82rem;
  }
  .lotto-ticket__number {
    min-width: 22px;
    min-height: 22px;
    padding: 2px 4px;
  }
  .lotto-ticket__corner {
    width: 9px;
    height: 7px;
  }
  .lotto-ticket__corner--tl,
  .lotto-ticket__corner--tr {
    top: 3px;
  }
  .lotto-ticket__corner--bl,
  .lotto-ticket__corner--br {
    bottom: 3px;
  }
  .lotto-ticket__corner--tl,
  .lotto-ticket__corner--bl {
    left: 3px;
  }
  .lotto-ticket__corner--tr,
  .lotto-ticket__corner--br {
    right: 3px;
  }
  .lotto-ticket__cell.is-selected .lotto-ticket__number {
    width: calc(100% - 8px);
    height: calc(100% - 8px);
  }
}

@media (max-width: 360px) {
  .container { padding: 0 10px; }
  .analyzer-workspace,
  .recommend-form,
  .analyzer-form {
    padding: var(--space-4);
  }
  .result-card__balls .lotto-ball {
    max-width: 31px;
    font-size: 0.72rem;
  }
  .lotto-ticket__grid {
    grid-auto-rows: minmax(28px, 1fr);
    row-gap: 12px;
    column-gap: 4px;
    padding: 18px 3px 16px;
  }
  .lotto-ticket__cell {
    min-height: 28px;
    font-size: 0.78rem;
  }
  .lotto-ticket__corner {
    width: 8px;
    height: 6px;
  }
}

@media (min-width: 480px) {
  .hero { padding: var(--space-7) 0; }
  .hero__inner { padding: var(--space-7) var(--space-6); }
  .hero__title { font-size: 1.95rem; }
  .hero__actions { flex-direction: row; justify-content: center; }
  .hero__actions .btn { width: auto; min-width: 200px; }
  .recommend-form__actions { flex-direction: row; }
  .recommend-form__actions .btn { flex: 1; }
  .analyzer-form__actions { flex-direction: row; }
  .analyzer-form__actions .btn { flex: 1; }
  .number-inputs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .number-input input { font-size: 1.05rem; }
  .result-card__balls { gap: 5px; }
  .lotto-ball { width: 38px; height: 38px; font-size: 0.92rem; }
  .result-card__balls .lotto-ball { width: min(36px, 100%); height: auto; }
}

@media (min-width: 600px) {
  .site-footer__grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr;
    gap: var(--space-6);
  }
  .page-hero__title { font-size: 2.05rem; }
  .prose { padding: var(--space-7) var(--space-6); font-size: 1rem; }
}

@media (min-width: 640px) {
  :root { --container-max: 760px; }
  .hero__inner { padding: var(--space-8) var(--space-7); }
  .hero__title { font-size: 2.25rem; }
  .section__title { font-size: 1.4rem; }
  .section__title::before { height: 20px; }
  .mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .results-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
  }
  .lotto-ball { width: 40px; height: 40px; font-size: 1rem; }
  .result-card__balls { gap: 6px; }
  .result-card__balls .lotto-ball { width: min(36px, 100%); height: auto; font-size: 0.9rem; }
  .analyzer-workspace {
    grid-template-columns: minmax(260px, 0.95fr) minmax(0, 1.05fr);
    align-items: stretch;
    gap: var(--space-4);
  }
  .lotto-ticket,
  .analyzer-result {
    min-height: 460px;
    height: 100%;
  }
  .lotto-ticket__grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .analyzer-result__balls { justify-content: flex-start; }
}

@media (min-width: 900px) {
  :root { --container-max: 880px; }
  .hero__title { font-size: 2.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .result-card:hover { transform: none; }
}
