:root {
  --bg-gradient-start: #ff7e5f;
  --bg-gradient-end: #feb47b;
  --glass-bg: rgba(255, 255, 255, 0.15);
  --glass-border: rgba(255, 255, 255, 0.3);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
  --text-main: #ffffff;
  --font-primary: 'Montserrat', sans-serif;
  --font-secondary: 'Playfair Display', serif;
}

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

body {
  font-family: var(--font-primary);
  background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* For absolute shapes */
  position: relative;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Moving background shapes */
.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: 0;
  animation: float 10s infinite alternate ease-in-out;
}

.shape1 {
  width: 400px;
  height: 400px;
  background: rgba(255, 105, 180, 0.5);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.shape2 {
  width: 500px;
  height: 500px;
  background: rgba(255, 215, 0, 0.3);
  bottom: -150px;
  right: -100px;
  animation-delay: -3s;
  animation-duration: 12s;
}

.shape3 {
  width: 300px;
  height: 300px;
  background: rgba(148, 0, 211, 0.4);
  top: 40%;
  left: 30%;
  animation-delay: -5s;
  animation-duration: 15s;
}

@keyframes float {
  0% { transform: translateY(0) translateX(0) scale(1); }
  50% { transform: translateY(-50px) translateX(30px) scale(1.1); }
  100% { transform: translateY(30px) translateX(-50px) scale(0.9); }
}

/* App container */
.app-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 600px;
  padding: 20px;
  display: flex;
  justify-content: center;
}

/* Screens */
.screen {
  display: none;
  width: 100%;
  opacity: 0;
  transition: opacity 0.6s ease-in-out, transform 0.6s ease-in-out;
  transform: translateY(20px);
}

.screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Screen 1: Login */
h1 {
  font-family: var(--font-secondary);
  font-size: 2.5rem;
  margin-bottom: 15px;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.highlight {
  color: #ffeb3b;
}

.subtitle {
  font-size: 1rem;
  margin-bottom: 30px;
  line-height: 1.5;
  opacity: 0.9;
}

.input-group {
  margin-bottom: 25px;
  position: relative;
}

input[type="text"] {
  width: 100%;
  padding: 15px 25px;
  border-radius: 50px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 1.2rem;
  text-align: center;
  outline: none;
  font-family: inherit;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  letter-spacing: 2px;
}

input[type="text"]::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

input[type="text"]:focus {
  background: rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 15px rgba(255,255,255,0.5);
}

.error-msg {
  color: #ff4757;
  background: rgba(255,255,255,0.9);
  padding: 8px 15px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.85rem;
  margin-top: 10px;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  display: none;
}

.error-msg.show {
  display: inline-block;
  opacity: 1;
  transform: translateY(0);
}

.shake {
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Buttons */
.glow-on-hover {
  width: 200px;
  height: 50px;
  border: none;
  outline: none;
  color: #fff;
  background: linear-gradient(45deg, #ff512f, #dd2476, #ff512f);
  background-size: 200% auto;
  cursor: pointer;
  position: relative;
  z-index: 0;
  border-radius: 50px;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  animation: bgScroll 3s linear infinite;
}

.glow-on-hover:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 25px rgba(221, 36, 118, 0.5);
}

.glow-on-hover:active {
  transform: translateY(1px);
}

@keyframes bgScroll {
  to { background-position: 200% center; }
}

/* Glass Card Global Structure */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 20px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Screen 2: Game */
.game-header {
  text-align: center;
  margin-bottom: 20px;
}

.game-header h2 {
  font-family: var(--font-secondary);
  font-size: 2rem;
  margin-bottom: 10px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.scratch-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.scratch-content {
  color: #ff4757;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  line-height: 1.2;
  user-select: none;
  padding: 5px;
  text-transform: uppercase;
  z-index: 1; /* Below canvas */
  animation: pulse 2s infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(1.05); opacity: 1; }
}

.scratch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2; /* Above content */
  cursor: crosshair;
  transition: opacity 0.4s ease; /* Fade out when done */
}


/* Screen 3: Prize */
.prize-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 30px;
}

.bounce-in {
  animation: bounceIn 1s cubic-bezier(0.280, 0.840, 0.420, 1);
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.1); opacity: 1; }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.prize-desc {
  font-size: 1.25rem;
  margin: 15px 0 35px;
  line-height: 1.4;
  font-weight: 600;
  color: #fff;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.qr-container {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 20px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  margin-bottom: 20px;
  transition: transform 0.3s ease;
}

.qr-container:hover {
  transform: scale(1.05);
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.qr-glow {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, #ff007f, #00ffff, #ff007f, #00ffff);
  z-index: -1;
  border-radius: 22px;
  background-size: 400%;
  filter: blur(10px);
  animation: glowing 20s linear infinite;
  opacity: 0.8;
}

@keyframes glowing {
  0% { background-position: 0 0; }
  50% { background-position: 400% 0; }
  100% { background-position: 0 0; }
}

.qr-text {
  font-size: 0.9rem;
  opacity: 0.8;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Utilities */
.hidden {
  display: none !important;
}

@media (max-width: 480px) {
  .scratch-content {
      font-size: 0.8rem;
  }
  h1 { font-size: 2rem; }
  .prize-desc { font-size: 1.1rem; }
}
