:root {
  color-scheme: dark;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --bg: #05050d;
  --surface: #080713;
  --ink: #f6f0ff;
  --muted: #8f87a7;
  --line: rgba(232, 121, 249, 0.28);
  --accent: #d946ef;
  --accent-soft: rgba(217, 70, 239, 0.16);
  --wave: #f5d0fe;
  --soft-heading: #b8aec8;
  --rounded-title-font: "Yuanti SC", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}

button {
  font: inherit;
}

.game-shell {
  width: 100vw;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 34%, rgba(217, 70, 239, 0.13), transparent 29%),
    radial-gradient(circle at 18% 88%, rgba(56, 189, 248, 0.08), transparent 24%),
    linear-gradient(180deg, #070714 0%, #080713 50%, #05050d 100%);
  touch-action: none;
  user-select: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 76px 1fr 116px;
  gap: 12px;
  padding:
    max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.top-line {
  align-self: start;
  justify-self: start;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
}

.top-line strong {
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.top-line span {
  color: var(--muted);
}

.stage {
  position: relative;
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 0;
  text-align: center;
}

.screen-label {
  color: var(--muted);
  font-size: 17px;
  font-weight: 500;
}

.start-copy {
  display: grid;
  gap: 18px;
  justify-items: center;
}

.title {
  margin: 0;
  color: var(--soft-heading);
  font-family: var(--rounded-title-font);
  font-size: clamp(38px, 10.5vw, 54px);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: 0;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.primary-tap,
.confirm-zone,
.next-zone,
.small-action {
  align-self: end;
  justify-self: center;
  min-width: 126px;
  min-height: 48px;
  padding: 0 22px;
  color: var(--accent);
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
  font-weight: 700;
}

.start-button,
.next-label {
  display: inline-grid;
  min-height: 48px;
  place-items: center;
  padding: 0;
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
}

.countdown {
  position: absolute;
  top: calc(max(18px, env(safe-area-inset-top)) + 54px);
  right: max(20px, env(safe-area-inset-right));
  z-index: 2;
  margin: 0;
  color: rgba(245, 208, 254, 0.72);
  font-size: clamp(21px, 7vw, 32px);
  font-weight: 500;
  line-height: 1;
  text-shadow: 0 0 14px rgba(217, 70, 239, 0.22);
}

.waveform {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(46vw, 170px);
  height: min(58vh, 500px);
  overflow: visible;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.waveform-motion {
  transform-box: fill-box;
  transform-origin: center;
}

.waveform-dots path {
  fill: none;
  opacity: var(--o);
  stroke: url(#waveDotsGradient);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: var(--w);
  stroke-dasharray: 0.4 8.4;
  filter: drop-shadow(0 0 4px rgba(245, 208, 254, 0.8))
    drop-shadow(0 0 12px rgba(217, 70, 239, 0.48));
  animation: waveformPulse 2.05s ease-in-out infinite;
}

.waveform-glow path {
  fill: none;
  opacity: var(--go);
  stroke: rgba(217, 70, 239, 0.6);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 9;
  stroke-dasharray: 0.4 8.4;
  filter: blur(1.5px);
}

.waveform-result {
  opacity: 0.72;
}

.confirm-zone,
.small-action {
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
}

.adjust-readout {
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 72px);
  display: flex;
  align-items: baseline;
  gap: 5px;
  text-align: left;
}

.adjust-readout strong {
  color: var(--ink);
  font-size: clamp(14px, 3.8vw, 16px);
  font-weight: 700;
  line-height: 1.35;
}

.adjust-readout span {
  color: var(--muted);
  font-size: clamp(13px, 3.5vw, 15px);
}

.swipe-hint {
  position: absolute;
  top: 34%;
  left: 22%;
  z-index: 4;
  width: 72px;
  height: 156px;
  opacity: 0.9;
  pointer-events: none;
}

.swipe-track {
  position: absolute;
  top: 4px;
  left: 34px;
  width: 2px;
  height: 138px;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(246, 240, 255, 0.7),
    rgba(217, 70, 239, 0.9),
    transparent
  );
  box-shadow:
    0 0 8px rgba(246, 240, 255, 0.42),
    0 0 18px rgba(217, 70, 239, 0.32);
}

.swipe-track::before,
.swipe-track::after {
  position: absolute;
  left: 50%;
  width: 9px;
  height: 9px;
  content: "";
  border-top: 2px solid rgba(246, 240, 255, 0.72);
  border-left: 2px solid rgba(246, 240, 255, 0.72);
}

.swipe-track::before {
  top: -3px;
  transform: translateX(-50%) rotate(45deg);
}

.swipe-track::after {
  bottom: -3px;
  transform: translateX(-50%) rotate(225deg);
}

.swipe-hand {
  position: absolute;
  left: 15px;
  bottom: 18px;
  width: 44px;
  height: 54px;
  filter:
    drop-shadow(0 0 8px rgba(246, 240, 255, 0.62))
    drop-shadow(0 0 18px rgba(217, 70, 239, 0.36));
  animation: swipeHand 1.7s ease-in-out infinite;
}

.swipe-finger,
.swipe-thumb,
.swipe-palm {
  position: absolute;
  display: block;
  background: rgba(246, 240, 255, 0.92);
}

.swipe-finger {
  top: 0;
  left: 18px;
  width: 11px;
  height: 34px;
  border-radius: 999px;
}

.swipe-thumb {
  top: 27px;
  left: 6px;
  width: 19px;
  height: 10px;
  border-radius: 999px;
  transform: rotate(-28deg);
  transform-origin: right center;
}

.swipe-palm {
  right: 5px;
  bottom: 1px;
  width: 31px;
  height: 28px;
  border-radius: 14px 14px 16px 16px;
}

.is-hidden {
  visibility: hidden;
}

.result-readout {
  position: absolute;
  bottom: calc(max(18px, env(safe-area-inset-bottom)) + 82px);
  left: max(20px, env(safe-area-inset-left));
  display: block;
  margin-bottom: 0;
  text-align: left;
}

.result-pitches {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 8px;
  max-width: min(82vw, 360px);
}

.target-pitch {
  color: var(--muted);
  font-size: clamp(12px, 3.2vw, 14px);
  line-height: 1.45;
}

.pitch-slash {
  color: var(--muted);
  font-size: clamp(12px, 3.2vw, 14px);
}

.player-pitch {
  color: var(--muted);
  font-size: clamp(13px, 3.5vw, 15px);
  line-height: 1.35;
}

.player-pitch strong {
  color: var(--ink);
  font-size: 1.08em;
  font-weight: 700;
}

.score {
  color: var(--accent);
  font-size: clamp(16px, 4.2vw, 20px);
  font-weight: 700;
  line-height: 1;
}

.result-screen .next-label {
  min-height: 48px;
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
}

.result-screen .next-zone:focus-visible {
  outline: 0;
}

.game-over {
  grid-template-rows: 132px 1fr 80px;
}

.end-header {
  align-self: start;
  justify-self: start;
  margin-top: 18px;
}

.end-header h1 {
  margin: 0;
  color: #d8c8eb;
  font-family: var(--rounded-title-font);
  font-size: clamp(30px, 7.6vw, 38px);
  font-weight: 600;
  line-height: 1.25;
  text-shadow: 0 0 18px rgba(217, 70, 239, 0.18);
}

.summary-board {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(100%, 430px);
}

.total-score {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  color: var(--accent);
  font-family: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
  font-size: clamp(46px, 13vw, 64px);
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 14px rgba(217, 70, 239, 0.45);
  white-space: nowrap;
  transform: skewX(-8deg);
}

.total-score span {
  font-size: 0.54em;
  font-style: normal;
  transform: skewX(8deg);
}

.score-table {
  width: min(78vw, 360px);
  max-width: 360px;
  margin: 0 auto;
  border-collapse: collapse;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: clamp(10px, 2.9vw, 13px);
}

.score-table th,
.score-table td {
  padding: 11px 7px;
  text-align: center;
  border: 1px solid var(--line);
}

.score-table th {
  width: 52px;
  color: var(--muted);
  font-size: clamp(9px, 2.5vw, 11px);
  font-weight: 700;
  letter-spacing: 0;
}

.summary-score-row td {
  color: var(--accent);
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 700;
}

.summary-target-row td {
  color: var(--muted);
}

.summary-player-row td {
  color: var(--ink);
}

.fade-in {
  animation: fadeIn 180ms ease-out both;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes waveformPulse {
  0%,
  100% {
    opacity: 0.78;
  }

  50% {
    opacity: 0.96;
  }
}

@keyframes swipeHand {
  0% {
    opacity: 0;
    transform: translateY(42px) rotate(-8deg) scale(0.94);
  }

  18% {
    opacity: 1;
  }

  68% {
    opacity: 1;
    transform: translateY(-36px) rotate(5deg) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-46px) rotate(5deg) scale(0.98);
  }
}

@media (min-width: 560px) {
  body {
    display: grid;
    place-items: center;
    background: var(--bg);
  }

  .game-shell {
    width: min(100vw, 430px);
    height: min(100dvh, 932px);
    border: 1px solid rgba(232, 121, 249, 0.18);
  }
}

@media (max-height: 620px) {
  .screen {
    grid-template-rows: 58px 1fr 72px;
    gap: 8px;
  }

  .game-over {
    grid-template-rows: 104px 1fr 64px;
  }

  .summary-board {
    gap: 8px;
  }

  .score-table th,
  .score-table td {
    padding: 8px 4px;
  }
}
