/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0; padding: 0; box-sizing: border-box;
}

:root {
  --bg-base: #F6EAD7;
  --accent: #F28C6B;
  --accent-grad: linear-gradient(135deg, #F28C6B, #E07A58);
  --timer-green: #5FBF8F;
  --timer-yellow: #E8C84A;
  --timer-red: #E05555;
  --text-primary: rgba(90,62,43,0.95);
  --text-secondary: rgba(90,62,43,0.60);
  --text-dim: rgba(90,62,43,0.35);
  --pulse-speed: 3s;
  --font: 'Fredoka', 'Trebuchet MS', sans-serif;
}

html, body {
  height: 100%; width: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Loading fade-in — hide flash of unstyled content */
body { animation: bodyFadeIn 0.3s ease; }
@keyframes bodyFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  width: 100%;
  z-index: 1;
}
.screen.active { display: flex; }

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

/* ===== HOME SCREEN ===== */
#screen-home {
  background: linear-gradient(160deg, #F6EAD7 0%, #F2E4CC 50%, #F6EAD7 100%);
  background-size: 100% 100%;
}
#screen-home::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(201,182,163,0.2) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

#home-bird, .floating {
  font-size: clamp(4rem, 18vw, 7rem);
  animation: float 3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(242,140,107,0.3));
}

.home-title {
  font-size: clamp(2.8rem, 10vw, 4.2rem);
  font-weight: 800;
  color: #5A3E2B;
  line-height: 1.1;
}

.home-subtitle {
  font-size: clamp(0.95rem, 3.5vw, 1.15rem);
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: -0.3rem;
}

.home-footer {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 1rem;
  letter-spacing: 0.5px;
}

/* Social Proof + Trending */
.home-social-proof {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  margin-top: 1.2rem;
  letter-spacing: 0.3px;
}

.home-trending {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(201,182,163,0.15);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(201,182,163,0.3);
  max-width: 280px;
  opacity: 0;
  animation: fadeIn 0.5s ease 0.3s forwards;
}
.home-trending:empty { display: none; }

/* ===== BUTTONS ===== */
.btn {
  font-family: var(--font);
  font-size: clamp(1rem, 4vw, 1.2rem);
  font-weight: 700;
  border: none;
  border-radius: 16px;
  padding: 1rem 2.8rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  min-width: 200px;
  letter-spacing: 0.3px;
}
.btn:active { transform: scale(0.96); box-shadow: 0 1px 8px rgba(201,182,163,0.25); }
.btn:disabled { opacity: 0.35; pointer-events: none; }

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 24px rgba(242,140,107,0.35), 0 0 0 0 rgba(242,140,107,0);
}
.btn-primary:hover { box-shadow: 0 6px 32px rgba(242,140,107,0.45); }

.btn-secondary {
  background: rgba(255,255,255,0.6);
  color: var(--text-primary);
  border: 1px solid rgba(201,182,163,0.4);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.75); }

.btn-dare {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 24px rgba(242,140,107,0.35);
  white-space: nowrap;
}
.btn-dare:hover { box-shadow: 0 6px 32px rgba(242,140,107,0.45); }

.btn-back {
  font-family: var(--font);
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  position: absolute;
  top: 1.5rem; left: 1.5rem;
  font-weight: 500;
}

.btn-text {
  font-family: var(--font);
  background: none; border: none;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  padding: 0.5rem 1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ===== NICKNAME SCREEN ===== */
#screen-nickname, #screen-post-nickname {
  background: linear-gradient(160deg, #F6EAD7 0%, #F0E0C8 100%);
}

.nickname-title {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--text-secondary);
}

.nickname-sub {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: -0.5rem;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 340px;
}

.avatar-btn {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  background: rgba(90,62,43,0.04);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 0.45rem;
  cursor: pointer;
  transition: all 0.15s;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-btn:hover { background: rgba(90,62,43,0.08); }
.avatar-btn.selected {
  border-color: var(--accent);
  background: rgba(242,140,107,0.12);
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(242,140,107,0.3);
}

.name-input {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  background: rgba(255,255,255,0.7);
  border: 2px solid rgba(201,182,163,0.4);
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  color: #5A3E2B;
  width: 100%;
  max-width: 280px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: rgba(242,140,107,0.5); }
.name-input::placeholder { color: var(--text-dim); }

/* ===== COUNTDOWN SCREEN ===== */
#screen-countdown { background: var(--bg-base); }

.countdown-number {
  font-size: clamp(6rem, 28vw, 12rem);
  font-weight: 800;
  color: #5A3E2B;
  animation: countPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== GAME SCREEN ===== */
#screen-game {
  background: linear-gradient(135deg, #F6EAD7 0%, #F0E0C8 100%);
  transition: background 1s ease;
  overflow: hidden;
}

#game-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.2rem 0.5rem;
  z-index: 10;
}

#round-display {
  font-size: clamp(0.9rem, 3.5vw, 1.1rem);
  font-weight: 700;
  color: var(--text-secondary);
  transition: color 0.4s, text-shadow 0.4s, transform 0.3s;
}
#round-display.milestone {
  animation: milestonePulse 0.6s ease;
}
#round-display.legendary {
  color: #ffd700;
  text-shadow: 0 0 12px rgba(255,215,0,0.5);
}

