/* ============================================
   LEGI JUNIOR — Main CSS
   Thème: RPG Juridique Sombre & Or
   ============================================ */

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

:root {
  --gold:       #FFD700;
  --gold-dark:  #C8A200;
  --gold-light: #FFF0A0;
  --deep:       #0a0a1a;
  --navy:       #0d1b3e;
  --panel:      #111827;
  --panel2:     #1e2a40;
  --panel3:     #263552;
  --text:       #e8e4d0;
  --text-dim:   #8a8070;
  --red:        #ff4a4a;
  --green:      #4ade80;
  --blue:       #60a5fa;
  --purple:     #a78bfa;
  --hp-bar:     #22c55e;
  --hp-warn:    #f59e0b;
  --hp-danger:  #ef4444;
  --radius:     12px;
  --radius-lg:  20px;
  --shadow:     0 4px 24px rgba(0,0,0,0.5);
  --glow-gold:  0 0 20px rgba(255,215,0,0.3);
  --font-title: 'Cinzel', serif;
  --font-body:  'Nunito', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--deep);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Background stars */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(1px 1px at 20% 30%, rgba(255,215,0,0.15) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.08) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 20%, rgba(255,215,0,0.1) 0%, transparent 100%),
    radial-gradient(2px 2px at 40% 80%, rgba(255,255,255,0.05) 0%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

/* ============================================
   LAYOUT
   ============================================ */
#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  min-height: 100dvh;
  animation: fadeIn 0.3s ease;
}
.screen.active { display: flex; }

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

/* ============================================
   TOP BAR
   ============================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.topbar-logo {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 0.05em;
}

.topbar-stats {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: 20px;
  padding: 4px 10px;
}

.stat-pill .icon { font-size: 0.9rem; }
.stat-pill .val  { color: var(--gold); }

/* ============================================
   BOTTOM NAV
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: linear-gradient(0deg, rgba(0,0,0,0.95) 0%, rgba(10,10,26,0.9) 100%);
  border-top: 1px solid rgba(255,215,0,0.15);
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  backdrop-filter: blur(12px);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn .nav-icon { font-size: 1.4rem; transition: transform 0.2s; }
.nav-btn:hover, .nav-btn.active {
  color: var(--gold);
}
.nav-btn.active .nav-icon { transform: scale(1.15); }

/* ============================================
   CARDS & PANELS
   ============================================ */
.card {
  background: var(--panel);
  border: 1px solid rgba(255,215,0,0.1);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card-gold {
  background: linear-gradient(135deg, var(--panel2) 0%, var(--panel3) 100%);
  border-color: rgba(255,215,0,0.3);
  box-shadow: var(--shadow), var(--glow-gold);
}

.section-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #000;
  box-shadow: 0 4px 16px rgba(255,215,0,0.3);
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(255,215,0,0.5); }

.btn-secondary {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-danger {
  background: linear-gradient(135deg, #ff4a4a 0%, #c41e1e 100%);
  color: #fff;
}

.btn-full { width: 100%; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-appearance: none;
}
.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255,215,0,0.1);
}
.form-input::placeholder { color: var(--text-dim); }

select.form-input option { background: var(--panel); }

/* ============================================
   HP BARS
   ============================================ */
.hp-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hp-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
}

.hp-bar {
  height: 10px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.hp-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.4,0,0.2,1), background-color 0.3s;
  background: var(--hp-bar);
}
.hp-fill.warn    { background: var(--hp-warn); }
.hp-fill.danger  { background: var(--hp-danger); }

/* ============================================
   XP BAR
   ============================================ */
.xp-bar-wrap { margin-top: 4px; }
.xp-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--purple) 0%, var(--blue) 100%);
  transition: width 0.6s ease;
}

/* ============================================
   COMBO INDICATOR
   ============================================ */
.combo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.05em;
  transition: all 0.3s;
}

.combo-badge.inactive { background: rgba(255,255,255,0.05); color: var(--text-dim); }
.combo-badge.active   { background: linear-gradient(135deg, #ff6b00,#ff0060); color: #fff; box-shadow: 0 0 20px rgba(255,60,0,0.4); animation: comboPulse 0.5s ease; }

@keyframes comboPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ============================================
   ANSWER BUTTONS
   ============================================ */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.answer-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  background: var(--panel2);
  border: 2px solid rgba(255,215,0,0.1);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  line-height: 1.3;
  min-height: 64px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.answer-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,215,0,0.05);
  opacity: 0;
  transition: opacity 0.2s;
}

.answer-btn:hover::before { opacity: 1; }
.answer-btn:active { transform: scale(0.97); }

.answer-btn.correct {
  border-color: var(--green);
  background: rgba(74,222,128,0.1);
  animation: correctFlash 0.4s ease;
}

