* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  background: linear-gradient(135deg, #2b1055, #7597de);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

/* Winner state: pesto photo behind everything */
body.won {
  background-image: linear-gradient(rgba(0, 0, 0, .35), rgba(0, 0, 0, .35)), url("../assets/images/pesto.jpeg");
}

.screen {
  position: relative;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

/* Login */
#login { align-items: center; justify-content: center; overflow: hidden; }
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.overlay { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }

.panel {
  position: relative;
  width: min(420px, 100%);
  padding: 28px 20px;
  text-align: center;
  background: rgba(0, 0, 0, .45);
  border: 2px solid rgba(255, 255, 255, .4);
  border-radius: 20px;
  backdrop-filter: blur(6px);
}
.panel h1 { margin: 0 0 8px; font-size: clamp(2rem, 9vw, 3rem); }
.panel p { margin: 0 0 16px; }
.panel input {
  width: 100%;
  padding: 14px;
  font-size: 1.3rem;
  text-align: center;
  border: 0;
  border-radius: 12px;
  margin-bottom: 14px;
}
.error { color: #ff8a8a; font-weight: bold; margin: 14px 0 0 !important; }
.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

.btn {
  font: inherit;
  font-weight: bold;
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  color: #fff;
}
.btn.primary { width: 100%; padding: 14px; font-size: 1.2rem; background: #e84393; }
.photos-section {
  position: relative;
  width: min(420px, 100%);
  margin-top: 14px;
  padding: 14px 20px;
  text-align: center;
  background: rgba(0, 0, 0, .45);
  border: 2px solid rgba(255, 255, 255, .4);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}
.photos-link { color: #fff; }

/* Game */
.intro-mode { align-items: center; justify-content: center; }
.intro-mode .status, .intro-mode .stage, .intro-mode .actions { display: none; }
#game:not(.intro-mode) .intro { display: none; }
.intro { text-align: left; }
.intro h2 { margin: 0 0 12px; text-align: center; font-size: 1.8rem; }
.intro ul { margin: 0 0 20px; padding-left: 20px; line-height: 1.5; }
.intro li { margin-bottom: 8px; }

.status { text-align: center; }
.counts { display: flex; justify-content: space-between; font-size: 1.1rem; margin-bottom: 8px; }
.progress { height: 10px; background: rgba(255, 255, 255, .25); border-radius: 99px; overflow: hidden; }
#bar { height: 100%; width: 0; background: #feca57; transition: width .3s; }
.hint { margin: 8px 0 0; font-size: .85rem; opacity: .8; }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px 0;
}

.card {
  width: min(420px, 100%);
  padding: 28px 20px;
  text-align: center;
  color: #1b1b1b;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  animation: card-in .35s ease-out;
}
.card .emoji { font-size: 4.5rem; display: block; }
.card h2 { margin: 8px 0; font-size: 1.6rem; }
.card p { margin: 0 0 8px; font-size: 1.05rem; }
.card a { color: #6c5ce7; }
.card .gift-message {
  padding: 0;
  border: 0;
  color: #6c5ce7;
  background: none;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.card.out { animation: card-out .3s ease-in forwards; }
#gift-dialog {
  width: min(420px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  padding: 24px;
  border: 0;
  border-radius: 8px;
  color: #1b1b1b;
  background: #fff;
  text-align: center;
  overflow-wrap: anywhere;
}
#gift-dialog::backdrop { background: rgba(0, 0, 0, .65); }
#gift-dialog h2 { margin: 0 0 12px; font-size: 1.5rem; }
#gift-dialog p { margin: 0 0 20px; line-height: 1.5; }
@keyframes card-in { from { transform: translateX(60px) rotate(4deg); opacity: 0; } }
@keyframes card-out { to { transform: translateX(-120px) rotate(-12deg); opacity: 0; } }

.card.winner {
  transform: scale(1.08);
  border: 5px solid #feca57;
  animation: glow 1.4s ease-in-out infinite alternate;
}
@keyframes glow {
  from { box-shadow: 0 0 20px 4px #feca57; }
  to { box-shadow: 0 0 50px 16px #ff9ff3; }
}

.win-message {
  margin: 8px 0 0;
  font-size: 1.6rem;
  font-weight: bold;
  text-align: center;
  text-shadow: 0 2px 8px #000;
}

.actions { display: flex; justify-content: center; gap: 12px; }
.choice {
  flex: 1;
  max-width: 220px;
  aspect-ratio: 1 / 1;
  font-size: 1.4rem;
  background-size: cover;
  background-position: center;
  position: relative;
  overflow: hidden;
}
.choice span {
  position: relative;
  padding: 4px 10px;
  background: rgba(0, 0, 0, .3);
  border-radius: 8px;
}
.choice.accept {
  background-image: linear-gradient(rgba(29, 209, 80, .2), rgba(29, 209, 80, .2)), url("../assets/images/velo.jpeg");
  border: 3px solid #1dd150;
}
.choice.discard {
  background-image: linear-gradient(rgba(235, 50, 50, .2), rgba(235, 50, 50, .2)), url("../assets/images/acrobat.jpeg");
  border: 3px solid #eb3232;
}
.choice:active { transform: scale(.97); }

/* Roulette */
.roulette {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  text-align: center;
  background: rgba(0, 0, 0, .9);
}
.roulette p { margin: 0; font-size: 1.2rem; }
.roulette-text {
  min-height: 3em;
  font-size: clamp(1.8rem, 8vw, 3rem);
  font-weight: bold;
  color: #feca57;
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
