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

:root {
  --bg-base: #0a0a1a;
  --accent: #ff5e5e;
  --accent-grad: linear-gradient(135deg, #ff5e5e, #ff8c42);
  --timer-green: #4ECDC4;
  --timer-yellow: #FFE66D;
  --timer-red: #FF5E5E;
  --text-primary: rgba(255,255,255,0.95);
  --text-secondary: rgba(255,255,255,0.55);
  --text-dim: rgba(255,255,255,0.3);
  --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;
}

/* ===== 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, #0a0a1a 0%, #0f1535 50%, #0a0a1a 100%);
  background-size: 100% 100%;
}
#screen-home::before {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 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(255,140,66,0.25));
}

.home-title {
  font-size: clamp(2.8rem, 10vw, 4.2rem);
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, #ffd6a0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  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.75rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 0.5rem;
  letter-spacing: 0.5px;
}

/* Social Proof + Trending */
.home-social-proof {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 1rem;
  letter-spacing: 0.3px;
}

.home-trending {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  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); }
.btn:disabled { opacity: 0.35; pointer-events: none; }

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

.btn-secondary {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(8px);
}
.btn-secondary:hover { background: rgba(255,255,255,0.12); }

.btn-dare {
  background: linear-gradient(135deg, rgba(255,140,66,0.15), rgba(255,94,94,0.15));
  color: #ff8c42;
  border: 1px solid rgba(255,140,66,0.3);
  font-weight: 700;
  backdrop-filter: blur(8px);
}
.btn-dare:hover { background: linear-gradient(135deg, rgba(255,140,66,0.25), rgba(255,94,94,0.25)); }

.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, #0a0a1a 0%, #121230 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(255,255,255,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(255,255,255,0.08); }
.avatar-btn.selected {
  border-color: var(--accent);
  background: rgba(255,94,94,0.12);
  transform: scale(1.1);
  box-shadow: 0 0 16px rgba(255,94,94,0.3);
}

.name-input {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 0.9rem 1.2rem;
  color: #fff;
  width: 100%;
  max-width: 280px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}
.name-input:focus { border-color: rgba(255,140,66,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;
  background: linear-gradient(135deg, #fff, #ffd6a0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: countPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== GAME SCREEN ===== */
#screen-game {
  background: linear-gradient(135deg, #0a1628 0%, #1a1a4e 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(255,255,255,0.06);
  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(78,205,196,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(255,255,255,0.06);
  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(255,255,255,0.08));
}
#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(0,0,0,0.5);
}
#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(255,255,255,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(255,60,60,0.5));
}

.replay-name {
  font-size: clamp(2.6rem, 10vw, 4rem);
  font-weight: 800;
  color: var(--timer-red);
  text-shadow: 0 0 40px rgba(255,60,60,0.4);
  animation: replayTextFade 0.9s ease-in-out;
}

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

/* ===== KILL SCREEN ===== */
#screen-kill {
  background: linear-gradient(160deg, #120808 0%, #1a0a0a 50%, #0a0a1a 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(255,255,255,0.15);
  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.6s; }

.kill-shame {
  font-size: clamp(0.75rem, 3vw, 0.9rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0;
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
}
.kill-shame.slide-up { animation: killSlide 0.4s ease forwards; }
.kill-shame.shame-rookie {
  color: #ff8c8c;
  background: rgba(255,94,94,0.12);
}
.kill-shame.shame-warmup {
  color: #ffb07a;
  background: rgba(255,160,100,0.10);
}
.kill-shame.shame-notbad {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.06);
}
.kill-shame.shame-solid {
  color: #7dd3c0;
  background: rgba(78,205,196,0.10);
}
.kill-shame.shame-impressive {
  color: #ffd700;
  background: rgba(255,215,0,0.1);
}
.kill-shame.shame-elite {
  color: #ffa500;
  background: rgba(255,165,0,0.12);
  text-shadow: 0 0 6px rgba(255,165,0,0.2);
}
.kill-shame.shame-inhuman {
  color: #ff6b6b;
  background: rgba(255,107,107,0.12);
  text-shadow: 0 0 8px rgba(255,107,107,0.25);
}
.kill-shame.shame-legend {
  color: #ffd700;
  background: rgba(255,215,0,0.15);
  text-shadow: 0 0 8px rgba(255,215,0,0.3);
}

.kill-text {
  font-size: clamp(1rem, 4vw, 1.35rem);
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
  opacity: 0;
  max-width: 320px;
}
.kill-text.slide-up { animation: killSlide 0.5s ease forwards; }

.kill-debate {
  font-size: clamp(0.8rem, 3vw, 0.95rem);
  font-weight: 600;
  color: var(--timer-yellow);
  opacity: 0;
  max-width: 280px;
  padding: 0.5rem 0.8rem;
  background: rgba(255,230,109,0.08);
  border-radius: 10px;
  border: 1px solid rgba(255,230,109,0.15);
}
.kill-debate:empty { display: none; }
.kill-debate.slide-up { animation: killSlide 0.4s 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, #0a0a1a 0%, #0f1535 100%);
}
.challenge-text {
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.6;
  max-width: 320px;
}

/* Inline challenge verdict on kill screen */
.kill-challenge-result {
  opacity: 0;
  font-size: 0.9rem;
  font-weight: 600;
  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(255,255,255,0.1);
  }
  100% {
    width: 350px; height: 350px;
    opacity: 0;
    border-color: rgba(255,255,255,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(255,60,60,0.6)); }
  60% { transform: scale(1.05); filter: drop-shadow(0 0 50px rgba(255,60,60,0.4)); }
  100% { transform: scale(1.08); opacity: 0.9; filter: drop-shadow(0 0 60px rgba(255,60,60,0.35)); }
}

@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: #0a0a1a; }
  30% { background: #1a0808; }
  100% { background: #0e0505; }
}

@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(78,205,196,0.92);
  color: #0a0a1a;
  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); }
}
