* {
  box-sizing: border-box;
}

:root {
  --accent-color: #7afcff;
  --retro-blue: #70a1ff;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: auto;
}

body {
  margin: 0;
  background: radial-gradient(circle, #002c5f 0%, #000a1a 100%);
  background-color: #000a1a;
  color: #70a1ff;
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.5;
}

#crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, transparent 70%, rgba(0, 0, 0, 0.5) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(100, 180, 255, 0.08) 0px,
      rgba(100, 180, 255, 0.08) 1px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0) 4px
    );
  z-index: 10;
}

#uptime-display {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 20;
  color: #7afcff;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-shadow: 0 0 2px #7afcff, 0 0 5px rgba(200, 255, 255, 0.45);
}

#terminal-container,
#message-wall {
  position: relative;
  z-index: 1;
  width: min(920px, 92vw);
  margin: 40px auto;
}

#terminal-container {
  min-height: 180px;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(circle at center, rgba(0, 44, 95, 0.28) 0%, rgba(0, 10, 26, 0.75) 100%);
  border: 1px solid rgba(122, 252, 255, 0.3);
  padding: 20px;
  white-space: pre-wrap;
}

#message-wall {
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#terminal-container::-webkit-scrollbar,
#message-wall::-webkit-scrollbar {
  width: 4px;
}

#terminal-container::-webkit-scrollbar-thumb,
#message-wall::-webkit-scrollbar-thumb {
  background: var(--retro-blue);
  border-radius: 2px;
}

#terminal-container.glitching {
  animation: glitch 0.2s steps(2, end);
}

#typing-content,
.cursor {
  letter-spacing: 1px;
}

#typing-content {
  display: block;
  min-height: 110px;
}

#skip-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  padding: 8px 14px;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 4px var(--accent-color), 0 0 1px rgba(0, 0, 0, 0.85);
  box-shadow: 0 0 8px rgba(122, 252, 255, 0.22);
  cursor: pointer;
  user-select: none;
  animation: skipPulse 1.8s ease-in-out infinite;
}

#sound-toggle {
  position: fixed;
  right: 150px;
  bottom: 24px;
  z-index: 9999;
  padding: 8px 14px;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 4px var(--accent-color), 0 0 1px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  user-select: none;
  animation: skipPulse 1.8s ease-in-out infinite;
}

#sound-toggle:hover {
  background: var(--accent-color);
  color: #000a1a;
}

#skip-btn:hover {
  background: var(--accent-color);
  color: #000a1a;
  box-shadow: 0 0 10px var(--accent-color), 0 0 18px rgba(122, 252, 255, 0.5);
  animation: skipHoverJitter 250ms linear infinite;
}

.cursor {
  display: inline-block;
  animation: blink 500ms steps(1, end) infinite;
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

#message-form {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

#message-form input,
#message-form textarea,
#message-form button {
  background: rgba(0, 10, 26, 0.55);
  color: #70a1ff;
  border: 1px solid rgba(122, 252, 255, 0.3);
  font: inherit;
  padding: 10px 12px;
  outline: none;
}

#message-form button {
  cursor: pointer;
  animation: bluePulse 2.2s ease-in-out infinite;
}

#messages-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.message-item {
  border: 1px solid rgba(122, 252, 255, 0.3);
  background: rgba(0, 10, 26, 0.7);
  backdrop-filter: blur(8px);
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

#visitor-counter {
  margin-top: 14px;
  color: #7afcff;
  letter-spacing: 0.08em;
  text-align: right;
  text-shadow: 0 0 2px #7afcff, 0 0 5px rgba(200, 255, 255, 0.45);
}

@keyframes bluePulse {
  0%,
  100% {
    box-shadow: 0 0 6px rgba(100, 180, 255, 0.45), 0 0 12px rgba(100, 180, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 12px rgba(100, 180, 255, 0.8), 0 0 20px rgba(100, 180, 255, 0.45);
  }
}

@keyframes skipPulse {
  0%,
  100% {
    opacity: 0.75;
    box-shadow: 0 0 6px rgba(122, 252, 255, 0.2);
  }
  50% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(122, 252, 255, 0.45);
  }
}

@keyframes skipHoverJitter {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(0.5px, -0.5px);
  }
  50% {
    transform: translate(-0.5px, 0.5px);
  }
  75% {
    transform: translate(0.5px, 0.5px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes glitch {
  0% {
    transform: translate(0, 0);
    opacity: 1;
  }
  25% {
    transform: translate(-1px, 1px);
    opacity: 0.82;
  }
  50% {
    transform: translate(1px, -1px);
    opacity: 0.9;
  }
  75% {
    transform: translate(-0.5px, 0.5px);
    opacity: 0.86;
  }
  100% {
    transform: translate(0, 0);
    opacity: 1;
  }
}

#terminal-container.rgb-split {
  animation: rgbSplit 120ms linear;
}

@keyframes rgbSplit {
  0% {
    filter: drop-shadow(-1px 0 rgba(255, 0, 80, 0.18)) drop-shadow(1px 0 rgba(0, 255, 255, 0.2));
  }
  50% {
    filter: drop-shadow(-2px 0 rgba(255, 0, 80, 0.25)) drop-shadow(2px 0 rgba(0, 255, 255, 0.28));
  }
  100% {
    filter: none;
  }
}

#terminal-container.terminal-exit {
  animation: terminalExit 150ms ease-out forwards;
}

@keyframes terminalExit {
  0% {
    opacity: 1;
    filter: brightness(1);
  }
  45% {
    opacity: 1;
    filter: brightness(2.2);
    color: #ffffff;
  }
  100% {
    opacity: 0;
    filter: brightness(0.65);
  }
}

@media (max-width: 768px) {
  #mobile-keyboard-trigger {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    z-index: 99999 !important;
  }

  #terminal-container {
    padding: 10px;
    font-size: 14px;
  }

  #typing-content {
    line-height: 1.4;
  }

  #skip-btn,
  #sound-toggle {
    font-size: 12px;
    padding: 5px;
  }
}
