:root {
  --bg: #05060d;
  --cyan: #3df0ff;
  --cyan-dim: #146e7a;
  --mag: #ff3d9a;
  --mag-dim: #7a1450;
  --gold: #ffe566;
  --ink: #eef6ff;
  --muted: #8b97b3;
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Hiragino Sans GB", "WenQuanYi Micro Hei", "文泉驿微米黑", sans-serif;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#scanlines,
#vignette,
#glitch,
#chroma,
#punch {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

#scanlines {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 2px,
    rgba(0, 0, 0, 0.12) 2px 3px
  );
  opacity: 0.35;
  mix-blend-mode: multiply;
}

#vignette {
  background: radial-gradient(ellipse at center, transparent 48%, rgba(0, 0, 0, 0.62) 100%);
}

#chroma {
  background:
    linear-gradient(90deg, rgba(61, 240, 255, 0.22), transparent 35%, rgba(255, 61, 154, 0.22));
  mix-blend-mode: screen;
  opacity: 0;
}

#chroma[hidden] {
  display: none;
}

#punch {
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.28), transparent 55%);
  opacity: 0;
}

#punch.go {
  animation: punch-flash 0.16s ease-out;
}

#punch[hidden] {
  display: none;
}

@keyframes punch-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

#glitch {
  background:
    linear-gradient(90deg, rgba(61, 240, 255, 0.12), transparent 40%, rgba(255, 61, 154, 0.16)),
    repeating-linear-gradient(
      0deg,
      transparent 0 7px,
      rgba(255, 255, 255, 0.04) 7px 8px
    );
  mix-blend-mode: screen;
  animation: glitch-jitter 0.12s steps(2) infinite;
}

#glitch.hard {
  background:
    linear-gradient(90deg, rgba(61, 240, 255, 0.28), transparent 38%, rgba(255, 61, 154, 0.32)),
    repeating-linear-gradient(
      0deg,
      transparent 0 5px,
      rgba(255, 255, 255, 0.08) 5px 7px
    );
  animation: glitch-hard 0.08s steps(2) infinite;
}

#glitch[hidden] {
  display: none;
}

@keyframes glitch-jitter {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-3px, 1px); }
  100% { transform: translate(2px, -2px); }
}

@keyframes glitch-hard {
  0% { transform: translate(0, 0) skewX(0); }
  25% { transform: translate(-18px, 10px) skewX(-3deg); }
  50% { transform: translate(20px, -12px) skewX(3deg); }
  75% { transform: translate(-14px, -8px) skewX(-2deg); }
  100% { transform: translate(12px, 8px) skewX(2deg); }
}

body.loser-shake {
  overflow: hidden;
}

body.loser-shake #app,
body.loser-shake #victory-screen {
  animation: loser-slam 0.06s linear 34 !important;
  will-change: transform;
}

@keyframes loser-slam {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-48px, 28px) rotate(-2.4deg); }
  40% { transform: translate(52px, -34px) rotate(2.8deg); }
  60% { transform: translate(-44px, -26px) rotate(-2.2deg); }
  80% { transform: translate(40px, 22px) rotate(1.8deg); }
  100% { transform: translate(-28px, 16px) rotate(-1.2deg); }
}

body.loser-shake::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: rgba(255, 40, 90, 0.18);
  animation: loser-flash 0.12s steps(2) 16;
}

@keyframes loser-flash {
  0% { opacity: 0.05; }
  50% { opacity: 0.35; }
  100% { opacity: 0.1; }
}

body.loser-shake #glitch.hard {
  opacity: 1;
  filter: contrast(1.4) saturate(1.6);
}

#hud {
  position: absolute;
  top: 14px;
  left: 22px;
  right: 22px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
  z-index: 3;
}

#hud[hidden] {
  display: none;
}

.hud-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-p2 {
  align-items: flex-end;
  text-align: right;
}

.hud-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: none;
}

.hud-p1 .hud-name {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(61, 240, 255, 0.7);
}

