/* ===== 로또핏 - Miro Design System ===== */

/* CSS Variables (Miro-inspired) */
:root {
  /* 색상 토큰 = RGB 채널(공백구분). Tailwind가 rgb(var(--x) / <alpha>)로 참조 → 다크는 값만 교체 */
  /* 면 구분형(2026-11): 연회색 바탕 + 흰 카드. 카드 테두리 대신 명도 차이로 구분 */
  --background: 242 244 247;
  --foreground: 28 28 30;
  --card: 255 255 255;
  --card-foreground: 28 28 30;
  --muted: 235 238 243;
  --muted-foreground: 85 90 106;
  --border: 222 226 232;
  --input: 233 234 239;
  --primary: 91 118 254;
  --primary-foreground: 255 255 255;
  --primary-pressed: 42 65 182;
  /* 작은 텍스트/링크용 — #5b76fe는 흰바탕 3.84:1(AA 미달)이라, 텍스트는 AA 통과(5.7:1) 진한 톤 */
  --primary-text: 66 87 224;
  --secondary: 235 238 243;
  --secondary-foreground: 28 28 30;
  --accent: 229 233 239;
  --accent-foreground: 28 28 30;
  --destructive: 239 68 68;
  --success: 0 180 115;
  --ring: rgb(224, 226, 232);
  --radius: 0.625rem;

  /* Miro Pastel Accents */
  --pastel-coral: #ffc6c6;
  --pastel-coral-dark: #600000;
  --pastel-rose: #ffd8f4;
  --pastel-teal: #c3faf5;
  --pastel-teal-dark: #187574;
  --pastel-orange: #ffe6cd;
  --pastel-yellow: #fff8e1;
  --pastel-pink: #fde0f0;
  --pastel-red: #fbd4d4;
}

