/* ==========================================================================
   سباق أبطال الميثاق – رحلة الدرجة الكاملة (الإصدار المطور 2.0)
   الهوية البصرية: كحلي ملكي فاخر + ذهبي + عنابي سينمائي
   تصميم Mobile-First متجاوب من 320px إلى 430px+ مع إمكانية التوسع للحاسوب
   ========================================================================== */

:root {
  --navy-950: #04091a;
  --navy-900: #07112b;
  --navy-800: #0e1e47;
  --navy-700: #172d63;
  --burgundy-900: #460f23;
  --burgundy-700: #7c1c3d;
  --burgundy-500: #b02a56;
  --gold-300: #fff0be;
  --gold-400: #f6ce72;
  --gold-500: #d8a238;
  --gold-600: #a8751d;
  --cream: #fbf7ec;
  --muted: #bccbe4;
  --emerald: #38e5a7;
  --cyan: #5edbff;
  --danger: #ff607e;
  --violet: #b794ff;
  --glass: rgba(11, 22, 54, 0.80);
  --glass-strong: rgba(7, 15, 38, 0.93);
  --border-gold: rgba(246, 206, 114, 0.36);
  --border-soft: rgba(255, 255, 255, 0.14);
  --shadow-deep: 0 18px 44px rgba(2, 6, 20, 0.65);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --font-main: "Cairo", "Tajawal", "IBM Plex Sans Arabic", Tahoma, Arial, system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  background-color: var(--navy-950);
  color: var(--cream);
  font-family: var(--font-main);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 0%, rgba(124, 28, 61, 0.40), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(216, 162, 56, 0.19), transparent 40%),
    linear-gradient(175deg, #060e26 0%, #091536 48%, #050a1c 100%);
}

body.boss-theme {
  background:
    radial-gradient(circle at 50% 8%, rgba(246, 206, 114, 0.28), transparent 42%),
    radial-gradient(circle at 15% 40%, rgba(176, 42, 86, 0.48), transparent 52%),
    radial-gradient(circle at 85% 75%, rgba(124, 28, 61, 0.50), transparent 52%),
    linear-gradient(180deg, #1b0614 0%, #0d0824 55%, #160512 100%);
}

button, input, textarea { font-family: inherit; }
button {
  cursor: pointer;
  border: none;
  color: inherit;
  background: none;
  touch-action: manipulation;
}
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold-400);
  outline-offset: 2px;
}
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

/* Ambient Orbs */
.ambient-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(75px);
  opacity: 0.42;
  animation: orbDrift 14s ease-in-out infinite alternate;
}
.ambient-orb.orb-1 { width: 280px; height: 280px; top: -70px; right: -100px; background: var(--burgundy-500); }
.ambient-orb.orb-2 { width: 260px; height: 260px; top: 42%; left: -120px; background: #1b4e8f; animation-delay: -4s; }
.ambient-orb.orb-3 { width: 240px; height: 240px; bottom: -80px; right: -80px; background: var(--gold-600); animation-delay: -8s; }
@keyframes orbDrift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(34px, -42px) scale(1.18); }
}

/* Main App Container */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 14px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 13px;
  animation: screenIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

/* Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.brand-mark { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-badge {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(140deg, var(--gold-300), var(--gold-500));
  color: var(--burgundy-900);
  display: grid; place-items: center;
  font-size: 19px; font-weight: 900;
  box-shadow: 0 4px 16px rgba(246, 206, 114, 0.38);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title {
  font-size: 14.5px; font-weight: 900; color: var(--gold-300);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-slogan { font-size: 11px; color: var(--muted); font-weight: 700; }

.icon-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.icon-btn {
  min-width: 40px; height: 40px; padding: 0 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  color: var(--cream); font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn.active { background: rgba(246, 206, 114, 0.18); border-color: var(--border-gold); color: var(--gold-300); }

/* Cards */
.card {
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 15px;
  box-shadow: var(--shadow-deep);
}
.card-burgundy {
  background: linear-gradient(155deg, rgba(124, 28, 61, 0.82), rgba(14, 25, 62, 0.92));
  border: 1.5px solid rgba(246, 206, 114, 0.52);
}

