:root {
  --bg: #fbf8f4;
  --surface: #ffffff;
  --text: #1d1b1a;
  --muted: #6b645e;
  --line: #e8e1d9;
  --accent: #d7263d;
  --accent-soft: #fde7ea;
  --good: #1f9d55;
  --good-soft: #e3f6ea;
  --bad: #c53030;
  --bad-soft: #fde8e8;
  --gold: #e0a100;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141212;
    --surface: #1e1b1b;
    --text: #f2eeea;
    --muted: #a59d96;
    --line: #34302d;
    --accent: #ff4d63;
    --accent-soft: #3a1f24;
    --good: #3ccf7a;
    --good-soft: #17301f;
    --bad: #ff6b6b;
    --bad-soft: #3a1c1c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; max-width: 900px; margin: 0 auto;
}
.brand { text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.xp { font-size: .85rem; color: var(--muted); text-align: right; }
.xp b { color: var(--accent); }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 16px; max-width: 900px; margin: 0 auto;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  flex: none; padding: 6px 14px; border-radius: 999px; text-decoration: none;
  font-weight: 600; font-size: .92rem; color: var(--muted);
}
.tabs a.active { background: var(--accent); color: #fff; }

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 48px; }
.footer { text-align: center; font-size: .8rem; color: var(--muted); padding: 24px 16px 40px; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
a.card { display: block; text-decoration: none; transition: transform .12s; }
a.card:hover { transform: translateY(-2px); }
.card .emoji { font-size: 1.8rem; line-height: 1; margin-bottom: 8px; display: block; }
.card.done { border-color: var(--good); }
.check { color: var(--good); font-weight: 700; font-size: .85rem; }

.hero { padding: 12px 0 20px; }
.hero h1 { font-size: 2rem; }
.rankbar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.rankbar > div { height: 100%; background: var(--accent); transition: width .4s; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 10px 18px; font: inherit; font-weight: 700;
  background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); color: var(--text); font: inherit; padding: 8px 14px; cursor: pointer; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }

ul.points { padding-left: 1.2em; margin: 0 0 1em; }
ul.points li { margin-bottom: 4px; }
.box { border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.box.bad { background: var(--bad-soft); }
.box.good { background: var(--good-soft); }
.video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 16 / 9; display: block; margin-bottom: 16px; }

/* Combo trainer */
.ring {
  text-align: center; padding: 28px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
}
.ring .phase { font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.ring .clock { font-size: 4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.ring .call { font-size: 2.6rem; font-weight: 800; color: var(--accent); min-height: 1.4em; margin: 8px 0; word-break: keep-all; }
.ring .call-sub { color: var(--muted); min-height: 1.6em; }
.ring.rest .clock { color: var(--good); }
.legend { font-size: .85rem; color: var(--muted); margin-top: 12px; }

/* Reflex */
.attack { font-size: 1.8rem; font-weight: 800; min-height: 2.4em; display: flex; align-items: center; justify-content: center; gap: 10px; }
.timer { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 12px 0 16px; }
.timer > div { height: 100%; background: var(--accent); width: 100%; }
.defenses { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.defenses button { padding: 16px; font-size: 1.1rem; }
.flash-good { animation: fg .4s; }
.flash-bad { animation: fb .4s; }
@keyframes fg { from { background: var(--good-soft); } }
@keyframes fb { from { background: var(--bad-soft); } }

/* Quiz */
.options { display: grid; gap: 8px; margin: 12px 0; }
.options button {
  text-align: left; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.options button.right { border-color: var(--good); background: var(--good-soft); }
.options button.wrong { border-color: var(--bad); background: var(--bad-soft); }

.badges { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.badge { text-align: center; padding: 12px 8px; border-radius: 12px; border: 1px dashed var(--line); font-size: .85rem; opacity: .45; }
.badge.on { opacity: 1; border-style: solid; border-color: var(--gold); }
.badge .emoji { font-size: 1.6rem; display: block; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 700; box-shadow: var(--shadow); z-index: 20; max-width: calc(100% - 32px);
}