#player-avatar-display {
  font-size: 1.5rem;
}

/* Timer Bar */
#timer-bar-container {
  position: absolute;
  top: 3.2rem; left: 0; right: 0;
  height: 4px;
  background: rgba(201,182,163,0.25);
  z-index: 10;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: var(--timer-green);
  transform-origin: left;
  transition: background-color 0.3s;
  border-radius: 0 2px 2px 0;
}

/* Vignette Overlay */
#vignette-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
}

/* Flash Overlay */
#flash-overlay {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
}
#flash-overlay.flash-green {
  background: rgba(95,191,143,0.15);
  animation: flashOut 0.5s ease forwards;
}
#flash-overlay.flash-yellow {
  background: rgba(255,230,109,0.18);
  animation: flashOut 0.5s ease forwards;
}
#flash-overlay.flash-red {
  background: rgba(255,60,60,0.25);
  animation: flashOut 0.5s ease forwards;
}

/* Pulse Rings */
#pulse-rings {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

.ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 120px; height: 120px;
  border: 1px solid rgba(201,182,163,0.2);
  border-radius: 50%;
  animation: pulseRing var(--pulse-speed) ease-out infinite;
}
.ring:nth-child(2) { animation-delay: calc(var(--pulse-speed) * 0.33); }
.ring:nth-child(3) { animation-delay: calc(var(--pulse-speed) * 0.66); }

/* Prompt */
#prompt-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 8;
  pointer-events: none;
}

#prompt-emoji {
  font-size: clamp(5rem, 22vw, 9rem);
  line-height: 1;
  transition: transform 0.05s;
  filter: drop-shadow(0 0 20px rgba(201,182,163,0.3));
}
#prompt-emoji.pop-in { animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
#prompt-emoji.fly-up { animation: flyUp 0.3s ease-in forwards; }
#prompt-emoji.drop-down { animation: dropDown 0.35s cubic-bezier(0.22, 0.61, 0.36, 1.1) forwards; }
#prompt-emoji.trembling { animation: tremble 0.08s linear infinite; }

#prompt-name {
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 800;
  text-shadow: 0 2px 20px rgba(90,62,43,0.15);
}
#prompt-name.pop-in { animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1); }

/* Tap Zone */
#tap-zone {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 2rem 1rem 2.5rem;
  text-align: center;
  z-index: 9;
  pointer-events: none;
}

#tap-zone span {
  font-size: clamp(0.9rem, 3.5vw, 1.05rem);
  font-weight: 600;
  color: rgba(90,62,43,0.35);
  animation: glowPulse var(--pulse-speed) ease-in-out infinite;
  letter-spacing: 0.5px;
}

/* ===== SLOW-MO REPLAY SCREEN ===== */
#screen-replay {
  background: var(--bg-base);
  z-index: 20;
  animation: replayBgPulse 1.1s ease-in-out;
}

.replay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  z-index: 2;
}

.replay-emoji {
  font-size: clamp(8rem, 38vw, 15rem);
  line-height: 1;
  animation: replayPulse 0.9s ease-in-out;
  filter: drop-shadow(0 0 60px rgba(242,140,107,0.4));
}

.replay-name {
  font-size: clamp(2.6rem, 10vw, 4rem);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(242,140,107,0.3);
  animation: replayTextFade 0.9s ease-in-out;
}

#replay-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(circle, transparent 20%, rgba(242,140,107,0.15) 70%, rgba(201,182,163,0.4) 100%);
  pointer-events: none;
  z-index: 1;
  animation: vignetteClose 1.1s ease-in forwards;
}

/* ===== KILL SCREEN ===== */
#screen-kill {
  background: linear-gradient(160deg, #ECD8C0 0%, #E4CCAE 50%, #F6EAD7 100%);
  overflow: hidden;
}
.kill-inner { gap: 1rem; z-index: 2; position: relative; }

/* Giant faded background emoji */
.kill-bg-emoji {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(18rem, 70vw, 35rem);
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  filter: blur(2px);
}
.kill-bg-emoji.visible {
  animation: bgEmojiFade 1.2s ease 0.3s forwards;
}

