@font-face {
  font-family: "VT323 Local";
  src: url("/fonts/VT323-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "IBM Plex Mono Local";
  src: url("/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-weight: 700;
}

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #050305;
  --fg: #ffd7ed;
  --pink: #ff8fc7;
  --pink-hot: #ff4ea7;
  --pink-dim: rgba(255, 143, 199, 0.34);
  --pink-faint: rgba(255, 143, 199, 0.11);
  --black-soft: rgba(0, 0, 0, 0.48);
  --shadow: rgba(255, 84, 173, 0.24);
  --stage-background:
    linear-gradient(var(--pink-faint) 1px, transparent 1px),
    linear-gradient(90deg, var(--pink-faint) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(255, 143, 199, 0.16), transparent 58%),
    var(--bg);
  --stage-background-size: 28px 28px, 28px 28px, auto, auto;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  overflow: hidden;
  background: var(--stage-background);
  background-size: var(--stage-background-size);
  color: var(--fg);
}

html {
  min-height: -webkit-fill-available;
}

body {
  position: fixed;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: calc(-1 * max(120px, env(safe-area-inset-bottom)));
  z-index: 0;
  background: var(--stage-background);
  background-size: var(--stage-background-size);
  pointer-events: none;
}

body,
button,
input {
  font-family: "IBM Plex Mono Local", ui-monospace, Menlo, Consolas, monospace;
}

button {
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--stage-background);
  background-size: var(--stage-background-size);
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  inset: auto;
  pointer-events: none;
}

.stage::before {
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 143, 199, 0.11), transparent 56%);
  opacity: 0.86;
}

.stage::after {
  inset: 0;
  background:
    linear-gradient(transparent, rgba(255, 143, 199, 0.045) 50%, transparent 51%),
    linear-gradient(90deg, transparent, rgba(255, 143, 199, 0.035) 50%, transparent 51%);
  opacity: 0.58;
}

.status {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(72vw, 520px);
  overflow: hidden;
  color: rgba(255, 215, 237, 0.62);
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.status.playing,
.status.ready {
  opacity: 0;
}

.arena-wrap {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: max(76px, env(safe-area-inset-top)) max(82px, env(safe-area-inset-right)) max(84px, env(safe-area-inset-bottom)) max(82px, env(safe-area-inset-left));
}

.arena {
  position: relative;
  width: min(84vmin, 860px);
  min-width: 240px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(255, 143, 199, 0.11) 0 20%, transparent 20.4%),
    radial-gradient(circle, rgba(255, 143, 199, 0.06), transparent 64%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 143, 199, 0.24),
    0 0 90px rgba(255, 80, 170, 0.08);
  overflow: visible;
}

.target-ring {
  position: absolute;
  z-index: 5;
  inset: 50% auto auto 50%;
  display: grid;
  place-items: center;
  width: 27%;
  min-width: 104px;
  aspect-ratio: 1;
  border: 1px solid var(--pink);
  border-radius: 50%;
  background: rgba(5, 3, 5, 0.82);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 42px rgba(255, 143, 199, 0.16),
    inset 0 0 38px rgba(255, 143, 199, 0.08);
  transform: translate(-50%, -50%);
}

.target-ring.hit {
  animation: hit-pulse 180ms ease-out;
}

.target-ring.paused {
  overflow: hidden;
}

.judgement {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  width: min(52vw, 360px);
  color: var(--pink);
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(42px, 9vmin, 92px);
  line-height: 0.9;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 0 24px rgba(255, 143, 199, 0.72),
    0 0 2px #050305;
  opacity: 0;
  transform: translate(-50%, calc(-50% - min(19vmin, 150px))) scale(0.96);
  pointer-events: none;
}

.judgement.show {
  animation: judgement-pop 560ms steps(2, end);
}

.judgement.perfect {
  color: #ffd7ed;
}

.judgement.ok,
.judgement.okay {
  color: var(--pink);
}

.judgement.miss {
  color: rgba(255, 143, 199, 0.46);
}

.judgement.freestyle {
  color: #fff36f;
  text-shadow:
    0 0 28px rgba(255, 243, 111, 0.58),
    0 0 2px #050305;
}

