:root {
  --ink: #1a1430;
  --muted: #6a6280;
  --panel: rgba(255, 255, 255, 0.9);
  --accent: #ff4d6d;
  --accent-2: #c9184a;
  --sky: #4cc9f0;
  --font-d: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  --font-b: "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-b);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  background: #1a1430;
}
.scene {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 60% 40% at 10% 0%, rgba(255, 77, 109, 0.35), transparent 55%),
    radial-gradient(ellipse 50% 35% at 90% 15%, rgba(76, 201, 240, 0.28), transparent 50%),
    linear-gradient(165deg, #2a2048 0%, #1a1430 55%, #120e22 100%);
}
.topbar {
  max-width: 1200px; margin: 0 auto; padding: 0.9rem 1.2rem 0.3rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; color: #f8f0ff;
}
.back { color: #ff8fa3; text-decoration: none; font-weight: 700; }
.brand { display: flex; gap: 0.7rem; align-items: center; flex: 1; }
.mark {
  width: 2.6rem; height: 2.6rem; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #ff8fa3, #ff4d6d);
  color: #fff; font-family: var(--font-d); font-size: 1.25rem;
}
.brand h1 { margin: 0; font-family: var(--font-d); font-size: 1.45rem; }
.brand p { margin: 0; font-size: 0.82rem; opacity: 0.75; }
main { max-width: 1200px; margin: 0 auto; padding: 0.4rem 1.2rem 2.5rem; }
.panel {
  background: var(--panel); border-radius: 20px; padding: 1.3rem;
  max-width: 440px; box-shadow: 0 16px 40px rgba(0,0,0,0.3);
}
.panel h2 { margin: 0 0 0.8rem; font-family: var(--font-d); font-size: 1.7rem; }
.field { display: grid; gap: 0.35rem; }
.field > span { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 0.5rem; }
.row input {
  flex: 1; border: 1px solid #d5cce8; border-radius: 12px;
  padding: 0.65rem 0.8rem; font: inherit;
}
.name-list { list-style: none; margin: 0.75rem 0; padding: 0; display: grid; gap: 0.3rem; }
.name-list li {
  display: flex; justify-content: space-between;
  padding: 0.45rem 0.65rem; background: #f3eefc; border-radius: 10px; font-weight: 700;
}
.name-list button { border: 0; background: transparent; color: var(--accent-2); cursor: pointer; font: inherit; }
.hint { color: var(--muted); font-size: 0.88rem; }
.btn {
  border: 0; cursor: pointer; font: inherit; font-weight: 700;
  border-radius: 14px; padding: 0.65rem 1.15rem;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(145deg, #ff8fa3, #ff4d6d); color: #fff; }
.btn.secondary { background: #fff; color: var(--ink); border: 1px solid #d5cce8; }
.btn.ghost { background: rgba(255,255,255,0.12); color: #f8f0ff; border: 1px solid rgba(255,255,255,0.25); }
.btn.wide { width: 100%; margin-top: 0.4rem; }
.layout { display: grid; gap: 1rem; }
@media (min-width: 960px) { .layout { grid-template-columns: 1fr 270px; } }
.status {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.status > span, #phaseEl {
  padding: 0.5rem 0.85rem; border-radius: 999px;
  background: rgba(255,255,255,0.12); color: #f0e8ff; font-weight: 600;
}
.status strong { color: #fff; }

.actor-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 143, 163, 0.22), rgba(76, 201, 240, 0.14));
  border: 1px solid rgba(255, 209, 102, 0.35);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset;
}
.actor-banner[hidden] { display: none !important; }
.actor-icon {
  flex: none;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.16);
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  line-height: 1;
}
.actor-meta { min-width: 0; flex: 1; }
.actor-who {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  font-family: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
}
.actor-who strong { color: #ffd166; }
.actor-power {
  margin: 0.28rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: rgba(240, 232, 255, 0.88);
}
.actor-next {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #ffd166;
}

.track {
  position: relative;
  margin: 0.75rem auto 0;
  border-radius: 24px;
  background: linear-gradient(160deg, #352a58, #241c3e 55%, #1c1530);
  border: 1px solid rgba(255,255,255,0.12);
  overflow: hidden;
  max-width: 100%;
}
.lane-ring {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 999px;
  border: 18px solid rgba(255, 143, 163, 0.12);
  box-sizing: border-box;
  pointer-events: none;
  z-index: 0;
}
.track.stadium .space {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 1.85rem;
  height: 1.85rem;
  min-height: 0;
  flex: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0.08rem;
  z-index: 1;
  box-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.track.stadium .space.start {
  background: rgba(76, 201, 240, 0.45);
  z-index: 2;
  width: 2.15rem;
  height: 2.15rem;
}
.track.stadium .space.finish,
.track.stadium .space.podium {
  width: 2.35rem;
  height: 2.35rem;
  background: rgba(255, 77, 109, 0.45);
  z-index: 2;
  box-shadow: 0 0 0 2px rgba(255, 209, 102, 0.55);
}
.space .idx {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.7);
  font-weight: 800;
  line-height: 1;
}
.stack {
  display: flex; flex-wrap: wrap; gap: 0;
  justify-content: center;
  margin-top: 0;
  max-width: 100%;
}
.piece-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.piece-layer .tok {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: 1.35rem;
  height: 1.35rem;
  font-size: 0.8rem;
  border-radius: 6px;
  z-index: 6;
  will-change: left, top, transform, opacity;
}
.tok {
  width: 1.05rem; height: 1.05rem; border-radius: 5px;
  border: 1.5px solid #fff; font-size: 0.65rem;
  display: grid; place-items: center; cursor: default;
  padding: 0; background: #fff;
}
.tok.tok-moving {
  z-index: 12;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.45));
}
.tok.tok-knock {
  outline: 2px solid #ff8fa3;
}
.tok.tok-warp-out {
  animation: tok-warp-out 0.14s ease forwards;
}
.tok.tok-warp-in {
  animation: tok-warp-in 0.18s ease;
}
@keyframes tok-warp-out {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
}
@keyframes tok-warp-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(1.45); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.anim-hint {
  margin: 0;
  text-align: center;
  color: rgba(240, 232, 255, 0.85);
  font-weight: 700;
  padding: 0.5rem;
}
.tok.tripped { opacity: 0.45; transform: rotate(90deg); }
.piece-layer .tok.tripped {
  transform: translate(-50%, -50%) rotate(90deg);
}
.tok.done { box-shadow: 0 0 0 2px #ffd166; }
.tok.c0 { background: #ffe3e3; }
.tok.c1 { background: #d0ebff; }
.tok.c2 { background: #d3f9d8; }
.tok.c3 { background: #ffe8cc; }
.tok.c4 { background: #e5dbff; }
.tok.c5 { background: #ffdeeb; }

.msg {
  text-align: center; font-family: var(--font-d); font-size: 1.35rem;
  color: #ff8fa3; margin: 0.75rem 0 0.15rem; min-height: 1.4em;
}
.submsg { text-align: center; color: rgba(240,232,255,0.7); font-size: 0.9rem; min-height: 1.2em; margin: 0 0 0.5rem; }
.actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center;
  min-height: 3rem;
}
.draft-row {
  display: flex; flex-wrap: wrap; gap: 0.55rem; justify-content: center;
  width: 100%;
}
.racer-card {
  width: 9.5rem; text-align: left;
  border: 1px solid #e0d6f5; border-radius: 14px;
  background: #fff; padding: 0.65rem 0.7rem;
  cursor: pointer; font: inherit; color: var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.racer-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(80, 40, 120, 0.15);
}
.racer-card .ic { font-size: 1.4rem; }
.racer-card strong { display: block; font-size: 0.95rem; margin: 0.15rem 0; }
.racer-card p { margin: 0; font-size: 0.72rem; color: var(--muted); line-height: 1.35; }
.pick-block { width: 100%; margin-bottom: 0.6rem; }
.pick-block h3 { margin: 0 0 0.4rem; color: #f0e8ff; font-size: 1rem; text-align: center; }
.roll-show {
  width: 100%; text-align: center; font-size: 2rem; font-weight: 900; color: #fff; margin: 0;
}
.roll-show.duel {
  display: flex; justify-content: center; gap: 1.2rem; flex-wrap: wrap;
}
.roll-show .duel-side {
  display: grid; gap: 0.2rem; justify-items: center;
  min-width: 5.5rem;
}
.roll-show .duel-side .nm { font-size: 0.85rem; font-weight: 700; color: rgba(240,232,255,0.85); }
.roll-show .duel-side .n { font-size: 2.2rem; font-weight: 900; color: #ffd166; line-height: 1; }

/* 技能发动提示 */
.skill-toast {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: min(92vw, 420px);
  padding: 0.9rem 1.1rem;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(48, 28, 78, 0.96), rgba(24, 16, 42, 0.96));
  border: 1px solid rgba(255, 209, 102, 0.55);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.08) inset;
  color: #fff;
  pointer-events: none;
  animation: skill-toast-in 0.28s ease;
}
.skill-toast[hidden] { display: none !important; }
.skill-toast.is-out { animation: skill-toast-out 0.25s ease forwards; }
.skill-toast-icon {
  flex: none;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  background: rgba(255, 209, 102, 0.2);
}
.skill-toast-kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ffd166;
  font-weight: 800;
}
.skill-toast-who {
  margin: 0.15rem 0 0;
  font-family: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}
.skill-toast-effect {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  line-height: 1.4;
  color: rgba(240, 232, 255, 0.92);
}
@keyframes skill-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-12px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}
@keyframes skill-toast-out {
  to { opacity: 0; transform: translateX(-50%) translateY(-8px) scale(0.97); }
}

/* 掷骰动画遮罩 */
.dice-overlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  background: rgba(12, 8, 28, 0.62);
  backdrop-filter: blur(3px);
  padding: 1rem;
}
.dice-overlay[hidden] { display: none !important; }
.dice-card {
  min-width: min(88vw, 320px);
  padding: 1.25rem 1.4rem 1.4rem;
  border-radius: 22px;
  background: linear-gradient(160deg, #3a2a62, #24183f);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.dice-caption {
  margin: 0 0 0.85rem;
  font-family: "ZCOOL KuaiLe", "Noto Sans SC", sans-serif;
  font-size: 1.25rem;
  color: #ff8fa3;
}
.dice-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  align-items: flex-end;
}
.dice-unit {
  display: grid;
  gap: 0.35rem;
  justify-items: center;
}
.dice-unit .lbl {
  font-size: 0.8rem;
  font-weight: 700;
  color: rgba(240, 232, 255, 0.8);
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dice-face {
  width: 4.2rem;
  height: 4.2rem;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  font-weight: 900;
  color: #24183f;
  background: linear-gradient(145deg, #fff7e0, #ffd166);
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}
.dice-face.is-spinning {
  animation: dice-spin 0.09s linear infinite;
}
.dice-face.is-settled {
  animation: dice-land 0.38s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.dice-result {
  margin: 0.9rem 0 0;
  min-height: 1.4em;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}
@keyframes dice-spin {
  0% { transform: rotate(-8deg) scale(0.96); }
  50% { transform: rotate(8deg) scale(1.04); }
  100% { transform: rotate(-8deg) scale(0.96); }
}
@keyframes dice-land {
  0% { transform: scale(1.35) rotate(-12deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.side {
  background: var(--panel); border-radius: 20px; padding: 1rem;
  box-shadow: 0 16px 40px rgba(0,0,0,0.25);
}
.side h2 { margin: 0; font-family: var(--font-d); font-size: 1.3rem; }
.log-h { margin-top: 0.85rem !important; }
.ability-tips {
  display: grid; gap: 0.4rem; margin: 0.45rem 0 0.2rem;
  max-height: 14rem; overflow: auto;
}
.tip-empty { margin: 0; font-size: 0.8rem; color: var(--muted); }
.tip-card {
  padding: 0.45rem 0.55rem; border-radius: 10px;
  background: #f3eefc; border-left: 3px solid #bbb; font-size: 0.78rem;
}
.tip-card.is-turn { box-shadow: inset 0 0 0 1px rgba(255, 77, 109, 0.4); }
.tip-card.c0 { border-left-color: #e03131; }
.tip-card.c1 { border-left-color: #1c7ed6; }
.tip-card.c2 { border-left-color: #2f9e44; }
.tip-card.c3 { border-left-color: #e8590c; }
.tip-card.c4 { border-left-color: #7048e8; }
.tip-card.c5 { border-left-color: #c2255c; }
.tip-hd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem; }
.tip-hd .who { margin-left: auto; color: var(--muted); font-size: 0.72rem; }
.tip-card p { margin: 0.25rem 0 0; color: var(--muted); line-height: 1.35; }
.tip-card em { display: block; margin-top: 0.2rem; color: var(--accent-2); font-size: 0.72rem; }
.scores { list-style: none; margin: 0.6rem 0; padding: 0; display: grid; gap: 0.4rem; }
.scores li {
  padding: 0.5rem 0.6rem; background: #f3eefc; border-radius: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 0.15rem;
  border-left: 4px solid transparent;
}
.scores li.is-turn { box-shadow: inset 0 0 0 2px rgba(255, 77, 109, 0.3); }
.scores li.c0 { border-left-color: #e03131; }
.scores li.c1 { border-left-color: #1c7ed6; }
.scores li.c2 { border-left-color: #2f9e44; }
.scores li.c3 { border-left-color: #e8590c; }
.scores li.c4 { border-left-color: #7048e8; }
.scores li.c5 { border-left-color: #c2255c; }
.scores .nm { font-weight: 700; }
.scores .pts { font-weight: 800; font-size: 1.2rem; color: var(--accent-2); }
.scores .team { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.chip {
  font-size: 0.68rem; padding: 0.12rem 0.35rem; border-radius: 6px;
  background: #fff; border: 1px solid #e0d6f5;
}
.chip.used { opacity: 0.4; text-decoration: line-through; }
.log { list-style: none; margin: 0.4rem 0; padding: 0; max-height: 9rem; overflow: auto; }
.log li { font-size: 0.78rem; color: var(--muted); padding: 0.2rem 0; border-bottom: 1px solid #eee; }
.rules { border-top: 1px solid #e8e0f5; padding-top: 0.6rem; margin-top: 0.5rem; }
.rules .t { margin: 0 0 0.3rem; font-weight: 700; }
.rules ul { margin: 0; padding-left: 1.05rem; font-size: 0.84rem; color: var(--muted); }
[hidden] { display: none !important; }