/* Watermark */
.kill-watermark {
  position: absolute;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: lowercase;
  color: rgba(90,62,43,0.35);
  z-index: 3;
  pointer-events: none;
}

.kill-emoji {
  font-size: clamp(5rem, 22vw, 9rem);
  line-height: 1;
  opacity: 0;
}
.kill-emoji.zoom-in { animation: killZoom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.kill-emoji.zoom-in.smug { animation: killZoom 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards, smugWiggle 0.4s ease 0.4s; }

.kill-text {
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
  opacity: 0;
  max-width: 340px;
}
.kill-text.slide-up { animation: killSlide 0.5s ease forwards; }

.kill-round {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.1;
  opacity: 0;
  letter-spacing: 0.5px;
  margin-top: -0.2rem;
}
.kill-round.slide-up { animation: killSlide 0.5s ease forwards; }

.kill-session-stats {
  font-size: 0.8rem;
  color: var(--text-dim);
  opacity: 0;
  max-width: 280px;
  line-height: 1.6;
}
.kill-session-stats:empty { display: none; }
.kill-session-stats.slide-up { animation: killSlide 0.4s ease forwards; }

.kill-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  max-width: 300px;
  opacity: 0;
}
.kill-buttons.slide-up { animation: killSlide 0.5s ease 0.2s forwards; }

/* ===== CHALLENGE SCREENS ===== */
#screen-challenge {
  background: linear-gradient(160deg, #F6EAD7 0%, #F0E0C8 100%);
}
.challenge-text {
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.6;
  max-width: 320px;
  white-space: pre-line;
}

.challenge-hint {
  font-size: 0.85rem;
  color: var(--text-secondary);
  opacity: 0.6;
  margin-top: 1rem;
}

/* Inline challenge verdict on kill screen */
.kill-challenge-result {
  opacity: 0;
  font-size: clamp(1.05rem, 4vw, 1.25rem);
  font-weight: 700;
  color: var(--accent);
  text-align: center;
}
.kill-challenge-result:empty { display: none; }
.kill-challenge-result.slide-up { animation: killSlide 0.4s ease forwards; }

/* ===== ANIMATIONS ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@keyframes popIn {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes countPop {
  from { transform: scale(2); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes flyUp {
  to { transform: translateY(-200px); opacity: 0; }
}

@keyframes dropDown {
  0% { transform: translateY(0); }
  70% { transform: translateY(150px); }
  85% { transform: translateY(135px); }
  100% { transform: translateY(150px); opacity: 0.3; }
}

@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2px) translateY(1px); }
  50% { transform: translateX(2px) translateY(-1px); }
  75% { transform: translateX(-1px) translateY(2px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}

@keyframes killZoom {
  from { transform: scale(3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes killSlide {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes smugWiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-5deg); }
  75% { transform: rotate(5deg); }
}

@keyframes bgEmojiFade {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 0.06; transform: translate(-50%, -50%) scale(1); }
}

@keyframes pulseRing {
  0% {
    width: 60px; height: 60px;
    opacity: 0.4;
    border-color: rgba(201,182,163,0.3);
  }
  100% {
    width: 350px; height: 350px;
    opacity: 0;
    border-color: rgba(201,182,163,0);
  }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

@keyframes flashOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes milestonePulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.5); color: #ffd700; text-shadow: 0 0 16px rgba(255,215,0,0.5); }
  100% { transform: scale(1); }
}

@keyframes screenBump {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

@keyframes replayPulse {
  0% { transform: scale(0.6); opacity: 0; filter: drop-shadow(0 0 0 transparent); }
  35% { transform: scale(1.2); opacity: 1; filter: drop-shadow(0 0 80px rgba(242,140,107,0.5)); }
  60% { transform: scale(1.05); filter: drop-shadow(0 0 50px rgba(242,140,107,0.35)); }
  100% { transform: scale(1.08); opacity: 0.9; filter: drop-shadow(0 0 60px rgba(242,140,107,0.3)); }
}

@keyframes replayTextFade {
  0% { opacity: 0; transform: translateY(15px); letter-spacing: 0.5px; }
  35% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0.85; letter-spacing: 1px; }
}

@keyframes replayBgPulse {
  0% { background: #F6EAD7; }
  30% { background: #EEDCC4; }
  100% { background: #EAD4B8; }
}

@keyframes vignetteClose {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes heartbeatSlow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* ===== UTILITY ===== */
.screen-shake { animation: shake 0.5s ease; }
.screen-bump { animation: screenBump 0.12s ease; }

/* ===== TOAST / SHARE FEEDBACK ===== */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(95,191,143,0.92);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.7rem 1.4rem;
  border-radius: 12px;
  z-index: 100;
  opacity: 0;
  animation: toastIn 0.3s ease forwards, toastOut 0.3s ease 1.8s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}
