:root {
  --bg: #14111c;
  --card: #1f1b2b;
  --card2: #2a2539;
  --line: #3b3552;
  --text: #f4f1fb;
  --muted: #a8a1bd;
  --accent: #ffd23f;
  --red: #ff3b4e;
  --title: 'Black Han Sans', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(circle at 50% 0%, #2b1f3f 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: 'Noto Sans KR', system-ui, -apple-system, 'Malgun Gothic', sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
#app { height: 100%; }
.hidden { display: none !important; }

.screen { display: none; height: 100%; overflow-y: auto; padding: 24px 16px; }
.screen.active { display: flex; align-items: flex-start; justify-content: center; }
.screen.active > * { margin: auto 0; }
#screen-game.active { display: block; padding: 0; overflow: hidden; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
h2 { font-family: var(--title); font-weight: 400; font-size: 30px; margin-bottom: 6px; }
.step { color: var(--accent); font-weight: 900; font-size: 13px; letter-spacing: 2px; }
.hint { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.hint.small { font-size: 13px; margin: 10px 0; }

.btn {
  font: inherit; font-weight: 700; font-size: 15px;
  border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 12px; padding: 12px 18px; cursor: pointer;
  transition: transform 0.08s, background 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: #363048; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, #ff5a5f, #e11d48); border-color: #ff7a86; color: #fff; }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #ff6d72, #f0284f); }
.btn.big { font-size: 18px; padding: 15px 22px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.small-btn { margin-top: 14px; font-size: 13px; padding: 8px 10px; }
.row-btns { display: flex; gap: 10px; margin-top: 16px; }
.row-btns .btn { flex: 1; }
.row-btns.center { justify-content: center; }
.row-btns.center .btn { flex: 0 1 280px; }

/* 인트로 */
.intro-card { max-width: 460px; text-align: center; }
.logo { font-family: var(--title); font-size: 34px; line-height: 1.05; color: #fff; }
.logo span { font-size: 62px; color: var(--accent); text-shadow: 4px 4px 0 var(--red), 8px 8px 0 rgba(0,0,0,0.35); display: inline-block; transform: rotate(-3deg); }
.tagline { margin: 18px 0 18px; color: var(--muted); font-size: 16px; }
.feature-list { list-style: none; text-align: left; background: var(--card2); border-radius: 14px; padding: 14px 18px; display: grid; gap: 8px; font-size: 15px; }
.privacy-box { margin-top: 14px; font-size: 13px; line-height: 1.55; color: #c9f2dc; background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.35); border-radius: 12px; padding: 10px 14px; text-align: left; }
.agree { display: flex; gap: 10px; align-items: flex-start; text-align: left; margin: 16px 0; font-size: 13px; color: var(--muted); cursor: pointer; line-height: 1.5; }
.agree input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--red); flex: none; }
.intro-card .btn { width: 100%; }
.demo-note { margin-top: 10px; font-size: 12px; color: #6f6888; }

/* 업로드 */
.upload-card { max-width: 640px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--line); border-radius: 16px; padding: 56px 16px; cursor: pointer;
  color: var(--muted); text-align: center; transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: rgba(255, 210, 63, 0.06); color: var(--text); }
.dz-icon { font-size: 44px; }
.detect-status { font-size: 14px; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.detect-status.loading { background: rgba(168, 161, 189, 0.12); color: var(--muted); }
.detect-status.ok { background: rgba(34, 197, 94, 0.12); color: #86efac; }
.detect-status.warn { background: rgba(245, 158, 11, 0.14); color: #fcd34d; }
.adjust-canvas-wrap { display: flex; justify-content: center; background: #0c0a12; border-radius: 12px; overflow: hidden; }
#adjust-canvas { max-width: 100%; max-height: 50vh; touch-action: none; cursor: grab; display: block; }
#adjust-canvas:active { cursor: grabbing; }
.sliders { display: grid; gap: 8px; }
.sliders label { display: grid; grid-template-columns: 76px 1fr; align-items: center; font-size: 14px; color: var(--muted); }
.sliders input { accent-color: var(--accent); width: 100%; }

/* 꾸미기 */
.custom-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; width: 100%; max-width: 1240px; align-items: start; }
.preview-wrap { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: #000; box-shadow: 0 20px 60px rgba(0,0,0,0.45); }
#preview-canvas { width: 100%; height: auto; display: block; }
.field { display: grid; gap: 6px; font-size: 14px; color: var(--muted); margin: 12px 0 4px; }
.field input { font: inherit; font-size: 16px; color: var(--text); background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; }
.field input:focus { border-color: var(--accent); }
.opt-group { margin-top: 14px; }
.opt-title { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opt {
  font: inherit; font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--card2); border: 2px solid transparent; border-radius: 12px; padding: 10px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer;
}
.opt .em { font-size: 22px; }
.opt:hover { background: #363048; }
.opt.on { border-color: var(--accent); background: rgba(255, 210, 63, 0.12); }
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 14px; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

/* 게임 */
#game-wrap { position: relative; width: 100%; height: 100%; overflow: hidden; user-select: none; -webkit-user-select: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.hud-top { position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; padding: 12px 16px 26px; pointer-events: none; background: linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.25) 70%, rgba(0,0,0,0)); }
.hud-top > * { pointer-events: auto; }
.hud-left { max-width: 340px; }
.nameplate { font-family: var(--title); font-size: 22px; text-shadow: 2px 2px 0 #000; }
.gauge { position: relative; height: 18px; margin-top: 4px; background: rgba(0,0,0,0.55); border: 2px solid #fff; border-radius: 10px; overflow: hidden; }
.gauge-fill { height: 100%; width: 0; transition: width 0.12s, background 0.3s; }
.gauge i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.5); }
.stage-label { font-weight: 900; font-size: 14px; margin-top: 4px; text-shadow: 1px 1px 0 #000; }
.timer { font-family: var(--title); font-size: 44px; line-height: 1; padding: 8px 18px; background: rgba(0,0,0,0.55); border: 2px solid #fff; border-radius: 14px; text-shadow: 2px 2px 0 #000; min-width: 120px; text-align: center; }
.timer.urgent { color: var(--red); border-color: var(--red); animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.hud-right { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; align-items: center; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,0.8); background: rgba(0,0,0,0.5); font-size: 18px; cursor: pointer; color: #fff; }
.icon-btn.off { opacity: 0.4; }
.icon-btn.on { background: var(--red); border-color: #fff; }
.mic-meter { width: 100%; max-width: 186px; height: 6px; background: rgba(0,0,0,0.5); border-radius: 4px; overflow: hidden; }
#mic-level { height: 100%; width: 0; background: linear-gradient(90deg, #22c55e, #facc15, #ef4444); transition: width 0.06s; }
.combo { position: absolute; right: 24px; top: 34%; font-family: var(--title); font-size: 64px; color: var(--accent); text-shadow: 4px 4px 0 var(--red), 6px 6px 0 #000; pointer-events: none; opacity: 0; }
.combo small { font-size: 28px; }
.combo.show { animation: combo-pop 1.1s forwards; }
@keyframes combo-pop { 0% { transform: scale(1.6) rotate(-6deg); opacity: 1; } 15% { transform: scale(1) rotate(-6deg); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1) rotate(-6deg); } }
.hud-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 16px 14px; background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.45) 40%, rgba(0,0,0,0.6)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.hud-bottom > * { pointer-events: auto; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.act { font: inherit; font-size: 13px; font-weight: 700; color: #fff; background: rgba(0,0,0,0.55); border: 2px solid rgba(255,255,255,0.6); border-radius: 10px; padding: 6px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; touch-action: manipulation; }
.act:active { background: var(--red); transform: scale(0.95); }
kbd { font-family: inherit; font-size: 11px; background: #fff; color: #111; border-radius: 4px; padding: 1px 5px; }
.voice-caption { max-width: min(560px, calc(100vw - 32px)); background: rgba(0,0,0,0.72); border: 2px solid rgba(255,59,78,0.85); border-radius: 14px; padding: 8px 14px; font-size: 15px; font-weight: 700; color: #fff; text-align: center; line-height: 1.45; pointer-events: none; }
.voice-caption.idle { border-color: rgba(255,255,255,0.35); color: var(--muted); font-weight: 400; }
.inapp-banner { display: grid; gap: 10px; text-align: left; font-size: 14px; line-height: 1.55; background: rgba(255, 210, 63, 0.12); border: 1px solid rgba(255, 210, 63, 0.5); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.inapp-banner .btn { width: 100%; }
.inapp-help { font-size: 13px; color: var(--accent); }
.chat-form { display: flex; gap: 8px; width: 100%; max-width: 560px; }
.chat-form input { flex: 1; min-width: 0; font: inherit; font-size: 16px; color: #fff; background: rgba(0,0,0,0.65); border: 2px solid rgba(255,255,255,0.7); border-radius: 12px; padding: 10px 14px; outline: none; }
.chat-form input:focus { border-color: var(--accent); }
.chat-form .btn { padding: 10px 16px; }
.watermark { position: absolute; left: 12px; bottom: 6px; font-size: 11px; color: rgba(255,255,255,0.45); pointer-events: none; }
.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--title); font-size: 160px; color: var(--accent); text-shadow: 6px 6px 0 var(--red), 10px 10px 0 #000; pointer-events: none; opacity: 0; }
.countdown.show { animation: count-pop 0.8s forwards; }
@keyframes count-pop { 0% { transform: scale(2); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(0.9); } }
.toast { position: absolute; left: 50%; top: 84px; transform: translateX(-50%) translateY(-10px); max-width: min(560px, calc(100% - 32px)); background: rgba(0,0,0,0.85); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.5; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 결과 */
.result-card { max-width: 580px; text-align: center; }
.result-head { font-family: var(--title); font-size: 26px; color: var(--muted); letter-spacing: 1px; }
.score-box { margin: 10px 0 14px; padding: 18px 12px; border-radius: 16px; background: radial-gradient(circle at 50% 0%, rgba(255, 59, 78, 0.22), transparent 70%), var(--card2); }
.grade-emoji { font-size: 54px; line-height: 1; }
.score-num { font-family: var(--title); font-size: 76px; line-height: 1.05; color: var(--accent); text-shadow: 4px 4px 0 var(--red); }
.score-num small { font-size: 30px; margin-left: 4px; color: #fff; text-shadow: none; }
.grade-line { font-size: 18px; font-weight: 700; margin-top: 4px; }
.grade-line b { font-family: var(--title); font-weight: 400; font-size: 26px; color: var(--accent); margin-left: 4px; }
.grade-desc { color: var(--muted); font-size: 14px; margin-top: 4px; }
.result-quote { background: var(--card2); border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.55; margin-bottom: 14px; }
.breakdown { display: grid; gap: 8px; margin-bottom: 14px; text-align: left; }
.bd-row { display: grid; grid-template-columns: 150px 1fr 72px; gap: 10px; align-items: center; font-size: 14px; }
.bd-label { font-weight: 700; display: flex; flex-direction: column; line-height: 1.25; }
.bd-label small { font-weight: 400; font-size: 11px; color: var(--muted); }
.bd-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bd-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #ff7a45, var(--red)); }
.bd-row.base .bd-bar i { background: #6b6585; }
.bd-pts { text-align: right; font-weight: 900; font-variant-numeric: tabular-nums; }
.privacy-box.center { text-align: center; margin-top: 14px; }
.cheer { margin-top: 12px; font-size: 16px; font-weight: 700; }
.result-quote b { color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--card2); border-radius: 12px; padding: 10px 4px; }
.stat .em { font-size: 22px; }
.stat .v { font-family: var(--title); font-size: 22px; margin-top: 2px; }
.stat .l { font-size: 12px; color: var(--muted); }

@media (max-width: 900px) {
  .custom-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .card { padding: 22px 16px; }
  .logo span { font-size: 50px; }
  .timer { font-size: 32px; min-width: 88px; padding: 6px 10px; }
  .hud-top { grid-template-columns: 1fr auto; padding: 10px 12px; }
  .hud-left { grid-column: 1 / -1; order: 2; max-width: none; }
  .hud-right { order: 1; }
  .timer { order: 0; justify-self: start; }
  .nameplate { font-size: 18px; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .act kbd { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .bd-row { grid-template-columns: 112px 1fr 64px; font-size: 13px; }
  .score-num { font-size: 60px; }
  .combo { font-size: 44px; right: 12px; }
}
@media (hover: none) {
  .act kbd { display: none; }
}
