@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400..800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@800&text=%E3%81%AA&display=swap');

:root {
  color-scheme: dark;
  /* nako family: black, neutral greys, pink on actions */
  --bg: #000000;
  --surface: #121212;
  --surface-2: #1c1c1c;
  --line: #262626;
  --text: #fafafa;
  --muted: #a1a1aa;
  --accent: #ec4899;
  --on-accent: #000000;
  --win: #4ade80;
  --lose: #ef4444;
  --skip: #fbbf24;
  --display: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --body: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* Album art wash behind the reveal */
.backdrop {
  position: fixed;
  inset: -80px -80px auto;
  height: 78vh;
  background-size: cover;
  background-position: center;
  filter: blur(90px) saturate(1.3);
  opacity: 0;
  transition: opacity 0.7s ease;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 30%, transparent);
  mask-image: linear-gradient(#000 30%, transparent);
}
.backdrop.on { opacity: 0.34; }

/* Top bar */
.topbar {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: baseline; gap: 12px; }

.brand-name {
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1;
}
.brand-name span {
  font-family: 'Noto Sans JP', 'Noto Sans CJK JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  font-size: 1.3em;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--accent);
  margin-right: -1px;
}

.catalog-pill { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.topbar-right { display: flex; align-items: center; gap: 20px; }

.stat { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }
.stat b {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-right: 4px;
}

.add-link {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: border-color 0.15s;
}
.add-link:hover { border-color: var(--text); }

/* Page column */
.shell {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 24px 64px;
}

[data-phase='reveal'] .only-play,
[data-phase='play'] .only-reveal { display: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 26px;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: transform 0.12s, opacity 0.15s;
}
.btn:hover:not(:disabled) { transform: scale(1.03); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }

.ghost-btn {
  background: none;
  border: none;
  color: var(--muted);
  min-height: 44px;
  padding: 0 4px;
  font-size: 0.85rem;
  font-weight: 600;
}
.ghost-btn:hover { color: var(--text); }

/* Pickers */
.controls { display: flex; gap: 8px; flex-wrap: wrap; }

.picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
}
.picker-btn:hover { border-color: var(--muted); }
.picker-btn[aria-expanded='true'] { background: var(--surface-2); border-color: var(--surface-2); }
.picker-btn small { font-size: 0.8rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.picker-btn svg { color: var(--muted); transition: transform 0.15s; }
.picker-btn[aria-expanded='true'] svg { transform: rotate(180deg); }

.drawer { padding: 18px 0 4px; }

.pl-group + .pl-group { margin-top: 16px; }
.pl-group-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.pl-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border-radius: 999px;
  border: none;
  background: var(--surface);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 40px;
  transition: background 0.12s;
}
.chip:hover { background: var(--surface-2); }
.chip small { font-size: 0.76rem; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip.active { background: var(--text); color: #000000; }
.chip.active small { color: #52525b; }
.pack-actions { display: flex; gap: 18px; margin-top: 6px; }

/* Two-ended slider: two range inputs stacked on one track */
.range { position: relative; height: 44px; }
.range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 20px;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-2);
}
.range-fill { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--text); }
.range input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 44px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.range input::-webkit-slider-runnable-track { background: none; height: 44px; }
.range input::-moz-range-track { background: none; }
.range input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: 11px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: grab;
  pointer-events: auto;
}
.range input::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--text);
  cursor: grab;
  pointer-events: auto;
}
.range input:focus-visible { outline: none; }
.range input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 3px; }
.range input:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent); outline-offset: 3px; }
.range-ends {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8rem;
  color: var(--muted);
}
.range-ends span:nth-child(2) { font-size: 0.92rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

/* Play deck */
.deck {
  position: relative;
  height: 220px;
  margin-top: 28px;
  display: grid;
  place-items: center;
}

.viz { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.play-btn {
  position: relative;
  width: 148px;
  height: 148px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-items: center;
}
.play-btn:disabled { cursor: default; }

.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring-track { stroke: var(--line); }
.ring-progress {
  stroke: var(--text);
  stroke-linecap: round;
  stroke-dasharray: 351.86;
  stroke-dashoffset: 351.86;
}

.play-face {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  transition: transform 0.14s, opacity 0.15s;
}
.play-btn:hover:not(:disabled) .play-face { transform: scale(1.04); }
.play-btn:active:not(:disabled) .play-face { transform: scale(0.97); }
.play-btn:disabled .play-face { opacity: 0.45; }

.clip-length {
  margin: 6px 0 0;
  min-height: 3.6rem;
  text-align: center;
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.clip-length.is-status { font-size: 1.1rem; font-weight: 600; letter-spacing: 0; color: var(--muted); line-height: 3.6rem; }

/* Six steps */
.steps { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 22px; }

.step i { display: block; height: 4px; border-radius: 4px; background: var(--surface-2); }
.step span {
  display: block;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #52525b;
  font-variant-numeric: tabular-nums;
}
.step.current i { background: var(--text); }
.step.current span { color: var(--text); }
.step.skipped i { background: #52525b; }
.step.skipped span { color: var(--muted); }
.step.wrong i { background: var(--lose); }
.step.wrong span { color: var(--lose); }
.step.artist i { background: var(--skip); }
.step.artist span { color: var(--skip); }
.step.won i { background: var(--win); }
.step.won span { color: var(--win); }

/* Guessing */
.guess-row { display: flex; gap: 8px; margin-top: 28px; }
.guess-wrap { position: relative; flex: 1; min-width: 0; }

.guess-input {
  width: 100%;
  height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--surface);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.guess-input:hover { background: var(--surface-2); }
.guess-input:focus { border-color: var(--text); background: var(--surface); }
.guess-input::placeholder { color: var(--muted); }

.btn-skip {
  height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s;
}
.btn-skip:hover:not(:disabled) { border-color: var(--text); }
.btn-skip:disabled { opacity: 0.4; cursor: default; }

.dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  padding: 6px;
  border-radius: 18px;
  background: var(--surface-2);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  max-height: 348px;
  overflow-y: auto;
}

.dd-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border: none;
  border-radius: 12px;
  background: transparent;
  text-align: left;
}
.dd-item:hover, .dd-item.selected { background: rgba(255, 255, 255, 0.09); }
.dd-cover { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--surface); flex-shrink: 0; }
.dd-meta { min-width: 0; }
.dd-title, .dd-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dd-title { font-size: 0.92rem; font-weight: 600; }
.dd-artist { font-size: 0.8rem; color: var(--muted); }

.guess-list { margin-top: 14px; }
.guess {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.guess span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guess em { font-style: normal; font-size: 0.8rem; font-weight: 600; flex-shrink: 0; }
.guess.skipped { color: var(--muted); }
.guess.wrong em { color: var(--lose); }
.guess.artist em { color: var(--skip); }
.guess.won em { color: var(--win); }

.sub-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  font-size: 0.8rem;
  color: #71717a;
}
kbd {
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface);
}