@keyframes judgement-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - min(19vmin, 150px))) scale(0.92);
  }
  16%,
  74% {
    opacity: 1;
    transform: translate(-50%, calc(-50% - min(19vmin, 150px))) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - min(19vmin, 150px))) scale(1.04);
  }
}

.end-summary {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 7;
  width: min(62vw, 420px);
  color: var(--pink);
  font-family: "VT323 Local", ui-monospace, monospace;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 0 22px rgba(255, 143, 199, 0.44),
    0 0 2px #050305;
  transform: translate(-50%, calc(-50% + min(20vmin, 150px)));
  isolation: isolate;
  pointer-events: auto;
}

.end-summary[hidden] {
  display: none;
}

.end-summary::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10%;
  z-index: -1;
  width: min(86vw, 680px);
  aspect-ratio: 1.45;
  background:
    radial-gradient(circle, #f6ffe8 0 2px, transparent 2.5px) 8% 24% / 78px 64px,
    radial-gradient(circle, #fff36f 0 2px, transparent 2.5px) 30% 9% / 96px 78px,
    radial-gradient(circle, #ff8fc7 0 1.6px, transparent 2.2px) 56% 18% / 70px 60px,
    radial-gradient(circle, #7df9ff 0 1.8px, transparent 2.4px) 82% 30% / 88px 72px,
    radial-gradient(circle, rgba(255, 143, 199, 0.28), transparent 58%);
  opacity: 0;
  filter:
    drop-shadow(0 0 8px rgba(246, 255, 232, 0.72))
    drop-shadow(0 0 18px rgba(255, 143, 199, 0.38));
  transform: translate(-50%, -48%) scale(0.92);
  transition: opacity 180ms steps(2, end);
  pointer-events: none;
}

.end-summary.full-clear::before {
  opacity: 0.95;
  animation: full-clear-stars 1400ms steps(2, end) infinite;
}

.summary-badge {
  position: relative;
  z-index: 1;
  margin-bottom: 6px;
  color: #f6ffe8;
  font-size: clamp(46px, 8.8vmin, 94px);
  line-height: 0.82;
  text-shadow:
    0 0 28px rgba(246, 255, 232, 0.64),
    0 0 24px rgba(255, 143, 199, 0.72),
    0 0 2px #050305;
}

.summary-badge[hidden] {
  display: none;
}

.summary-main {
  color: #ffd7ed;
  font-size: clamp(42px, 8vmin, 82px);
}

.summary-meta {
  margin-top: 4px;
  color: #fff36f;
  font-size: clamp(36px, 7vmin, 72px);
}

.summary-sub {
  margin-top: 4px;
  color: rgba(255, 215, 237, 0.66);
  font-size: clamp(32px, 6vmin, 62px);
}

.summary-url {
  margin-top: 6px;
  color: rgba(255, 143, 199, 0.74);
  font-size: clamp(15px, 2.4vmin, 25px);
  text-transform: none;
}

.share-button {
  margin-top: 12px;
  min-width: min(58vw, 260px);
  height: clamp(54px, 7vmin, 72px);
  border: 1px solid var(--pink);
  border-radius: 0;
  background: rgba(255, 143, 199, 0.12);
  color: #ffd7ed;
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(34px, 5.8vmin, 58px);
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  box-shadow:
    0 0 28px rgba(255, 143, 199, 0.18),
    inset 0 0 24px rgba(255, 143, 199, 0.08);
}

.share-button:active {
  color: #050305;
  background: var(--pink);
  transform: scale(0.96);
}

.play-button {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pink);
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(28px, 5.2vmin, 52px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 0 22px rgba(255, 143, 199, 0.42);
}

.play-button[hidden] {
  display: none;
}

.play-button:disabled {
  color: rgba(255, 143, 199, 0.48);
  cursor: default;
}

.play-button.playing {
  color: rgba(255, 143, 199, 0.5);
}

.pause-actions {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr 1fr;
  border-radius: 50%;
  overflow: hidden;
  pointer-events: auto;
}

.pause-actions[hidden] {
  display: none;
}

.pause-action {
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  border-radius: 0;
  background: rgba(255, 143, 199, 0.10);
  color: var(--pink);
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(17px, 3.5vmin, 34px);
  line-height: 0.86;
  letter-spacing: 0;
  text-shadow: 0 0 18px rgba(255, 143, 199, 0.38);
  pointer-events: auto;
}

.pause-resume {
  border-bottom: 1px solid rgba(255, 143, 199, 0.44);
  color: #ffd7ed;
}

.pause-action:active {
  background: var(--pink);
  color: #050305;
}

@keyframes hit-pulse {
  0% {
    box-shadow:
      0 0 0 0 var(--tone, rgba(255, 143, 199, 0.35)),
      0 0 42px rgba(255, 143, 199, 0.16);
  }
  100% {
    box-shadow:
      0 0 0 28px rgba(255, 143, 199, 0),
      0 0 42px rgba(255, 143, 199, 0.16);
  }
}

@keyframes full-clear-stars {
  0%,
  100% {
    background-position:
      8% 24%,
      30% 9%,
      56% 18%,
      82% 30%,
      center;
    transform: translate(-50%, -48%) scale(0.92);
  }
  50% {
    background-position:
      14% 18%,
      24% 16%,
      62% 12%,
      76% 36%,
      center;
    transform: translate(-50%, -48%) scale(1);
  }
}

.beat-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.beat-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 143, 199, 0.36);
  border-radius: 50%;
  box-shadow:
    0 0 18px rgba(255, 143, 199, 0.08),
    inset 0 0 26px rgba(255, 143, 199, 0.025);
  transform-origin: center;
  will-change: opacity, transform;
}

.notes-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.note-orb {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(32px, 5.7vmin, 52px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: var(--tone);
  color: #050305;
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(25px, 4.9vmin, 43px);
  line-height: 0.86;
  letter-spacing: 0;
  text-shadow: 0 1px rgba(255, 255, 255, 0.22);
  box-shadow:
    0 0 22px color-mix(in srgb, var(--tone) 56%, transparent),
    inset 0 0 0 3px rgba(255, 255, 255, 0.16);
  will-change: transform, opacity;
}

.note-orb::after,
.combo-part::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px dotted rgba(255, 255, 255, 0.58);
  border-radius: inherit;
  opacity: 0.64;
}

.note-orb.combo {
  border-radius: 50%;
}

.note-orb.soft {
  opacity: 0.78;
}

.note-combo {
  position: absolute;
  inset: 0;
  will-change: transform, opacity;
  pointer-events: none;
}

.combo-bridge-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.combo-bridge-path {
  fill: none;
  stroke: var(--bridge-tone);
  stroke-linecap: round;
  stroke-width: clamp(6px, 1.35vmin, 11px);
  opacity: 0.78;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--bridge-tone) 70%, transparent));
}

