:root {
  --bg-deep: #050a18;
  --bg-navy: #0a142d;
  --bg-panel: rgba(12, 23, 49, 0.76);
  --bg-panel-strong: rgba(10, 19, 41, 0.92);
  --gold-bright: #fde047;
  --gold-main: #eab308;
  --gold-dark: #a16207;
  --emerald-bright: #34d399;
  --emerald-main: #10b981;
  --emerald-dark: #065f46;
  --crimson: #ef4444;
  --crimson-dark: #991b1b;
  --sky-glow: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-glass: rgba(250, 204, 21, 0.28);
  --shadow-glow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 25px rgba(234, 179, 8, 0.14);
}

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

body {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 10%, #102347 0%, var(--bg-deep) 70%);
  color: var(--text-main);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ==================== AMBIENT ANIMATED BACKGROUND ==================== */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: floatNebula 16s ease-in-out infinite alternate;
}

.nebula-blue {
  width: 480px;
  height: 480px;
  background: #1d4ed8;
  top: -120px;
  left: -100px;
}

.nebula-emerald {
  width: 420px;
  height: 420px;
  background: #059669;
  bottom: 10%;
  right: -80px;
  animation-delay: -5s;
}

.nebula-gold {
  width: 320px;
  height: 320px;
  background: #d97706;
  top: 38%;
  left: 42%;
  opacity: 0.2;
  animation-delay: -9s;
}

@keyframes floatNebula {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(30px, -25px) scale(1.12);
  }
}

.particles-container {
  position: absolute;
  inset: 0;
}

.firefly {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  animation: riseParticle linear infinite;
}

@keyframes riseParticle {
  0% {
    transform: translateY(105vh) scale(0.6);
    opacity: 0;
  }
  20% {
    opacity: 0.9;
  }
  80% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-10vh) translateX(35px) scale(1.2);
    opacity: 0;
  }
}

.horizon-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 220px;
  opacity: 0.85;
}

/* ==================== TOP UTILITY BAR ==================== */
.top-utility-bar {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.75rem;
  background: rgba(5, 10, 24, 0.72);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(250, 204, 21, 0.2);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  transition: transform 0.2s ease, color 0.2s ease;
}

.brand-mini:hover {
  transform: translateY(-1px);
  color: var(--gold-bright);
}

.brand-mini strong {
  color: var(--emerald-bright);
}

.utility-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.status-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.status-pill.status-online {
  border-color: rgba(16, 185, 129, 0.5);
  color: #a7f3d0;
}

.status-pill.status-online .dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-pill.status-offline {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fecaca;
}

.status-pill.status-offline .dot {
  background: #ef4444;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(30, 41, 59, 0.75);
  color: var(--text-main);
  border: 1px solid rgba(250, 204, 21, 0.28);
  padding: 0.42rem 0.85rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s ease;
}

.icon-btn:hover {
  background: rgba(234, 179, 8, 0.18);
  border-color: var(--gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.22);
}

