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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b3d91;
  color: #fff;
  font-family: "Press Start 2P", "Courier New", monospace;
  -webkit-font-smoothing: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

body.playing #game {
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

.muted {
  opacity: 0.7;
}

.small {
  font-size: 10px;
}

.tiny {
  font-size: 8px;
  opacity: 0.45;
}

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.8;
  pointer-events: none;
  text-shadow: 3px 3px 0 #000;
}

.hud-right {
  text-align: right;
}

.lives {
  color: #ff4d6d;
  letter-spacing: 4px;
}

.combo {
  color: #ffe600;
  font-size: 16px;
  min-height: 1em;
}

.countdown {
  min-height: 1em;
  font-size: 22px;
  color: #ff4d6d;
  animation: troll-blink 0.5s steps(2) infinite;
}

.timer-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.35);
}

.timer-fill {
  height: 100%;
  background: #33ff00;
  transform-origin: left center;
  transition: background-color 0.2s;
}

.timer-bar.warning .timer-fill {
  background: #ff4d6d;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 14px;
  padding: 24px;
  overflow-y: auto;
  text-align: center;
  background: rgba(3, 14, 40, 0.55);
  backdrop-filter: blur(2px);
}

.domain {
  margin: 0;
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.8;
}

.title {
  margin: 0;
  font-size: clamp(28px, 7vw, 64px);
  line-height: 1.25;
  text-shadow: 5px 5px 0 #000;
}

.small-title {
  font-size: clamp(24px, 6vw, 48px);
  color: #ff4d6d;
}

.rainbow-text {
  background: linear-gradient(90deg, #ff0000, #ff9900, #ffff00, #33ff00, #0099ff, #6633ff, #ff0000);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbow 3s linear infinite;
  filter: drop-shadow(4px 4px 0 #000);
  text-shadow: none;
}

@keyframes rainbow {
  to {
    background-position: 300% 0;
  }
}

.tagline {
  margin: 0;
  max-width: 560px;
  font-size: 11px;
  line-height: 1.8;
  color: #ffe600;
}

.rules {
  margin: 6px 0;
  padding: 0;
  list-style: none;
  font-size: 10px;
  line-height: 2.2;
}

.rules li::before {
  content: "\2605  ";
  color: #ff99ff;
}

.btn {
  margin-top: 8px;
  padding: 16px 28px;
  font: inherit;
  font-size: 16px;
  color: #000;
  background: #ffe600;
  border: 4px solid #000;
  box-shadow: 6px 6px 0 #000;
  cursor: pointer;
  animation: pulse 1s steps(2) infinite;
}

.btn:hover {
  background: #ff99ff;
}

.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 2px 2px 0 #000;
}

.btn:focus-visible {
  outline: 3px dashed #fff;
  outline-offset: 6px;
}

.btn-secondary,
.btn-small {
  animation: none;
}

.btn-secondary {
  margin-top: 0;
  padding: 12px 20px;
  font-size: 12px;
  background: #fff;
}

.btn-small {
  margin-top: 0;
  padding: 10px 14px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.submit-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.submit-row {
  display: flex;
  gap: 10px;
}

.submit-form input {
  width: 16ch;
  padding: 10px;
  font: inherit;
  font-size: 12px;
  color: #000;
  background: #fff;
  border: 4px solid #000;
  box-shadow: 4px 4px 0 #000;
  user-select: text;
  -webkit-user-select: text;
}

.submit-form input:focus {
  outline: 3px dashed #ffe600;
  outline-offset: 3px;
}

.submit-status {
  margin: 0;
  min-height: 1em;
  color: #ffe600;
}

.leaderboard {
  width: min(420px, 100%);
  margin: 0;
  padding: 12px 16px;
  list-style: none;
  font-size: 11px;
  line-height: 2.2;
  background: rgba(0, 0, 0, 0.45);
  border: 4px solid #fff;
  box-shadow: 6px 6px 0 #000;
}

.leaderboard:empty {
  display: none;
}

.leaderboard li {
  display: flex;
  gap: 12px;
}

.leaderboard .rank {
  width: 3ch;
  text-align: right;
  opacity: 0.7;
}

.leaderboard .name {
  flex: 1;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard li:nth-child(1) {
  color: #ffe600;
}

.leaderboard li:nth-child(2) {
  color: #dddddd;
}

.leaderboard li:nth-child(3) {
  color: #ffb070;
}

.leaderboard li.me {
  color: #ff99ff;
  animation: pulse 1s steps(2) infinite;
}

.leaderboard li.empty {
  justify-content: center;
  opacity: 0.7;
}

@keyframes pulse {
  50% {
    filter: brightness(1.2);
    transform: scale(1.05);
  }
}

.final {
  margin: 8px 0 0;
  font-size: 20px;
}

.new-record {
  margin: 0;
  font-size: 16px;
}

.toast {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: clamp(18px, 4vw, 36px);
  color: #ffe600;
  text-shadow: 4px 4px 0 #000;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.troll-banner {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
}

.troll-title {
  font-size: clamp(16px, 4vw, 32px);
  color: #ff0000;
  text-shadow: 4px 4px 0 #000;
  animation: troll-blink 0.6s steps(2) infinite, troll-wobble 0.6s ease-in-out infinite;
}

.troll-marquee {
  width: 100%;
  overflow: hidden;
  padding: 6px 0;
  font-size: 10px;
  color: #000;
  background: #ffe600;
  border-block: 3px solid #000;
  white-space: nowrap;
}

.troll-marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: troll-scroll 9s linear infinite;
}

body.trolled #game {
  animation: troll-filter 2s linear infinite;
}

body.trolled .hud {
  animation: troll-wobble 0.4s ease-in-out infinite;
}

@keyframes troll-blink {
  50% {
    color: #ffe600;
  }
}

@keyframes troll-wobble {
  25% {
    transform: rotate(-4deg) scale(1.05);
  }
  75% {
    transform: rotate(4deg) scale(0.95);
  }
}

@keyframes troll-scroll {
  to {
    transform: translateX(-100%);
  }
}

@keyframes troll-filter {
  from {
    filter: hue-rotate(0deg) saturate(1.5);
  }
  to {
    filter: hue-rotate(360deg) saturate(1.5);
  }
}

.mute-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  padding: 10px 12px;
  font: inherit;
  font-size: 10px;
  color: #fff;
  background: rgba(0, 0, 0, 0.45);
  border: 3px solid #fff;
  cursor: pointer;
  z-index: 10;
}

.mute-btn:hover {
  background: rgba(255, 153, 255, 0.4);
}

.footer {
  position: fixed;
  left: 16px;
  bottom: 20px;
  font-size: 8px;
  opacity: 0.5;
  pointer-events: none;
}

@media (max-width: 600px) {
  .hud {
    font-size: 10px;
    padding: 12px;
  }

  .footer {
    display: none;
  }
}
