:root {
  --ink: #2f2733;
  --muted: #75657b;
  --paper: #fff8ec;
  --mint: #00b277;
  --sky: #5ac5ef;
  --sun: #ffd45f;
  --rose: #ff6f91;
  --plum: #695083;
  --line: rgba(47, 39, 51, .16);
  --shadow: 0 18px 44px rgba(83, 54, 80, .18);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 245, 198, .96), rgba(188, 238, 235, .94) 48%, rgba(255, 204, 218, .96));
  user-select: none;
  -webkit-user-select: none;
}

button {
  font: inherit;
  color: inherit;
}

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #2f2733;
  color: #ffd45f;
  font-size: 32px;
  font-weight: 900;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.character-btn,
.primary-action,
.secondary-action {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .7);
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 24px rgba(80, 56, 70, .12);
  font-size: 24px;
}

.game-shell {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  gap: 14px;
}

.stage-zone {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
}

.stage {
  width: 100%;
  height: 100%;
  max-height: calc(100dvh - 96px);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 24%, #fff9cf 0%, #bdefff 46%, #f6b4c8 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

.control-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 12px;
  align-content: start;
}

.character-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.character-btn {
  min-height: 78px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .72);
  box-shadow: inset 0 0 0 1px var(--line), 0 12px 28px rgba(75, 51, 72, .13);
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  text-align: left;
}

.character-btn[aria-pressed="true"] {
  background: #2f2733;
  color: #fff8ec;
}

.avatar-dot {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55);
}

.character-btn strong {
  display: block;
  font-size: 17px;
  line-height: 1.05;
}

.character-tag {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: 800;
  opacity: .72;
}

.dance-actions {
  display: grid;
  gap: 10px;
}

.primary-action,
.secondary-action {
  width: 100%;
  min-height: 70px;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow);
}

.primary-action {
  background: #00b277;
  color: #fff;
}

.secondary-action {
  background: #ffd45f;
  color: #312920;
}

.primary-action span,
.secondary-action span {
  font-size: 25px;
}

.primary-action strong,
.secondary-action strong {
  font-size: 19px;
  line-height: 1;
}

.mini-board {
  min-height: 88px;
  padding: 16px;
  border-radius: 24px;
  background: rgba(255, 255, 255, .56);
  box-shadow: inset 0 0 0 1px var(--line);
}

.beat-row {
  height: 56px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  align-items: center;
  gap: 7px;
}

.beat-dot {
  height: 18px;
  border-radius: 999px;
  background: rgba(47, 39, 51, .16);
  box-shadow: inset 0 0 0 1px rgba(47, 39, 51, .08);
  transition: transform .16s ease, background .16s ease;
}

.beat-dot.is-on {
  transform: scaleY(1.8);
  background: #ff6f91;
}

.back-orbit {
  fill: none;
  stroke: rgba(255, 255, 255, .62);
  stroke-width: 9;
  stroke-dasharray: 18 18;
}

.back-orbit--two {
  stroke: rgba(255, 250, 198, .72);
}

.curtain {
  opacity: .68;
}

.curtain--left {
  fill: #ff7c70;
}

.curtain--right {
  fill: #695083;
}

.part {
  stroke: rgba(47, 39, 51, .22);
  stroke-width: 7;
  paint-order: stroke fill;
}

.joint {
  stroke: rgba(47, 39, 51, .18);
  stroke-width: 6;
}

.face-line {
  stroke: #2f2733;
  stroke-width: 7;
  stroke-linecap: round;
  fill: none;
}

.handle {
  cursor: grab;
  pointer-events: auto;
}

.handle-ring {
  fill: rgba(255, 255, 255, .42);
  stroke: rgba(47, 39, 51, .18);
  stroke-width: 5;
}

.handle-core {
  fill: #fff8ec;
  stroke: #2f2733;
  stroke-width: 5;
}

.handle:active .handle-core {
  fill: #ffd45f;
}

.handle.is-active .handle-ring {
  fill: rgba(255, 212, 95, .38);
  stroke: rgba(47, 39, 51, .32);
}

.handle.is-active .handle-core {
  fill: #ffd45f;
}

.handle-label {
  fill: #2f2733;
  font-size: 32px;
  font-weight: 900;
  pointer-events: none;
}

.beat-lights circle {
  transition: opacity .16s ease, r .16s ease;
}

.float-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.float-item {
  position: absolute;
  left: 50%;
  top: 50%;
  font-size: 26px;
  animation: float-up 1.15s ease-out forwards;
  transform: translate(-50%, -50%);
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, -34%) scale(.7) rotate(-8deg);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), -168px) scale(1.25) rotate(18deg);
  }
}

.app[data-dancing="true"] .primary-action {
  background: #ff6f91;
}

.app[data-dancing="true"] .handle {
  opacity: .36;
}

@media (max-width: 820px) {
  .app {
    gap: 8px;
  }

  .topbar {
    min-height: 56px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    font-size: 28px;
  }

  h1 {
    font-size: 22px;
  }

  .brand p {
    font-size: 14px;
  }

  .icon-btn {
    width: 50px;
    height: 50px;
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .stage {
    max-height: none;
    border-radius: 22px;
  }

  .control-panel {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  .character-strip {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .character-btn {
    min-height: 66px;
    grid-template-columns: 34px 1fr;
    border-radius: 18px;
    padding: 8px;
  }

  .avatar-dot {
    width: 34px;
    height: 34px;
    border-radius: 13px;
  }

  .character-btn strong {
    font-size: 15px;
  }

  .character-tag {
    display: none;
  }

  .dance-actions {
    grid-template-columns: 1fr 1fr;
  }

  .primary-action,
  .secondary-action {
    min-height: 60px;
    border-radius: 20px;
  }

  .mini-board {
    min-height: 60px;
    padding: 12px;
  }

  .beat-row {
    height: 36px;
  }
}

@media (max-width: 600px) {
  .brand p {
    display: none;
  }

  .character-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel {
    grid-template-columns: 1fr;
  }
}

@media (orientation: portrait) and (min-width: 700px) {
  .game-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .control-panel {
    grid-template-columns: 1fr 260px;
    grid-template-rows: auto auto;
  }

  .character-strip {
    grid-column: 1 / -1;
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
