@font-face { font-family: 'Galmuri11'; src: url('../undertale/fonts/Galmuri11.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #0b0820;
  --panel: #161036;
  --panel-2: #1f1748;
  --line: #342b6e;
  --ink: #f6f3ff;
  --muted: #aaa3d8;
  --pink: #ff4fa3;
  --cyan: #3ee8ff;
  --yellow: #ffd84d;
  --outline: #1a1145;
  --pixel: 'Galmuri11', ui-monospace, monospace;
  --lyric: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--pixel); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, .track:focus-visible, .sheet-line:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

.app { width: min(1100px, 100%); margin: 0 auto; padding: 14px 16px 28px; display: grid; gap: 12px; }

.topbar { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.topbar a { color: var(--muted); text-decoration: none; padding: 6px 0; }
.topbar a:hover { color: var(--ink); }
.brand { font-size: 18px; letter-spacing: 1px; }
.brand i { color: var(--pink); font-style: normal; display: inline-block; animation: wobble 1.2s ease-in-out infinite; }
.state { color: var(--muted); min-width: 64px; text-align: right; }
@keyframes wobble { 50% { transform: translateY(-3px) rotate(-8deg); } }

.stage {
  position: relative; overflow: hidden; border: 3px solid var(--line); border-radius: 18px;
  height: clamp(380px, 64vh, 620px); background: #120c33;
  box-shadow: 0 0 0 3px #0005, 0 18px 50px #0008;
}
#sky { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

.hud { position: absolute; top: 14px; left: 16px; right: 16px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud span { background: #0b082099; border: 2px solid #ffffff22; border-radius: 999px; padding: 3px 12px; font-size: 13px; }
.hud .chord b { color: var(--yellow); font-weight: normal; }

.titlecard, .endcard {
  position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); width: min(92%, 560px);
  text-align: center; transition: opacity 0.6s ease, transform 0.6s ease;
}
.titlecard.hide { opacity: 0; transform: translate(-50%, -60%); pointer-events: none; }
.titlecard.playing .bigplay { display: none; }
.eyebrow { margin: 0; color: var(--cyan); letter-spacing: 3px; font-size: 13px; }
.titlecard h1 {
  margin: 8px 0 6px; font-family: var(--lyric); font-weight: 900; font-size: clamp(36px, 8vw, 76px); line-height: 1.1;
  color: #fff; letter-spacing: -1px;
  text-shadow: 0 4px 0 var(--pink), 0 8px 0 #7a1f6e, 0 0 30px #ff4fa388;
}
.credit { margin: 0 0 18px; color: var(--muted); }
.bigplay {
  border: 3px solid #fff; background: var(--pink); color: #fff; border-radius: 14px; padding: 12px 26px; font-size: 18px;
  box-shadow: 0 5px 0 #8f1f63; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.bigplay:hover { transform: translateY(-1px); }
.bigplay:active { transform: translateY(4px); box-shadow: 0 1px 0 #8f1f63; }
.endcard p { margin: 0; font-family: var(--lyric); font-weight: 900; font-size: clamp(34px, 7vw, 64px); text-shadow: 0 4px 0 var(--pink); }
.endcard strong { display: block; margin: 6px 0 18px; font-weight: normal; font-size: 20px; color: var(--yellow); }

.lyrics { position: absolute; left: 0; right: 0; bottom: 18px; padding: 0 clamp(14px, 4vw, 44px); display: grid; gap: clamp(6px, 1.4vh, 14px); }
.row { position: relative; display: flex; justify-content: flex-start; min-height: 1.3em; font-family: var(--lyric); font-weight: 900; font-size: clamp(24px, 5vw, 52px); line-height: 1.25; }
.row.right { justify-content: flex-end; }
.line { position: relative; white-space: pre; transition: opacity 0.25s ease; }
.line.next { opacity: 0.88; }
.line .base, .line .fill { display: block; white-space: pre; letter-spacing: 1px; }
.line .base {
  color: #fff;
  text-shadow: 3px 0 0 var(--outline), -3px 0 0 var(--outline), 0 3px 0 var(--outline), 0 -3px 0 var(--outline),
    2px 2px 0 var(--outline), -2px -2px 0 var(--outline), 2px -2px 0 var(--outline), -2px 2px 0 var(--outline), 0 6px 0 #0007;
}
.line .fill {
  position: absolute; inset: 0; color: var(--pink); clip-path: inset(0 100% 0 0);
  text-shadow: 3px 0 0 #fff, -3px 0 0 #fff, 0 3px 0 #fff, 0 -3px 0 #fff, 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
}
.row.right .line .fill { color: var(--cyan); }
.line .s { display: inline-block; }
.line .s.pop { animation: pop 0.25s ease-out; }
@keyframes pop { 40% { transform: translateY(-0.12em) scale(1.08); } }
.tag { position: absolute; top: -1.05em; display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-weight: normal; font-size: 13px; line-height: 1.4; transition: opacity 0.25s ease; }
.row.right .tag { right: 0; flex-direction: row-reverse; }
.who { color: #1a1145; border-radius: 999px; padding: 0 8px; box-shadow: 0 2px 0 #0007; }
.who:empty { display: none; }
.dots { color: var(--yellow); text-shadow: 0 2px 0 #000a; letter-spacing: 2px; }

.controls { display: grid; grid-template-areas: 'play time singer restart'; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.play { grid-area: play; width: 52px; height: 52px; border-radius: 50%; border: 3px solid #fff; background: var(--pink); font-size: 20px; box-shadow: 0 4px 0 #8f1f63; }
.play:active { transform: translateY(3px); box-shadow: 0 1px 0 #8f1f63; }
.timeline { grid-area: time; display: grid; gap: 4px; min-width: 0; }
.track { position: relative; height: 26px; border-radius: 8px; background: #0b0820; border: 2px solid var(--line); cursor: pointer; touch-action: none; overflow: hidden; }
.segments { position: absolute; inset: 0; display: flex; }
.segments span { position: relative; height: 100%; border-right: 2px solid #0b0820; color: #ffffff88; font-size: 11px; line-height: 22px; text-align: center; overflow: hidden; white-space: nowrap; }
.segments span[data-style='intro'], .segments span[data-style='interlude'], .segments span[data-style='outro'] { background: #241c52; }
.segments span[data-style='verse'] { background: #1d2b5e; }
.segments span[data-style='pre'] { background: #2f2366; }
.segments span[data-style='chorus'] { background: #4a1f5a; }
.segments span[data-style='bridge'] { background: #173f4f; }
.segments span[data-style='final'] { background: #5a3a1f; }
.progress { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #ff4fa355, #ff4fa3aa); pointer-events: none; mix-blend-mode: screen; }
.knob { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 10px #fff; pointer-events: none; }
.times { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.toggle { border: 2px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 14px; white-space: nowrap; }
#singer { grid-area: singer; min-width: 150px; }
#restart { grid-area: restart; }
.toggle:hover { border-color: #fff6; }
.toggle[data-mode='off'] { color: var(--yellow); border-color: var(--yellow); }
.toggle[data-mode='pink'] { border-color: var(--pink); }
.toggle[data-mode='blue'] { border-color: var(--cyan); }

.tip { margin: -2px 4px 0; color: var(--muted); font-size: 13px; }
.help { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; padding: 0 4px; }
kbd { font-family: var(--pixel); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 6px; color: var(--ink); }

.sheet { background: var(--panel); border: 2px solid var(--line); border-radius: 16px; padding: 14px 16px 6px; }
.sheet h2 { margin: 0 0 8px; font-size: 16px; font-weight: normal; }
.sheet h2 small { color: var(--muted); font-size: 12px; margin-left: 8px; }
.sheet-body { columns: 2 280px; column-gap: 28px; }
.sheet-block { break-inside: avoid; margin: 0 0 14px; }
.sheet-block h3 { margin: 0 0 4px; font-size: 12px; font-weight: normal; color: var(--cyan); letter-spacing: 2px; }
.sheet-line { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid transparent; background: none; padding: 3px 8px; margin: 0 -8px; border-radius: 8px; font-family: var(--lyric); font-weight: 700; font-size: 16px; color: var(--ink); }
.sheet-line:hover { background: var(--panel-2); }
.sheet-line.now { background: #ff4fa333; color: #fff; }

footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; color: #8c86b8; font-size: 12px; padding: 0 4px; }

@media (max-width: 640px) {
  .app { padding: 10px 12px 22px; gap: 10px; }
  .brand { font-size: 15px; }
  .state { display: none; }
  .stage { height: clamp(360px, 58vh, 520px); border-radius: 14px; }
  .controls { grid-template-areas: 'play time time' 'singer singer restart'; grid-template-columns: auto 1fr auto; }
  .help { display: none; }
  .segments span { font-size: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .brand i, .line .s.pop { animation: none; }
  .titlecard, .endcard { transition: none; }
}
