/* ============================================================
   汉字大冒险 · shared design system
   Night-quest canvas · gold reserved for stars & victory
   ============================================================ */
:root {
  --bg:        oklch(21% 0.045 278);
  --bg-deep:   oklch(16% 0.04 280);
  --surface:   oklch(27% 0.05 277);
  --surface-2: oklch(32% 0.055 276);
  --fg:        oklch(96% 0.01 90);
  --muted:     oklch(72% 0.025 275);
  --border:    oklch(38% 0.05 276);

  --gold:      oklch(83% 0.155 88);   /* stars, victory only */
  --action:    oklch(66% 0.15 250);   /* primary buttons */
  --action-hi: oklch(72% 0.15 250);
  --success:   oklch(72% 0.17 150);
  --danger:    oklch(63% 0.21 25);

  --font-ui: "Avenir Next", "PingFang SC", "Noto Sans SC", -apple-system, system-ui, sans-serif;
  --font-hanzi: "Kaiti SC", "KaiTi", "STKaiti", "DFKai-SB", "Noto Serif SC", serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px oklch(10% 0.03 280 / 0.5);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1200px 700px at 50% -10%, oklch(26% 0.06 276) 0%, transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px clamp(16px, 4vw, 32px);
  max-width: 1080px; margin: 0 auto;
}
.topbar .brand {
  font-weight: 800; font-size: 18px; letter-spacing: 0.02em;
  display: flex; align-items: center; gap: 10px; color: var(--fg);
  text-decoration: none;
}
.brand .seal {
  font-family: var(--font-hanzi); font-size: 20px; line-height: 1;
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; color: var(--gold);
}
.star-wallet {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 7px 14px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  color: var(--fg); text-decoration: none;
}
.star-wallet .s { color: var(--gold); }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 16px;
  border: none; cursor: pointer; color: #fff;
  background: var(--action);
  padding: 13px 22px; min-height: 48px;
  border-radius: var(--radius-sm);
  transition: background 100ms var(--ease-out), transform 80ms var(--ease-out);
  touch-action: manipulation;
}
.btn:hover { background: var(--action-hi); }
.btn:active { transform: scale(0.97); }
.btn.ghost {
  background: transparent; color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn.ghost:hover { color: var(--fg); border-color: var(--muted); }
.btn.good { background: var(--success); color: oklch(18% 0.05 150); }
.btn.bad  { background: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---------- keyboard focus ---------- */
.btn:focus-visible, .tile:focus-visible, a:focus-visible {
  outline: 3px solid var(--action-hi);
  outline-offset: 2px;
}

/* ---------- stars ---------- */
.stars { display: inline-flex; gap: 3px; }
.stars .st { width: 18px; height: 18px; }
.stars .st path { fill: var(--border); }
.stars .st.on path { fill: var(--gold); }

/* ---------- hearts ---------- */
.hearts { display: flex; gap: 6px; }
.hearts .hp { width: 26px; height: 26px; transition: transform 150ms var(--ease-out), opacity 150ms; }
.hearts .hp path { fill: var(--danger); }
.hearts .hp.lost { opacity: 0.22; transform: scale(0.82); }
.hearts .hp.lost path { fill: var(--border); }

/* ---------- boss medallion ---------- */
/* flat 印章-style seal tile — no glow, carved inner ring */
.boss {
  width: clamp(72px, 15vw, 100px); aspect-ratio: 1;
  border-radius: 18px;
  display: grid; place-items: center; position: relative;
  font-family: var(--font-hanzi); font-weight: 700;
  font-size: clamp(36px, 8vw, 52px); line-height: 1;
  color: oklch(94% 0.03 var(--boss-hue, 275));
  background: oklch(35% 0.1 var(--boss-hue, 275));
  border: 3px solid oklch(56% 0.13 var(--boss-hue, 275));
  box-shadow: inset 0 0 0 5px oklch(28% 0.08 var(--boss-hue, 275));
  user-select: none;
}
.boss img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit;
}
.boss.hit { animation: boss-hit 320ms var(--ease-out); }
@keyframes boss-hit {
  0% { transform: translateX(0); filter: brightness(1); }
  20% { transform: translateX(-7px) rotate(-3deg); filter: brightness(1.6); }
  50% { transform: translateX(6px) rotate(2deg); }
  100% { transform: translateX(0); filter: brightness(1); }
}
.boss.defeated { animation: boss-down 700ms var(--ease-out) forwards; }
@keyframes boss-down {
  to { transform: translateY(24px) rotate(8deg) scale(0.85); opacity: 0.15; }
}

/* ---------- HP bar ---------- */
.hpbar {
  width: 100%; height: 14px; border-radius: 999px;
  background: var(--bg-deep); border: 1.5px solid var(--border);
  overflow: hidden;
}
.hpbar .fill {
  height: 100%; border-radius: 999px;
  background: var(--danger);
  transition: width 300ms var(--ease-out);
}

/* ---------- cards / tiles ---------- */
.card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: clamp(16px, 3vw, 26px);
}
.tile {
  font-family: var(--font-hanzi); font-size: clamp(22px, 4.5vw, 30px);
  background: var(--surface-2); color: var(--fg);
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 18px; min-height: 56px; cursor: pointer;
  transition: border-color 100ms, background 100ms, transform 80ms var(--ease-out);
  touch-action: manipulation;
}
.tile:hover { border-color: var(--action); }
.tile:active { transform: scale(0.97); }
.tile.correct { border-color: var(--success); background: oklch(34% 0.08 150); }
.tile.wrong { border-color: var(--danger); background: oklch(32% 0.08 25); animation: shake 300ms var(--ease-out); }
.tile.used { opacity: 0.3; pointer-events: none; }
.choices.locked .tile { pointer-events: none; }
.choices.locked .tile:not(.correct):not(.wrong) { opacity: 0.5; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  60% { transform: translateX(5px); }
}

/* ---------- hanzi display ---------- */
.hanzi-big {
  font-family: var(--font-hanzi);
  font-size: clamp(34px, 7vw, 56px);
  line-height: 1.4; text-align: center;
}

/* ---------- confetti (one-shot) ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i {
  position: absolute; top: -4vh; width: 10px; height: 16px;
  animation: drop 1400ms var(--ease-out) forwards;
}
@keyframes drop {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .boss.hit, .boss.defeated, .tile.wrong { animation: none; }
  .confetti { display: none; }
  * { transition-duration: 1ms !important; }
}