/* Buttons */
.btn-primary {
  width: 100%; min-height: 54px; padding: 13px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffe9a8 0%, #f1be54 48%, #c98a24 100%);
  color: #240c14; font-size: 16.5px; font-weight: 900;
  box-shadow: 0 10px 26px rgba(216, 162, 56, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.45; filter: grayscale(0.5); cursor: not-allowed; }

.btn-royal {
  width: 100%; min-height: 52px; padding: 12px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #a6254f 0%, #7a1839 55%, #4a0e24 100%);
  border: 1.5px solid var(--gold-400);
  color: var(--gold-300); font-size: 16px; font-weight: 900;
  box-shadow: 0 12px 28px rgba(124, 28, 61, 0.52);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s ease;
}
.btn-royal:active { transform: scale(0.97); }

.btn-secondary {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-soft);
  color: var(--cream); font-size: 14.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background 0.15s ease, transform 0.15s ease;
}
.btn-secondary:active { transform: scale(0.97); }

/* ================= WELCOME SCREEN ================= */
.hero-banner { text-align: center; padding: 2px 4px 0; }
.pill-ribbon {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 14px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(124, 28, 61, 0.65), rgba(216, 162, 56, 0.25));
  border: 1px solid var(--border-gold);
  color: var(--gold-300); font-size: 12px; font-weight: 800;
}
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--emerald); box-shadow: 0 0 10px var(--emerald);
  animation: pulseGlow 1.8s infinite;
}
@keyframes pulseGlow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.65; }
}
.main-heading {
  margin: 9px 0 3px;
  font-size: clamp(26px, 7.2vw, 35px); line-height: 1.2; font-weight: 900;
  background: linear-gradient(100deg, #fff6d1 0%, #f6ce72 48%, #e2a43b 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sub-heading { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; }

.hero-stage {
  position: relative; height: 215px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.hero-halo {
  position: absolute; width: 188px; height: 188px; border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(246, 206, 114, 0.42), rgba(124, 28, 61, 0.34) 55%, transparent 74%);
  box-shadow: 0 0 0 12px rgba(246, 206, 114, 0.08), 0 0 42px rgba(246, 206, 114, 0.25);
}
.hero-ring {
  position: absolute; width: 228px; height: 66px; border-radius: 50%;
  border: 1.5px solid rgba(246, 206, 114, 0.45); transform: rotate(-14deg);
  pointer-events: none;
}
.hero-preview-img {
  position: relative; z-index: 2; height: 184px; width: auto; max-width: 72%;
  object-fit: contain;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.72));
  animation: heroFloat 3.4s ease-in-out infinite;
}
@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
.hero-speech-preview {
  position: relative; z-index: 3; margin-top: -10px;
  padding: 5px 14px; border-radius: 999px;
  background: rgba(7, 17, 43, 0.94); border: 1px solid var(--border-gold);
  color: var(--gold-300); font-size: 12px; font-weight: 800;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.field-label { display: block; font-size: 13px; font-weight: 800; color: var(--gold-300); margin-bottom: 6px; }
.name-input {
  width: 100%; min-height: 50px; padding: 11px 14px;
  border-radius: 14px; background: rgba(4, 10, 28, 0.88);
  border: 1.5px solid rgba(246, 206, 114, 0.35);
  color: var(--cream); font-size: 16px; font-weight: 700;
}
.name-input::placeholder { color: rgba(188, 203, 228, 0.55); }
.name-input:focus { outline: none; border-color: var(--gold-400); box-shadow: 0 0 0 3px rgba(246, 206, 114, 0.22); }

.gender-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 11px; }
.gender-btn {
  min-height: 48px; padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.06); border: 1.5px solid var(--border-soft);
  font-size: 15px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.18s ease;
}
.gender-btn.selected {
  background: linear-gradient(135deg, rgba(124, 28, 61, 0.78), rgba(216, 162, 56, 0.28));
  border-color: var(--gold-400); color: var(--gold-300);
  box-shadow: 0 6px 18px rgba(216, 162, 56, 0.24);
}

.hero-picker { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 10px; }
.hero-tile {
  padding: 7px 3px 6px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.1);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.18s ease;
}
.hero-tile img {
  width: 44px; height: 54px; object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));
}
.hero-tile span { font-size: 11px; font-weight: 800; color: var(--muted); }
.hero-tile.selected {
  background: linear-gradient(180deg, rgba(246, 206, 114, 0.24), rgba(124, 28, 61, 0.5));
  border-color: var(--gold-400); transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(246, 206, 114, 0.25);
}
.hero-tile.selected span { color: var(--gold-300); }

