/* ═══════════════════════════════════════════════════════════════════════════
   RETRO GAME RESULT OVERLAY
   Pixel particles · Scanline tint · CRT flash · 5-game daily progress
   ═══════════════════════════════════════════════════════════════════════════ */

@keyframes particleFloat {
  0% { opacity: 0; transform: translateY(0) translateX(0) rotate(var(--rot-start)) scale(0.3); }
  10% { opacity: 1; transform: translateY(-10vh) translateX(calc(var(--drift) * 0.1)) rotate(var(--rot-start)) scale(1); }
  80% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-110vh) translateX(var(--drift)) rotate(var(--rot-end)) scale(0.5); }
}

.retro-screen-flash {
  position: fixed; inset: 0; z-index: 9999; opacity: 0;
  pointer-events: none; transition: opacity 0.15s ease-out; mix-blend-mode: screen;
}
.retro-screen-flash.active { opacity: 1; }

#game-result-overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.4s ease;
}
#game-result-overlay.hidden { display: none !important; }
#game-result-overlay.result-exiting { opacity: 0; pointer-events: none; }

.result-scanline-bg {
  position: absolute; inset: 0;
  background-size: 100% 4px;
  animation: scanline 8s linear infinite; z-index: 0;
}
.result-win .result-scanline-bg {
  background:
    linear-gradient(rgba(34,197,94,0.06) 50%, rgba(0,0,0,0.10) 50%),
    radial-gradient(ellipse at center, rgba(34,197,94,0.25) 0%, rgba(0,0,0,0.92) 70%);
  background-size: 100% 4px, 100% 100%;
}
.result-lose .result-scanline-bg {
  background:
    linear-gradient(rgba(239,68,68,0.06) 50%, rgba(0,0,0,0.10) 50%),
    radial-gradient(ellipse at center, rgba(239,68,68,0.25) 0%, rgba(0,0,0,0.92) 70%);
  background-size: 100% 4px, 100% 100%;
}

#result-particles { position: absolute; inset: 0; overflow: hidden; z-index: 1; pointer-events: none; }
.retro-particle {
  image-rendering: pixelated; image-rendering: crisp-edges;
  box-shadow: inset -1px -1px 0 rgba(0,0,0,0.3), inset 1px 1px 0 rgba(255,255,255,0.15);
}

.result-content {
  position: relative; z-index: 10; text-align: center;
  padding: 2.5rem 3.5rem; max-width: 600px; width: 90%;
  background: rgba(0,0,0,0.85); border-radius: 1.5rem; border: 4px solid;
  animation: resultCardEnter 0.6s cubic-bezier(0.22,1,0.36,1) forwards;
  max-height: 90vh; overflow-y: auto;
}
.result-win .result-content {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34,197,94,0.4), 0 0 60px rgba(34,197,94,0.15), inset 0 0 30px rgba(34,197,94,0.05);
}
.result-lose .result-content {
  border-color: #ef4444;
  box-shadow: 0 0 20px rgba(239,68,68,0.4), 0 0 60px rgba(239,68,68,0.15), inset 0 0 30px rgba(239,68,68,0.05);
}

@keyframes resultCardEnter {
  0% { opacity: 0; transform: scale(0.6) translateY(30px); filter: brightness(3); }
  40% { filter: brightness(1.5); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: brightness(1); }
}

