:root {
  --primary-color: #FFFFFF;
  --glow-intensity: 0 0 15px;
}

html {
  font-size: 18px;
  background: #000;
}

@media (min-width: 900px) {
  html {
    font-size: 20px;
  }
}

body {
  font-family: 'Courier New', monospace;
  font-weight: 400;
  line-height: 1.4;
  color: var(--primary-color);
  background: transparent;
  margin: 0;
  padding: 0;
  position: relative;
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
              linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
  z-index: 9999;
}

/* CRT Scanline Effect */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15),
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 2px
  );
  pointer-events: none;
  z-index: 9998;
  animation: scanline 8s linear infinite;
}

@keyframes scanline {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 0 100vh;
  }
}

::selection {
  background: var(--primary-color);
  color: #000;
}

h1, h2 {
  color: var(--primary-color);
  text-shadow: 0 0 5px var(--primary-color);
  border-bottom: 1px dashed var(--primary-color);
  padding-bottom: 5px;
  margin: 1rem 0;
  font-weight: 700;
  text-align: center;
  width: 100%;
}

h1 {
  font-size: 2.2rem;
  line-height: 1.15;
}

@media (min-width: 900px) {
  h1 {
    font-size: 2.488rem;
  }
}

h2 {
  font-size: 1.4rem;
  line-height: 1.15;
}

@media (min-width: 900px) {
  h2 {
    font-size: 1.44rem;
  }
}

p {
  margin-top: 0.5rem;
}

a {
  color: #D0F0E8;
  text-decoration: none;
  transition: all 0.3s;
}

a:hover {
  color: #E8FFF8;
  text-decoration: underline;
  text-shadow: 0 0 5px var(--primary-color);
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

@media (min-width: 900px) {
  .container {
    padding: 20px;
  }
}

.app {
  position: relative;
  background: transparent;
  display: flex;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
  border: 2px solid var(--primary-color);
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 2rem);
  margin: 1rem;
  overflow: hidden;
}

@media (max-width: 768px) {
  .app {
    margin: 0.5rem;
    min-height: calc(100vh - 1rem);
  }
}

.app--debug .grab-zone {
  background: rgba(255, 255, 255, 0.05);
}

.app--debug .grab-zone__debug {
  display: block;
}

.app--debug .grab-zone__danger {
  background: rgba(255, 255, 255, 0.05);
}

.app--debug .grabber__arm-wrapper {
  background: rgba(255, 255, 255, 0.05);
}

.matrix-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.05;
  pointer-events: none;
}

.terminal {
  border: 1px solid var(--primary-color);
  padding: 15px;
  margin: 20px 0;
  background: rgba(0, 20, 0, 0.3);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.terminal.no-border {
  border: none;
  background: none;
  padding: 15px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  border-radius: 12px;
  position: relative;
}

.ascii-art {
  text-align: center;
  margin: 20px auto;
  color: var(--primary-color);
  font-family: monospace;
  white-space: pre;
  text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#ascii-canvas {
  cursor: crosshair;
  display: block;
  margin: 0 auto;
  max-width: 100%;
  filter: drop-shadow(0 0 15px var(--primary-color));
}

/* Glitch Animation */
@keyframes glitch {
  0% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
  100% {
    transform: translate(0);
  }
}

h1:hover {
  animation: glitch 0.3s infinite;
}

/* Glow pulse on hover */
.terminal:hover {
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
  transition: box-shadow 0.3s ease;
}

/* Button press effect */
button:active, .trap-button:active {
  transform: scale(0.95);
  transition: transform 0.1s;
}

@keyframes glow-pulse {
  0% {
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
  }
  50% {
    text-shadow: 0 0 20px var(--primary-color), 0 0 30px var(--primary-color);
  }
  100% {
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color);
  }
}

.blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  from, to {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.grab-zone-wrapper {
  position: absolute;
  bottom: 0;
  right: 0;
  transform: translateX(30%) translateY(50%);
}

.grab-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 700px;
  height: 700px;
  border-radius: 50%;
}
.grab-zone__danger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 400px;
  height: 400px;
  border-radius: 50%;
}
.grab-zone__debug {
  display: none;
  position: absolute;
  width: 300px;
  top: -100px;
  font-size: 14px;
  text-align: center;
  text-transform: uppercase;
}

.grabber {
  position: relative;
  width: 100px;
  height: 100px;
}
.grabber__arm-wrapper {
  position: absolute;
  top: -80px;
  width: 24px;
  height: 260px;
}
.grabber__arm {
  position: relative;
  width: 24px;
  height: 200px;
  background: #1a3a3a;
  border: 1px solid var(--primary-color);
  border-radius: 20px;
  overflow: visible;
  transform: translateY(100%);
  transition: transform 0.2s ease;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}
.grabber__hand {
  display: block;
  position: absolute;
  top: -12px;
  transform: scale(1.4) rotate(-10deg) translateY(100%);
  transform-origin: bottom center;
  transition: transform 0.3s ease;
}
.grabber__face {
  position: absolute;
  width: 75px;
  height: 84px;
  right: 5%;
  transition: transform 0.3s ease;
}
.grabber__body {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 110px;
  height: 95px;
  border-radius: 50%;
  background: #1a3a3a;
  border: 2px solid var(--primary-color);
  transition: transform 0.3s ease;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}
.grabber--waiting .grabber__hand {
  transform: scale(1.4) rotate(-10deg);
}
.grabber--waiting .grabber__arm {
  transform: translateY(80%);
}
.grabber--waiting .grabber__face {
  transform: translateY(60%);
}
.grabber--stalking .grabber__hand {
  transform: scale(1.4) rotate(-10deg);
}
.grabber--stalking .grabber__arm {
  transform: translateY(70%);
}
.grabber--stalking .grabber__face {
  transform: translateY(10%);
}
.grabber--grabbing .grabber__face {
  transform: translateY(-40%) rotate(10deg);
}
.grabber--grabbing .grabber__arm {
  transform: translateY(0%);
}
.grabber--grabbing .grabber__body {
  transform: translateY(-20%);
}
.grabber--grabbing .grabber__hand {
  transform: scale(1.7) rotate(10deg);
}
.grabber--grabbed .grabber__arm {
  transition: transform 1s ease;
}
.grabber--grabbed .grabber__hand {
  transition: transform 2.5s ease;
}
.grabber--grabbed .grabber__face {
  transform: translateY(70%);
  transition: transform 1s ease;
}
.grabber--grabbed .grabber__body {
  transform: translateY(50%);
  transition: transform 1s ease;
}
.grabber--extended .grabber__arm {
  transform: translateY(-20%);
}
.grabber--extended .grabber__face {
  transform: translateY(-60%) rotate(15deg);
}
.grabber--extended .grabber__body {
  transform: translateY(-40%);
}
.grabber--shaka .grabber__arm {
  transform: translateY(50%);
}
.grabber--shaka .grabber__hand {
  transform: scale(2.5) translateY(10%);
  -webkit-animation: shaka 0.5s infinite alternate forwards;
          animation: shaka 0.5s infinite alternate forwards;
  transform-origin: 55% 60%;
}
.grabber--shaka .grabber__face {
  transform: translateY(70%);
  transition: transform 1s ease;
}
.grabber--shaka .grabber__body {
  transform: translateY(50%);
  transition: transform 1s ease;
}