.inline-error {
  margin-top: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgba(255, 96, 126, 0.16); border: 1px solid rgba(255, 96, 126, 0.5);
  color: #ffc2ce; font-size: 12.5px; font-weight: 800;
}

/* ================= HUB SCREEN ================= */
.profile-strip { display: flex; align-items: center; gap: 11px; padding: 12px 13px; }
.profile-avatar {
  width: 56px; height: 66px; border-radius: 15px;
  background: radial-gradient(circle at 50% 35%, rgba(246, 206, 114, 0.3), rgba(124, 28, 61, 0.45));
  border: 1.5px solid var(--border-gold);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.profile-avatar img { height: 60px; width: auto; object-fit: contain; }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 15.5px; font-weight: 900; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-rank { font-size: 12px; font-weight: 800; color: var(--gold-400); }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.stat-chip {
  background: rgba(5, 11, 28, 0.68); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px; padding: 6px 4px; text-align: center;
}
.stat-chip b { display: block; font-size: 13.5px; font-weight: 900; color: var(--gold-300); }
.stat-chip small { display: block; font-size: 10px; color: var(--muted); font-weight: 700; }

.journey-progress-box { padding: 11px 14px; }
.journey-progress-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 800; margin-bottom: 7px; }
.progress-track { width: 100%; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--burgundy-500), var(--gold-400), var(--emerald)); transition: width 0.5s ease; }

.worlds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.world-card {
  position: relative; text-align: right; padding: 12px 11px; border-radius: 18px;
  background: linear-gradient(155deg, rgba(16, 32, 74, 0.88), rgba(7, 15, 38, 0.94));
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  display: flex; flex-direction: column; gap: 5px; min-height: 128px;
  transition: transform 0.16s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.world-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--w-accent, var(--gold-400)); }
.world-card.unlocked:hover { border-color: var(--gold-400); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45); }
.world-card.unlocked:active { transform: scale(0.97); }
.world-card.cleared { border-color: rgba(56, 229, 167, 0.55); background: linear-gradient(155deg, rgba(14, 48, 56, 0.86), rgba(7, 18, 40, 0.94)); }
.world-card.locked { opacity: 0.54; filter: saturate(0.45); cursor: not-allowed; }

.world-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.world-num { font-size: 10.5px; font-weight: 900; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: var(--gold-300); }
.world-icon { font-size: 21px; }
.world-title { font-size: 14px; font-weight: 900; color: var(--cream); line-height: 1.25; }
.world-sub { font-size: 11px; color: var(--muted); line-height: 1.32; }
.world-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; font-weight: 800; padding-top: 4px; }
.stars-inline { color: var(--gold-400); letter-spacing: 1px; }

