/* =========================================================
   히트송 — 연보라 테마
   ========================================================= */
:root {
  color-scheme: light;
  --lav-50:  #F6F2FD;
  --lav-100: #ECE4FB;
  --lav-200: #DCCFF7;
  --lav-300: #C4B0F0;
  --lav-400: #AB93E6;   /* 대표색 (연보라) */
  --lav-500: #9C84E0;
  --lav-600: #7E62CF;   /* 흰 글씨 버튼용 */
  --lav-700: #6547B8;
  --ink:     #2E2350;
  --ink-2:   #6B5F8C;
  --white:   #FFFFFF;
  --danger:  #D64C6A;
  --radius:  20px;
  --shadow:  0 10px 30px rgba(101, 71, 184, .15);
  --font: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, var(--lav-200) 0, transparent 45%),
    radial-gradient(circle at 100% 100%, var(--lav-200) 0, transparent 40%),
    var(--lav-50);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select: none;
  user-select: none;
}

[hidden] { display: none !important; }

/* ---------- 헤더 ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 8px;
}
.top-logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: var(--shadow); }
.top h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.top p  { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.chip {
  margin-left: auto;
  border: 1px solid var(--lav-300);
  background: var(--white);
  color: var(--lav-700);
  border-radius: 999px;
  padding: 8px 12px;
  font: 600 12px var(--font);
}

/* ---------- 연도 범위 ---------- */
.range {
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: 4px 16px 0;
}
/* 분류 체크칸 */
.cats { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.cat { flex: 1; min-width: 0; }
.cat input { position: absolute; opacity: 0; pointer-events: none; }
.cat span {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 42px; border-radius: 14px;
  background: var(--white); border: 1.5px solid var(--lav-200);
  font: 700 15px var(--font); color: var(--ink-2);
  box-shadow: var(--shadow); cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.cat span small { font-size: 11px; font-weight: 700; opacity: .75; }
.cat input:checked + span { background: var(--lav-600); border-color: var(--lav-600); color: var(--white); }
.cat input:focus-visible + span { outline: 2px solid var(--lav-500); outline-offset: 2px; }
.cat input:disabled + span { opacity: .45; cursor: default; box-shadow: none; }
.range.locked .cat span { box-shadow: none; cursor: not-allowed; }
.range.locked .cat input:not(:checked) + span { opacity: .4; }
.range.locked .cat input:checked + span { opacity: 1; background: var(--lav-500); border-color: var(--lav-500); color: var(--white); }

.range-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--white); border-radius: 16px; box-shadow: var(--shadow);
  padding: 8px 10px;
}
.range-row select {
  flex: 1; min-width: 0;
  appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--lav-200); border-radius: 12px;
  background: var(--lav-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%237E62CF' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding: 10px 30px 10px 14px;
  font: 800 18px var(--font); color: var(--lav-700);
  text-align: center; text-align-last: center;
}
.range-row select:focus { outline: 0; border-color: var(--lav-500); }
.range-sep { font-weight: 800; color: var(--lav-500); font-size: 18px; }
.range-info { margin: 6px 4px 0; font-size: 13px; color: var(--ink-2); text-align: center; }
.range-info.warn { color: var(--danger); font-weight: 600; }
/* 게임 중: 연도 잠금 */
.range.locked .range-row { background: var(--lav-100); box-shadow: none; }
.range.locked select {
  opacity: 1; color: var(--lav-700); cursor: not-allowed;
  background-image: none; padding-right: 14px; border-color: transparent; background-color: var(--white);
}
.range.locked .range-info::before { content: '🔒 '; }

