* {
  box-sizing: border-box;
  font-family: 'Press Start 2P', cursive;
}

html,
body {
  margin: 0;
  background: black;
  overflow: hidden;
}

/* ---------- stage: fixed 1024x576 game scaled to fit the window ---------- */
#stage {
  position: relative;
  margin: 0 auto;
}

#game {
  position: absolute;
  top: 0;
  left: 0;
  width: 1024px;
  height: 576px;
  transform-origin: top left;
  overflow: hidden;
  user-select: none;
}

canvas {
  display: block;
  image-rendering: pixelated;
}

/* ---------- help text (from the original) ---------- */
#help {
  text-align: center;
}

p {
  color: rgba(238, 229, 229, 0.212);
  font-size: 10px;
  margin: 8px 0;
  padding-left: 10px;
}

p:hover {
  color: #0f0;
}

.namez {
  color: rgb(231, 222, 222);
  text-shadow: 1px 1px #0f0;
  padding-left: 4px;
  padding-right: 4px;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: 100%;
  align-items: center;
  padding: 20px;
}

.fighter-tag {
  position: relative;
}

.pips {
  position: absolute;
  top: 22px;
  left: 4px;
  display: flex;
  gap: 6px;
}

.pips i {
  width: 12px;
  height: 12px;
  border: 2px solid rgb(105, 45, 245);
  background: black;
}

.pips i.won {
  background: #0f0;
  box-shadow: 0 0 8px #0f0;
}

.bar {
  position: relative;
  width: 100%;
  height: 38px;
  background-color: red;
  border-top: 4px solid rgb(76, 0, 255);
  border-bottom: 4px solid rgb(76, 0, 255);
}

.bar--left {
  border-left: 4px solid rgb(105, 45, 245);
}

.bar--right {
  border-right: 4px solid rgb(105, 45, 245);
}

.bar__fill,
.bar__ghost {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
}

/* both bars drain away from the timer */
.bar--left .bar__fill,
.bar--left .bar__ghost {
  right: 0;
}

.bar--right .bar__fill,
.bar--right .bar__ghost {
  left: 0;
}

.bar__fill {
  background: #0f0;
  transition: width 0.12s linear;
}

.bar__ghost {
  background: rgb(255, 238, 150);
  transition: width 0.5s ease-in 0.35s;
}

.bar.low .bar__fill {
  animation: low-health 0.6s steps(2) infinite;
}

@keyframes low-health {
  50% {
    background: #9f0;
  }
}

#timer {
  background-color: black;
  width: 100px;
  height: 50px;
  font-size: 1.3rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f0;
  border: 4px solid rgb(76, 0, 255);
  box-shadow: rgb(255, 0, 0) 0px 22px 70px 4px;
  position: relative;
  z-index: 1;
}

#timer.warning {
  color: red;
}

/* ---------- announcer band ---------- */
#announcer {
  position: absolute;
  left: 0;
  right: 0;
  top: 220px;
  padding: 26px 0;
  text-align: center;
  letter-spacing: 1.1rem;
  color: rgb(206, 206, 206);
  background-color: rgba(0, 26, 255, 0.534);
  font-size: 2.2rem;
  text-shadow: 4px 4px rgba(0, 0, 0, 0.575);
  pointer-events: none;
  display: none;
}

#announcer.show {
  display: block;
  animation: slam 0.25s ease-out;
}

#announcer small {
  display: block;
  margin-top: 14px;
  font-size: 0.8rem;
  letter-spacing: 0.3rem;
  color: #0f0;
}

@keyframes slam {
  from {
    transform: scaleY(0);
    letter-spacing: 3rem;
  }
}

/* ---------- overlays: menu, pause, result ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgb(206, 206, 206);
  text-align: center;
}

.overlay.hidden {
  display: none;
}

#loading {
  background: black;
  color: #0f0;
}

#menu {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.82) 30%, rgba(0, 0, 0, 0.55) 75%);
}

#pause,
#displayText {
  letter-spacing: 1.1rem;
  background-color: rgba(0, 26, 255, 0.534);
  text-shadow: 4px 4px rgba(0, 0, 0, 0.575);
}

h1,
h2 {
  margin: 0 0 24px;
  font-weight: normal;
}

h2 {
  font-size: 2.2rem;
}

h1 {
  font-size: 3.4rem;
  color: #fff;
  text-transform: uppercase;
}

h1 small {
  font-size: 1.6rem;
  color: #0f0;
  vertical-align: middle;
}

.subtitle {
  font-size: 0.8rem;
  letter-spacing: 0.6rem;
  color: rgba(238, 229, 229, 0.75);
  margin-bottom: 40px;
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  letter-spacing: normal;
}

.menu-list button {
  font-size: 1rem;
  padding: 12px 28px;
  min-width: 380px;
  color: rgb(206, 206, 206);
  background: rgba(0, 0, 0, 0.6);
  border: 4px solid rgb(76, 0, 255);
  cursor: pointer;
  text-shadow: 2px 2px rgba(0, 0, 0, 0.6);
}

.menu-list button.selected,
.menu-list button:hover {
  color: #0f0;
  border-color: #0f0;
  box-shadow: rgb(255, 0, 0) 0px 0px 30px 2px;
}

.menu-list button.selected::before {
  content: "> ";
}

.record {
  margin-top: 30px;
  font-size: 0.6rem;
  color: rgba(238, 229, 229, 0.6);
  min-height: 1em;
}

.hint {
  margin-top: 16px;
  font-size: 0.55rem;
  color: rgba(238, 229, 229, 0.6);
}

/* ---------- glitch title (revived from the original stylesheet) ---------- */
.glitch {
  text-shadow: 0.05em 0 0 rgba(47, 0, 255, 0.849),
    -0.025em -0.05em 0 rgba(255, 0, 0, 0.75),
    0.025em 0.05em 0 rgba(3, 3, 61, 0.75);
  animation: glitch 500ms infinite;
}

@keyframes glitch {
  0% {
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
      -0.05em -0.025em 0 rgba(0, 59, 0, 0.75),
      -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
  }
  14% {
    text-shadow: 0.05em 0 0 rgba(255, 0, 0, 0.75),
      -0.05em -0.025em 0 rgba(0, 65, 0, 0.75),
      -0.025em 0.05em 0 rgba(0, 0, 255, 0.75);
  }
  15% {
    text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
      0.025em 0.025em 0 rgba(0, 26, 0, 0.75),
      -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
  }
  49% {
    text-shadow: -0.05em -0.025em 0 rgba(255, 0, 0, 0.75),
      0.025em 0.025em 0 rgba(0, 255, 0, 0.75),
      -0.05em -0.05em 0 rgba(0, 0, 255, 0.75);
  }
  50% {
    text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
      0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75);
  }
  99% {
    text-shadow: 0.025em 0.05em 0 rgba(255, 0, 0, 0.75),
      0.05em 0 0 rgba(0, 255, 0, 0.75), 0 -0.05em 0 rgba(0, 0, 255, 0.75);
  }
  100% {
    text-shadow: -0.025em 0 0 rgba(255, 0, 0, 0.75),
      -0.025em -0.025em 0 rgba(0, 255, 0, 0.75),
      -0.025em -0.05em 0 rgba(0, 0, 255, 0.75);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }
}
