:root {
  --bg-deep: #0b0914;
  --bg-panel: rgba(23, 18, 38, 0.84);
  --border-soft: rgba(236, 109, 155, 0.24);
  --border-glow: rgba(236, 109, 155, 0.55);
  --rose: #ec6d9b;
  --rose-soft: #f7b3cc;
  --violet: #9580ff;
  --teal: #64dfdf;
  --text-main: #f3effa;
  --text-dim: #a398bd;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: radial-gradient(circle at 50% 18%, #221636 0%, #100c1c 48%, #090710 100%);
  color: var(--text-main);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.page-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.layout {
  display: flex;
  gap: 18px;
  align-items: stretch;
  max-width: 920px;
  width: 100%;
  justify-content: center;
}

.stage-shell {
  position: relative;
  width: min(480px, calc(100vw - 28px));
  aspect-ratio: 3 / 4;
  max-height: calc(100dvh - 28px);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-glow);
  background: #0d0a17;
  box-shadow:
    0 0 36px rgba(236, 109, 155, 0.14),
    0 18px 48px rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
}

#danmaku-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* Top in-stage spell banner */
.spell-banner {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(15, 11, 26, 0.68);
  border: 1px solid rgba(149, 128, 255, 0.28);
  backdrop-filter: blur(6px);
  pointer-events: none;
  font-size: 12px;
  transition: opacity 0.3s ease;
}

.spell-banner.hidden {
  opacity: 0;
}

.spell-tag {
  color: var(--rose-soft);
  font-weight: 600;
  letter-spacing: 0.4px;
}

.spell-phase {
  color: var(--teal);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  text-align: center;
  background: rgba(11, 8, 20, 0.78);
  backdrop-filter: blur(6px);
  transition: opacity 0.2s ease;
  z-index: 5;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.emblem {
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  filter: drop-shadow(0 0 12px rgba(236, 109, 155, 0.45));
}

.overlay h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--rose-soft);
  margin-bottom: 6px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 18px;
  max-width: 340px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 18px;
}

.result-item {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 6px;
}

.result-item .label {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.result-item .val {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 11px 28px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #ec6d9b 0%, #8b5cf6 100%);
  box-shadow: 0 6px 20px rgba(236, 109, 155, 0.35);
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: scale(0.97);
}

.hint-line {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
}

/* Side Info & HUD Panel */
.side-panel {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 16px;
  backdrop-filter: blur(8px);
}

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--rose);
  margin-bottom: 12px;
  font-weight: 700;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 14px;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--text-dim);
}

.stat-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.stat-value.accent {
  color: var(--gold);
}

.stat-value.teal {
  color: var(--teal);
}

.controls-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}

.controls-list kbd {
  display: inline-block;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 5px;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn-ghost {
  flex: 1;
  appearance: none;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn-ghost:hover {
  border-color: var(--border-glow);
  background: rgba(236, 109, 155, 0.12);
}

.footer-note {
  margin-top: auto;
  font-size: 11px;
  color: rgba(163, 152, 189, 0.65);
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 800px) {
  .page-wrap {
    padding: 10px;
    align-items: flex-start;
  }

  .layout {
    flex-direction: column;
    align-items: center;
    gap: 12px;
  }

  .stage-shell {
    width: min(460px, calc(100vw - 20px));
    max-height: 72dvh;
  }

  .side-panel {
    width: min(460px, calc(100vw - 20px));
  }
}

