:root {
  color-scheme: dark;
  --bg: #49c9f4;
  --panel: #18222f;
  --line: #7d45ff;
  --text: #ffffff;
  --muted: #c7eefc;
  --gold: #ffd969;
  --rose: #ff72f6;
  --green: #78f7ff;
  --danger: #ff4d85;
  --purple: #5b16c9;
  --purple-dark: #26076d;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Trebuchet MS", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 84% 10%, rgba(255, 255, 255, 0.88) 0 5rem, transparent 8rem),
    radial-gradient(circle at 20% 86%, rgba(255, 64, 235, 0.58), transparent 20rem),
    radial-gradient(circle at 78% 86%, rgba(0, 255, 217, 0.54), transparent 21rem),
    linear-gradient(180deg, #4fd4ff 0%, #61d7ff 36%, #79e8f0 62%, #32d6c9 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  position: fixed;
  inset: auto -8vw 6vh;
  z-index: -1;
  height: 34vh;
  content: "";
  filter: blur(2px);
  opacity: 0.82;
}

body::before {
  background:
    radial-gradient(ellipse at 18% 30%, rgba(255, 0, 211, 0.78), transparent 26%),
    radial-gradient(ellipse at 50% 70%, rgba(255, 255, 255, 0.9), transparent 20%),
    radial-gradient(ellipse at 84% 46%, rgba(30, 255, 173, 0.74), transparent 28%);
}

body::after {
  inset: 33vh -8vw auto;
  height: 4px;
  background: linear-gradient(90deg, transparent, rgba(255, 165, 255, 0.95), #ffffff, rgba(96, 242, 255, 0.9), transparent);
  box-shadow: 0 0 22px rgba(255, 255, 255, 0.96), 0 0 42px rgba(185, 67, 255, 0.92);
}

button {
  min-height: 44px;
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:focus-visible {
  outline: 3px solid #fff0a8;
  outline-offset: 3px;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  width: 100%;
  height: 58px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(18, 29, 42, 0.74);
  border-bottom: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(10px);
}

.more-menu {
  position: relative;
  margin-left: auto;
}

.more-menu summary {
  min-height: 34px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(174, 246, 255, 0.42);
  border-radius: 999px;
  color: var(--text);
  background: rgba(8, 21, 34, 0.42);
  font-size: 0.86rem;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(6, 47, 75, 0.9);
}

.more-menu summary::-webkit-details-marker {
  display: none;
}

.more-menu[open] summary {
  border-color: rgba(255, 217, 105, 0.72);
}

.more-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 210px;
  padding: 8px;
  border: 1px solid rgba(127, 218, 255, 0.72);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%),
    rgba(10, 24, 36, 0.96);
  box-shadow: 0 14px 28px rgba(18, 49, 73, 0.28);
}

.more-panel p {
  margin: 4px 10px 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
}

.more-panel a {
  min-height: 38px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  border-radius: 7px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 800;
  text-decoration: none;
}

.more-panel a:hover,
.more-panel a:focus-visible {
  background: rgba(120, 247, 255, 0.16);
}

.logo-mark {
  width: 34px;
  height: 28px;
  background: url("./assets/qte-butterfly.png") center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(255, 120, 255, 0.56));
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  text-shadow: 0 2px 0 #17212e, 0 0 8px rgba(92, 221, 255, 0.8);
}