/* ---------- 레이아웃 ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  display: flex;
}
.view { flex: 1; display: flex; flex-direction: column; gap: 16px; justify-content: center; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
}
.card h2 { margin: 18px 0 6px; font-size: 20px; }
.muted  { color: var(--ink-2); font-size: 15px; line-height: 1.5; margin: 0; word-break: keep-all; }
.center { text-align: center; }

/* ---------- 버튼 ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 16px;
  padding: 16px 14px;
  font: 700 16px var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease;
  min-height: 56px;
}
.btn:active { transform: scale(.97); }
.btn .ico { font-size: 1.15em; line-height: 1; }
.btn.big { width: 100%; font-size: 18px; min-height: 64px; }
.btn.primary { background: var(--lav-600); color: var(--white); box-shadow: 0 8px 20px rgba(126, 98, 207, .35); }
.btn.primary:active { background: var(--lav-700); }
.btn.soft { background: var(--lav-100); color: var(--lav-700); }
.btn.soft:active { background: var(--lav-200); }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--lav-300); }

.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-row .btn { width: 100%; font-size: 15px; line-height: 1.3; word-break: keep-all; padding: 12px 10px; }
.end-btn {
  align-self: center; min-height: 40px; padding: 8px 18px;
  background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 600;
  border: 1px solid var(--lav-200); border-radius: 999px;
}
.end-btn.confirm { color: var(--white); background: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: .45; cursor: default; transform: none; box-shadow: none; }

/* ---------- 처음 화면 그림 ---------- */
.hero-art {
  position: relative;
  width: 150px; height: 150px;
  margin: 4px auto 0;
  border-radius: 36px;
  background: linear-gradient(145deg, var(--lav-300), var(--lav-500));
  display: grid; place-items: center;
}
.hero-disc {
  width: 84px; height: 84px; border-radius: 50%;
  background:
    radial-gradient(circle, var(--lav-50) 0 13px, var(--lav-200) 13px 19px, transparent 19px),
    repeating-radial-gradient(circle, rgba(255,255,255,.10) 0 2px, transparent 2px 6px),
    conic-gradient(from 30deg, var(--lav-700), var(--lav-500), var(--lav-300), var(--lav-500), var(--lav-700));
  box-shadow: 0 6px 16px rgba(101, 71, 184, .35);
  animation: spin 6s linear infinite;
}
.note {
  position: absolute; color: var(--lav-500); font-size: 26px; font-weight: 700;
  animation: float 3s ease-in-out infinite;
}
.n1 { top: -14px; right: -18px; }
.n2 { bottom: -6px; right: -26px; animation-delay: .8s; font-size: 30px; }
.n3 { top: 36px; left: -30px; animation-delay: 1.6s; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- 재생 화면 ---------- */
.player-card { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.q-no {
  background: var(--lav-100); color: var(--lav-700);
  border-radius: 999px; padding: 6px 16px; font-weight: 700; font-size: 15px;
}
.q-no b { font-size: 20px; }

.stage { position: relative; width: 220px; height: 220px; }

/* 유튜브 iframe: 원판보다 작고 둥글게 잘라서 뒤에 숨기고, 거의 투명하게 만듦
   (완전히 숨기면(display:none, opacity:0) 브라우저가 재생을 막을 수 있어서 0.01) */
.yt-wrap {
  position: absolute; left: 50%; top: 50%;
  width: 140px; height: 140px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  overflow: hidden;
  opacity: .01;
  z-index: 0;
  pointer-events: none;
}
.yt-wrap iframe { width: 100%; height: 100%; border: 0; }

.disc {
  position: absolute; inset: 0; z-index: 2;
  border: 0; padding: 0; cursor: pointer;
  border-radius: 50%;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.07) 0 2px, transparent 2px 7px),
    conic-gradient(from 30deg, var(--lav-700), var(--lav-500), var(--lav-300), var(--lav-500), var(--lav-700));
  box-shadow: 0 14px 30px rgba(101, 71, 184, .35), inset 0 0 0 6px rgba(255,255,255,.15);
  display: grid; place-items: center;
}
.disc-center {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--lav-50);
  box-shadow: inset 0 0 0 10px var(--lav-200);
}
.disc.spin { animation: spin 3.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.eq {
  position: absolute; z-index: 3; left: 50%; bottom: -6px; transform: translateX(-50%);
  display: flex; gap: 4px; align-items: flex-end; height: 26px;
  background: var(--white); padding: 5px 10px; border-radius: 999px;
  box-shadow: 0 4px 12px rgba(101, 71, 184, .2);
  opacity: 0; transition: opacity .2s;
}
.eq.on { opacity: 1; }
.eq i { width: 4px; height: 6px; border-radius: 2px; background: var(--lav-600); }
.eq.on i { animation: eq 0.9s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: .15s; }
.eq i:nth-child(3) { animation-delay: .3s; }
.eq i:nth-child(4) { animation-delay: .45s; }
.eq i:nth-child(5) { animation-delay: .6s; }
@keyframes eq { 0%,100% { height: 5px; } 50% { height: 16px; } }

/* 들은 시간 */
.listen {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--lav-100); color: var(--ink-2);
  border-radius: 999px; padding: 5px 14px;
  font-size: 14px; font-weight: 700;
  transition: background .2s, color .2s;
}
.listen b { font-size: 22px; font-weight: 800; color: var(--lav-700); font-variant-numeric: tabular-nums; }
.listen.short { background: #FFF1DD; color: #A35A00; }
.listen.short b { color: #D97706; }
.listen.ok { background: #E3F7EA; color: #1F7A3E; }
.listen.ok b { color: #1F9D4C; }
.listen.ok::after { content: '✓'; font-weight: 800; margin-left: 2px; }

.status { margin: 4px 0 0; font-size: 15px; color: var(--ink-2); min-height: 1.5em; }
.status.error { color: var(--danger); font-weight: 600; }

/* ---------- 재생 시작 위치 ---------- */
.seek { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.seek-row { display: flex; align-items: stretch; gap: 8px; }
.rewind-btn {
  min-height: 0; padding: 6px 14px; border-radius: 16px;
  font-size: 15px; white-space: nowrap;
}
.rewind-btn .ico { font-size: 18px; margin-right: 2px; }
.seek-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--lav-50); border: 2px solid var(--lav-200); border-radius: 16px;
  padding: 6px 14px;
}
.seek-input:focus-within { border-color: var(--lav-500); background: var(--white); }
.seek-input input {
  width: 96px; border: 0; background: transparent; outline: 0;
  font: 800 30px var(--font); color: var(--lav-700); text-align: right;
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.seek-input input::-webkit-outer-spin-button,
.seek-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.seek-input span { font-size: 16px; font-weight: 700; color: var(--ink-2); }
.seek-total { margin: 0; font-size: 14px; color: var(--ink-2); }
.seek-total b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- 정답 ---------- */
.answer-btn {
  width: 100%; min-height: 46px; font-size: 15px;
  background: transparent; color: var(--lav-700);
  border: 1.5px dashed var(--lav-300);
}
.answer-btn:active { background: var(--lav-50); }
.answer {
  width: 100%;
  background: linear-gradient(145deg, var(--lav-100), var(--lav-50));
  border-radius: 16px;
  padding: 14px 16px 16px;
  animation: pop .25s ease-out;
}
.ans-year {
  font-size: 40px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em;
  color: var(--lav-700); font-variant-numeric: tabular-nums;
}
.ans-year.none { font-size: 16px; color: var(--ink-2); font-weight: 600; }
.ans-title { font-size: 19px; font-weight: 800; margin-top: 6px; word-break: keep-all; overflow-wrap: anywhere; }
.ans-artist { font-size: 15px; color: var(--ink-2); margin-top: 2px; }
.ans-cat {
  display: inline-block; margin-bottom: 4px;
  background: var(--white); color: var(--lav-700);
  border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 800;
}
.ans-quote {
  margin-top: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--white); color: var(--ink);
  font-size: 15px; font-weight: 600; line-height: 1.5; word-break: keep-all;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- 토스트 ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--ink); color: var(--white);
  padding: 12px 18px; border-radius: 14px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  z-index: 10;
}

@media (prefers-reduced-motion: reduce) {
  .note, .hero-disc, .disc.spin, .eq.on i { animation: none; }
}

/* ---------- 명대사 카드 (원판 아래) ---------- */
.quote-card {
  position: relative; display: block; box-sizing: border-box;
  width: 100%; align-self: stretch;
  margin: 6px 0 14px; padding: 26px 18px 24px;
  border-radius: 18px;
  color: #FBF8FF;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(171, 147, 230, .35), transparent 60%),
    linear-gradient(160deg, #3A2B6B 0%, #2A1F52 55%, #1E1640 100%);
  box-shadow: 0 14px 30px rgba(46, 35, 80, .28), inset 0 0 0 1px rgba(255, 255, 255, .06);
  overflow: hidden;
  text-align: center;
}
/* 위아래 필름 구멍 */
.quote-card::before, .quote-card::after {
  content: ''; position: absolute; left: 0; right: 0; height: 8px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.16) 0 10px, transparent 10px 20px);
  opacity: .7;
}
.quote-card::before { top: 7px; }
.quote-card::after { bottom: 7px; }
.quote-label {
  display: inline-block; margin-bottom: 10px;
  padding: 3px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); color: var(--lav-200);
  font-size: 12px; font-weight: 800; letter-spacing: .12em;
}
.quote-text {
  position: relative; margin: 0 auto; padding: 0 26px; max-width: 30em;
  font-family: "Gowun Batang", "Nanum Myeongjo", "AppleMyungjo", "Batang", "Noto Serif KR", serif;
  font-size: 23px; font-weight: 700; line-height: 1.5;
  word-break: keep-all; overflow-wrap: anywhere;
  text-shadow: 0 2px 12px rgba(171, 147, 230, .45);
}
.quote-text::before, .quote-text::after {
  position: absolute; font-family: Georgia, serif; font-size: 46px; line-height: 1;
  color: var(--lav-400); opacity: .75;
}
.quote-text::before { content: '\201C'; left: 0; top: -10px; }
.quote-text::after  { content: '\201D'; right: 0; bottom: -24px; }
.quote-card.long  .quote-text { font-size: 19px; }
.quote-card.xlong .quote-text { font-size: 16px; line-height: 1.6; }

/* 나타날 때: 카드가 떠오르고, 글자가 흐릿함에서 또렷해짐 */
.quote-card.show { animation: quoteIn .5s cubic-bezier(.2, .8, .2, 1) both; }
.quote-card.show .quote-text { animation: quoteFocus .9s .15s ease-out both; }
@keyframes quoteIn { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes quoteFocus { from { opacity: 0; filter: blur(6px); letter-spacing: .08em; } to { opacity: 1; filter: blur(0); letter-spacing: 0; } }
@media (prefers-reduced-motion: reduce) {
  .quote-card.show, .quote-card.show .quote-text { animation: none; }
}