.trap-button {
  position: absolute;
  bottom: 80px;
  right: 70px;
  min-width: 125px;
  background: #111;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
  border-radius: 0;
  display: inline-block;
  padding: 8px 15px;
  margin: 5px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.42857143;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  cursor: pointer;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  font-family: 'Courier New', monospace;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: all 0.3s;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.trap-button:hover {
  background: var(--primary-color);
  color: #000;
  box-shadow: 0 0 15px var(--primary-color);
}

.debug-button {
  position: fixed;
  top: 0;
  right: 0;
  background: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 0.5rem 1rem;
  margin: 1rem;
  font-size: 14px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  cursor: pointer;
  transition: all 0.3s;
}

.debug-button:hover {
  opacity: 1;
  box-shadow: 0 0 10px var(--primary-color);
}

.status-bar {
  background: #000;
  color: var(--primary-color);
  padding: 8px 20px;
  border-top: 1px solid var(--primary-color);
  font-size: 0.8em;
  position: fixed;
  bottom: 0;
  width: 100%;
  z-index: 10000;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  box-shadow: 0 -5px 15px rgba(255, 255, 255, 0.2);
  text-align: center;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .status-bar {
    font-size: 0.6em;
    padding: 8px 10px;
    line-height: 1.6;
    word-wrap: break-word;
  }
  
  .status-bar span {
    display: inline-block;
    margin: 2px 3px;
  }
  
  /* Mobile optimizations */
  body {
    font-size: 16px;
  }
  
  .container {
    padding: 15px;
    padding-bottom: 80px; /* Space for button */
  }
  
  h1 {
    font-size: 1.5rem;
    word-break: break-word;
  }
  
  .terminal.no-border {
    font-size: 0.85em;
  }
  
  .terminal.no-border p {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  .ascii-art {
    font-size: 0.6em;
    overflow-x: auto;
  }
  
  #ascii-canvas {
    height: 120px !important;
  }
  
  /* Hide the grab zone on mobile */
  .grab-zone-wrapper {
    display: none !important;
  }
  
  /* Update button text for mobile */
  .trap-button {
    bottom: 70px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    font-size: 13px;
    padding: 10px 20px;
    white-space: nowrap;
  }
  
  .trap-button::after {
    content: ' (PC Only)';
    font-size: 0.75em;
    opacity: 0.7;
  }
  
  /* Optimize matrix background for mobile */
  .matrix-bg {
    opacity: 0.1;
  }
  
  /* Hide debug button on mobile */
  .debug-button {
    display: none;
  }
}

@-webkit-keyframes shaka {
  0% {
    transform: scale(2.5) translateY(0%) rotate(-20deg);
  }
  100% {
    transform: scale(2.5) translateY(0%) rotate(20deg);
  }
}

@keyframes shaka {
  0% {
    transform: scale(2.5) translateY(0%) rotate(-20deg);
  }
  100% {
    transform: scale(2.5) translateY(0%) rotate(20deg);
  }
}

/* Encrypting text animation */
.encrypting-text {
  display: inline-block;
  position: relative;
  color: var(--primary-color);
  text-shadow: 0 0 5px var(--primary-color);
  animation: encrypt-glitch 0.3s ease-in-out infinite alternate;
  letter-spacing: 2px;
}

@keyframes encrypt-glitch {
  0% {
    text-shadow: 0 0 5px var(--primary-color), 2px 0 0 rgba(255, 0, 0, 0.3);
    transform: translateX(0);
  }
  25% {
    text-shadow: 0 0 10px var(--primary-color), -2px 0 0 rgba(255, 255, 255, 0.3);
    transform: translateX(-2px);
  }
  50% {
    text-shadow: 0 0 15px var(--primary-color), 1px 0 0 rgba(0, 0, 255, 0.3);
    transform: translateX(1px);
  }
  75% {
    text-shadow: 0 0 10px var(--primary-color), -1px 0 0 rgba(255, 0, 255, 0.3);
    transform: translateX(-1px);
  }
  100% {
    text-shadow: 0 0 5px var(--primary-color), 1px 0 0 rgba(0, 255, 255, 0.3);
    transform: translateX(0);
  }
}

/* Animated dots for loading effect */
.encrypting-text .dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

/* Quote text styling */
.quote-text {
  margin-top: 1.5rem !important;
  font-style: italic;
  opacity: 0.8;
  letter-spacing: 1px;
  text-shadow: 0 0 8px var(--primary-color);
}

@keyframes dots {
  0%, 20% {
    content: '';
  }
  40% {
    content: '.';
  }
  60% {
    content: '..';
  }
  80%, 100% {
    content: '...';
  }
}

/* Three.js Container */
#three-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  pointer-events: none;
  overflow: hidden;
}