/* ===== 다크 모드 ===== (로드 시 inline 스크립트가 html에 .dark/.light를 명시 지정) */
html.dark {
  color-scheme: dark;
  --background: 15 17 21;
  --foreground: 230 231 234;
  --card: 24 27 34;
  --card-foreground: 230 231 234;
  --muted: 31 35 43;
  --muted-foreground: 160 166 180;
  --border: 44 49 60;
  --input: 36 41 51;
  --primary: 124 145 255;
  --primary-foreground: 255 255 255;
  --primary-pressed: 170 184 255;
  --primary-text: 147 164 255;
  --secondary: 31 35 43;
  --secondary-foreground: 230 231 234;
  --accent: 38 43 53;
  --accent-foreground: 230 231 234;
  --destructive: 248 113 113;
  --success: 52 211 153;
}
/* 리터럴 흰 배경/하드코딩 그림자를 다크 토큰으로 전환 (Tailwind 유틸은 토큰 참조라 자동 전환됨) */
html.dark body { background-color: rgb(var(--background)); color: rgb(var(--foreground)); }
html.dark .bg-white { background-color: rgb(var(--card)) !important; }
html.dark .ring-border { box-shadow: rgb(var(--border)) 0px 0px 0px 1px !important; }
html.dark .card-hover:hover { box-shadow: rgb(var(--border)) 0px 0px 0px 1px, 0 4px 12px rgba(0,0,0,0.4); }
html.dark ::-webkit-scrollbar-thumb { background: #3a3f4a; }
html.dark .mode-btn.active { background-color: rgb(var(--primary) / 0.16) !important; }
html.dark .chip-text-input { background: rgb(var(--input)); box-shadow: rgb(var(--border)) 0px 0px 0px 1px; }
/* 반투명 흰 헤더/서브바(bg-white/95·/60 등 opacity 변형)는 .bg-white 매칭 안 돼 따로 처리 */
html.dark header { background-color: rgb(var(--card) / 0.92) !important; }
html.dark .bg-white\/95, html.dark .bg-white\/90, html.dark .bg-white\/80, html.dark .bg-white\/70, html.dark .bg-white\/60, html.dark .bg-white\/50 { background-color: rgb(var(--card) / 0.92) !important; }
/* 인라인 라이트 하어라인 테두리(rgb(224,226,232)) → 다크 테두리 (헤더·햄버거·드롭다운·서브바) */
html.dark [style*="224, 226, 232"] { box-shadow: rgb(var(--border)) 0px 0px 0px 1px !important; }
/* 테마 토글 아이콘 스왑: 라이트=달, 다크=해 */
html.dark .theme-moon { display: none; }
html.dark .theme-sun { display: block; }

/* 애니메이션 */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes dailyPop {
  from { opacity: 0; transform: scale(0) rotate(-20deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.fade-up { animation: fadeUp 0.3s ease-out both; }
.pop-in { animation: popIn 0.2s ease-out both; }
.slide-down { animation: slideDown 0.15s ease-out both; }

/* 결과 카드 순차 애니메이션 */
.result-item:nth-child(2) { animation: fadeUp 0.3s ease-out 0.05s both; }
.result-item:nth-child(3) { animation: fadeUp 0.3s ease-out 0.1s both; }
.result-item:nth-child(4) { animation: fadeUp 0.3s ease-out 0.15s both; }
.result-item:nth-child(5) { animation: fadeUp 0.3s ease-out 0.2s both; }
.result-item:nth-child(6) { animation: fadeUp 0.3s ease-out 0.25s both; }
.result-item:nth-child(7) { animation: fadeUp 0.3s ease-out 0.3s both; }
.result-item:nth-child(8) { animation: fadeUp 0.3s ease-out 0.35s both; }
.result-item:nth-child(9) { animation: fadeUp 0.3s ease-out 0.4s both; }
.result-item:nth-child(10) { animation: fadeUp 0.3s ease-out 0.45s both; }
.result-item:nth-child(11) { animation: fadeUp 0.3s ease-out 0.5s both; }

/* 로또 볼 - 실사 유광 구체 (좌상단 하이라이트 + 하단 음영으로 입체감) */
.ball-shadow {
  background-image: radial-gradient(circle at 34% 28%, rgba(255,255,255,0.65), rgba(255,255,255,0.08) 44%, rgba(0,0,0,0.10) 100%);
  box-shadow:
    inset 0 -4px 6px rgba(0,0,0,0.22),
    inset 0 2px 3px rgba(255,255,255,0.55),
    0 2px 4px rgba(0,0,0,0.18);
  text-shadow: 0 1px 0 rgba(255,255,255,0.35);
}

/* Miro ring-shadow border */
.ring-border {
  box-shadow: rgb(224, 226, 232) 0px 0px 0px 1px;
}

/* 테이블 반응형 */
@media (max-width: 640px) {
  table { font-size: 0.8rem; }
  table th, table td { padding: 0.5rem; }
}

/* 광고 플레이스홀더 */
.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}

/* 스크롤바 (Miro minimal) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7cad5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a5a8b5; }

/* 모드 버튼 활성 상태 */
.mode-btn.active {
  border-color: rgb(var(--primary)) !important;
  background-color: #eff2ff !important;
  color: rgb(var(--primary)) !important;
}

/* Miro-style focus ring */
.focus-ring:focus-visible {
  outline: 2px solid rgb(var(--primary));
  outline-offset: 2px;
}

/* 브랜드 텍스트 대비(WCAG AA) — text-primary는 진한 톤으로. 채움(bg/ring/border-primary)은 그대로 #5b76fe.
   style.css는 tailwind 뒤 로드 + unlayered라 레이어드 유틸리티를 이김. */
.text-primary { color: rgb(var(--primary-text)); }
a.text-primary:hover, .hover\:text-primary:hover { color: rgb(var(--primary-pressed)); }

/* Miro card hover effect */
.card-hover {
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}
.card-hover:hover {
  box-shadow: rgb(224, 226, 232) 0px 0px 0px 1px, 0 4px 12px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

/* Miro pastel backgrounds */
.bg-pastel-coral { background-color: var(--pastel-coral); }
.bg-pastel-rose { background-color: var(--pastel-rose); }
.bg-pastel-teal { background-color: var(--pastel-teal); }
.bg-pastel-orange { background-color: var(--pastel-orange); }
.bg-pastel-yellow { background-color: var(--pastel-yellow); }
.bg-pastel-pink { background-color: var(--pastel-pink); }

/* 슬롯머신 스타일 */
.reel-wrapper {
  width: 48px;
  height: 80px;
}
.reel-wrapper.bonus {
  width: 56px;
}
.reel-window {
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #1c1c1e 0%, #2a2a2e 50%, #1c1c1e 100%);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
  transition: box-shadow 0.2s, transform 0.1s;
}
.reel-window:hover {
  transform: scale(1.03);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 8px rgba(91,118,254,0.3);
}
.reel-window.bonus {
  border: 2px solid #c7cad5;
}
.reel {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
}
.reel-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.reel-item {
  width: 48px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
}
.reel-wrapper.bonus .reel-item {
  width: 56px;
}
#lever:active {
  transform: rotate(30deg);
}

/* ===== 번호 칩 입력 ===== */
.chip-input-wrapper {
  position: relative;
}
.chip-text-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  background: #ffffff;
  border-radius: 0.75rem;
  outline: none;
  box-shadow: rgb(224, 226, 232) 0px 0px 0px 1px;
  transition: box-shadow 0.15s;
}
.chip-text-input:focus {
  box-shadow: rgb(224, 226, 232) 0px 0px 0px 1px, #5b76fe 0px 0px 0px 3px;
}
.chip-text-input:disabled {
  background: #f5f5f7;
  color: #a5a8b5;
  cursor: not-allowed;
}
.chip-hint {
  font-size: 0.6875rem;
  color: #a5a8b5;
  margin-top: 0.375rem;
}
.chip-balls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.625rem;
  min-height: 2.25rem;
}
.chip-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.chip-ball:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.chip-ball:active {
  transform: scale(0.95);
}
.chip-ball.chip-amber   { background: #fbbf24; color: #78350f; }
.chip-ball.chip-sky     { background: #38bdf8; color: #0c4a6e; }
.chip-ball.chip-rose    { background: #fb7185; color: #881337; }
.chip-ball.chip-violet  { background: #a78bfa; color: #3b0764; }
.chip-ball.chip-emerald { background: #34d399; color: #064e3b; }

/* 스켈레톤 로딩 */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 애드핏: 광고가 실제로 채워졌을 때만 위아래 여백 (미노출 시 ins가 display:none → 여백 0) */
ins.kakao_ad_area { margin-top: 1.5rem; margin-bottom: 1.5rem; }

/* 가로 스크롤 탭·칩 줄: 스크롤바 숨김 (표처럼 스크롤 여부를 알려야 하는 곳에는 쓰지 않음) */
.no-scrollbar { scrollbar-width: none; }
.no-scrollbar::-webkit-scrollbar { display: none; }

/* ===== 면 구분형 카드 (라이트 모드) =====
   흰 카드(.bg-card/.bg-white)의 테두리를 없애고 연회색 바탕과의 명도 차이로 구분한다.
   버튼·입력칸은 테두리를 유지(흰 카드 위에서 경계가 사라지면 안 됨). 다크 모드는 원래 이 방식. */
html:not(.dark) main :is(.bg-card, .bg-white):is(.ring-border, .border, .ring-1):not(button, input, select, textarea) {
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
  border-color: transparent !important;
}
/* 카드 안의 카드: 테두리 대신 연회색 면 */
html:not(.dark) main :is(.bg-card, .bg-white) :is(.bg-card, .bg-white):is(.ring-border, .border, .ring-1):not(button, input, select, textarea) {
  background-color: rgb(245 247 250) !important;
  box-shadow: none !important;
}
/* 회색 면 + 테두리 상자(안내 박스 등): 바탕 위에선 흰 카드로, 카드 안에선 연회색 면으로 */
html:not(.dark) main :is(.bg-muted, .bg-muted\/40, .bg-muted\/50):is(.ring-border, .border):not(button, input, select, textarea) {
  background-color: rgb(var(--card)) !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04) !important;
  border-color: transparent !important;
}
html:not(.dark) main :is(.bg-card, .bg-white) :is(.bg-muted, .bg-muted\/40, .bg-muted\/50):is(.ring-border, .border):not(button, input, select, textarea) {
  background-color: rgb(245 247 250) !important;
  box-shadow: none !important;
}
/* 표 머리줄: bg-muted/50는 흰 카드 위에서 바탕 회색과 같아져 카드 윗변이 사라짐 → 바탕보다 밝은 면 */
html:not(.dark) main thead :is(tr, th):is(.bg-muted, .bg-muted\/40, .bg-muted\/50) { background-color: rgb(249 250 252) !important; }
/* 회색 칩·토글 버튼(비선택 상태): 연회색 바탕에 묻히므로 흰 면 + 얇은 테두리. JS가 bg-muted를 붙였다 뗐다 하므로 클래스 기준 */
html:not(.dark) main :is(button, a, select):is(.bg-muted, .bg-muted\/60) {
  background-color: rgb(var(--card)) !important;
  box-shadow: inset 0 0 0 1px rgb(var(--border));
}
html:not(.dark) main :is(button, a, select):is(.bg-muted, .bg-muted\/60):hover { background-color: rgb(var(--accent)) !important; }
/* 세그먼트 탭 틀(판매점 1등/2등): 틀은 흰 면, 선택 탭은 연회색 면 */
html:not(.dark) main #rank-tabs { background-color: rgb(var(--card)); box-shadow: inset 0 0 0 1px rgb(var(--border)); }
html:not(.dark) main #rank-tabs .rank-tab.bg-card { background-color: rgb(var(--muted)) !important; }