/* ==================== MAIN STAGE & GLASS PANELS ==================== */
.main-stage {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.screen {
  display: none;
  width: 100%;
  animation: fadeInScreen 0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@keyframes fadeInScreen {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  box-shadow: var(--shadow-glow);
}

/* ==================== WELCOME SCREEN ==================== */
.hero-card {
  padding: 2rem 2.25rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero-badge-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.cr-ribbon {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(29, 78, 216, 0.35), rgba(220, 38, 38, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #e2e8f0;
}

.best-score-chip {
  font-size: 0.85rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: var(--gold-bright);
}

.emblem-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.crest-svg {
  width: 84px;
  height: 94px;
  filter: drop-shadow(0 0 16px rgba(250, 204, 21, 0.4));
  animation: pulseCrest 3.5s ease-in-out infinite;
}

@keyframes pulseCrest {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-5px) scale(1.04);
  }
}

.game-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4.2vw, 3.3rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fffbeb 0%, #fde047 55%, #ca8a04 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.75));
}

.game-title .accent-cr {
  background: linear-gradient(180deg, #6ee7b7 0%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.game-subtitle {
  font-size: clamp(1rem, 2vw, 1.22rem);
  color: #cbd5e1;
  font-style: italic;
  margin-top: 0.25rem;
  margin-bottom: 1.25rem;
}

/* Hero Duel Illustration */
.hero-duel-showcase {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin: 0.75rem auto 1.4rem;
  padding: 0.9rem 1.4rem;
  max-width: 680px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.75), rgba(239, 68, 68, 0.12));
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.duel-character {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.character-svg {
  width: 128px;
  height: 105px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
}

.duel-knight .character-svg {
  animation: bobKnight 2.2s ease-in-out infinite;
}

.duel-dragon .character-svg {
  animation: bobDragon 2.5s ease-in-out infinite;
}

@keyframes bobKnight {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes bobDragon {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.03); }
}

.duel-caption {
  font-size: 0.78rem;
  font-weight: 700;
  color: #cbd5e1;
  letter-spacing: 0.04em;
}

.duel-vs {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.vs-spark {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 12px #facc15);
}

.vs-distance {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  font-weight: 700;
}

/* Setup Bar */
.setup-bar {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.2rem;
  text-align: left;
  background: rgba(7, 14, 32, 0.68);
  padding: 1rem 1.25rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 1.4rem;
}

.setup-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.setup-field label,
.setup-field .field-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #cbd5e1;
}

.setup-field input {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  color: #fff;
  font-size: 0.98rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.setup-field input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
}

.difficulty-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 0.4rem;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.diff-btn:hover {
  border-color: var(--gold-bright);
  transform: translateY(-1px);
}

.diff-btn.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.32), rgba(234, 179, 8, 0.25));
  border-color: var(--gold-bright);
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.25);
}

.diff-title {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--gold-bright);
}

.diff-desc {
  font-size: 0.72rem;
  color: #cbd5e1;
}

/* Main Buttons */
.welcome-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.72rem 1.35rem;
  border-radius: 11px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.btn:hover {
  transform: translateY(-3px);
}

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

.btn-lg {
  padding: 0.88rem 1.85rem;
  font-size: 1.05rem;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
}

.btn-primary {
  background: linear-gradient(135deg, #facc15 0%, #eab308 55%, #ca8a04 100%);
  color: #090d16;
  border-color: #fef08a;
  box-shadow: 0 8px 22px rgba(234, 179, 8, 0.38);
}

.btn-primary:hover {
  box-shadow: 0 12px 28px rgba(250, 204, 21, 0.55);
  filter: brightness(1.06);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.85);
  color: #f8fafc;
  border-color: rgba(148, 163, 184, 0.4);
}

.btn-secondary:hover {
  border-color: var(--sky-glow);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.25);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  border-color: #6ee7b7;
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.btn-emerald:hover {
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5);
}

.btn-gold {
  background: rgba(234, 179, 8, 0.18);
  color: var(--gold-bright);
  border-color: rgba(250, 204, 21, 0.55);
}

.btn-gold:hover {
  background: rgba(234, 179, 8, 0.3);
  box-shadow: 0 8px 22px rgba(234, 179, 8, 0.3);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.22);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.38);
}

.hidden {
  display: none !important;
}

/* ==================== GAMEPLAY HUD (PARTE SUPERIOR) ==================== */
.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.85rem 1.35rem;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.hud-crest {
  font-size: 1.7rem;
}

.hud-title {
  font-weight: 900;
  font-size: 0.98rem;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
}

