/* ========================================
   Moji Logic — Premium Emoji Guessing Game
   ======================================== */

/* --- Design Tokens --- */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.08);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);

  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.3);
  --warning: #f59e0b;

  --streak-gradient: linear-gradient(135deg, #f59e0b, #ef4444);

  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(99, 102, 241, 0.3);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px var(--accent-glow);

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* --- Animated Background --- */
.bg-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-particles::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 50%);
  animation: bgDrift 20s ease-in-out infinite alternate;
}

@keyframes bgDrift {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(-3%, -3%) rotate(3deg); }
}

.particle {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat linear infinite;
}

@keyframes particleFloat {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-10vh) scale(1);
  }
}

/* --- App Container --- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  padding: 32px 20px 48px;
}

/* --- Header --- */
.app-header {
  text-align: center;
  margin-bottom: 32px;
  animation: fadeInDown 0.6s ease-out;
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.logo-emoji {
  font-size: 2.4rem;
  filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.4));
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(3deg); }
}

.logo-text {
  font-size: 2.4rem;
  font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* --- Category Nav --- */
.category-nav {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  animation: fadeInUp 0.6s ease-out 0.1s both;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.cat-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-base);
  border-radius: inherit;
}

.cat-btn:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.cat-btn.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.cat-btn.active::before {
  opacity: 0;
}

.cat-icon {
  font-size: 1.1rem;
  position: relative;
  z-index: 1;
}

.cat-label {
  position: relative;
  z-index: 1;
}

/* --- Controls Row --- */
.controls-row {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  animation: fadeInUp 0.6s ease-out 0.2s both;
}

.difficulty-selector,
.mode-selector {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.diff-btn,
.mode-btn {
  padding: 8px 20px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.diff-btn:hover,
.mode-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.diff-btn.active,
.mode-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* --- Rounds Selector --- */
.rounds-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
  animation: fadeInUp 0.6s ease-out 0.25s both;
}

.rounds-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.rounds-selector {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.rounds-btn {
  padding: 8px 22px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-base);
  letter-spacing: 0.5px;
}

.rounds-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.rounds-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 20px var(--accent-glow);
}

/* --- Scoreboard --- */
.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
  animation: fadeInUp 0.6s ease-out 0.3s both;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.score-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.score-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.streak-item {
  position: relative;
}

.streak-value {
  background: var(--streak-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.streak-fire {
  position: absolute;
  top: -8px;
  right: -20px;
  font-size: 1.2rem;
  opacity: 0;
  transition: all var(--transition-spring);
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.6));
}

.streak-fire.visible {
  opacity: 1;
  animation: fireWiggle 0.6s ease-in-out infinite;
}

@keyframes fireWiggle {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.1); }
}

/* --- Game Card --- */
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 24px;
  text-align: center;
  margin-bottom: 24px;
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.6s ease-out 0.4s both;
  transition: border-color var(--transition-base);
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  opacity: 0.6;
}

.card-category-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent-light);
  margin-bottom: 28px;
}

.emoji-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  min-height: 80px;
}

.emoji-char {
  font-size: 3.2rem;
  display: inline-block;
  animation: emojiPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  cursor: default;
  transition: transform var(--transition-fast);
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.emoji-char:hover {
  transform: scale(1.2) rotate(5deg);
}

.emoji-char:nth-child(1) { animation-delay: 0.1s; }
.emoji-char:nth-child(2) { animation-delay: 0.2s; }
.emoji-char:nth-child(3) { animation-delay: 0.3s; }
.emoji-char:nth-child(4) { animation-delay: 0.4s; }
.emoji-char:nth-child(5) { animation-delay: 0.5s; }

@keyframes emojiPop {
  0% { opacity: 0; transform: scale(0) rotate(-20deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* --- Hint Area --- */
.hint-area {
  margin-top: 8px;
}

.hint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--warning);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.hint-btn:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.hint-btn.used {
  opacity: 0.5;
  pointer-events: none;
}

.hint-icon {
  font-size: 1rem;
}

.hint-text {
  margin-top: 12px;
  padding: 10px 16px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.15);
  border-radius: var(--radius-md);
  color: var(--warning);
  font-size: 0.9rem;
  font-style: italic;
  animation: fadeInUp 0.3s ease-out;
}

/* --- Answer Section --- */
.answer-section {
  animation: fadeInUp 0.6s ease-out 0.5s both;
}

.type-answer-area {
  display: flex;
  gap: 10px;
}

.answer-input {
  flex: 1;
  padding: 14px 20px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-base);
  backdrop-filter: blur(8px);
}

.answer-input::placeholder {
  color: var(--text-muted);
}

.answer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.submit-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.submit-btn:active {
  transform: translateY(0);
}

/* --- Multiple Choice --- */
.mc-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mc-option {
  padding: 14px 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  backdrop-filter: blur(8px);
}

.mc-option:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.mc-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  box-shadow: 0 0 20px var(--success-glow);
  animation: correctPulse 0.5s ease-out;
}