.arena {
  width: min(980px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 82px 0 28px;
  display: grid;
  place-items: center;
}

.trainer,
.result-panel {
  width: min(100%, 920px);
  border-radius: 8px;
}

.trainer {
  position: relative;
  z-index: 0;
  padding: 58px clamp(18px, 4vw, 36px) 30px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.trainer::before {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -2;
  width: min(1180px, 116vw);
  height: 270px;
  content: "";
  transform: translate(-50%, -55%);
  background: url("./assets/qte-backdrop-panel.png") center / 100% 100% no-repeat;
  opacity: 1;
  filter: none;
}

.trainer::after {
  display: none;
}

.mode-ready .trainer,
.mode-countdown .trainer,
.mode-transitioning .trainer {
  width: min(100%, 560px);
  padding: 38px 34px;
  border: 2px solid rgba(127, 218, 255, 0.78);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 26%),
    linear-gradient(180deg, rgba(30, 46, 62, 0.95), rgba(10, 24, 36, 0.96));
  box-shadow:
    inset 0 0 0 2px rgba(10, 20, 34, 0.8),
    inset 0 0 24px rgba(106, 207, 255, 0.12),
    0 14px 28px rgba(18, 49, 73, 0.26);
  overflow: hidden;
}

.mode-ready .trainer::before,
.mode-countdown .trainer::before,
.mode-transitioning .trainer::before,
.mode-ready .trainer::after,
.mode-countdown .trainer::after,
.mode-transitioning .trainer::after {
  display: none;
}

.mode-ready .timer-shell,
.mode-countdown .timer-shell,
.mode-transitioning .timer-shell,
.mode-ready .sequence,
.mode-countdown .sequence,
.mode-transitioning .sequence {
  display: none;
}

.mode-transitioning .trainer {
  display: none;
}

.mode-ready .message,
.mode-countdown .message,
.mode-transitioning .message {
  margin-top: 0;
  text-align: center;
  font-size: 1.6rem;
}

.mode-countdown .controls,
.mode-transitioning .controls {
  display: none;
}

.mode-running .controls,
.mode-finished .controls {
  display: none;
}

.mode-countdown .message {
  color: var(--gold);
  font-size: clamp(4rem, 18vw, 8rem);
  line-height: 1;
}

.mode-running .message,
.mode-finished .message,
.mode-transitioning .message {
  display: none;
}

.timer-shell {
  position: relative;
  z-index: 2;
  width: min(360px, 52%);
  height: 17px;
  margin: 30px auto 0;
  padding: 3px;
  border: 3px solid #56118f;
  border-radius: 999px;
  background: linear-gradient(180deg, #260154, #120023);
  box-shadow:
    0 0 0 2px rgba(255, 196, 255, 0.38),
    inset 0 2px 0 rgba(255, 216, 255, 0.42),
    0 0 14px rgba(152, 42, 255, 0.82);
}

.timer-shell::before {
  position: absolute;
  inset: -7px -22px;
  z-index: -1;
  content: "";
  pointer-events: none;
  background: url("./assets/qte-gauge-frame.png") center / 100% 100% no-repeat;
  opacity: 0.95;
}

#timerFill {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #f08dff 0%, #ba38ff 50%, #6c15d8 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.58),
    inset 0 -2px 0 rgba(50, 0, 110, 0.58),
    0 0 10px rgba(192, 83, 255, 0.9);
  transform-origin: left center;
}

.sequence {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: clamp(8px, 1.35vw, 14px);
  align-items: center;
  max-width: 760px;
  margin: 0 auto;
}

.key-tile {
  position: relative;
  z-index: 0;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1.04;
  border: 0;
  border-radius: 0;
  color: var(--text);
  background: transparent;
  font-size: clamp(1rem, 2.35vw, 1.85rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #7631b1,
    1px 0 0 #a85ee1,
    -1px 0 0 #a85ee1,
    0 0 5px rgba(255, 255, 255, 0.74);
}

.key-tile::after {
  position: absolute;
  inset: 3% -3% -3%;
  z-index: -1;
  content: "";
  background: url("./assets/qte-butterfly.png") center / contain no-repeat;
  opacity: 1;
}

.key-tile.current {
  color: #ffffff;
  text-shadow:
    0 2px 0 #7631b1,
    1px 0 0 #a85ee1,
    -1px 0 0 #a85ee1,
    0 0 6px #ffffff;
}

.key-tile.current::before {
  position: absolute;
  top: -26px;
  left: 50%;
  width: 28px;
  height: 24px;
  content: "";
  transform: translateX(-50%);
  background: url("./assets/qte-pointer.png") center / contain no-repeat;
}

.key-tile.burst {
  color: #ffffff;
  animation: tileBurst 460ms ease-out forwards;
}

.key-tile.burst::after {
  filter: brightness(2) saturate(0.2);
  animation: tileFade 420ms ease-out forwards;
}

.key-tile.vanished {
  visibility: hidden;
}

.key-tile.crack {
  color: rgba(255, 255, 255, 0.58);
  animation: crackTile 520ms ease-out forwards;
}

.key-tile.crack::after {
  filter: grayscale(1) brightness(0.72) contrast(1.1);
  animation: crackFade 520ms ease-out forwards;
}

.key-tile.missed {
  color: rgba(255, 255, 255, 0.42);
  border-color: rgba(97, 66, 140, 0.8);
}

.key-tile.missed::after {
  opacity: 0.34;
}

.particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 0 8px #ffffff, 0 0 14px #ffbfff;
  transform: translate(-50%, -50%);
  animation: particleScatter 420ms ease-out forwards;
}

.particle.debris {
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: #c9c9d2;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
  animation-duration: 520ms;
}

.crack-line {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 3px;
  height: 44%;
  border-radius: 999px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.92), rgba(42, 42, 52, 0.9), transparent);
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.62);
  opacity: 0;
  transform-origin: top center;
  animation: crackLine 520ms ease-out forwards;
}