.hud-sub {
  font-size: 0.78rem;
  color: var(--emerald-bright);
  font-weight: 600;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(7, 13, 28, 0.72);
  padding: 0.4rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  min-width: 82px;
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.hud-value {
  font-size: 1.12rem;
  font-weight: 900;
}

.gold-text {
  color: var(--gold-bright);
}

.emerald-text {
  color: var(--emerald-bright);
}

.timer-text {
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

.timer-text.timer-warning {
  color: #ef4444;
  animation: pulseUrgent 0.45s infinite alternate;
}

@keyframes pulseUrgent {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

.hud-controls {
  display: flex;
  gap: 0.5rem;
}

/* Timer Progress Bar */
.timer-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(250, 204, 21, 0.25);
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #eab308, #38bdf8);
  transition: width 0.1s linear, background 0.25s ease;
}

.timer-bar-fill.danger {
  background: linear-gradient(90deg, #ef4444, #f97316);
}

/* ==================== ZONA CENTRAL: BATTLE ARENA ==================== */
.battle-arena {
  position: relative;
  padding: 1rem 1.35rem 1.25rem;
  overflow: hidden;
}

.arena-header {
  margin-bottom: 0.55rem;
}

.chase-indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #cbd5e1;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.distance-pill {
  background: rgba(15, 23, 42, 0.85);
  padding: 0.25rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  color: var(--gold-bright);
}

.scenic-track {
  position: relative;
  height: 165px;
  background: linear-gradient(180deg, rgba(14, 30, 64, 0.65) 0%, rgba(6, 78, 59, 0.35) 75%, rgba(30, 41, 59, 0.9) 100%);
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.landmark {
  position: absolute;
  top: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  background: rgba(5, 10, 24, 0.65);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.landmark-1 { left: 4%; }
.landmark-2 { left: 32%; }
.landmark-3 { left: 60%; }
.landmark-4 { right: 4%; }

.medieval-road {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border-top: 3px solid #eab308;
}

.road-stones {
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.08) 0px,
    rgba(255, 255, 255, 0.08) 28px,
    transparent 28px,
    transparent 44px
  );
}

/* Track Sprites — Move via left / transform translateX */
.track-sprite {
  position: absolute;
  bottom: 18px;
  left: 0;
  width: 100%;
  pointer-events: none;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.arena-svg {
  width: 112px;
  height: 86px;
  display: block;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.65));
}

.sprite-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  margin-left: 18px;
  margin-bottom: -4px;
}

.badge-danger {
  background: rgba(220, 38, 38, 0.9);
  color: #fff;
}

.badge-knight {
  background: rgba(2, 132, 199, 0.92);
  color: #fff;
  border: 1px solid #fde047;
}

/* Chase Progress Bar */
.chase-progress-wrapper {
  padding: 0 0.4rem;
}

.chase-progress-track {
  position: relative;
  height: 12px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.chase-danger-fill {
  height: 100%;
  background: linear-gradient(90deg, #991b1b, #ef4444);
  border-radius: 999px;
  transition: width 0.5s ease;
}

.chase-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.1rem;
  transition: left 0.5s ease;
}

/* Arena Feedback Flash Animations */
.battle-arena.arena-success {
  box-shadow: 0 0 35px rgba(16, 185, 129, 0.55);
  border-color: #10b981;
}

.battle-arena.arena-error {
  animation: arenaShake 0.42s ease;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.65);
  border-color: #ef4444;
}

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

/* Pause Overlay */
.pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 24, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.pause-box {
  padding: 1.5rem 2rem;
  text-align: center;
  max-width: 420px;
}

.pause-box h3 {
  color: var(--gold-bright);
  margin-bottom: 0.5rem;
}

.pause-box p {
  font-size: 0.9rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
}

