:root {
  --body: #fff6fb;
  --bg-base: linear-gradient(160deg, #fff4fa, #f3f0ff 50%, #eefaff);
  --bg-glow: 0.32;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.75);
  --card-border: rgba(255, 255, 255, 0.9);
  --lead: #4a4470;
  --chip: #eef0f6;
  --chip-bad: #ffe3ee;
  --key-white: #ffffff;
  --key-black: #3a3260;
  --key-line: #e7e4f3;
  --warn: #b35c00;
  --stage: linear-gradient(170deg, #fff1f8, #f1edff 45%, #e9f8ff);
  --veil: rgba(255, 246, 251, 0.6);
  --shadow: rgba(124, 77, 255, 0.14);
  --pink: #ff3d8b;
  --orange: #ff8a00;
  --cyan: #00b3f0;
  --violet: #7c4dff;
  --ink: #2a1f5c;
  --muted: #7a7f99;
  --line: rgba(124, 77, 255, 0.14);
  --card: rgba(255, 255, 255, 0.82);
  --grad: linear-gradient(110deg, var(--pink), var(--orange) 50%, var(--violet));
  --grad-cool: linear-gradient(110deg, var(--cyan), var(--violet));
  --radius: var(--radius-4, 18px);
  --font: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --display: 'Unbounded', var(--font);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--body);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; }

.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60vmax 60vmax at 0% 0%, rgba(255, 61, 139, 0.32), transparent 60%),
    radial-gradient(55vmax 55vmax at 100% 10%, rgba(0, 179, 240, 0.3), transparent 60%),
    radial-gradient(60vmax 50vmax at 60% 110%, rgba(255, 138, 0, 0.3), transparent 60%),
    var(--bg-base);
}

/* 헤더 */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.02em;
}
nav { display: flex; gap: 4px; }
nav a {
  text-decoration: none;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
nav a:hover { color: var(--ink); background: var(--surface-soft); }
nav a.active { color: #fff; background: var(--grad); box-shadow: 0 6px 18px rgba(255, 61, 139, 0.3); }

main { max-width: 1120px; margin: 0 auto; padding: 0 16px 64px; }

/* 히어로 */
.hero { padding: 24px 0 28px; }
.hero h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(34px, 6.4vw, 68px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 0 0 14px;
  word-break: keep-all;
}
.small-hero { padding-bottom: 16px; }
.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lead { font-size: clamp(15px, 1.8vw, 18px); color: var(--lead); max-width: 620px; line-height: 1.6; margin: 0; word-break: keep-all; }
.small-lead { font-size: 15px; }

/* 카드 */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(124, 77, 255, 0.14), 0 2px 6px rgba(42, 31, 92, 0.05);
  padding: 22px;
  min-width: 0;
}
.side { display: grid; gap: 20px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 800; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-head h3 { margin: 0; }

.field { display: grid; gap: 6px; min-width: 0; }
.field span { font-size: 13px; font-weight: 700; color: var(--muted); }
input[type='text'],
input[type='number'],
select {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type='text']:focus,
input[type='number']:focus,
select:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 61, 139, 0.15); }