.combo-part {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: clamp(32px, 5.7vmin, 52px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: var(--tone);
  color: #050305;
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(25px, 4.9vmin, 43px);
  line-height: 0.86;
  letter-spacing: 0;
  text-shadow: 0 1px rgba(255, 255, 255, 0.22);
  box-shadow:
    0 0 22px color-mix(in srgb, var(--tone) 56%, transparent),
    inset 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.ring-pad-layer {
  display: none;
}

.pad-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.pad {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(68px, 10vmin, 94px);
  aspect-ratio: 1;
  border: 1px solid var(--pink);
  border-radius: 0;
  background: rgba(5, 3, 5, 0.78);
  box-shadow:
    0 0 30px rgba(255, 143, 199, 0.11),
    inset 0 0 24px rgba(255, 143, 199, 0.06);
  color: var(--pink);
  opacity: 0.16;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pad span {
  display: block;
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: clamp(42px, 8vmin, 68px);
  line-height: 0.86;
  opacity: 0;
  text-shadow: 0 0 18px rgba(255, 143, 199, 0.32);
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.pad.active {
  opacity: 0.72;
  background: var(--tone, var(--pink));
  border-color: rgba(255, 255, 255, 0.5);
  color: #050305;
  transform: scale(0.95);
}

.pad-left {
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
}

.pad-up {
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
}

.pad-right {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
}

.pad-down {
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(18px, env(safe-area-inset-left));
}

.bpm-control {
  position: fixed;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 12;
  display: grid;
  grid-template-columns: auto 118px 34px;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: rgba(255, 143, 199, 0.64);
  font-family: "VT323 Local", ui-monospace, monospace;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
}

.bpm-control input {
  width: 118px;
  accent-color: var(--pink);
}

.bpm-control output {
  width: 34px;
  color: rgba(255, 215, 237, 0.72);
  text-align: right;
}

.bpm-control input::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(255, 143, 199, 0.38);
}

.bpm-control input::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -7px;
  border: 1px solid var(--pink);
  border-radius: 0;
  background: var(--bg);
  box-shadow: 0 0 16px rgba(255, 143, 199, 0.42);
  -webkit-appearance: none;
}

.bpm-control input {
  appearance: none;
  background: transparent;
}

.bpm-control input:disabled {
  opacity: 0.42;
}

@media (max-width: 700px) {
  .status {
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 42px);
    font-size: 18px;
  }

  .arena-wrap {
    padding: 76px 22px 112px;
  }

  .arena {
    width: min(88vw, 64vh);
    min-width: 210px;
    box-shadow: 0 0 90px rgba(255, 80, 170, 0.08);
  }

  .target-ring {
    min-width: 84px;
  }

  .ring-pad-layer {
    position: absolute;
    inset: -2.5%;
    z-index: 4;
    display: block;
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
  }

  .ring-pad-layer::before,
  .ring-pad-layer::after {
    content: none;
  }

  .ring-pad {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 50%;
    background: transparent;
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -webkit-mask: radial-gradient(circle, transparent 0 29%, #000 29.6% 99%, transparent 100%);
    mask: radial-gradient(circle, transparent 0 29%, #000 29.6% 99%, transparent 100%);
    transition: filter 90ms linear;
    user-select: none;
  }

  .ring-pad::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--tone, var(--pink));
    opacity: 0.14;
    transition: opacity 90ms linear;
  }

  .ring-pad span {
    position: absolute;
    display: block;
    color: rgba(255, 215, 237, 0.66);
    font-family: "VT323 Local", ui-monospace, monospace;
    font-size: clamp(34px, 11vw, 58px);
    line-height: 0.86;
    opacity: 0.72;
    text-shadow: 0 0 20px color-mix(in srgb, var(--tone) 52%, transparent);
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .ring-pad-left {
    clip-path: polygon(50% 50%, 0 100%, 0 0);
  }

  .ring-pad-left span {
    left: 11%;
    top: 50%;
    transform: translate(-50%, -50%);
  }

  .ring-pad-up {
    clip-path: polygon(50% 50%, 0 0, 100% 0);
  }

  .ring-pad-up span {
    left: 50%;
    top: 11%;
    transform: translate(-50%, -50%);
  }

  .ring-pad-right {
    clip-path: polygon(50% 50%, 100% 0, 100% 100%);
  }

  .ring-pad-right span {
    right: 11%;
    top: 50%;
    transform: translate(50%, -50%);
  }

  .ring-pad-down {
    clip-path: polygon(50% 50%, 100% 100%, 0 100%);
  }

  .ring-pad-down span {
    left: 50%;
    bottom: 11%;
    transform: translate(-50%, 50%);
  }

  .ring-pad.active {
    filter: drop-shadow(0 0 18px color-mix(in srgb, var(--tone) 60%, transparent));
  }

  .ring-pad.active::before {
    opacity: 0.42;
  }

  .ring-pad.active span {
    color: #050305;
    opacity: 0.86;
    text-shadow: 0 1px rgba(255, 255, 255, 0.22);
  }

  .pad-layer {
    display: none;
  }

  .end-summary {
    width: 88vw;
    transform: translate(-50%, calc(-50% + 148px));
  }

  .end-summary.full-clear {
    transform: translate(-50%, calc(-50% + 126px));
  }

  .summary-badge {
    margin-bottom: 4px;
    font-size: clamp(40px, 13vw, 64px);
  }

  .share-button {
    margin-top: 8px;
    min-width: 184px;
    height: 50px;
    font-size: 34px;
  }

  .bpm-control {
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    grid-template-columns: auto 92px 30px;
    gap: 8px;
    font-size: 18px;
    opacity: 0.84;
    transform: translateX(-50%);
  }

  .bpm-control input {
    width: 92px;
  }
}
