/* ==========================================
 *  shared/core.css — Design system dùng chung
 *  Trích từ typing.html (Typing Quest) cho Portal / lop3 / lop5
 *  ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --neon-purple: #9d4edd;
  --neon-blue: #00f5ff;
  --neon-yellow: #ffd700;
  --neon-green: #39ff14;
  --neon-pink: #ff6ec7;
  --dark-bg: #0a0015;
  --card-bg: rgba(20, 5, 40, 0.85);
  --text-light: #f0e6ff;
}

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

body {
  font-family: 'Nunito', sans-serif;
  background: var(--dark-bg);
  color: var(--text-light);
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
}

/* ====== SCREEN MANAGEMENT ====== */
.screen { display: none; min-height: 100vh; position: relative; }
.screen.active { display: flex; flex-direction: column; }

/* ====== STARFIELD ====== */
#starfield {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.star {
  position: absolute; border-radius: 50%;
  background: white; animation: twinkle var(--dur) infinite ease-in-out;
}
@keyframes twinkle {
  0%,100% { opacity: 0.1; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.5); }
}
.firefly {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--neon-yellow); box-shadow: 0 0 10px var(--neon-yellow);
  animation: fly var(--dur) infinite ease-in-out alternate;
}
@keyframes fly {
  0% { transform: translate(0,0) scale(0.5); opacity: 0.3; }
  50% { opacity: 1; transform: translate(var(--tx), var(--ty)) scale(1.2); }
  100% { transform: translate(calc(var(--tx)*2), calc(var(--ty)*0.5)) scale(0.7); opacity: 0.2; }
}