.hud-p2 .hud-name {
  color: var(--mag);
  text-shadow: 0 0 12px rgba(255, 61, 154, 0.7);
}

.hud-pips {
  display: flex;
  gap: 8px;
}

.pip {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid currentColor;
  opacity: 0.35;
  box-shadow: inset 0 0 8px currentColor;
}

.hud-p1 .pip {
  color: var(--cyan);
}

.hud-p2 .pip {
  color: var(--mag);
}

.pip.on {
  opacity: 1;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

.hud-clock {
  text-align: center;
  min-width: 120px;
}

.hud-clock-label {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
}

#clock {
  font-variant-numeric: tabular-nums;
  font-size: 42px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(255, 229, 102, 0.45);
}

#clock.low {
  color: #ff6b6b;
  text-shadow: 0 0 18px rgba(255, 80, 80, 0.7);
}

#carry-chip {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.18em;
  background: rgba(8, 10, 20, 0.72);
  border: 1px solid rgba(255, 229, 102, 0.45);
  color: var(--gold);
  box-shadow: 0 0 18px rgba(255, 229, 102, 0.2);
}

#carry-chip[hidden] {
  display: none;
}

#streak-chip {
  position: absolute;
  top: 114px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2em;
  background: rgba(8, 10, 20, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  text-shadow: 0 0 14px currentColor;
}

#streak-chip[hidden] {
  display: none;
}

#float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.score-pop {
  position: absolute;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: 0.12em;
  animation: pop-up 0.9s ease-out forwards;
  text-shadow: 0 0 16px currentColor;
}

@keyframes pop-up {
  0% { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -48px); opacity: 0; }
}

.panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 20px 40px;
  background: radial-gradient(ellipse at center, rgba(8, 10, 22, 0.28) 0%, rgba(5, 6, 13, 0.72) 70%);
}

.panel[hidden],
#banner[hidden],
#victory-screen[hidden] {
  display: none;
}

.kicker {
  letter-spacing: 0.42em;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

h1 {
  font-size: clamp(52px, 10vw, 108px);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  background: linear-gradient(180deg, #fff 10%, #9af6ff 45%, #3df0ff 70%, #ff3d9a 120%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(61, 240, 255, 0.45));
}

.subtitle {
  margin-top: 6px;
  letter-spacing: 0.5em;
  font-size: 13px;
  color: var(--gold);
}

.tagline {
  margin: 16px 0 22px;
  color: var(--muted);
  max-width: 520px;
  line-height: 1.7;
}

.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: min(680px, 92vw);
  margin-bottom: 18px;
}

.ctrl {
  text-align: left;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(10, 12, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.ctrl.cyan {
  box-shadow: 0 0 24px rgba(61, 240, 255, 0.08);
  border-color: rgba(61, 240, 255, 0.28);
}

.ctrl.mag {
  box-shadow: 0 0 24px rgba(255, 61, 154, 0.08);
  border-color: rgba(255, 61, 154, 0.28);
}

.ctrl h2 {
  font-size: 15px;
  margin-bottom: 10px;
  letter-spacing: 0.14em;
}

.ctrl.cyan h2 { color: var(--cyan); }
.ctrl.mag h2 { color: var(--mag); }

.ctrl li {
  list-style: none;
  font-size: 14px;
  color: #d5def0;
  line-height: 1.9;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  font-family: inherit;
  font-size: 12px;
  text-align: center;
}

.hint {
  font-size: 13px;
  color: #c4cde0;
  margin-top: 4px;
}

.hint.dim {
  color: var(--muted);
  font-size: 12px;
}

.cta {
  margin-top: 22px;
  appearance: none;
  border: 0;
  cursor: pointer;
  color: #061018;
  font-weight: 800;
  letter-spacing: 0.28em;
  font-size: 15px;
  padding: 14px 28px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), #fff, var(--mag));
  background-size: 180% 100%;
  box-shadow: 0 0 28px rgba(61, 240, 255, 0.35);
}

.cta:hover,
.cta:focus-visible {
  outline: none;
  background-position: 100% 0;
}

.pulse {
  animation: cta-pulse 1.4s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 22px rgba(61, 240, 255, 0.3); }
  50% { transform: scale(1.04); box-shadow: 0 0 36px rgba(255, 61, 154, 0.4); }
}

.panel-title {
  font-size: 56px;
  letter-spacing: 0.16em;
}

#banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  z-index: 6;
  text-align: center;
  pointer-events: none;
  padding: 22px 36px;
  min-width: min(760px, 90vw);
  background: rgba(5, 6, 14, 0.72);
  border: 1px solid rgba(255, 229, 102, 0.28);
  box-shadow: 0 0 50px rgba(255, 229, 102, 0.22);
}