/* 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(124, 77, 255, 0.15); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 10px 26px rgba(255, 61, 139, 0.32); }
.btn.ghost { background: transparent; }
.btn.big { padding: 15px 22px; font-size: 16px; border-radius: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row > .btn { flex: 1 1 auto; }
.row.center { justify-content: center; }
.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; line-height: 1.7; word-break: keep-all; }
kbd {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 2px 0 var(--line);
}
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.6; }
.center { text-align: center; }

/* MIDI */
.chip {
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--muted);
  white-space: nowrap;
}
.chip.ok { background: linear-gradient(110deg, #10d39a, var(--cyan)); color: #fff; }
.chip.bad { background: var(--chip-bad); color: var(--pink); }
#midi-devices { margin: 10px 0; word-break: break-all; }
.piano { position: relative; height: 64px; margin: 6px 0 10px; display: flex; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.piano .w { flex: 1; background: var(--key-white); border-right: 1px solid var(--key-line); position: relative; transition: background 0.08s; }
.piano .w:last-child { border-right: 0; }
.piano .b { position: absolute; top: 0; width: 9%; height: 58%; background: var(--key-black); border-radius: 0 0 4px 4px; z-index: 1; transition: background 0.08s; }
.piano .zone { position: absolute; bottom: 4px; left: 0; right: 0; height: 5px; border-radius: 3px; margin: 0 3px; }
.mapping { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mapping div {
  text-align: center;
  border-radius: 10px;
  padding: 6px 2px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.mapping b { display: block; font-family: var(--display); font-size: 14px; }
.learn-msg { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 138, 0, 0.12); color: var(--warn); font-weight: 700; }
.settings { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.settings summary { cursor: pointer; font-weight: 800; font-size: 14px; }
.range { display: grid; gap: 6px; margin-top: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.range span { display: flex; justify-content: space-between; }
.range b { color: var(--ink); }
input[type='range'] { width: 100%; accent-color: var(--pink); }

.rank-SS { background: linear-gradient(110deg, #ff3d8b, #ff8a00, #ffd400, #00b3f0, #7c4dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank-S { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank-A { color: var(--orange); }
.rank-B { color: var(--cyan); }
.rank-C { color: #10b981; }
.rank-D { color: var(--muted); }

/* 리더보드 */
.song-board { margin-top: 22px; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-size: 14px;
}
.board li.muted { display: block; text-align: center; color: var(--muted); }
.board li.me { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(255, 61, 139, 0.12); }
.board .pos { font-family: var(--display); font-weight: 900; text-align: center; color: var(--muted); }
.board li:nth-child(1) .pos { color: var(--orange); }
.board li:nth-child(2) .pos { color: var(--violet); }
.board li:nth-child(3) .pos { color: var(--cyan); }
.board .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.board .who small { font-weight: 500; color: var(--muted); margin-left: 6px; }
.board .val { font-family: var(--display); font-weight: 800; font-size: 13px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.board .val .rk { font-weight: 900; }
.big-board li { padding: 13px 14px; }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.tab.active { background: var(--grad); color: #fff; border-color: transparent; }

/* 플레이 화면 */
.stage { position: fixed; inset: 0; z-index: 50; background: var(--stage); }
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(40vmax 40vmax at 10% 20%, rgba(255, 61, 139, 0.25), transparent 60%),
    radial-gradient(40vmax 40vmax at 90% 70%, rgba(0, 179, 240, 0.25), transparent 60%);
  animation: pulse 2.4s ease-in-out infinite alternate;
}
@keyframes pulse { to { opacity: 0.55; } }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.quit {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 800;
  font-size: 12px;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(42, 31, 92, 0.1);
}

.result { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 16px; background: var(--veil); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); overflow-y: auto; }
.result-card {
  width: min(520px, 100%);
  background: var(--surface);
  border-radius: 24px;
  padding: 26px;
  box-shadow: 0 30px 80px rgba(124, 77, 255, 0.25);
  animation: pop 0.45s var(--ease-spring-3, cubic-bezier(0.2, 1.4, 0.4, 1));
}
@keyframes pop { from { transform: scale(0.88) translateY(20px); opacity: 0; } }
.result-top { display: flex; align-items: center; gap: 20px; }
.rank-letter { font-family: var(--display); font-weight: 900; font-size: 96px; line-height: 1; min-width: 110px; text-align: center; }
.r-score { font-family: var(--display); font-weight: 900; font-size: clamp(30px, 8vw, 40px); letter-spacing: -0.02em; }
.r-combo { font-size: 13px; color: var(--muted); font-weight: 700; }
.r-combo b { color: var(--ink); font-family: var(--display); }
.judges { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0; }
.j { border-radius: 14px; padding: 10px 6px; text-align: center; color: #fff; }
.j span { display: block; font-family: var(--display); font-size: 10px; font-weight: 800; opacity: 0.95; }
.j b { font-family: var(--display); font-size: 22px; }
.j.perfect { background: linear-gradient(120deg, var(--pink), var(--orange)); }
.j.great { background: linear-gradient(120deg, var(--cyan), var(--violet)); }
.j.good { background: linear-gradient(120deg, #10d39a, var(--cyan)); }
.j.miss { background: linear-gradient(120deg, #a5acbd, #c4c9d6); }
.places { text-align: center; font-weight: 700; margin: 14px 0 0; line-height: 1.6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(42, 31, 92, 0.3);
  max-width: calc(100% - 32px);
}

@media (max-width: 860px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .card { padding: 16px; }
  .result-card { padding: 18px; }
  .result-top { gap: 12px; }
  .rank-letter { font-size: 68px; min-width: 76px; }
  .judges { gap: 6px; }
  .j b { font-size: 18px; }
  .top { padding: 14px 16px; }
  .logo span { font-size: 17px; }
  nav a { padding: 7px 10px; font-size: 14px; }
}

/* ---------- 공용 추가 ---------- */
.btn.wide { width: 100%; }
.btn.icon { padding: 10px 12px; }
.row.col { flex-direction: column; }
.row.col > .btn { width: 100%; }
.field { margin-top: 12px; }
.field:first-child { margin-top: 0; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; cursor: pointer; }
.toggle input[type='checkbox'] { width: 16px; height: 16px; accent-color: var(--pink); }
.settings .toggle { margin-top: 12px; }
select { padding: 10px 12px; cursor: pointer; }
.empty-state { display: grid; gap: 8px; justify-items: center; text-align: center; padding: 40px 20px; grid-column: 1 / -1; }
.empty-state p { margin: 0; }
.missing { max-width: 560px; margin: 24px auto 0; text-align: center; }
.missing h2 { margin: 0 0 8px; }
.missing .btn { margin-top: 16px; }
.hero-cta { margin-top: 20px; }
.hero-cta .btn { flex: 0 0 auto; }

/* 홈 목록 */
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.chart-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: 0 14px 36px rgba(124, 77, 255, 0.13);
  transition: transform 0.18s, box-shadow 0.18s;
  min-width: 0;
}
.chart-card:hover { transform: translateY(-3px); box-shadow: 0 20px 44px rgba(255, 61, 139, 0.2); }
.cc-top { height: 74px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: flex-start; color: #fff; }
.cc-level { font-family: var(--display); font-weight: 900; font-size: 13px; background: rgba(255, 255, 255, 0.25); padding: 4px 9px; border-radius: 999px; }
.cc-code { font-family: var(--display); font-weight: 800; font-size: 13px; opacity: 0.9; }
.cc-body { padding: 14px; display: grid; gap: 4px; min-width: 0; }
.cc-title { font-weight: 900; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-artist { color: var(--muted); font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.cc-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); min-width: 0; }
.cc-foot > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-top-score span { font-family: var(--display); font-weight: 900; }

/* 플레이 페이지 */
.play-head { display: flex; gap: 16px; align-items: center; min-width: 0; }
.level-badge {
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: 26px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 10px 24px rgba(255, 61, 139, 0.3);
}
.level-badge::before { content: 'LV'; position: absolute; font-size: 9px; transform: translateY(-22px); opacity: 0.9; }
.level-badge { position: relative; }
.play-title { min-width: 0; }
.play-title h2 { margin: 0; font-size: clamp(22px, 4vw, 32px); font-weight: 900; letter-spacing: -0.03em; word-break: keep-all; overflow-wrap: anywhere; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 14px 0; font-size: 13px; color: var(--muted); }
.meta-row b { color: var(--ink); }
.share { display: flex; gap: 8px; align-items: center; padding: 10px 10px 10px 16px; border-radius: 16px; background: linear-gradient(120deg, rgba(255, 61, 139, 0.12), rgba(124, 77, 255, 0.12)); margin-bottom: 14px; }
.share-url { flex: 1; min-width: 0; font-family: var(--display); font-weight: 800; font-size: clamp(13px, 3.4vw, 17px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#p-play { margin-top: 16px; }

/* 에디터 */
.editor-head { padding: 8px 0 18px; }
.editor-title { font-family: var(--display); font-weight: 900; font-size: clamp(28px, 5vw, 44px); letter-spacing: -0.03em; margin: 0 0 6px; }
.editor-head p { margin: 0; }
.draft-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; padding: 14px 18px; }
.draft-banner .row { margin: 0; }
.dropzone {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 16px;
  border-radius: 16px;
  border: 2px dashed rgba(124, 77, 255, 0.35);
  background: linear-gradient(120deg, rgba(255, 61, 139, 0.07), rgba(0, 179, 240, 0.07));
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}
.dropzone:hover, .dropzone.over { border-color: var(--pink); background: linear-gradient(120deg, rgba(255, 61, 139, 0.14), rgba(0, 179, 240, 0.14)); }
.editor-grid { grid-template-columns: minmax(0, 1fr) 300px; }
.ed-left { display: grid; gap: 20px; min-width: 0; }
.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.info-grid .field { margin-top: 0; }
.info-grid.timing { margin-top: 12px; }
.inline { display: flex; gap: 6px; min-width: 0; }
.inline input { min-width: 0; flex: 1; }
.inline .btn { flex: none; padding: 10px 12px; }
.btn.pulse { transform: scale(0.94); background: var(--grad); color: #fff; }
#ed-file-name { margin: 12px 0 0; }
#ed-file-name a { color: var(--violet); font-weight: 700; }
.timeline-card { padding: 14px; }
.timeline-card.recording { box-shadow: 0 0 0 3px #ff1f5a, 0 18px 50px rgba(255, 31, 90, 0.25); }
.overview { width: 100%; height: 40px; display: block; cursor: pointer; touch-action: none; }
.timeline { width: 100%; height: 300px; display: block; margin-top: 10px; border-radius: 12px; border: 1px solid var(--line); touch-action: none; user-select: none; -webkit-user-select: none; }
.transport { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.transport.sub { margin-top: 8px; }
.transport select { width: auto; padding: 9px 10px; font-size: 14px; font-weight: 700; }
.transport .time { margin-left: auto; font-family: var(--display); font-weight: 800; font-size: 13px; white-space: nowrap; }
.transport .spacer { flex: 1; }
.transport .help { line-height: 1.5; }
.transport input[type='range'] { width: 110px; }
.btn.rec .rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff1f5a; }
.btn.rec.on { background: #ff1f5a; color: #fff; border-color: transparent; animation: recblink 1s steps(2) infinite; }
.btn.rec.on .rec-dot { background: #fff; }
@keyframes recblink { 50% { box-shadow: 0 0 0 4px rgba(255, 31, 90, 0.25); } }
.ed-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { display: grid; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.stat span { font-size: 11px; font-weight: 800; color: var(--muted); }
.stat b { font-family: var(--display); font-weight: 900; font-size: 18px; }

@media (max-width: 960px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .timeline { height: 240px; }
  .transport .time { margin-left: 0; width: 100%; }
}

/* 좋아요 */
.like-btn {
  margin-left: auto;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.12s, background 0.2s, color 0.2s, border-color 0.2s;
}
.like-btn svg { fill: none; stroke: currentColor; stroke-width: 2; }
.like-btn b { font-family: var(--display); }
.like-btn:hover { color: var(--pink); border-color: rgba(255, 61, 139, 0.4); }
.like-btn.on { background: linear-gradient(120deg, #ff3d8b, #ff7a59); color: #fff; border-color: transparent; box-shadow: 0 8px 20px rgba(255, 61, 139, 0.35); }
.like-btn.on svg { fill: currentColor; }
.like-btn.pop svg { animation: heartpop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes heartpop { 30% { transform: scale(1.45); } }
.wide-like { margin: 12px auto 0; }
.cc-likes { display: inline-flex; align-items: center; gap: 3px; color: var(--pink); font-weight: 700; }
.board .val svg { color: var(--pink); }
@media (max-width: 520px) {
  .like-btn { padding: 8px 11px; font-size: 14px; }
}

/* ---------- 다크 테마: 깊은 남보라 바탕 + 네온 그라디언트 ---------- */
:root[data-theme='dark'] {
  color-scheme: dark;
  --body: #0f0a24;
  --bg-base: linear-gradient(160deg, #1a0b2e, #120d33 50%, #071a33);
  --bg-glow: 0.42;
  --surface: #1d1640;
  --surface-soft: rgba(36, 27, 78, 0.75);
  --card: rgba(26, 19, 60, 0.78);
  --card-border: rgba(160, 130, 255, 0.18);
  --ink: #f3efff;
  --muted: #a49cc9;
  --lead: #cfc6f5;
  --line: rgba(180, 150, 255, 0.2);
  --chip: #2a2257;
  --chip-bad: rgba(255, 61, 139, 0.18);
  --key-white: #e9e4ff;
  --key-black: #120d2b;
  --key-line: #b9b0e6;
  --warn: #ffb057;
  --stage: linear-gradient(170deg, #1c0a2e, #120d38 45%, #06223a);
  --veil: rgba(15, 10, 36, 0.6);
  --shadow: rgba(0, 0, 0, 0.45);
}
:root[data-theme='dark'] .bg {
  background:
    radial-gradient(60vmax 60vmax at 0% 0%, rgba(255, 61, 139, 0.36), transparent 60%),
    radial-gradient(55vmax 55vmax at 100% 10%, rgba(0, 179, 240, 0.3), transparent 60%),
    radial-gradient(60vmax 50vmax at 60% 110%, rgba(124, 77, 255, 0.4), transparent 60%),
    var(--bg-base);
}
:root[data-theme='dark'] .card,
:root[data-theme='dark'] .chart-card,
:root[data-theme='dark'] .result-card { box-shadow: 0 18px 50px var(--shadow), 0 0 0 1px var(--card-border); }
:root[data-theme='dark'] .result-card { background: var(--surface); }
:root[data-theme='dark'] .board li.me { box-shadow: 0 0 0 3px rgba(255, 61, 139, 0.3); }
:root[data-theme='dark'] .rank-D { color: #8d86b3; }
:root[data-theme='dark'] .j.miss { background: linear-gradient(120deg, #4a4470, #5f5893); }
:root[data-theme='dark'] .song, :root[data-theme='dark'] .dropzone { background: linear-gradient(120deg, rgba(255, 61, 139, 0.12), rgba(0, 179, 240, 0.12)); }
:root[data-theme='dark'] input::placeholder { color: #7d74a8; }
:root[data-theme='dark'] kbd { box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4); }
:root[data-theme='dark'] .share-url, :root[data-theme='dark'] .cc-title, :root[data-theme='dark'] .play-title h2 { color: var(--ink); }

/* 테마 버튼 */
.theme-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  flex: none;
  transition: transform 0.2s;
}
.theme-btn:hover { transform: rotate(-18deg); }
.theme-btn .moon { display: none; }
:root[data-theme='dark'] .theme-btn .sun { display: none; }
:root[data-theme='dark'] .theme-btn .moon { display: block; }
.top-right { display: flex; align-items: center; gap: 8px; }
body, .card, .btn, input, select, .board li { transition: background-color 0.25s, color 0.25s, border-color 0.25s; }

/* 좁은 화면 헤더: 메뉴 + 테마 버튼이 한 줄에 들어가게 */
nav a { white-space: nowrap; }
@media (max-width: 460px) {
  .top { gap: 8px; }
  .logo span { display: none; }
  .top-right { gap: 6px; }
  nav { gap: 2px; }
  nav a { padding: 7px 10px; font-size: 14px; }
  .theme-btn { width: 36px; height: 36px; }
}
@media (max-width: 340px) {
  nav a { padding: 6px 7px; font-size: 13px; }
}

/* ---------- 유튜브 ---------- */
.or { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 13px; font-weight: 700; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.yt-row { display: flex; gap: 8px; align-items: center; }
.yt-row svg { flex: none; }
.yt-row input { flex: 1; min-width: 0; }
.yt-row .btn { flex: none; }
.yt-note { margin: 10px 0 0; }
.yt-badge {
  display: inline-block;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
  background: #ff0033;
  color: #fff;
  vertical-align: 1px;
}
.cc-top.has-thumb { text-shadow: 0 1px 6px rgba(0, 0, 0, 0.35); }
.video-slot { width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: #000; margin: 4px 0 14px; }
.video-card { padding: 12px; }
.video-card .video-slot { margin: 0; }

/* 플레이어 본체: 자리(.video-slot)를 따라다니는 fixed 요소 */
#yt-dock { position: fixed; z-index: 20; left: -10000px; top: 0; width: 320px; height: 180px; border-radius: 14px; overflow: hidden; visibility: hidden; background: #000; }
#yt-dock iframe { width: 100%; height: 100%; display: block; border: 0; }
/* 플레이 중: 왼쪽 아래에 작게 (영상은 가리지 않음) */
#yt-dock.stage-mode { z-index: 60; left: 16px; top: auto; bottom: 16px; width: 288px; height: 162px; pointer-events: none; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3); }
@media (max-width: 1150px) {
  /* 양옆 여백이 영상보다 좁으면: 영상을 위에 두고 게임 화면을 그 아래로 */
  #yt-dock.stage-mode { left: 50%; bottom: auto; top: 8px; transform: translateX(-50%); width: 224px; height: 126px; }
  .stage.has-video #game-canvas { top: 142px; height: calc(100% - 142px); }
  .stage.has-video .quit { top: 8px; left: auto; right: 8px; transform: none; padding: 6px 9px; }
  .stage.has-video .quit span { display: none; }
}

/* ---------- 계정 / 배지 / 프로필 ---------- */
.account { display: flex; align-items: center; }
.account-btn { padding: 8px 12px; border-radius: 999px; font-size: 14px; }
.me-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 12px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface-soft);
  font-weight: 800; font-size: 14px; max-width: 200px;
}
.me-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-out { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 999px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none; }
.me-out:hover { color: var(--pink); background: var(--chip); }

a.name { text-decoration: none; color: inherit; }
a.name:hover { text-decoration: underline; text-decoration-color: var(--pink); text-underline-offset: 3px; }
.badge { width: 17px; height: 17px; vertical-align: -3px; margin-left: 3px; flex: none; filter: drop-shadow(0 1px 2px rgba(42, 31, 92, 0.25)); }
.badge.b-top { width: 19px; height: 19px; animation: crownglow 2.2s ease-in-out infinite; }
@keyframes crownglow { 50% { filter: drop-shadow(0 0 6px rgba(255, 196, 0, 0.9)); } }
.board .who { display: flex; align-items: center; gap: 0; }
.board .who > .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.board .who small { flex: none; }

.auth-dlg { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); width: 400px; }
.auth-dlg::backdrop { background: rgba(20, 10, 50, 0.45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.auth-card { position: relative; background: var(--surface); color: var(--ink); border-radius: 22px; padding: 22px; box-shadow: 0 30px 80px rgba(124, 77, 255, 0.3); display: grid; gap: 12px; }
.auth-card .field { margin-top: 0; }
.auth-card input[type='password'] { width: 100%; font: inherit; font-size: 16px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); outline: none; }
.auth-card input[type='password']:focus { border-color: var(--pink); box-shadow: 0 0 0 4px rgba(255, 61, 139, 0.15); }
.auth-tabs { margin: 0; }
.dlg-close { position: absolute; right: 14px; top: 14px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 999px; border: 0; background: var(--chip); color: var(--muted); cursor: pointer; }
.nick-input[readonly] { background: var(--chip); cursor: default; }

.profile-card { margin-top: 8px; }
.prof-head { display: flex; align-items: center; gap: 16px; min-width: 0; }
.prof-avatar { flex: none; width: 72px; height: 72px; border-radius: 22px; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-size: 30px; color: #fff; background: var(--grad); box-shadow: 0 12px 26px rgba(255, 61, 139, 0.3); }
.prof-title { min-width: 0; }
.prof-title h1 { margin: 0; font-size: clamp(24px, 5vw, 36px); font-weight: 900; letter-spacing: -0.03em; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; overflow-wrap: anywhere; }
.prof-title h1 .badge { width: 28px; height: 28px; vertical-align: middle; }
.prof-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 18px; }
.sec-title { margin: 26px 0 10px; font-size: 16px; font-weight: 900; }
#prof-badge-note { margin: 12px 0 0; }
@media (max-width: 460px) {
  .account-btn span { display: none; }
  .account-btn { padding: 8px; width: 36px; height: 36px; }
  .me-chip { max-width: 120px; padding-left: 10px; font-size: 13px; }
  .me-chip .badge { display: none; }
}
:root[data-theme='dark'] .toast { background: #ffffff; color: #2a1f5c; }
@media (max-width: 380px) {
  .top { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .top-right { gap: 4px; }
  nav a { padding: 6px 6px; font-size: 13px; }
  .me-chip { max-width: 78px; padding: 2px 2px 2px 8px; font-size: 12px; gap: 2px; }
  .me-out { width: 24px; height: 24px; }
  .theme-btn, .account-btn { width: 32px; height: 32px; }
  .logo svg { width: 24px; height: 24px; }
}
/* 좁을 때 이름보다 부가 정보(1곡 · SS 1)가 먼저 줄어들게 */
.board .who > .name { flex: 0 1 auto; min-width: 2.6em; }
.board .who .badge { flex: none; }
.board .who small { flex: 0 1000 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
