:root {
  --bg: #1f1a17;
  --panel: #2c2521;
  --line: #43382f;
  --text: #f6efe6;
  --muted: #b5a797;
  --accent: #ff8a5b;
  --a: #4cc9f0;
  --b: #ff6b9a;
  --gold: #ffd166;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }

#board { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.bar {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 6px;
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.logo { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; }
.logo span { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; margin-left: 4px; }
.hud { margin-left: auto; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.hud b { color: var(--text); }
.icon { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; width: 40px; height: 40px; font-size: 18px; flex: none; }

.hud .n { display: inline-block; }
.hud .n.bump { animation: bump .5s; color: var(--gold); }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.7); } 100% { transform: scale(1); } }

.shape-name {
  position: fixed; left: 0; right: 0; top: calc(62px + env(safe-area-inset-top));
  text-align: center; font-size: 16px; font-weight: 700; color: var(--muted); pointer-events: none;
  opacity: 0; transition: opacity .3s;
}
.shape-name.show { opacity: 1; animation: namein .4s ease-out; }
@keyframes namein { from { transform: translateY(-6px); } }

.combo {
  position: fixed; left: 0; right: 0; top: calc(64px + env(safe-area-inset-top));
  text-align: center; pointer-events: none; opacity: 0;
}
.combo .n { display: block; font-size: 34px; font-weight: 900; letter-spacing: -0.02em; color: var(--text); text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.combo.big .n { font-size: 52px; color: var(--accent); }
.combo .rec { display: inline-block; margin-top: 6px; padding: 6px 14px; border-radius: 999px; background: var(--gold); color: #1f1a17; font-weight: 800; font-size: 16px; }
.combo.show { animation: combo 1.8s ease-out forwards; }
@keyframes combo {
  0% { opacity: 0; transform: translateY(16px) scale(.6); }
  15% { opacity: 1; transform: translateY(0) scale(1.12); }
  25% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

.hint {
  position: fixed; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom));
  margin: 0; text-align: center; color: var(--muted); font-size: 15px; pointer-events: none;
  transition: opacity .3s;
}
.hint b { color: var(--text); }
.hint.gone { opacity: 0; }

.toast {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.9);
  background: rgba(20, 16, 14, .92); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 14px; font-size: 15px; text-align: center; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0;
  margin: 0 auto; max-width: 520px;
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  text-align: center;
  animation: up .25s ease-out;
}
.sheet[hidden] { display: none; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-title { font-size: 14px; color: var(--muted); min-height: 1.2em; }
.ratio { font-size: clamp(40px, 12vw, 60px); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ratio .a { color: var(--a); }
.ratio .b { color: var(--b); }
.ratio .sep { color: var(--muted); font-weight: 400; padding: 0 .15em; }
.detail { font-size: 14px; color: var(--muted); min-height: 1.3em; font-variant-numeric: tabular-nums; }
.grade { font-size: 22px; font-weight: 800; min-height: 1.4em; margin-top: 2px; }
.grade.perfect { color: var(--gold); text-shadow: 0 0 18px rgba(255, 209, 102, .6); animation: pop .5s; }
.grade.master { color: var(--a); }
.grade.bad, .grade.dust { color: var(--muted); }
.grade small { display: block; font-size: 14px; font-weight: 500; margin-top: 2px; }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } }
.vs { font-size: 15px; min-height: 0; }
.vs:not(:empty) { margin-top: 4px; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions button {
  flex: 1; min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); font-size: 15px; font-weight: 600;
}
.actions button.primary { background: var(--accent); border-color: var(--accent); color: #1f1a17; }
.actions button:disabled { opacity: .4; cursor: default; }
.actions button[hidden] { display: none; }

@media (min-width: 700px) {
  .sheet { bottom: 24px; border-radius: 22px; border-bottom: 1px solid var(--line); }
}
