:root {
  color: #1d2740;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "WenQuanYi Micro Hei", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 12%, #fff 0 34px, transparent 36px),
    radial-gradient(circle at 14% 18%, #fff 0 16px, transparent 18px),
    radial-gradient(circle at 92% 8%, #fff 0 40px, transparent 42px),
    linear-gradient(180deg, #b7e6ff 0%, #e7f6ff 42%, #fff6ea 100%);
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }
[hidden] { display: none !important; }

.home {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
}
.home-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.eyebrow { margin: 0 0 4px; color: #0369a1; font-weight: 800; letter-spacing: 0.06em; }
h1 { margin: 0; font-size: clamp(34px, 6vw, 60px); line-height: 1.05; }
h2 { margin: 0 0 8px; font-size: 22px; }
.lead, .fine { color: #334155; line-height: 1.45; }
.fine { font-size: 15px; }
.text-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 800;
}
.pickers { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.picker { padding: 12px; border-radius: 24px; background: rgba(255, 255, 255, 0.72); }
.picker.left { box-shadow: inset 0 0 0 3px #bfdbfe; }
.picker.right { box-shadow: inset 0 0 0 3px #fecdd3; }
.cast { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 2px 8px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: #fff;
}
.char img, .hero { width: min(100%, 96px); height: auto; display: block; }
.hero { width: min(210px, 30vw); }
.face { position: relative; display: inline-block; }
.fighter.right .face { transform: scaleX(-1); }
.acc {
  position: absolute;
  pointer-events: none;
}
.acc-band .acc {
  left: 22%;
  top: 18%;
  width: 56%;
  height: 8px;
  border-radius: 99px;
  background: #fff;
  box-shadow: 0 3px 0 #38bdf8;
}
.acc-star .acc {
  right: 8%;
  top: 42%;
  width: 14px;
  height: 14px;
  background: #fde047;
  clip-path: polygon(50% 0, 62% 35%, 100% 38%, 70% 60%, 80% 100%, 50% 78%, 20% 100%, 30% 60%, 0 38%, 38% 35%);
}
.acc-bow .acc {
  left: 18%;
  top: 16%;
  width: 16px;
  height: 12px;
  background: #ef476f;
  border-radius: 8px 2px;
}
.acc-ribbon .acc {
  left: 58%;
  top: 10%;
  width: 8px;
  height: 28px;
  background: #c4b5fd;
  border-radius: 4px;
}
.acc-flower .acc {
  right: 6%;
  top: 14%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fb7185;
  box-shadow: 0 0 0 3px #fde68a;
}
.mini { position: relative; display: inline-block; }
.mini .acc { transform: scale(0.7); }
.char.selected { border-color: #f0b429; background: #fffbeb; }
.primary, .ghost {
  min-height: 64px;
  border: 0;
  border-radius: 18px;
  font-size: 22px;
  font-weight: 800;
}
.primary { background: #16a34a; color: #fff; box-shadow: 0 5px 0 #166534; }
.ghost { background: #fff; box-shadow: 0 5px 0 #d5e2f2; }
.start { width: 100%; margin: 16px 0 8px; font-size: 26px; }
.primary:active, .ghost:active, .char:active, .choice:active, .subject.open:active { transform: translateY(2px); }
.back { margin-bottom: 8px; }
.subjects {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}
.subject {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 210px;
  padding: 16px;
  border: 0;
  border-radius: 24px;
  background: #fff;
  text-align: left;
  box-shadow: 0 8px 0 rgba(29, 39, 64, 0.06);
}
.subject strong { font-size: 32px; }
.subject em { font-style: normal; font-weight: 800; color: #0369a1; }
.subject-kicker { font-size: 13px; font-weight: 800; letter-spacing: 0.08em; color: #16a34a; }
.subject-blurb { color: #64748b; line-height: 1.4; }
.subject-action {
  margin-top: auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-weight: 800;
}
.subject.open { box-shadow: 0 8px 0 #86efac; }
.subject.soon { background: #f8fafc; color: #64748b; box-shadow: 0 8px 0 #e2e8f0; }
.subject.soon em, .subject.soon .subject-kicker { color: #94a3b8; }
.subject.soon .subject-action { background: #e2e8f0; color: #64748b; }
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 30;
  translate: -50% 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: #1d2740;
  color: #fff;
  font-weight: 800;
}

.arena {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  touch-action: manipulation;
}
.topbar, .hud-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mode-pill { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.85); font-weight: 800; }
.hud-row { align-items: stretch; }
.hp-card {
  flex: 1;
  min-width: 0;
  padding: 6px 10px 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
}
.hp-card.right { text-align: right; }
.hud-top { display: flex; gap: 8px; align-items: baseline; }
.hp-card.right .hud-top { flex-direction: row-reverse; }
.who { color: #64748b; font-size: 13px; font-weight: 800; }
.hud-top strong, .hp-num { font-size: clamp(18px, 2.4vw, 28px); }
.hp-label { color: #94a3b8; font-size: 12px; font-weight: 800; }
.hp { height: 14px; margin-top: 3px; border-radius: 999px; background: #e7eef8; overflow: hidden; }
.hp-card.right .hp { display: flex; justify-content: flex-end; }
.hp > span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #4ade80, #16a34a); transition: width 0.35s ease; }
.hp.hurt { animation: hp-hurt 0.4s ease; }
.hp.healed { animation: hp-heal 0.4s ease; }
.combo.pop { animation: pop 0.35s ease; }
.hp.mid > span { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.hp.low > span { background: linear-gradient(90deg, #fb7185, #e11d48); }
.combo { min-height: 1.1em; font-size: 14px; font-weight: 800; color: #94a3b8; }
.combo.hot { color: #c2410c; }
.vs { align-self: center; font-weight: 900; color: #0369a1; }

.stage {
  position: relative;
  flex: 1;
  min-height: 90px;
  display: grid;
  grid-template-columns: 1fr 40px 1fr;
  align-items: end;
}
.fighter { display: flex; justify-content: center; align-items: flex-end; min-width: 0; }
.pose { position: relative; width: min(210px, 30vw); transform-origin: 50% 90%; animation: bob 2.6s ease-in-out infinite; }
.pose svg { width: 100%; height: auto; display: block; max-height: 28vh; }
.fighter.lunge .pose { animation: lunge-left 0.42s ease; }
.fighter.right.lunge .pose { animation: lunge-right 0.42s ease; }
.fighter.charged .pose { filter: drop-shadow(0 0 12px #fde68a); }
.fighter.whiff .pose { animation: whiff 0.5s ease; }
.fighter.hit .pose { animation: recoil-left 0.4s ease; }
.fighter.right.hit .pose { animation: recoil-right 0.4s ease; }
.fighter.hit::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  top: 22%;
  bottom: 8%;
  border-radius: 40%;
  background: rgba(255, 90, 110, 0.28);
}
.fighter { position: relative; }
.fighter.ko .pose { animation: none; transform: translateY(46px) rotate(-28deg); filter: saturate(0.5); opacity: 0.75; }
.fighter.right.ko .pose { transform: translateY(46px) rotate(28deg); }
.fighter.win .pose { animation: none; transform: translateY(-8px) scale(1.04); }

.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; min-height: 42%; }
.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
}
.panel.left { box-shadow: inset 0 0 0 3px #bfdbfe; }
.panel.right { box-shadow: inset 0 0 0 3px #fecdd3; }
.ask { display: flex; flex-direction: column; gap: 4px; }
.ask-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.factors { font-size: clamp(26px, 4.4vw, 56px); font-weight: 900; line-height: 1.05; }
.clock { font-size: clamp(18px, 2vw, 28px); color: #0369a1; white-space: nowrap; }
.choices.three { grid-template-columns: repeat(3, 1fr); grid-template-rows: 1fr; }
.settings {
  margin-top: 16px;
  padding: 16px 16px 12px;
  border-radius: 22px;
  background: #1b2340;
  color: #e8eefc;
}
.settings h3 { margin: 12px 0 8px; font-size: 16px; letter-spacing: 0.04em; }
.settings h3:first-child { margin-top: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  min-height: 52px;
  padding: 8px 12px;
  border: 0;
  border-radius: 14px;
  background: #2c3a62;
  color: #dbe4ff;
  font-weight: 800;
}
.chip small { font-size: 12px; font-weight: 700; opacity: 0.85; }
.chip.on { background: #f5c518; color: #1b2340; }
.setting-help { margin: 10px 0 0; color: #c9d4f5; }
.lane-timer { height: 8px; border-radius: 99px; background: #e5eef8; overflow: hidden; }
.lane-timer span { display: block; height: 100%; width: 100%; background: #2563eb; transform-origin: left center; }
.panel.right .lane-timer span { transform-origin: right center; }
.lane-timer.warn span { background: #e11d48; }
.rhyme { min-height: 1.2em; text-align: center; color: #5b4bdb; font-weight: 800; font-size: clamp(16px, 2.2vw, 28px); }
.note { min-height: 1.2em; text-align: center; font-weight: 800; color: #64748b; }
.note.hit { color: #15803d; }
.note.miss, .note.timeout { color: #be123c; }
.choices { flex: 1; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; }
.choice {
  min-height: 56px;
  border: 0;
  border-radius: 16px;
  background: #f8fafc;
  box-shadow: 0 4px 0 #d5e2f2;
  font-size: clamp(26px, 4vw, 44px);
  font-weight: 900;
}
.choice.good { background: #dcfce7; color: #166534; box-shadow: 0 4px 0 #86efac; }
.choice.bad { background: #ffe4e6; color: #be123c; box-shadow: 0 4px 0 #fda4af; }
.panel.shake { animation: shake 0.35s ease; }

.fx { position: absolute; inset: 0; pointer-events: none; }
.shot { position: absolute; top: 42%; width: 48px; height: 48px; z-index: 3; }
.shot svg { width: 100%; height: 100%; }
.shot.from-left { left: 18%; animation: fly-right 0.28s linear forwards; }
.shot.from-right { right: 18%; animation: fly-left 0.28s linear forwards; }
.shot.big { width: 72px; height: 72px; filter: drop-shadow(0 0 10px #fde68a); }
.impact {
  position: absolute;
  top: 34%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 6px solid #fff;
  box-shadow: 0 0 0 8px rgba(255, 196, 87, 0.7);
  animation: impact 0.42s ease-out forwards;
}
.impact.left { left: 22%; }
.impact.right { right: 22%; }
.guard {
  position: absolute;
  left: 50%;
  top: 18%;
  translate: -50% 0;
  z-index: 4;
  padding: 8px 12px;
  border-radius: 18px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 900;
  box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.7);
  animation: guard 0.55s ease forwards;
}
.combo-pop {
  position: absolute;
  left: 50%;
  top: 8%;
  translate: -50% 0;
  z-index: 5;
  color: #c2410c;
  font-size: 28px;
  font-weight: 900;
  animation: pop 0.7s ease forwards;
}
.combo-pop.hot { font-size: 36px; color: #ef476f; }
.stage.bump { animation: bump 0.28s linear; }
.stage.bump-hard { animation: bump-hard 0.4s linear; }
.confetti { position: relative; height: 0; }
.confetti i {
  position: absolute;
  top: 0;
  width: 10px;
  height: 14px;
  border-radius: 3px;
  animation: confetti 0.8s ease-out both;
}
.result-card { position: relative; overflow: hidden; }
.floater {
  position: absolute;
  left: 50%;
  top: -28px;
  translate: -50% 0;
  z-index: 4;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fff;
  color: #e11d48;
  font-weight: 900;
  font-size: 28px;
  box-shadow: 0 4px 0 rgba(225, 29, 72, 0.15);
  animation: float-up 0.9s ease-out forwards;
}
.floater.heal { color: #15803d; box-shadow: 0 4px 0 rgba(22, 163, 74, 0.15); }
.floater.big { font-size: 36px; background: #fff7d6; }
.countdown {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  font-size: clamp(72px, 14vw, 160px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 8px 0 rgba(29, 39, 64, 0.18);
  pointer-events: none;
}
.ko-banner {
  position: absolute;
  left: 50%;
  top: 36%;
  z-index: 6;
  font-size: clamp(72px, 12vw, 160px);
  font-weight: 900;
  color: #ffe08a;
  -webkit-text-stroke: 8px #ef476f;
  paint-order: stroke fill;
  animation: ko-in 0.5s cubic-bezier(0.15, 0.8, 0.2, 1) forwards;
}
.result, .modal-back {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(255, 248, 240, 0.55);
}
.modal-back { z-index: 12; background: rgba(29, 39, 64, 0.28); }
.result-card, .modal {
  width: min(480px, 100%);
  padding: 20px 16px 14px;
  border-radius: 28px;
  background: #fff;
  text-align: center;
  box-shadow: 0 18px 40px rgba(29, 39, 64, 0.16);
}
.result-card h2, .modal h3 { margin: 0; font-size: clamp(28px, 5vw, 44px); }
.kicker { margin: 0; color: #ef476f; font-weight: 900; letter-spacing: 0.12em; }
.cheer { margin: 6px 0; color: #5b4bdb; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 8px 4px; border-radius: 12px; background: #f8fafc; }
.stat span { display: block; color: #64748b; font-size: 13px; }
.stat strong { font-size: 20px; }
.result-actions { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; margin-top: 12px; }

@media (max-width: 800px) {
  .subjects { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .pickers { grid-template-columns: 1fr; }
  .pose { width: min(140px, 36vw); }
  .factors { font-size: 32px; }
  .choice { min-height: 52px; font-size: 28px; }
  .hud-top strong, .hp-num { font-size: 16px; }
}
@media (max-height: 560px) {
  .pose svg { max-height: 18vh; }
  .choice { min-height: 44px; font-size: 22px; }
  .rhyme, .note { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes lunge-left { 45% { transform: translateX(26px) scale(1.04); } }
@keyframes lunge-right { 45% { transform: translateX(-26px) scale(1.04); } }
@keyframes recoil-left { 35% { transform: translateX(-14px) rotate(-6deg); } }
@keyframes recoil-right { 35% { transform: translateX(14px) rotate(6deg); } }
@keyframes fly-right { to { transform: translateX(42vw); opacity: 0.2; } }
@keyframes fly-left { to { transform: translateX(-42vw); opacity: 0.2; } }
@keyframes float-up {
  0% { opacity: 0; transform: translateY(8px) scale(0.7); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-36px); }
}
@keyframes shake {
  20% { transform: translateX(-8px); }
  45% { transform: translateX(8px); }
  70% { transform: translateX(-4px); }
}
@keyframes ko-in {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.8) rotate(8deg); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes hp-hurt { 40% { filter: brightness(1.8); } }
@keyframes hp-heal { 40% { filter: brightness(1.5) saturate(1.4); } }
@keyframes whiff {
  0% { transform: rotate(0); }
  35% { transform: rotate(-8deg) translateX(-8px); }
  100% { transform: rotate(0); }
}
@keyframes guard {
  0% { transform: scale(0.4); opacity: 0; }
  30% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}
@keyframes impact {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
@keyframes bump {
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
@keyframes bump-hard {
  20% { transform: translate(-6px, 2px); }
  40% { transform: translate(6px, -2px); }
  60% { transform: translate(-4px, 2px); }
  80% { transform: translate(3px, -1px); }
}
@keyframes confetti {
  to { transform: translateY(48px) rotate(30deg); opacity: 0; }
}