/* Reveal */
.reveal { display: grid; grid-template-columns: 232px 1fr; gap: 28px; align-items: end; margin-top: 36px; }

.reveal-cover {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.reveal-cover.loaded { opacity: 1; }

.reveal-info { min-width: 0; }

.result { font-size: 0.86rem; font-weight: 700; margin: 0 0 10px; color: var(--muted); }
.result.won { color: var(--win); }

.reveal-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.05;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.reveal-artist { margin: 10px 0 0; font-size: 1.1rem; font-weight: 600; }
.reveal-album { margin: 4px 0 0; font-size: 0.86rem; color: var(--muted); }

.scrubber-row { display: flex; align-items: center; gap: 14px; margin-top: 30px; }

.scrubber-btn {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.scrubber-btn:hover { background: #262626; }

.scrubber-track { flex: 1; padding: 18px 0; cursor: pointer; }
.scrubber-line { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.scrubber-fill { height: 100%; width: 0; background: var(--text); border-radius: 4px; }
.scrubber-time { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.reveal-actions { display: flex; align-items: center; gap: 22px; margin-top: 26px; }
.ext-link { font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.ext-link:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translate(-50%, 12px);
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--text);
  color: #000000;
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.artist { background: var(--skip); }
.toast.err { background: var(--lose); }

/* Add songs page */
.panel { margin-top: 28px; display: flex; flex-direction: column; gap: 16px; }
.panel + .panel { margin-top: 48px; }
.panel h2 { margin: 0; font-family: var(--display); font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.panel p { margin: 0; color: var(--muted); line-height: 1.55; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.inline-form { display: flex; gap: 8px; }
.stack-form { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }

.field-input, .field-textarea {
  width: 100%;
  border: 1px solid transparent;
  background: var(--surface);
  outline: none;
}
.field-input { height: 48px; padding: 0 20px; border-radius: 999px; }
.field-textarea { min-height: 132px; padding: 16px 20px; border-radius: 18px; resize: vertical; line-height: 1.5; font-size: 0.9rem; }
.field-input:focus, .field-textarea:focus { border-color: var(--text); }

.tag-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 600;
}
.tag-chip:hover { background: var(--surface-2); }
.tag-chip.active { background: var(--text); color: #000000; }

.track-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.track-row img { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; }
.track-row-info { flex: 1; min-width: 0; }
.track-row-title, .track-row-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-row-title { font-weight: 600; font-size: 0.92rem; }
.track-row-sub { font-size: 0.8rem; color: var(--muted); }
.track-row.failed .track-row-title { color: var(--lose); }
.badge-ok, .badge-dup { font-size: 0.8rem; font-weight: 700; }
.badge-ok { color: var(--win); }
.badge-dup { color: var(--skip); }
.btn-del {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}
.btn-del:hover { border-color: var(--lose); color: var(--lose); }

@media (max-width: 560px) {
  .topbar { padding: 16px 18px; }
  .catalog-pill { display: none; }
  .topbar-right { gap: 14px; }
  .shell { padding: 4px 18px 48px; }
  .deck { height: 190px; margin-top: 18px; }
  .reveal { grid-template-columns: 1fr; gap: 22px; margin-top: 26px; }
  .reveal-cover { max-width: 260px; }
  .inline-form { flex-direction: column; }
  .sub-actions { justify-content: flex-end; }
  .sub-actions span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