.answer-btn.wrong {
  border-color: var(--red);
  background: rgba(255,74,74,0.1);
  animation: wrongShake 0.4s ease;
}

.answer-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: rgba(255,215,0,0.1);
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.8rem;
  color: var(--gold);
}

.answer-btn.correct .answer-letter { background: var(--green); color: #000; }
.answer-btn.wrong   .answer-letter { background: var(--red);   color: #fff; }

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

@keyframes wrongShake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================
   DAMAGE POPUP
   ============================================ */
.damage-popup {
  position: absolute;
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 900;
  pointer-events: none;
  animation: damageFloat 1s ease forwards;
  z-index: 999;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.damage-popup.enemy { color: var(--green); left: 50%; transform: translateX(-50%); }
.damage-popup.player { color: var(--red); }

@keyframes damageFloat {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  50%  { opacity: 1; transform: translateX(-50%) translateY(-30px) scale(1.2); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.8); }
}

/* ============================================
   CHARACTER SPRITES
   ============================================ */
.battle-arena {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  position: relative;
  min-height: 200px;
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
}

.fighter-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid rgba(255,215,0,0.3);
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

.fighter-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.fighter-img.hit {
  animation: hitAnim 0.3s ease;
}
.fighter-img.attack {
  animation: attackAnim 0.3s ease;
}

@keyframes hitAnim {
  0%,100% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(0.9); filter: brightness(2) saturate(0); }
}
@keyframes attackAnim {
  0%,100% { transform: translateX(0); }
  50% { transform: translateX(12px); }
}

.fighter.enemy .fighter-img {
  border-color: rgba(255,74,74,0.3);
}
.fighter.enemy .fighter-img.attack {
  animation: attackAnimReverse 0.3s ease;
}
@keyframes attackAnimReverse {
  0%,100% { transform: translateX(0); }
  50% { transform: translateX(-12px); }
}

/* ============================================
   CHARACTER SELECT
   ============================================ */
.chars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.char-card {
  background: var(--panel2);
  border: 2px solid rgba(255,215,0,0.1);
  border-radius: var(--radius-lg);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
}

.char-card:hover { border-color: rgba(255,215,0,0.4); transform: translateY(-2px); }
.char-card.selected { border-color: var(--gold); box-shadow: var(--glow-gold); }

.char-card .char-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 0 auto 8px;
  background: var(--panel3);
  border: 2px solid rgba(255,215,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  overflow: hidden;
}

.char-card .char-avatar img { width: 100%; height: 100%; object-fit: cover; }
.char-card .char-name { font-weight: 800; font-size: 0.9rem; margin-bottom: 4px; }
.char-card .char-level { font-size: 0.75rem; color: var(--gold); font-weight: 700; }
.char-card .char-skill { font-size: 0.7rem; color: var(--text-dim); margin-top: 4px; }

/* ============================================
   STAGE LIST
   ============================================ */
.stages-list { display: flex; flex-direction: column; gap: 10px; }

.stage-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--panel2);
  border: 1px solid rgba(255,215,0,0.08);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.stage-item:hover { border-color: rgba(255,215,0,0.3); transform: translateX(4px); }
.stage-item.completed::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 12px;
  color: var(--green);
  font-weight: 900;
  font-size: 0.9rem;
}
.stage-item.locked { opacity: 0.4; cursor: not-allowed; }
.stage-item.boss {
  border-color: rgba(255,74,74,0.3);
  background: linear-gradient(135deg, var(--panel2) 0%, rgba(255,74,74,0.05) 100%);
}

.stage-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: rgba(255,215,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stage-item.boss .stage-icon { background: rgba(255,74,74,0.1); }
.stage-info { flex: 1; min-width: 0; }
.stage-name { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-meta { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }

/* ============================================
   LEADERBOARD
   ============================================ */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,0.05);
  transition: background 0.2s;
}

.lb-row.top-1 { background: linear-gradient(135deg, rgba(255,215,0,0.15), rgba(255,200,0,0.05)); border-color: rgba(255,215,0,0.3); }
.lb-row.top-2 { background: linear-gradient(135deg, rgba(200,200,200,0.1), transparent); border-color: rgba(200,200,200,0.2); }
.lb-row.top-3 { background: linear-gradient(135deg, rgba(205,127,50,0.1), transparent); border-color: rgba(205,127,50,0.2); }

.lb-rank { width: 32px; text-align: center; font-weight: 800; font-size: 1rem; color: var(--gold); }
.lb-name { flex: 1; font-weight: 700; }
.lb-level { font-size: 0.8rem; color: var(--gold); font-weight: 700; }
.lb-score { font-size: 0.75rem; color: var(--text-dim); }

