/* ── 공통 디자인 토큰 (CLAUDE.md 1.4 / DESIGN.md) ── */
:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-soft: #dbeafe;
  --color-secondary: #16a34a;
  --color-secondary-soft: #dcfce7;
  --color-gold: #f59e0b;
  --color-danger: #dc2626;
  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-canvas: #ffffff;
  --color-surface: #f8fafc;
  --color-surface-soft: #f1f5f9;
  --color-hairline: #e2e8f0;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-2: 0 8px 24px rgba(15, 23, 42, 0.10);
  --shadow-3: 0 20px 60px rgba(15, 23, 42, 0.18);
  --font-main: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  --font-display: 'Jua', var(--font-main);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  background: var(--color-surface);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--color-primary); text-decoration: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  background: var(--color-primary);
  color: #fff;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s;
  box-shadow: var(--shadow-1);
}
.btn:hover { background: var(--color-primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--color-primary); border-color: var(--color-primary-soft); box-shadow: none; }
.btn-ghost:hover { background: var(--color-primary-soft); }
.btn-secondary { background: var(--color-secondary); }
.btn-secondary:hover { background: #15803d; }
.btn-lg { padding: 1.125rem 2rem; font-size: 1.125rem; }

.card {
  background: var(--color-canvas);
  border: 1px solid var(--color-hairline);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-1);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
}

.tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface-soft);
  color: var(--color-text-muted);
  font-weight: 600;
}
.tag.tag-new { background: var(--color-secondary-soft); color: #166534; }
.tag.tag-live { background: #fee2e2; color: #b91c1c; }

.hidden { display: none !important; }
.invisible { visibility: hidden; }

/* ── 카운트다운 링 ── */
.countdown {
  --size: 80px;
  --pct: 1; /* 1 → full, 0 → empty */
  width: var(--size);
  height: var(--size);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.countdown svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.countdown circle { fill: none; stroke-width: 8; }
.countdown circle.track { stroke: var(--color-hairline); }
.countdown circle.bar {
  stroke: var(--color-primary);
  stroke-linecap: round;
  stroke-dasharray: var(--circ);
  stroke-dashoffset: calc(var(--circ) * (1 - var(--pct)));
  transition: stroke-dashoffset 0.25s linear, stroke 0.2s;
}
.countdown.warn circle.bar { stroke: var(--color-gold); }
.countdown.danger circle.bar { stroke: var(--color-danger); }
.countdown .label {
  position: absolute;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--color-text);
}

/* ── 모달 알림 (간단 토스트) ── */
.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-weight: 600;
  font-size: 0.9375rem;
  max-width: 320px;
}

/* 키패드 가림 방지 */
input:focus { scroll-margin-top: 100px; }

/* ── 아바타 (3×3 스프라이트 슬라이싱) ──
   - 각 PNG는 3×3 그리드. background-size:300% → 셀 1개가 칩 크기와 일치.
   - background-position 0% / 50% / 100% 조합으로 9칸 매핑. */
.avatar-chip {
  display: inline-block;
  flex-shrink: 0;
  background-repeat: no-repeat;
  background-size: 300% 300%;
  vertical-align: middle;
  user-select: none;
}

/* 아바타 그리드 (닉네임 입력 단계) */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
}
.avatar-tile {
  border: 3px solid transparent;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.25rem 0.375rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: border-color 0.12s, transform 0.1s, background 0.12s;
}
.avatar-tile:active { transform: scale(0.96); }
.avatar-tile.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.avatar-tile .face {
  width: 68px;
  height: 68px;
  background-repeat: no-repeat;
  background-size: 300% 300%;
}
.avatar-tile .name {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--color-text-muted);
}
.avatar-tile.selected .name { color: var(--color-primary-dark); }

@media (min-width: 480px) {
  .avatar-tile .face { width: 76px; height: 76px; }
}

/* 스타일(plain/deco/sunglass) 토글 행 — 각 버튼에 현재 동물 썸네일 + 라벨 */
.avatar-style-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 1rem;
}
.avatar-style-row button {
  flex: 1;
  padding: 0.5rem 0.5rem;
  border: 2px solid var(--color-hairline);
  background: #fff;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}
.avatar-style-row button .avatar-chip {
  width: 44px;
  height: 44px;
}
.avatar-style-row button.selected {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
}

/* 큰 미리보기 */
.avatar-preview {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
}
.avatar-preview .avatar-chip {
  width: 112px;
  height: 112px;
}