.crack-line-1 {
  transform: translate(-50%, -50%) rotate(-18deg);
}

.crack-line-2 {
  height: 34%;
  transform: translate(-8%, -48%) rotate(24deg);
}

.crack-line-3 {
  height: 26%;
  transform: translate(-86%, -26%) rotate(58deg);
}

.message {
  min-height: 32px;
  margin: 18px 0;
  color: #ffffff;
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 2px 0 rgba(21, 29, 48, 0.78);
}

.controls {
  display: flex;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border: 2px solid rgba(174, 246, 255, 0.85);
  border-radius: 999px;
  color: #ffffff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 38%),
    linear-gradient(180deg, #44d7f2, #168ab8 58%, #0f5b7e);
  box-shadow:
    inset 0 0 0 2px rgba(9, 49, 80, 0.68),
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    0 3px 0 rgba(6, 35, 52, 0.78),
    0 0 12px rgba(94, 232, 255, 0.56);
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(6, 47, 75, 0.9), 0 0 8px rgba(255, 255, 255, 0.64);
}

.result-panel {
  max-width: 520px;
  min-height: 0;
  padding: 34px 34px 30px;
  border: 2px solid rgba(127, 218, 255, 0.78);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.11), transparent 22%),
    linear-gradient(180deg, rgba(30, 46, 62, 0.97), rgba(10, 24, 36, 0.98));
  box-shadow:
    inset 0 0 0 2px rgba(10, 20, 34, 0.8),
    inset 0 0 34px rgba(106, 207, 255, 0.11),
    0 18px 38px rgba(18, 49, 73, 0.32);
  text-align: center;
  overflow: hidden;
}

.result-panel[hidden] {
  display: none;
}

.mode-finished .trainer {
  display: none;
}

.result-kicker {
  margin: 0 0 8px;
  color: #ffdc6e;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.result-score {
  display: block;
  font-size: clamp(3.2rem, 12vw, 5.8rem);
  line-height: 1;
  text-shadow: 0 3px 0 #111a29, 0 0 18px rgba(96, 219, 255, 0.8);
}

.result-guide {
  margin: 14px 0 22px;
  color: #ffdc6e;
  font-size: 1.25rem;
  font-weight: 900;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0 0 18px;
}

.result-stats div {
  padding: 12px;
  border: 2px solid rgba(111, 203, 244, 0.58);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    rgba(8, 21, 34, 0.62);
  box-shadow: inset 0 0 0 1px rgba(5, 12, 21, 0.8);
}

.result-stats dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-stats dd {
  margin: 4px 0 0;
  font-size: 1.8rem;
  font-weight: 900;
}

@media (max-width: 560px) {
  .arena {
    width: min(100% - 20px, 980px);
  }

  .sequence {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes tileBurst {
  0% {
    opacity: 1;
    transform: scale(1);
    text-shadow: 0 0 10px #ffffff, 0 0 18px #ffffff;
  }
  35% {
    opacity: 1;
    transform: scale(1.035);
    text-shadow: 0 0 14px #ffffff, 0 0 22px #ffffff;
  }
  100% {
    opacity: 0;
    transform: scale(0.94);
    text-shadow: 0 0 4px #ffffff;
  }
}

@keyframes tileFade {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  42% {
    opacity: 0.86;
    transform: scale(1.035);
  }
  100% {
    opacity: 0;
    transform: scale(0.9) rotate(3deg);
  }
}

@keyframes particleScatter {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform:
      translate(-50%, -50%)
      rotate(var(--angle))
      translateY(calc(-0.55 * var(--distance)))
      scale(0.2);
  }
}

@keyframes crackTile {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  32% {
    opacity: 1;
    transform: scale(1.015) rotate(-0.5deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.93) rotate(2deg);
  }
}

@keyframes crackFade {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  40% {
    opacity: 0.95;
    transform: scale(1.01);
  }
  100% {
    opacity: 0;
    transform: scale(0.9);
  }
}

@keyframes crackLine {
  0% {
    opacity: 0;
  }
  24% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