/* ============================================
   BADGES
   ============================================ */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
}

.badge-item {
  text-align: center;
  padding: 16px 8px;
  border-radius: var(--radius);
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,0.05);
  transition: all 0.2s;
}

.badge-item.earned {
  border-color: rgba(255,215,0,0.3);
  background: linear-gradient(135deg, rgba(255,215,0,0.1), rgba(255,215,0,0.02));
}

.badge-icon { font-size: 2rem; margin-bottom: 6px; filter: grayscale(1); transition: filter 0.3s; }
.badge-item.earned .badge-icon { filter: none; }
.badge-name { font-size: 0.7rem; font-weight: 700; color: var(--text-dim); }
.badge-item.earned .badge-name { color: var(--gold); }

/* ============================================
   MASTERY BARS
   ============================================ */
.mastery-list { display: flex; flex-direction: column; gap: 14px; }

.mastery-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mastery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.mastery-bar {
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  overflow: hidden;
}

.mastery-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  animation: overlayIn 0.2s ease;
  backdrop-filter: blur(4px);
}

@media (min-width: 640px) {
  .modal-overlay { align-items: center; justify-content: center; }
}

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

.modal {
  background: var(--panel);
  border: 1px solid rgba(255,215,0,0.2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  animation: modalIn 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@media (min-width: 640px) {
  .modal {
    border-radius: var(--radius-lg);
    max-width: 480px;
  }
}

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

.modal-title {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
  text-align: center;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
#toast-container {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 300px;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease;
  pointer-events: auto;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success { background: rgba(74,222,128,0.15); border: 1px solid var(--green); color: var(--green); }
.toast.error   { background: rgba(255,74,74,0.15); border: 1px solid var(--red); color: var(--red); }
.toast.info    { background: rgba(96,165,250,0.15); border: 1px solid var(--blue); color: var(--blue); }
.toast.gold    { background: rgba(255,215,0,0.1); border: 1px solid var(--gold); color: var(--gold); }

/* ============================================
   SCROLL
   ============================================ */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: 80px; /* nav height */
  -webkit-overflow-scrolling: touch;
}

.scroll-area::-webkit-scrollbar { width: 4px; }
.scroll-area::-webkit-scrollbar-track { background: transparent; }
.scroll-area::-webkit-scrollbar-thumb { background: rgba(255,215,0,0.2); border-radius: 2px; }

/* ============================================
   AUTH SCREENS
   ============================================ */
.auth-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,215,0,0.08) 0%, transparent 60%),
              var(--deep);
}
.auth-screen.active {
  display: flex;
}

.auth-logo {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  margin-bottom: 8px;
  text-align: center;
}

.auth-tagline {
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 32px;
  font-size: 0.9rem;
}

.auth-box {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid rgba(255,215,0,0.15);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.auth-tabs {
  display: flex;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-tab.active {
  background: var(--gold);
  color: #000;
  box-shadow: 0 2px 8px rgba(255,215,0,0.3);
}

/* ============================================
   VICTORY / DEFEAT SCREENS
   ============================================ */
.result-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}
.result-screen.active {
  display: flex;
}

.result-emoji {
  font-size: 5rem;
  margin-bottom: 16px;
  animation: bounceIn 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes bounceIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.result-title {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.result-title.victory { color: var(--gold); text-shadow: var(--glow-gold); }
.result-title.defeat  { color: var(--red); }

.result-rewards {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin: 24px 0;
}

.reward-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,215,0,0.15);
}

.reward-val {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
}

.reward-lbl { font-size: 0.75rem; color: var(--text-dim); font-weight: 600; }

/* ============================================
   EXPLANATION BOX
   ============================================ */
.explanation-box {
  background: rgba(96,165,250,0.08);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--blue);
  margin-top: 12px;
  display: none;
}

.explanation-box.visible { display: block; animation: fadeIn 0.3s ease; }

/* ============================================
   QUESTION PROGRESS
   ============================================ */
.q-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.q-progress-dots {
  display: flex;
  gap: 4px;
  flex: 1;
}

.q-dot {
  flex: 1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  transition: background 0.3s;
}

.q-dot.done    { background: var(--green); }
.q-dot.current { background: var(--gold); animation: dotPulse 1s ease infinite; }
.q-dot.wrong   { background: var(--red); }