/* ====== LOGIN / PIN ====== */
/* ====== LOGIN SCREEN ====== */
#screen-login {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1a003a 0%, #0a0015 70%);
}
.login-container {
  position: relative; z-index: 1; text-align: center; width: 100%; max-width: 600px; padding: 20px;
}
.game-title {
  font-family: 'Fredoka One', cursive;
  font-size: clamp(2rem, 5vw, 3.5rem);
  background: linear-gradient(135deg, var(--neon-yellow), var(--neon-pink), var(--neon-blue));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  animation: titlePulse 3s infinite ease-in-out;
  line-height: 1.2; margin-bottom: 8px;
}
@keyframes titlePulse {
  0%,100% { filter: brightness(1) drop-shadow(0 0 20px #9d4edd); }
  50% { filter: brightness(1.3) drop-shadow(0 0 40px #ff6ec7); }
}
.game-subtitle {
  font-size: 1.1rem; color: var(--neon-blue); margin-bottom: 40px;
  text-shadow: 0 0 10px var(--neon-blue);
  animation: subtitleGlow 2s infinite alternate;
}
@keyframes subtitleGlow {
  from { text-shadow: 0 0 5px var(--neon-blue); }
  to { text-shadow: 0 0 20px var(--neon-blue), 0 0 40px var(--neon-blue); }
}
.player-cards {
  display: flex; gap: 24px; justify-content: center; flex-wrap: wrap;
}
.player-card {
  background: var(--card-bg);
  border: 2px solid var(--neon-purple);
  border-radius: 20px; padding: 30px 40px;
  cursor: pointer; transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(157,78,221,0.3);
  min-width: 200px;
}
.player-card:hover {
  transform: translateY(-8px) scale(1.05);
  border-color: var(--neon-pink);
  box-shadow: 0 0 40px rgba(255,110,199,0.5);
}
.player-card .avatar { font-size: 4rem; margin-bottom: 12px; display: block; }
.player-card .player-name {
  font-size: 1.4rem; font-weight: 800; color: var(--neon-yellow);
  text-shadow: 0 0 10px var(--neon-yellow);
}
.player-card .player-stars { font-size: 1rem; color: #ccc; margin-top: 6px; }

/* PIN Modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); z-index: 100; align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal-box {
  background: linear-gradient(135deg, #1a003a, #0d001f);
  border: 2px solid var(--neon-purple);
  border-radius: 24px; padding: 40px; text-align: center;
  box-shadow: 0 0 60px rgba(157,78,221,0.5);
  min-width: 300px;
}
.modal-box h2 { font-size: 1.5rem; color: var(--neon-yellow); margin-bottom: 20px; }
.pin-display {
  font-size: 2rem; letter-spacing: 10px; color: var(--neon-blue);
  min-height: 50px; margin-bottom: 20px;
  text-shadow: 0 0 10px var(--neon-blue);
}
.pin-buttons { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; max-width: 240px; margin: 0 auto 16px; }
.pin-btn {
  background: rgba(157,78,221,0.3); border: 2px solid var(--neon-purple);
  color: white; font-size: 1.5rem; font-weight: 700;
  padding: 16px; border-radius: 12px; cursor: pointer;
  transition: all 0.15s; font-family: 'Nunito', sans-serif;
}
.pin-btn:hover { background: var(--neon-purple); transform: scale(1.05); }
.pin-btn:active { transform: scale(0.95); }
.pin-error { color: #ff4444; font-size: 0.9rem; min-height: 20px; }
.btn-cancel { background: none; border: 1px solid #666; color: #aaa; padding: 8px 20px; border-radius: 8px; cursor: pointer; margin-top: 12px; font-family: 'Nunito', sans-serif; }

/* ====== BUTTONS ====== */
.btn-primary {
  background: linear-gradient(135deg, var(--neon-purple), #5a189a);
  border: none; color: white; padding: 14px 32px;
  border-radius: 50px; font-size: 1.1rem; font-weight: 700;
  cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(157,78,221,0.4);
  font-family: 'Nunito', sans-serif;
}
.btn-primary:hover { transform: translateY(-3px); box-shadow: 0 8px 30px rgba(157,78,221,0.6); }
.btn-primary:active { transform: translateY(0); }
.btn-gold {
  background: linear-gradient(135deg, var(--neon-yellow), #ff9500);
  border: none; color: #1a0000; padding: 14px 32px;
  border-radius: 50px; font-size: 1.1rem; font-weight: 800;
  cursor: pointer; transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(255,215,0,0.4);
  font-family: 'Nunito', sans-serif;
}
.btn-gold:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 8px 30px rgba(255,215,0,0.6); }


/* ====== HIỆU ỨNG ====== */
.confetti-piece {
  position: fixed; width: 10px; height: 10px; top: -10px;
  animation: confettiFall var(--dur) var(--delay) ease forwards;
  border-radius: 2px; pointer-events: none; z-index: 200;
}
@keyframes confettiFall {
  0% { transform: translateX(0) rotate(0deg); opacity: 1; top: -10px; }
  100% { transform: translateX(var(--drift)) rotate(720deg); opacity: 0; top: 110vh; }
}

/* Rain effect for defeat */
.rain-drop {
  position: fixed; width: 2px; background: rgba(100,150,255,0.4);
  animation: rainFall var(--dur) var(--delay) linear infinite;
  border-radius: 0 0 2px 2px; top: -20px; pointer-events: none; z-index: 200;
}
@keyframes rainFall {
  0% { transform: translateY(-20px); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(110vh); opacity: 0; }
}


/* ====== TOAST ====== */
/* ====== TOASTS ====== */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  background: rgba(20,5,40,0.95); border: 1px solid var(--neon-purple);
  padding: 10px 18px; border-radius: 10px; font-size: 0.9rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  box-shadow: 0 0 20px rgba(157,78,221,0.3);
}
@keyframes toastIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neon-purple); border-radius: 3px; }


/* ====== POPUP ====== */
.evo-popup {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #1a003a, #0d001f);
  border: 3px solid var(--neon-yellow); border-radius: 24px;
  padding: 40px; text-align: center; z-index: 250;
  box-shadow: 0 0 80px rgba(255,215,0,0.5);
  animation: evoPop 0.5s ease;
}
@keyframes evoPop { from { transform: translate(-50%,-50%) scale(0); } to { transform: translate(-50%,-50%) scale(1); } }
.evo-popup h2 { color: var(--neon-yellow); font-family: 'Fredoka One', cursive; font-size: 2rem; margin-bottom: 12px; }
.evo-popup .evo-sprite { font-size: 5rem; display: block; margin: 16px 0; }

/* Star gain animation */
.star-gain {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 4rem; z-index: 250;
  animation: starGain 1.5s ease forwards;
  pointer-events: none;
}
@keyframes starGain {
  0% { transform: translate(-50%,-50%) scale(0) rotate(-30deg); opacity: 0; }
  30% { transform: translate(-50%,-80%) scale(1.5) rotate(10deg); opacity: 1; }
  70% { transform: translate(-50%,-120%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%,-160%) scale(0.5) rotate(5deg); opacity: 0; }
}
