@import url("https://fonts.googleapis.com/css2?family=Jersey+10&display=swap");

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

body {
  background: #222;
  color: #fff;
  font-family: "Press Start 2P", "VT323", "Consolas", monospace;
  margin: 0;
  padding: 0;
  height: 100%;
}

body::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0px,
    rgba(255, 255, 255, 0.02) 2px,
    transparent 2px,
    transparent 6px
  );
  z-index: 1;
}

.back-button {
  position: absolute;
  top: 2rem;
  left: 2rem;
  width: 50px;
  height: 50px;
  color: #222;
  border: none;
  font-size: 1rem;
  cursor: pointer;
}

.back-button:hover {
  animation: pixel-bounce 0.5s infinite alternate;
}
.back-button:active {
  transform: translateY(2px) scale(0.9);
}

.signup-container,
.login-container {
  background: #222;
  color: #fff;
  font-family: "Jersey 10", monospace;
  font-size: 18px;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

h1,
h2 {
  font-family: inherit;
  font-size: 2rem;
  text-align: center;
  margin-top: 2rem;
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #000, 4px 4px 0 #ff00cc;
}

p {
  text-shadow: 1px 1px #000;
  margin: 16px 0;
  animation: fade-in-text 0.5s ease-in-out;
  font-size: 1.5rem;
}
@keyframes fade-in-text {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

form {
  background: #333;
  border: 4px solid #ffcc00;
  border-radius: 0;
  padding: 24px 16px;
  box-shadow: 8px 8px 0 #000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 320px;
  max-width: 95vw;
  margin: 2rem auto;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

label {
  font-size: 1rem;
  letter-spacing: 1px;
  color: #ffcc00;
  margin-bottom: 4px;
  font-family: "Jersey 10", monospace;
}

input[type="email"],
input[type="text"],
input[type="password"] {
  background: #111;
  color: #fff;
  border: 2px solid #ff00cc;
  border-radius: 0;
  font-family: inherit;
  font-size: 1rem;
  padding: 8px 12px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 0 0 #ff00cc;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: #00eaff;
  box-shadow: 0 0 8px #00eaff;
  background: #222;
}

button {
  background: #ff00cc;
  color: #fff;
  border: 4px solid #fff;
  border-radius: 0;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.75em 2em;
  cursor: pointer;
  box-shadow: 2px 2px 0 #000;
  transition: background 0.2s, color 0.2s;
  letter-spacing: 1px;
  position: relative;
  z-index: 2;
  animation: pixel-bounce 1.2s infinite alternate;
}

@keyframes pixel-bounce {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-4px);
  }
}

button:hover {
  background: #fff;
  color: #ff00cc;
  border-color: #ff00cc;
}

button:active {
  transform: translateY(2px) scale(0.97);
  box-shadow: 1px 1px 0 #000;
  background: #ffe066;
  color: #222;
}

a {
  color: #00eaff;
  text-decoration: none;
  font-weight: bold;
  transition: color 0.2s, text-shadow 0.2s;
  text-shadow: 1px 1px #000;
  font-family: inherit;
}

a:hover {
  color: #ff00cc;
  text-shadow: 2px 2px #00eaff;
}

a:active {
  transform: translateY(2px) scale(0.97);
  text-shadow: 1px 1px 0 #000;
  color: #222;
}

#video,
.pixel-frame {
  display: block;
  margin: 2rem auto 1rem auto;
  border: 6px solid #fff;
  box-shadow: 0 0 0 4px #ff00cc, 0 0 16px 4px #000;
  image-rendering: pixelated;
  background: #111;
}

#pic-result,
#emotion-result,
.pixel-emotion {
  margin: 2rem auto 0 auto;
  max-width: 400px;
  background: #111;
  border: 4px solid #ff00cc;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  padding: 1em;
  text-align: center;
  box-shadow: 2px 2px 0 #000;
  word-break: break-word;
}

.flash-messages {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: #222;
  padding: 8px 16px;
  margin: 0;
  font-size: 1rem;
  font-family: inherit;
  list-style: none;
  border-radius: 6px;
  z-index: 1000;
  box-shadow: 4px 4px 0 #000;
  animation: popup-in 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
  opacity: 1;
  transition: opacity 0.5s;
}

.flash-messages.hide {
  opacity: 0;
  pointer-events: none;
}

.flash-error {
  border: 2px solid #ff3333;
  color: #ff3333;
  border-left: 4px solid #ff3333;
  padding-left: 8px;
  background: #2a0000;
}

.flash-success {
  color: #33ff57;
  border-left: 4px solid #33ff57;
  border: 2px solid #33ff57;
  padding-left: 8px;
  background: #002a00;
}

@keyframes popup-in {
  0% {
    transform: scale(0.7) translateY(40px);
    opacity: 0;
  }
  80% {
    transform: scale(1.05) translateY(-6px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

.pixel-loader {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 4px solid #ff00cc;
  border-top: 4px solid #fff;
  border-radius: 50%;
  animation: pixel-spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes pixel-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (max-width: 700px) {
  .signup-container,
  .login-container {
    margin-top: 2rem;
  }

  .back-button {
    top: -1rem;
    left: 0.8rem;
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }
  .flash-messages {
    left: 4vw;
    bottom: 4vw;
    font-size: 0.95rem;
    padding: 6px 8px;
    max-width: 90vw;
    word-break: break-word;
  }
}

@media (max-width: 500px) {
  #video,
  .pixel-frame {
    width: 95vw;
    height: auto;
  }
  #pic-result,
  #emotion-result,
  .pixel-emotion {
    max-width: 95vw;
    font-size: 0.85rem;
  }
}

@media (max-width: 400px) {
  h1,
  h2 {
    font-size: 1rem;
  }
  .flash-messages {
    font-size: 0.85rem;
    padding: 4px 4px;
    left: 2vw;
    bottom: 2vw;
  }
}