.result-icon { font-size: 3.5rem; margin-bottom: 0.75rem; animation: resultIconBounce 0.8s 0.3s cubic-bezier(0.34,1.56,0.64,1) both; }
.result-win .result-icon { color: #facc15; text-shadow: 0 0 20px rgba(250,204,21,0.8), 0 0 40px rgba(250,204,21,0.4); }
.result-lose .result-icon { color: #ef4444; text-shadow: 0 0 20px rgba(239,68,68,0.6), 0 0 40px rgba(239,68,68,0.3); }

@keyframes resultIconBounce {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-title {
  font-size: 3rem; margin-bottom: 0.5rem; letter-spacing: 0.1em;
  animation: resultTitleGlow 2s ease-in-out infinite, resultTitleEnter 0.5s 0.2s ease-out both;
}
.result-win .result-title { color: #4ade80; text-shadow: 0 0 10px #22c55e, 0 0 20px #22c55e, 0 0 40px #22c55e, 0 0 80px #22c55e; }
.result-lose .result-title { color: #f87171; text-shadow: 0 0 10px #ef4444, 0 0 20px #ef4444, 0 0 40px #ef4444, 0 0 80px #ef4444; }

@keyframes resultTitleGlow { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.3); } }
@keyframes resultTitleEnter { 0% { opacity: 0; transform: translateY(-20px); } 100% { opacity: 1; transform: translateY(0); } }

.result-subtitle { font-size: 1.5rem; color: rgba(255,255,255,0.8); margin-bottom: 1.5rem; animation: resultFadeIn 0.5s 0.4s ease-out both; }
@keyframes resultFadeIn { 0% { opacity: 0; transform: translateY(10px); } 100% { opacity: 1; transform: translateY(0); } }

.result-stats { display: flex; justify-content: center; gap: 1.25rem; margin-bottom: 1.5rem; animation: resultFadeIn 0.5s 0.5s ease-out both; }
.result-stat {
  display: flex; flex-direction: column; align-items: center;
  padding: 0.6rem 1rem; border-radius: 0.75rem;
  border: 2px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); min-width: 90px;
}
.result-win .result-stat { border-color: rgba(34,197,94,0.3); background: rgba(34,197,94,0.08); }
.result-lose .result-stat { border-color: rgba(239,68,68,0.3); background: rgba(239,68,68,0.08); }
.result-stat-label { font-size: 0.9rem; color: rgba(255,255,255,0.5); margin-bottom: 0.2rem; }
.result-stat-value { font-size: 1.4rem; color: #ffffff; }

.result-word-reveal { margin-bottom: 1.5rem; animation: resultFadeIn 0.6s 0.6s ease-out both; }
.result-revealed-word {
  font-size: 2.2rem; letter-spacing: 0.3em; margin-top: 0.5rem;
  padding: 0.4rem 1.2rem; display: inline-block; border-radius: 0.75rem;
  border: 3px solid #ef4444; color: #f87171; background: rgba(239,68,68,0.1);
  text-shadow: 0 0 10px rgba(239,68,68,0.5);
  animation: resultWordReveal 0.8s 0.8s ease-out both;
}
@keyframes resultWordReveal {
  0% { opacity: 0; letter-spacing: 0.8em; filter: blur(8px); }
  100% { opacity: 1; letter-spacing: 0.3em; filter: blur(0); }
}

/* ─── Progress dots ────────────────────────────────────────────────────────── */
.result-progress {
  margin-bottom: 1.5rem;
  animation: resultFadeIn 0.5s 0.55s ease-out both;
}
.result-progress-label {
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
  margin-bottom: 0.75rem;
}
.result-progress-dots {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}
.result-dot {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  font-size: 1.2rem;
  border: 3px solid;
  font-family: 'Press Start 2P', cursive;
}
.result-dot-won {
  color: #4ade80; border-color: #22c55e; background: rgba(34,197,94,0.15);
  text-shadow: 0 0 8px rgba(34,197,94,0.6);
}
.result-dot-lost {
  color: #f87171; border-color: #ef4444; background: rgba(239,68,68,0.15);
  text-shadow: 0 0 8px rgba(239,68,68,0.6);
}
.result-dot-current {
  color: #facc15; border-color: #facc15; background: rgba(250,204,21,0.15);
  text-shadow: 0 0 8px rgba(250,204,21,0.6);
  animation: dotPulse 1.5s ease-in-out infinite;
}
.result-dot-pending {
  color: rgba(255,255,255,0.3); border-color: rgba(255,255,255,0.2); background: rgba(255,255,255,0.03);
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ─── Daily summary (shown when all 5 complete) ───────────────────────────── */
.result-daily-summary {
  margin-bottom: 1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid rgba(250,204,21,0.3);
  background: rgba(250,204,21,0.05);
  animation: resultFadeIn 0.5s 0.6s ease-out both;
}
.result-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
}
.result-summary-row + .result-summary-row {
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 0.3rem;
  padding-top: 0.6rem;
}

/* ─── Action buttons ───────────────────────────────────────────────────────── */
.result-actions { display: flex; justify-content: center; gap: 0.75rem; animation: resultFadeIn 0.5s 0.7s ease-out both; flex-wrap: wrap; }
.result-btn {
  padding: 0.75rem 1.5rem; border-radius: 0.75rem; font-size: 1rem;
  border: 3px solid #ffffff; color: #ffffff; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s; box-shadow: 0 4px 0 #000;
}
.result-btn:hover { transform: translateY(2px); box-shadow: 0 2px 0 #000; }
.result-btn:active { transform: translateY(4px); box-shadow: none; }
.result-btn-primary { background: linear-gradient(to bottom, #a855f7, #7c3aed); }
.result-win .result-btn-primary { background: linear-gradient(to bottom, #22c55e, #16a34a); }
.result-lose .result-btn-primary { background: linear-gradient(to bottom, #ef4444, #dc2626); }
.result-btn-secondary { background: linear-gradient(to bottom, #6366f1, #4f46e5); }

/* NEXT WORD button — always bright & prominent */
.result-btn-next {
  background: linear-gradient(to bottom, #facc15, #d97706);
  color: #000;
  border-color: #fde047;
  font-size: 1.1rem;
  padding: 0.875rem 2rem;
  animation: nextWordPulse 2s ease-in-out infinite;
}
.result-btn-next:hover {
  background: linear-gradient(to bottom, #fde047, #facc15);
}
@keyframes nextWordPulse {
  0%, 100% { box-shadow: 0 4px 0 #000, 0 0 15px rgba(250,204,21,0.3); }
  50% { box-shadow: 0 4px 0 #000, 0 0 25px rgba(250,204,21,0.6); }
}

/* Shimmer ring on win */
.result-win .result-content::before {
  content: ""; position: absolute; inset: -4px; border-radius: 1.7rem;
  background: conic-gradient(from 0deg, #22c55e, #facc15, #06b6d4, #22c55e);
  z-index: -1; opacity: 0.3; animation: shimmerRing 3s linear infinite;
}
@keyframes shimmerRing { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .result-content { padding: 1.5rem 1.25rem; }
  .result-title { font-size: 2rem; }
  .result-icon { font-size: 2.5rem; }
  .result-stats { flex-direction: row; align-items: center; gap: 0.5rem; }
  .result-dot { width: 32px; height: 32px; font-size: 1rem; }
  .result-progress-dots { gap: 0.5rem; }
  .result-btn { padding: 0.6rem 1rem; font-size: 0.85rem; }
  .result-revealed-word {font-size: 1rem; }