#three-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0;
  left: 0;
}

/* Animated Ghost */
.ghost {
  position: fixed;
  width: 80px;
  height: 100px;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
  pointer-events: none;
}

.ghost.show {
  opacity: 1;
  pointer-events: auto;
}

/* Ghost positioning */
.ghost.top-left {
  top: -100px;
  left: -80px;
}

.ghost.top-left.peek {
  top: 20px;
  left: 20px;
}

.ghost.top-right {
  top: -100px;
  right: -80px;
}

.ghost.top-right.peek {
  top: 20px;
  right: 20px;
}

.ghost.bottom-left {
  bottom: -100px;
  left: -80px;
}

.ghost.bottom-left.peek {
  bottom: 80px;
  left: 20px;
}

.ghost.bottom-right {
  bottom: -100px;
  right: -80px;
}

.ghost.bottom-right.peek {
  bottom: 80px;
  right: 20px;
}

.ghost {
  transition: all 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.ghost.scared {
  transition: all 0.3s cubic-bezier(0.95, 0.05, 0.795, 0.035) !important;
}

/* Ghost body */
.ghost-body {
  position: relative;
  width: 80px;
  height: 80px;
  background: var(--primary-color);
  border-radius: 40px 40px 0 0;
  box-shadow: 0 0 20px var(--primary-color), 0 0 40px var(--primary-color);
  animation: ghost-float 2s ease-in-out infinite;
}

@keyframes ghost-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Ghost eyes */
.ghost-eyes {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
}

.ghost-eye {
  width: 12px;
  height: 16px;
  background: #000;
  border-radius: 50% 50% 50% 50%;
  animation: blink-eye 4s infinite;
}

@keyframes blink-eye {
  0%, 98%, 100% {
    transform: scaleY(1);
  }
  99% {
    transform: scaleY(0.1);
  }
}

/* Ghost tail */
.ghost-tail {
  position: absolute;
  bottom: -15px;
  left: 0;
  width: 100%;
  height: 20px;
  display: flex;
  justify-content: space-around;
}

.ghost-wave {
  width: 20px;
  height: 20px;
  background: var(--primary-color);
  border-radius: 0 0 20px 20px;
  animation: ghost-wave 1s ease-in-out infinite;
}

.ghost-wave:nth-child(2) {
  animation-delay: 0.1s;
}

.ghost-wave:nth-child(3) {
  animation-delay: 0.2s;
}

.ghost-wave:nth-child(4) {
  animation-delay: 0.3s;
}

@keyframes ghost-wave {
  0%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(1.3);
  }
}

/* Ghost scared effect - runs away when cursor approaches */
.ghost.scared .ghost-body {
  animation: ghost-shake 0.1s infinite;
}

@keyframes ghost-shake {
  0%, 100% {
    transform: translateX(0) translateY(0);
  }
  25% {
    transform: translateX(-3px) translateY(-2px) rotate(-3deg);
  }
  75% {
    transform: translateX(3px) translateY(2px) rotate(3deg);
  }
}

/* Mobile ghost adjustments */
@media (max-width: 768px) {
  .ghost {
    width: 60px;
    height: 80px;
  }
  
  .ghost-body {
    width: 60px;
    height: 60px;
  }
  
  .ghost.top-left.peek,
  .ghost.top-right.peek,
  .ghost.bottom-left.peek,
  .ghost.bottom-right.peek {
    top: auto;
    bottom: 100px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
  }
}