@keyframes dotPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.q-counter {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ============================================
   SHOP
   ============================================ */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.shop-item {
  background: var(--panel2);
  border: 1px solid rgba(255,215,0,0.1);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  transition: all 0.2s;
}

.shop-item.owned { border-color: rgba(74,222,128,0.3); }
.shop-item:hover { border-color: rgba(255,215,0,0.3); transform: translateY(-2px); }

.shop-item-icon { font-size: 2rem; margin-bottom: 8px; }
.shop-item-name { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; }
.shop-item-price { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 0.8rem; color: var(--gold); font-weight: 700; }
.shop-item-owned { font-size: 0.75rem; color: var(--green); font-weight: 700; }

/* ============================================
   ADMIN
   ============================================ */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: var(--panel2);
  border: 1px solid rgba(255,215,0,0.1);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.admin-stat-val { font-family: var(--font-title); font-size: 2rem; font-weight: 700; color: var(--gold); }
.admin-stat-lbl { font-size: 0.8rem; color: var(--text-dim); font-weight: 600; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 12px;
  background: rgba(255,215,0,0.05);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gold);
  border-bottom: 1px solid rgba(255,215,0,0.1);
}
td {
  padding: 10px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
tr:hover td { background: rgba(255,255,255,0.02); }

/* ============================================
   DIFFICULTY TOGGLE
   ============================================ */
.difficulty-toggle {
  display: flex;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  padding: 4px;
  gap: 4px;
  width: fit-content;
  margin: 0 auto 20px;
}

.diff-btn {
  padding: 8px 20px;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  background: none;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn.active { background: var(--gold); color: #000; }

/* ============================================
   LOADING
   ============================================ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,215,0,0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   HOME SCREEN
   ============================================ */
.hero-banner {
  background: linear-gradient(135deg, var(--navy) 0%, var(--panel3) 50%, var(--navy) 100%);
  border-bottom: 1px solid rgba(255,215,0,0.1);
  padding: 24px 16px;
  text-align: center;
}

.hero-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.hero-sub { color: var(--text-dim); font-size: 0.85rem; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.theme-card {
  background: var(--panel2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}

.theme-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background: var(--theme-color, var(--gold));
  transition: opacity 0.25s;
}

.theme-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.theme-card:hover::before { opacity: 0.12; }
.theme-icon { font-size: 2rem; margin-bottom: 10px; }
.theme-name { font-weight: 800; font-size: 0.9rem; }
.theme-count { font-size: 0.75rem; color: var(--text-dim); margin-top: 4px; }

/* ============================================
   PROFILE SCREEN
   ============================================ */
.profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  background: linear-gradient(180deg, var(--panel2) 0%, transparent 100%);
  border-bottom: 1px solid rgba(255,215,0,0.08);
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--panel3);
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin-bottom: 12px;
  box-shadow: var(--glow-gold);
}

.profile-name {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 4px;
}

.profile-level {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 600;
}

.stats-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card-mini {
  background: var(--panel2);
  border: 1px solid rgba(255,215,0,0.08);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}

.stat-card-mini .val { font-family: var(--font-title); font-size: 1.3rem; font-weight: 700; color: var(--gold); }
.stat-card-mini .lbl { font-size: 0.65rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; margin-top: 2px; }

/* ============================================
   REVISION MODE
   ============================================ */
.revision-item {
  background: rgba(255,74,74,0.06);
  border: 1px solid rgba(255,74,74,0.2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.revision-q { font-weight: 700; margin-bottom: 6px; }
.revision-wrong { color: var(--red); font-size: 0.85rem; margin-bottom: 4px; }
.revision-correct { color: var(--green); font-size: 0.85rem; font-weight: 700; }
.revision-expl { color: var(--text-dim); font-size: 0.8rem; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,0.06); }

/* ============================================
   RESPONSIVE DESKTOP
   ============================================ */
@media (min-width: 768px) {
  .scroll-area { padding: 24px; padding-bottom: 100px; }
  .chars-grid   { grid-template-columns: repeat(5, 1fr); }
  .answer-grid  { gap: 16px; }
  .answer-btn   { padding: 16px 14px; font-size: 0.95rem; }
  .fighter-img  { width: 100px; height: 100px; font-size: 3rem; }

  .bottom-nav { padding-left: 20%; padding-right: 20%; }
}

@media (min-width: 1024px) {
  .battle-arena { min-height: 260px; }
  .fighter-img  { width: 120px; height: 120px; }
  .hero-title   { font-size: 2.2rem; }
  .theme-grid   { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
}

/* ============================================
   MISC UTILITIES
   ============================================ */
.hidden   { display: none !important; }
.text-gold { color: var(--gold); }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-dim   { color: var(--text-dim); }
.text-center { text-align: center; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.w-full { width: 100%; }
.p-16 { padding: 16px; }
.fw-bold { font-weight: 700; }
.fs-sm { font-size: 0.85rem; }
.divider { height: 1px; background: rgba(255,255,255,0.06); margin: 16px 0; }
