:root {
  --bg: #0b1020; --bg2: #10142a; --panel: #161b36; --line: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9; --dim: #94a3b8; --accent: #38bdf8; --pink: #e879f9; --gold: #fbbf24; --ok: #34d399; --bad: #f43f5e;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(circle at 50% -10%, #1d1b4b, var(--bg) 65%);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
.back-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  background: rgba(255,255,255,0.07); border: 1px solid var(--line); color: var(--text);
  text-decoration: none; font-size: 0.85rem; font-weight: 600;
}
.back-btn:hover { background: rgba(255,255,255,0.14); }
.total { margin-left: auto; font-weight: 700; }
.total small { color: var(--dim); font-weight: 500; }
.tools { display: flex; gap: 6px; }
.mini { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,0.07); font-weight: 700; }

/* ── 메뉴 ── */
.screen { flex: 1; overflow-y: auto; padding: 4px 16px 32px; }
.logo { text-align: center; margin: 2px 0 12px; }
.logo h1 { margin: 4px 0 4px; font-size: 1.55rem; letter-spacing: -0.5px; text-shadow: 0 0 18px rgba(56,189,248,0.45); }
.logo h1 span { background: linear-gradient(135deg, var(--accent), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { margin: 0; color: var(--dim); font-size: 0.9rem; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 720px; margin: 0 auto 12px; }
.tab { padding: 9px 2px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.tab.on { background: rgba(56,189,248,0.16); border-color: var(--accent); color: #bae6fd; }
.panel-wrap { max-width: 720px; margin: 0 auto; display: grid; gap: 12px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.card h2 { margin: 0 0 2px; font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; }
.card h2 small { margin-left: auto; color: var(--gold); font-size: 0.85rem; }
.card p { margin: 0 0 10px; color: var(--dim); font-size: 0.82rem; line-height: 1.45; }
.card p b { color: var(--text); }
.lv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .lv-grid { grid-template-columns: repeat(6, 1fr); } }
.lv-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 92px;
}
.lv-btn:hover:not(:disabled) { border-color: var(--accent); }
.lv-btn b { font-size: 1rem; }
.lv-btn span { font-size: 0.7rem; color: var(--dim); text-align: center; line-height: 1.2; }
.lv-btn span.g { color: #bae6fd; font-size: 0.66rem; }
.lv-btn i { font-style: normal; font-size: 0.78rem; letter-spacing: 1px; color: var(--gold); margin-top: auto; }
.lv-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.lv-btn.cleared { background: #1e2252; }
.resume {
  width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(52,211,153,0.5);
  background: rgba(52,211,153,0.12); font-weight: 800; text-align: left; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
}
.resume span { font-weight: 500; font-size: 0.8rem; color: var(--dim); }
.diff-list { display: grid; gap: 8px; }
.diff {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); text-align: left; width: 100%;
}
.diff:hover { border-color: var(--accent); }
.diff .ico { font-size: 1.6rem; }
.diff b { display: block; font-size: 1rem; }
.diff span { color: var(--dim); font-size: 0.8rem; }
.diff .rec { margin-left: auto; text-align: right; color: var(--gold); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.diff .rec small { display: block; color: var(--dim); font-weight: 500; }
.daily-rec, .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.stat-grid { margin: 12px 0 0; }
.daily-rec div, .stat-grid div { background: var(--panel); border-radius: 12px; padding: 10px; text-align: center; }
.daily-rec small, .stat-grid small { display: block; color: var(--dim); font-size: 0.75rem; }
.daily-rec b, .stat-grid b { font-size: 1.25rem; color: var(--gold); }
.big-btn {
  display: block; width: 100%; padding: 14px; border-radius: 14px; border: 0; font-weight: 800; font-size: 1.05rem;
  background: linear-gradient(135deg, #38bdf8, #a855f7); color: #fff; box-shadow: 0 6px 22px rgba(56,189,248,0.3);
}
.stat-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.stat-table th, .stat-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: center; }
.stat-table th { color: var(--dim); font-weight: 600; }

.btn {
  padding: 10px 16px; border-radius: 12px; border: 0; font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #a855f7); color: #fff;
}
.btn.ghost { background: rgba(255,255,255,0.08); border: 1px solid var(--line); }
.btn.danger { color: #fda4af; width: 100%; }
.btn.small { padding: 7px 11px; font-size: 0.85rem; background: rgba(255,255,255,0.08); border: 1px solid var(--line); font-weight: 700; }

/* ── 플레이 ── */
.logo-bubbles { display: inline-flex; gap: 4px; height: 44px; align-items: flex-end; }
.logo-bubbles i { width: 26px; height: 26px; border-radius: 50%; animation: bob 2.4s ease-in-out infinite; }
.logo-bubbles .b1 { background: radial-gradient(circle at 35% 30%, #fb7185, #e11d48 65%, #4c0519); }
.logo-bubbles .b2 { width: 34px; height: 34px; background: radial-gradient(circle at 35% 30%, #60a5fa, #2563eb 65%, #172554); animation-delay: -0.8s; }
.logo-bubbles .b3 { background: radial-gradient(circle at 35% 30%, #fde047, #eab308 65%, #422006); animation-delay: -1.6s; }
@keyframes bob { 50% { transform: translateY(-8px); } }
#play { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 12px max(8px, env(safe-area-inset-bottom)); max-width: 720px; width: 100%; margin: 0 auto; }
.p-head { display: flex; align-items: center; gap: 8px; }
.p-title { flex: 1; text-align: center; font-weight: 800; font-size: 0.98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0 4px; }
.chip { position: relative; padding: 4px 10px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); font-size: 0.8rem; color: var(--dim); }
.chip b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip.warn { border-color: var(--bad); }
.chip.warn b { color: #fda4af; }
.chip.goal { color: #bae6fd; }
.chip .stars { color: var(--gold); letter-spacing: 1px; margin-left: 4px; }
.board-wrap { position: relative; flex: 1; min-height: 220px; touch-action: none; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#cvs { display: block; border-radius: 14px; box-shadow: 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,0.5); touch-action: none; cursor: crosshair; }
.toast {
  position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%); z-index: 9; pointer-events: none;
  background: rgba(15, 23, 42, 0.92); border: 1px solid var(--accent); border-radius: 999px; padding: 7px 14px;
  font-size: 0.85rem; font-weight: 700; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { animation: tin 0.25s ease-out; }
@keyframes tin { from { opacity: 0; transform: translate(-50%, -8px); } }
.controls { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; }
.item {
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 54px; padding: 5px 8px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--bg2); font-size: 0.72rem; color: var(--dim); touch-action: manipulation;
}
.item i { font-style: normal; font-size: 1.3rem; line-height: 1.2; color: var(--text); }
.item b { color: var(--text); }
.item:disabled { opacity: 0.38; }
.item.on { border-color: var(--gold); background: rgba(251,191,36,0.18); box-shadow: 0 0 14px rgba(251,191,36,0.4); }
.item.got { animation: got 0.6s ease-out; }
@keyframes got { 30% { transform: scale(1.25); } }
.item.swap b { font-weight: 600; color: var(--dim); }
.meter { position: relative; flex: 1; max-width: 200px; height: 22px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden; }
.meter div { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #f472b6, #fbbf24); transition: width 0.3s; }
.meter span { position: relative; display: block; text-align: center; font-size: 0.68rem; line-height: 22px; color: #fff; font-weight: 700; text-shadow: 0 1px 2px #000; }
.keys { text-align: center; color: var(--dim); font-size: 0.72rem; margin: 6px 0 0; }
@media (hover: none) { .keys { display: none; } }
@media (max-height: 640px) { .keys { display: none; } .hud { margin: 3px 0 2px; } }
.lv-btn span.g { color: #bae6fd; font-size: 0.66rem; }

/* ── 모달 ── */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(2, 6, 23, 0.72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; padding: 18px; width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto; text-align: center; animation: tin2 0.22s ease-out;
}
@keyframes tin2 { from { transform: scale(0.92); opacity: 0; } }
.dialog h2 { margin: 0 0 8px; }
.dialog p { margin: 6px 0; color: var(--text); }
.dialog .dim { color: var(--dim); font-size: 0.85rem; }
.dialog .row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.big-num { font-size: 2rem; font-weight: 900; color: var(--gold); }
.big-stars { font-size: 2.6rem; letter-spacing: 6px; }
.big-stars span { color: #334155; display: inline-block; }
.big-stars span.on { color: var(--gold); animation: starIn 0.4s ease-out both; text-shadow: 0 0 14px rgba(251,191,36,0.7); }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.help { text-align: left; padding-left: 18px; margin: 0; font-size: 0.88rem; line-height: 1.55; color: var(--dim); }
.help b { color: var(--text); }
kbd { display: inline-block; min-width: 1.4em; padding: 0 4px; border-radius: 5px; border: 1px solid var(--line); background: var(--panel); font-size: 0.78rem; text-align: center; color: var(--text); }
.noscript { text-align: center; padding: 40px; }

/* 업적 */
.ach-bar { height: 6px; border-radius: 3px; background: var(--panel); overflow: hidden; margin: 6px 0 10px; }
.ach-bar div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.ach-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 560px) { .ach-list { grid-template-columns: 1fr 1fr; } }
.ach { display: flex; gap: 10px; align-items: center; padding: 7px 9px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); opacity: 0.5; }
.ach.on { opacity: 1; border-color: rgba(251, 191, 36, 0.45); }
.ach > span { font-size: 1.3rem; width: 28px; text-align: center; }
.ach b { display: block; font-size: 0.85rem; }
.ach small { display: block; font-size: 0.72rem; color: var(--dim); line-height: 1.3; }
.ach-new { margin: 10px 0; display: grid; gap: 6px; text-align: left; }
.ach-new div { display: grid; grid-template-columns: 30px 1fr; column-gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.5); animation: achIn 0.5s ease both; }
.ach-new span { font-size: 1.4rem; grid-row: span 2; text-align: center; }
.ach-new b { color: var(--gold); font-size: 0.88rem; }
.ach-new small { color: var(--dim); font-size: 0.75rem; }
@keyframes achIn { from { transform: scale(0.9); opacity: 0; } to { transform: none; opacity: 1; } }