.boss-hub-card {
  position: relative; overflow: hidden; padding: 15px; border-radius: 22px;
  background: linear-gradient(140deg, rgba(124, 28, 61, 0.88), rgba(20, 14, 48, 0.96) 60%, rgba(168, 117, 29, 0.4));
  border: 2px solid var(--gold-400);
  box-shadow: 0 14px 36px rgba(124, 28, 61, 0.48);
}
.boss-hub-card.locked-boss {
  border-color: rgba(246, 206, 114, 0.28);
  background: linear-gradient(140deg, rgba(50, 18, 36, 0.72), rgba(10, 18, 42, 0.92));
}
.boss-hub-badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 900;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(246, 206, 114, 0.2); color: var(--gold-300); border: 1px solid rgba(246, 206, 114, 0.45);
}
.boss-hub-title { margin: 7px 0 4px; font-size: 18px; font-weight: 900; color: var(--gold-300); }
.boss-hub-desc { margin: 0 0 12px; font-size: 12.5px; color: #e6ddf2; }
.boss-actions-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.boss-actions-row.two-cols { grid-template-columns: 1fr 1fr; }

.modes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode-btn {
  padding: 11px 7px; border-radius: 16px;
  background: rgba(14, 28, 66, 0.84); border: 1px solid var(--border-soft);
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-height: 90px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.mode-btn:active { transform: scale(0.96); }
.mode-btn:hover { border-color: var(--gold-400); }
.mode-icon { font-size: 23px; }
.mode-title { font-size: 12px; font-weight: 900; color: var(--cream); }
.mode-meta { font-size: 10.5px; font-weight: 700; color: var(--gold-400); }

/* ================= BOSS TRANSITION SCREEN ================= */
.boss-intro-card {
  position: relative; text-align: center; padding: 20px 15px; border-radius: 26px;
  background:
    radial-gradient(circle at 50% 18%, rgba(246, 206, 114, 0.34), transparent 55%),
    linear-gradient(165deg, #4b0d24 0%, #190c33 52%, #090c22 100%);
  border: 2.5px solid var(--gold-400);
  box-shadow: 0 0 48px rgba(246, 206, 114, 0.3), inset 0 0 36px rgba(176, 42, 86, 0.45);
  overflow: hidden;
}
.boss-alert-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 999px;
  background: rgba(255, 96, 126, 0.22); border: 1.5px solid #ff8aa1;
  color: #ffe2e8; font-size: 12.5px; font-weight: 900;
  animation: alertPulse 1.4s ease-in-out infinite;
}
@keyframes alertPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 96, 126, 0.45); }
  50% { box-shadow: 0 0 0 10px rgba(255, 96, 126, 0); }
}
.boss-crown-stage {
  position: relative; height: 210px; margin: 10px auto 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
}
.royal-crown {
  font-size: 46px; line-height: 1; margin-bottom: -10px; z-index: 3;
  filter: drop-shadow(0 0 18px rgba(255, 220, 110, 0.95));
  animation: crownCelebrate 1.8s ease-in-out infinite;
}
@keyframes crownCelebrate {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1); }
  50% { transform: translateY(-10px) rotate(4deg) scale(1.12); }
}
.boss-hero-celebrate {
  position: relative; z-index: 2; height: 158px; width: auto; object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.85));
  animation: heroCelebrate 1.6s ease-in-out infinite;
}
@keyframes heroCelebrate {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.04); }
}
.boss-glow-ring {
  position: absolute; bottom: 6px; width: 210px; height: 46px; border-radius: 50%;
  background: radial-gradient(ellipse, rgba(246, 206, 114, 0.55), transparent 72%);
}
.boss-warning-headline {
  margin: 8px 0 10px; font-size: clamp(17.5px, 4.9vw, 21.5px); line-height: 1.45; font-weight: 900; color: var(--gold-300);
}
.boss-rules-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 16px; }
.boss-rule-box {
  background: rgba(5, 9, 26, 0.72); border: 1px solid rgba(246, 206, 114, 0.35);
  border-radius: 14px; padding: 9px 6px;
}
.boss-rule-box b { display: block; font-size: 17px; font-weight: 900; color: var(--gold-400); }
.boss-rule-box span { font-size: 11px; color: var(--muted); font-weight: 700; }
.boss-start-btn {
  width: 100%; min-height: 58px; padding: 14px 18px; border-radius: 18px;
  background: linear-gradient(135deg, #fff2bf 0%, #f4c254 45%, #c78119 100%);
  color: #290913; font-size: 18px; font-weight: 900;
  box-shadow: 0 0 30px rgba(246, 206, 114, 0.55), 0 12px 26px rgba(0, 0, 0, 0.5);
  animation: ctaPulse 2s ease-in-out infinite;
}
@keyframes ctaPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.022); } }

/* ================= GAMEPLAY / RUNNER SCREEN ================= */
.race-hud { display: flex; flex-direction: column; gap: 7px; }
.hud-top-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 11px;
  background: rgba(8, 17, 42, 0.86); border: 1px solid var(--border-soft);
  font-size: 12px; font-weight: 800;
}
.hud-pill.gold { border-color: var(--border-gold); color: var(--gold-300); }
.hud-pill.combo {
  background: linear-gradient(135deg, rgba(176, 42, 86, 0.85), rgba(216, 162, 56, 0.45));
  border-color: var(--gold-400); color: #fff;
}