/* ==================== ZONA INFERIOR: TYPING ZONE ==================== */
.typing-zone {
  padding: 1.15rem 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.phrase-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.char-counters {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.counter-chip {
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.counter-ok {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.4);
}

.counter-err {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.target-phrase-display {
  background: rgba(5, 10, 24, 0.88);
  border: 1px solid rgba(250, 204, 21, 0.32);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  font-size: clamp(1.1rem, 2.1vw, 1.42rem);
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.02em;
  user-select: none;
  min-height: 68px;
}

.char-span {
  transition: color 0.1s ease, background-color 0.1s ease;
  border-radius: 3px;
}

.char-pending {
  color: #94a3b8;
}

.char-correct {
  color: #34d399;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.35);
}

.char-incorrect {
  color: #ffffff;
  background-color: rgba(239, 68, 68, 0.82);
  text-decoration: underline wavy #fde047;
}

.char-current {
  border-bottom: 2px solid var(--gold-bright);
  color: #ffffff;
}

.input-row {
  display: flex;
  gap: 0.75rem;
}

.typing-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid rgba(56, 189, 248, 0.45);
  border-radius: 12px;
  padding: 0.82rem 1.1rem;
  font-size: 1.12rem;
  color: #ffffff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.typing-input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.2);
}

.feedback-banner {
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.25s ease;
}

.feedback-neutral {
  background: rgba(30, 41, 59, 0.65);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.feedback-success {
  background: rgba(6, 95, 70, 0.65);
  color: #a7f3d0;
  border: 1px solid #10b981;
}

.feedback-error {
  background: rgba(153, 27, 27, 0.65);
  color: #fecaca;
  border: 1px solid #ef4444;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  animation: fadeBackdrop 0.25s ease;
}

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

.modal-card {
  width: 100%;
  max-width: 500px;
  background: var(--bg-panel-strong);
  padding: 1.75rem 2rem;
  border: 1px solid rgba(250, 204, 21, 0.45);
}

.modal-wide {
  max-width: 720px;
}

.modal-animate {
  animation: popModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popModal {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.45rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding-bottom: 1rem;
}

.academic-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.15);
  border: 2px solid var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.3);
}

.modal-emoji {
  font-size: 2.2rem;
}

.modal-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
}

/* Academic Modal Exact Format */
.academic-details {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.academic-lead {
  text-align: center;
  color: var(--emerald-bright);
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 0.25rem;
}

.info-item {
  background: rgba(15, 23, 42, 0.8);
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border-left: 4px solid var(--gold-main);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.info-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--gold-bright);
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 1rem;
  font-weight: 600;
  color: #f8fafc;
}

.modal-footer {
  margin-top: 1.4rem;
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Instructions List */
.instructions-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.instr-step {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: rgba(15, 23, 42, 0.75);
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-size: 0.92rem;
  line-height: 1.45;
}

.step-num {
  min-width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gold-main);
  color: #090d16;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Ranking Table */
.ranking-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  font-size: 0.88rem;
}

.filter-pills {
  display: flex;
  gap: 0.4rem;
}

.pill-btn {
  background: rgba(30, 41, 59, 0.8);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--emerald-main);
  color: #fff;
  border-color: var(--emerald-bright);
}

.table-responsive {
  overflow-x: auto;
  max-height: 310px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.ranking-table th,
.ranking-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.ranking-table th {
  color: var(--gold-bright);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(15, 23, 42, 0.9);
  position: sticky;
  top: 0;
}

.ranking-table tbody tr:hover {
  background: rgba(250, 204, 21, 0.07);
}

.empty-cell {
  text-align: center !important;
  color: var(--text-muted);
  padding: 1.5rem !important;
}

/* Game Over Stats Grid */
.gameover-heading {
  color: #f87171;
  font-size: 1.85rem;
}

.gameover-sub {
  font-size: 0.92rem;
  color: #cbd5e1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-box {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  padding: 0.8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-box-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stat-box-val {
  font-size: 1.35rem;
  font-weight: 900;
}

.save-status-msg {
  text-align: center;
  font-size: 0.84rem;
  color: var(--emerald-bright);
}

kbd {
  background: #1e293b;
  border: 1px solid #64748b;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.8rem;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 820px) {
  .setup-bar {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .hud-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .hud-metrics {
    justify-content: space-between;
  }
}

@media (max-width: 540px) {
  .hero-card {
    padding: 1.35rem 1rem;
  }
  .hero-duel-showcase {
    gap: 0.6rem;
    padding: 0.65rem;
  }
  .character-svg {
    width: 92px;
    height: 78px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .input-row {
    flex-direction: column;
  }
  .btn-label-sm {
    display: none;
  }
}