.mc-option.wrong {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  animation: wrongShake 0.5s ease-out;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* --- Feedback Overlay --- */
.feedback-overlay,
.gameover-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  animation: overlayIn 0.3s ease-out;
}

@keyframes overlayIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.feedback-card,
.gameover-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 48px;
  text-align: center;
  max-width: 420px;
  width: 90%;
  animation: cardPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-lg);
}

@keyframes cardPopIn {
  0% { opacity: 0; transform: scale(0.8) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.feedback-emoji {
  font-size: 4rem;
  margin-bottom: 16px;
  display: inline-block;
}

.feedback-card.correct .feedback-emoji {
  animation: celebrateEmoji 0.6s ease-out;
}

.feedback-card.wrong .feedback-emoji {
  animation: sadEmoji 0.6s ease-out;
}

@keyframes celebrateEmoji {
  0% { transform: scale(0) rotate(-180deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes sadEmoji {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.feedback-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.feedback-card.correct .feedback-title {
  color: var(--success);
}

.feedback-card.wrong .feedback-title {
  color: var(--error);
}

.feedback-detail {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.next-btn,
.play-again-btn {
  padding: 12px 32px;
  background: var(--accent-gradient);
  border: none;
  border-radius: var(--radius-full);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.next-btn:hover,
.play-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px var(--accent-glow);
}

/* --- Game Over --- */
.gameover-emoji {
  font-size: 4rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: celebrateEmoji 0.6s ease-out;
}

.gameover-title {
  font-size: 2rem;
  font-weight: 900;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
}

.gameover-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 28px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.stat-number {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-light);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

/* --- Confetti --- */
.confetti-piece {
  position: fixed;
  z-index: 200;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(-10vh) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(110vh) rotate(720deg);
  }
}

/* --- Utilities --- */
.hidden {
  display: none !important;
}

/* --- Animations --- */
@keyframes fadeInDown {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* Card shake for wrong answer */
.game-card.shake {
  animation: wrongShake 0.5s ease-out;
}

/* Card glow for correct answer */
.game-card.glow-correct {
  border-color: var(--success);
  box-shadow: 0 0 30px var(--success-glow);
}

.game-card.glow-wrong {
  border-color: var(--error);
  box-shadow: 0 0 30px var(--error-glow);
}

/* Input shake */
.answer-input.shake {
  animation: wrongShake 0.5s ease-out;
  border-color: var(--error) !important;
}

.answer-input.correct {
  border-color: var(--success) !important;
  box-shadow: 0 0 0 4px var(--success-glow) !important;
}

/* Score pop */
.score-pop {
  animation: scorePop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scorePop {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .app-container {
    padding: 20px 14px 36px;
  }

  .logo-text {
    font-size: 1.8rem;
  }

  .logo-emoji {
    font-size: 1.8rem;
  }

  .tagline {
    font-size: 0.82rem;
  }

  .cat-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .emoji-char {
    font-size: 2.4rem;
  }

  .emoji-display {
    gap: 10px;
  }

  .game-card {
    padding: 24px 16px;
  }

  .mc-area {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    padding: 12px 16px;
  }

  .score-value {
    font-size: 1.2rem;
  }

  .gameover-stats {
    gap: 20px;
  }

  .stat-number {
    font-size: 1.6rem;
  }

  .feedback-card,
  .gameover-card {
    padding: 28px 24px;
  }

  .type-answer-area {
    flex-direction: column;
  }

  .submit-btn {
    justify-content: center;
  }
}