#banner.slam {
  animation: banner-slam 0.38s cubic-bezier(0.2, 1.4, 0.3, 1);
}

@keyframes banner-slam {
  0% { transform: translate(-50%, -50%) scale(0.7); filter: blur(8px); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1); filter: blur(0); opacity: 1; }
}

.banner-kicker {
  letter-spacing: 0.4em;
  color: var(--gold);
  font-size: 12px;
  margin-bottom: 8px;
}

#banner-title {
  font-size: clamp(36px, 7vw, 72px);
  letter-spacing: 0.14em;
}

#banner-sub {
  margin-top: 8px;
  color: var(--muted);
}

.victory-panel {
  background: radial-gradient(ellipse at center, rgba(12, 8, 18, 0.35) 0%, rgba(5, 6, 13, 0.86) 68%);
}

.victory-rgb {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(61, 240, 255, 0.16), transparent 40%, rgba(255, 61, 154, 0.2));
  mix-blend-mode: screen;
  animation: victory-rgb 0.14s steps(2) infinite;
}

@keyframes victory-rgb {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-6px, 2px); }
  100% { transform: translate(5px, -3px); }
}

.taunt {
  position: relative;
  font-size: clamp(44px, 9vw, 112px);
  letter-spacing: 0.08em;
  line-height: 1.12;
  max-width: 14em;
  color: #fff;
  text-shadow:
    0 0 28px rgba(255, 61, 154, 0.85),
    5px 0 0 rgba(61, 240, 255, 0.7),
    -5px 0 0 rgba(255, 61, 154, 0.7);
  animation: taunt-in 0.55s cubic-bezier(0.2, 1.4, 0.3, 1);
}

.victory-mode #taunt {
  animation: taunt-in 0.55s cubic-bezier(0.2, 1.4, 0.3, 1), taunt-chroma 0.16s steps(2) infinite;
}

@keyframes taunt-chroma {
  0% { text-shadow: 0 0 28px rgba(255, 61, 154, 0.85), 6px 0 0 rgba(61, 240, 255, 0.75), -6px 0 0 rgba(255, 61, 154, 0.75); }
  50% { text-shadow: 0 0 28px rgba(255, 61, 154, 0.85), -7px 2px 0 rgba(61, 240, 255, 0.75), 5px -2px 0 rgba(255, 61, 154, 0.75); }
  100% { text-shadow: 0 0 28px rgba(255, 61, 154, 0.85), 4px -1px 0 rgba(61, 240, 255, 0.75), -8px 1px 0 rgba(255, 61, 154, 0.75); }
}

@keyframes taunt-in {
  0% { transform: scale(0.7) rotate(-3deg); opacity: 0; filter: blur(8px); }
  100% { transform: scale(1) rotate(0); opacity: 1; filter: blur(0); }
}

#mute-btn {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 10, 20, 0.7);
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
}

#mute-btn.muted {
  color: #6a7388;
  text-decoration: line-through;
}

#mute-btn:focus-visible {
  outline: 2px solid var(--cyan);
}

@media (max-width: 720px) {
  .controls-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 48px;
  }

  #clock {
    font-size: 26px;
  }
}