.timer-wrap {
  width: 100%; height: 11px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.timer-bar {
  height: 100%; width: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--emerald), var(--gold-400));
  transition: width 0.12s linear;
}
.timer-bar.urgent { background: linear-gradient(90deg, #ff3e64, #ff9642); }
.timer-bar.frozen { background: linear-gradient(90deg, #62ecff, #b3f7ff); }

.runner-viewport {
  position: relative; width: 100%; height: 215px; border-radius: 22px; overflow: hidden;
  border: 2px solid var(--border-gold); background: #060d24; box-shadow: var(--shadow-deep);
  touch-action: pan-y; user-select: none;
}
.runner-viewport.boss-arena-border {
  border: 2.5px solid var(--gold-400);
  box-shadow: 0 0 28px rgba(246, 206, 114, 0.42), 0 14px 36px rgba(124, 28, 61, 0.6);
}
#runnerCanvas { width: 100%; height: 100%; display: block; }

.canvas-overlay-top {
  position: absolute; top: 8px; inset-inline: 10px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; z-index: 3;
}
.world-chip {
  padding: 4px 10px; border-radius: 999px;
  background: rgba(5, 11, 28, 0.80); border: 1px solid rgba(246, 206, 114, 0.42);
  font-size: 11px; font-weight: 800; color: var(--gold-300);
}
.timer-badge {
  padding: 4px 10px; border-radius: 999px;
  background: rgba(5, 11, 28, 0.86); border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 13px; font-weight: 900; color: var(--cream); font-variant-numeric: tabular-nums;
}
.timer-badge.urgent { background: rgba(205, 32, 68, 0.92); border-color: #ff9ab0; color: #fff; }

.swipe-hint {
  position: absolute; bottom: 8px; left: 10px; z-index: 3;
  font-size: 10px; font-weight: 700; color: rgba(255, 240, 190, 0.72);
  background: rgba(5, 11, 28, 0.65); padding: 2px 8px; border-radius: 999px;
  pointer-events: none;
}

.hero-bubble {
  position: absolute; top: 40px; inset-inline: 14px; z-index: 4;
  padding: 6px 12px; border-radius: 13px;
  background: rgba(6, 14, 38, 0.92); border: 1px solid var(--border-gold);
  color: var(--gold-300); font-size: 12px; font-weight: 800; text-align: center;
  pointer-events: none; opacity: 0; transform: translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.hero-bubble.show { opacity: 1; transform: translateY(0); }

.chest-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 13px; border-radius: 16px;
  background: linear-gradient(120deg, rgba(168, 117, 29, 0.92), rgba(124, 28, 61, 0.92));
  border: 1.5px solid var(--gold-300);
  box-shadow: 0 8px 24px rgba(246, 206, 114, 0.35);
  animation: chestBounce 1s ease-in-out infinite;
}
@keyframes chestBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.chest-btn {
  padding: 8px 13px; border-radius: 12px;
  background: var(--gold-300); color: #2b0c16; font-size: 12.5px; font-weight: 900; flex-shrink: 0;
}

.question-panel {
  padding: 13px; border-radius: 20px;
  background: var(--glass-strong); border: 1.5px solid var(--border-gold);
}
.question-meta {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 7px; font-size: 11px; font-weight: 800; color: var(--gold-400);
}
.question-text { margin: 0; font-size: clamp(15.5px, 4.3vw, 18px); font-weight: 900; line-height: 1.48; color: var(--cream); }

.gates-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 11px; }
.gate-btn {
  position: relative; min-height: 66px; padding: 10px; border-radius: 15px;
  background: linear-gradient(160deg, rgba(22, 42, 92, 0.94), rgba(10, 20, 48, 0.96));
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  text-align: right; display: flex; align-items: flex-start; gap: 8px;
  transition: transform 0.14s ease, border-color 0.16s ease, background 0.16s ease;
}
.gate-btn:active:not(:disabled) { transform: scale(0.96); }
.gate-btn:hover:not(:disabled), .gate-btn.lane-focused { border-color: var(--gold-400); }
.gate-letter {
  width: 28px; height: 28px; border-radius: 9px;
  background: linear-gradient(145deg, var(--gold-400), var(--gold-600));
  color: #1f0a12; font-size: 14px; font-weight: 900;
  display: grid; place-items: center; flex-shrink: 0; margin-top: 1px;
}
.gate-label { font-size: 13px; font-weight: 800; line-height: 1.36; color: var(--cream); word-break: break-word; }

.gate-btn.correct {
  background: linear-gradient(145deg, rgba(16, 118, 84, 0.95), rgba(9, 64, 48, 0.96));
  border: 2px solid var(--emerald); box-shadow: 0 0 20px rgba(56, 229, 167, 0.42);
}
.gate-btn.correct .gate-letter { background: var(--emerald); color: #042419; }
.gate-btn.wrong {
  background: linear-gradient(145deg, rgba(145, 24, 54, 0.95), rgba(74, 12, 30, 0.96));
  border: 2px solid var(--danger);
}
.gate-btn.wrong .gate-letter { background: var(--danger); color: #fff; }
.gate-btn.shield-blocked {
  background: linear-gradient(145deg, rgba(24, 90, 128, 0.82), rgba(10, 35, 62, 0.9));
  border: 2px dashed var(--cyan); opacity: 0.52; pointer-events: none;
}
.gate-btn.eliminated { opacity: 0.22; filter: grayscale(1); pointer-events: none; }

.powerups-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.power-btn {
  min-height: 46px; padding: 6px 6px; border-radius: 13px;
  background: rgba(14, 28, 66, 0.86); border: 1px solid rgba(246, 206, 114, 0.28);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 800; color: var(--cream);
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.power-btn:active:not(:disabled) { transform: scale(0.95); }
.power-btn.armed { background: rgba(94, 219, 255, 0.22); border-color: var(--cyan); color: var(--cyan); }
.power-btn:disabled { opacity: 0.38; cursor: not-allowed; }
.power-cost { font-size: 10px; color: var(--gold-400); font-weight: 700; }

.explain-box {
  margin-top: 10px; padding: 11px 12px; border-radius: 15px;
  background: rgba(7, 17, 43, 0.96); border: 1.5px solid var(--border-gold);
  animation: screenIn 0.2s ease both;
}
.explain-status { font-size: 14px; font-weight: 900; margin-bottom: 4px; }
.explain-status.ok { color: var(--emerald); }
.explain-status.bad { color: #ff9ab0; }
.explain-status.shield { color: var(--cyan); }
.explain-text { margin: 0 0 10px; font-size: 13px; color: #e4ecf9; line-height: 1.52; }

/* ================= RESULT SCREEN ================= */
.result-hero-box { text-align: center; padding: 18px 14px; }
.result-stars { font-size: 36px; letter-spacing: 6px; margin-bottom: 4px; color: var(--gold-400); text-shadow: 0 0 20px rgba(246, 206, 114, 0.55); }
.result-avatar { height: 148px; margin: 6px auto 10px; object-fit: contain; filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.7)); }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.result-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }

/* ================= ESSAY ARENA ================= */
.essay-card { display: flex; flex-direction: column; gap: 10px; }
.essay-textarea {
  width: 100%; min-height: 92px; padding: 11px; border-radius: 14px;
  background: rgba(4, 10, 28, 0.9); border: 1.5px solid rgba(246, 206, 114, 0.3);
  color: var(--cream); font-size: 14px; resize: vertical;
}
.rubric-list { display: flex; flex-direction: column; gap: 7px; }
.rubric-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 11px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px; cursor: pointer;
}
.rubric-item input { width: 18px; height: 18px; accent-color: var(--gold-400); margin-top: 2px; flex-shrink: 0; }

/* ================= MODAL & TOAST ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(2, 6, 18, 0.84); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal-card {
  width: 100%; max-width: 450px; max-height: 90dvh; overflow-y: auto;
  background: linear-gradient(170deg, #0f1f4a, #08122d);
  border: 1.5px solid var(--gold-400); border-radius: 22px; padding: 17px 15px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  animation: screenIn 0.22s ease both;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.modal-title { margin: 0; font-size: 17.5px; font-weight: 900; color: var(--gold-300); }
.cert-preview-img {
  width: 100%; border-radius: 12px; border: 2px solid var(--gold-400);
  margin: 10px 0 12px; box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
}

.toast {
  position: fixed; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%) translateY(20px); z-index: 90;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(8, 17, 42, 0.96); border: 1.5px solid var(--gold-400);
  color: var(--gold-300); font-size: 13px; font-weight: 800;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
  opacity: 0; pointer-events: none; transition: opacity 0.22s ease, transform 0.22s ease;
  max-width: calc(100vw - 28px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Footer Credits */
.credits-footer {
  margin-top: auto; padding: 13px 8px 6px; text-align: center;
  font-size: 11px; color: var(--muted);
  border-top: 1px solid rgba(246, 206, 114, 0.16); line-height: 1.75;
}
.credits-footer strong { color: var(--gold-300); }
.disclaimer-note { margin-top: 5px; font-size: 10.5px; color: rgba(188, 203, 228, 0.72); }

/* Compact Mobile (320px - 360px) */
@media (max-width: 360px) {
  .app-shell { padding-inline: 10px; }
  .hero-picker { gap: 4px; }
  .hero-tile img { width: 38px; height: 48px; }
  .gates-grid { grid-template-columns: 1fr; }
  .worlds-grid { gap: 8px; }
  .runner-viewport { height: 192px; }
  .boss-rules-grid { gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation: none !important; transition: none !important; }
