:root {
  --bg: #12141c;
  --bg2: #1a1e2a;
  --card: #222736;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f3efe8;
  --muted: #9aa3b8;
  --accent: #ff7a3c;
  --accent2: #ff4458;
  --gold: #ffd166;
  --good: #3ddc97;
  --danger: #ff5d6c;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #12141c; color: #f3efe8; }
html, body { font-family: "Tajawal", "Cairo", sans-serif; }
h1, h2, h3, .btn, .eyebrow, .wave-pill { font-family: "Cairo", "Tajawal", sans-serif; }
button, .tile, .ctrl-btn, .stat-card, .icon-btn { user-select: none; -webkit-user-select: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; color: inherit; }

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

.hidden { display: none !important; }

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.loading-screen {
  background: #141821;
  color: #f3efe8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.load-art { position: absolute; inset: 0; }
.load-art img { width: 100%; height: 100%; object-fit: cover; }
.load-art-fade {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(18,20,28,0.15) 0%, rgba(18,20,28,0.55) 48%, #12141c 100%);
}
.load-copy {
  position: relative;
  z-index: 1;
  padding: 32px 24px 48px;
}
.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  font-weight: 700;
  color: #ffd166;
}
.load-copy h1, .menu-hero h1 {
  margin: 0;
  font-size: 48px;
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-weight: 900;
  color: #f3efe8;
}
.load-sub { margin: 12px 0 20px; color: #9aa3b8; font-size: 15px; }
.load-bar {
  height: 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
#load-fill {
  display: block;
  height: 100%;
  width: 8%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ff7a3c, #ff4458);
  transition: width 0.35s var(--ease);
}

.error-screen, .dim-screen {
  background: rgba(10, 12, 18, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  color: #f3efe8;
}
.panel {
  width: min(420px, 100%);
  background: #1c2030;
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 28px 22px 22px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.panel h2 { margin: 0 0 8px; font-size: 24px; letter-spacing: -0.02em; color: #f3efe8; }
.panel p { margin: 0 0 20px; color: #9aa3b8; font-size: 15px; line-height: 1.6; }

.menu-screen {
  background: linear-gradient(180deg, rgba(62, 28, 16, 0.06) 0%, rgba(72, 34, 18, 0.10) 58%, rgba(86, 40, 18, 0.38) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 16px 24px;
  color: #f3efe8;
}
.menu-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 99px;
  background: rgba(18, 12, 10, 0.34);
  color: #f3efe8;
  border: 1px solid rgba(255, 232, 210, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 22px rgba(18, 8, 4, 0.22), inset 0 1px 0 rgba(255, 244, 230, 0.18);
  font-weight: 700;
  font-size: 15px;
}
.chip img { width: 22px; height: 22px; object-fit: contain; }
.chip-gold { color: #ffd166; }
.icon-btn {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 232, 210, 0.28);
  border-radius: 12px;
  background: rgba(18, 12, 10, 0.34);
  color: #f3efe8;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 20px rgba(18, 8, 4, 0.2), inset 0 1px 0 rgba(255, 244, 230, 0.16);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.12s ease-out, background 0.2s;
}
.icon-btn:active { transform: scale(0.97); background: rgba(40, 22, 14, 0.55); }

.menu-hero { padding: 12px 8px 0; }
.menu-hero .eyebrow {
  font-size: 16px;
  color: #ffe29a;
  text-shadow: 0 2px 10px rgba(18, 8, 4, 0.7), 0 0 18px rgba(255, 196, 90, 0.35);
}
.menu-hero h1 {
  font-size: 54px;
  background: linear-gradient(180deg, #ffffff 0%, #ffe7d2 42%, #ffb089 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 196, 92, 0.5)) drop-shadow(0 5px 14px rgba(16, 8, 4, 0.68));
}
.best-line {
  margin: 14px 0 0;
  color: #ffe8c8;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(18, 8, 4, 0.72), 0 0 14px rgba(255, 180, 80, 0.28);
}
.best-line strong { color: #ffd166; font-size: 1.08em; }

.menu-actions { display: flex; flex-direction: column; gap: 12px; }
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 48px;
  padding: 0 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  transition: transform 0.12s ease-out, filter 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid #ffd166; outline-offset: 3px; }
.btn-primary {
  background: linear-gradient(115deg, #ff8a3d, #ff4458);
  color: #fff8f4;
  box-shadow: 0 10px 24px rgba(255, 77, 70, 0.28);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-xl { min-height: 56px; font-size: 18px; width: 100%; }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.08);
  width: 100%;
  margin-top: 8px;
}
.btn.danger, .btn-ghost.danger { color: #ff5d6c; }
.btn-primary.danger {
  background: linear-gradient(115deg, #ff5d6c, #c93448);
  color: #fff8f4;
}

.tile {
  position: relative;
  border: 1px solid rgba(255, 232, 210, 0.26);
  background: rgba(16, 12, 10, 0.32);
  color: #f3efe8;
  border-radius: 14px;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 10px 26px rgba(18, 8, 4, 0.24), inset 0 1px 0 rgba(255, 244, 230, 0.16);
  transition: transform 0.2s var(--ease);
}
.tile:active { transform: scale(0.97); }
.tile-ico { font-size: 22px; line-height: 1; }
.badge {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #ff4458;
  color: #fff;
  font-size: 11px;
  display: grid;
  place-items: center;
}

.sheet-screen {
  background: linear-gradient(180deg, rgba(14,16,24,0.55) 0%, #12141c 28%);
  color: #f3efe8;
  padding: 12px 16px 32px;
}
.sheet-head {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.sheet-head h2 {
  margin: 0;
  text-align: center;
  font-size: 18px;
  letter-spacing: -0.02em;
  color: #f3efe8;
}
.back-btn svg { transform: scaleX(-1); }
.sheet-hint { margin: -4px 0 16px; color: #9aa3b8; font-size: 13px; line-height: 1.6; }

.char-list, .stack, .shop-pane { display: flex; flex-direction: column; gap: 10px; }
.char-card, .shop-card, .mission-card, .ach-card {
  background: #1c2030;
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.char-swatch {
  width: 52px; height: 52px; border-radius: 14px; flex: 0 0 auto;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
}
.char-meta { flex: 1; min-width: 0; }
.char-meta h3, .shop-card h3, .mission-card h3 { margin: 0 0 4px; font-size: 16px; color: #f3efe8; }
.char-meta p, .shop-card p, .mission-card p { margin: 0; color: #9aa3b8; font-size: 13px; line-height: 1.5; }
.char-card.is-on { border-color: rgba(255,122,60,0.55); box-shadow: 0 0 0 1px rgba(255,122,60,0.35); }
.char-card button, .shop-card button, .mission-card button {
  flex: 0 0 auto;
  min-width: 92px;
}

.shop-ico {
  width: 48px; height: 48px; object-fit: contain; flex: 0 0 auto;
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: #1a1e2a;
  padding: 4px;
  border-radius: 12px;
}
.tab {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #9aa3b8;
  font-weight: 700;
  cursor: pointer;
}
.tab.is-on { background: #2a3144; color: #f3efe8; }

.sec-title {
  margin: 22px 0 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9aa3b8;
}
.streak-card {
  background: linear-gradient(120deg, #2a2118, #3a241c);
  color: #f3efe8;
  border: 1px solid rgba(255,209,102,0.18);
  border-radius: 16px;
  padding: 16px;
}
.streak-card h3 { margin: 0 0 6px; font-size: 18px; color: #ffd166; }
.streak-card p { margin: 0 0 12px; color: #c9bba8; font-size: 14px; line-height: 1.55; }
.progress {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff7a3c, #ff4458);
  border-radius: 99px;
  width: 0;
}
.mission-card.is-done { border-color: rgba(61,220,151,0.35); }
.ach-card.is-off { opacity: 0.55; }
.ach-lock { font-size: 20px; width: 36px; text-align: center; }

.settings-block {
  background: #1c2030;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  overflow: hidden;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 0 14px;
  color: #f3efe8;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: relative;
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch {
  width: 48px; height: 28px; border-radius: 99px;
  background: #3a4156;
  position: relative;
  flex: 0 0 auto;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; inset-inline-start: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #f3efe8;
  transition: transform 0.2s var(--ease);
}
.toggle-row input:checked + .switch { background: #ff7a3c; }
.toggle-row input:checked + .switch::after { transform: translateX(-20px); }
html[dir="rtl"] .toggle-row input:checked + .switch::after { transform: translateX(-20px); }

.howto {
  margin: 0;
  padding: 0 0 0 18px;
  color: #c5cbe0;
  font-size: 15px;
  line-height: 1.7;
}
.howto b { color: #ffd166; }
.howto-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 24px;
}
.howto-keys span {
  background: #1c2030;
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 0;
}
.stat-card {
  width: min(34vw, 132px);
  background: rgba(18,20,28,0.62);
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 14px;
  padding: 8px 10px;
}
.stat-card small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9aa3b8;
}
.stat-card strong {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 20px;
  font-family: "Cairo", sans-serif;
  letter-spacing: -0.02em;
  color: #f3efe8;
}
.stat-card strong img { width: 18px; height: 18px; }
.stat-mid { text-align: center; min-width: 0; flex: 1; }
.wave-pill {
  display: inline-block;
  background: rgba(255,122,60,0.18);
  color: #ffd4b8;
  border: 1px solid rgba(255,122,60,0.3);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}
#hud-dist { margin-top: 4px; font-size: 13px; color: #f3efe8; font-weight: 700; }
.pause-btn {
  pointer-events: auto;
  position: absolute;
  top: 78px;
  inset-inline-end: 10px;
}
.hud-pups {
  position: absolute;
  top: 78px;
  inset-inline-start: 10px;
  display: flex;
  gap: 8px;
}
.pup {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(18,20,28,0.7);
  border: 2px solid rgba(255,255,255,0.1);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}
.pup img { width: 26px; height: 26px; position: relative; z-index: 1; }
.pup::before {
  content: "";
  position: absolute; inset: 0;
  background: conic-gradient(#ff7a3c var(--p, 0%), transparent 0);
  opacity: 0.95;
}
.pup::after {
  content: "";
  position: absolute; inset: 4px;
  background: #161922;
  border-radius: 50%;
}
.combo-pop {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Cairo", sans-serif;
  font-weight: 900;
  font-size: 28px;
  color: #ffd166;
  text-shadow: 0 6px 18px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
}

.controls {
  position: fixed;
  z-index: 11;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 12px 14px;
  pointer-events: none;
}
.ctrl-cluster { display: flex; gap: 10px; pointer-events: auto; }
.ctrl-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(18,20,28,0.62);
  color: #f3efe8;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  transition: transform 0.12s ease-out, background 0.15s;
}
.ctrl-btn em {
  font-style: normal;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #d7dce8;
  margin-top: -2px;
}
.ctrl-btn:active, .ctrl-btn.is-down {
  transform: scale(0.94);
  background: rgba(255,122,60,0.55);
  color: #fff8f4;
}
.ctrl-action { width: 72px; height: 72px; background: rgba(255,122,60,0.28); }

.wave-banner {
  position: fixed;
  z-index: 15;
  top: 28%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border-radius: 99px;
  background: linear-gradient(115deg, #ff8a3d, #ff4458);
  color: #fff8f4;
  font-family: "Cairo", sans-serif;
  font-weight: 900;
  font-size: 24px;
  letter-spacing: -0.02em;
  box-shadow: 0 16px 40px rgba(255,70,60,0.35);
  pointer-events: none;
}
.pickup-float {
  position: fixed;
  z-index: 15;
  left: 50%;
  top: 42%;
  transform: translate(-50%, 0);
  color: #ffd166;
  font-weight: 800;
  font-size: 20px;
  pointer-events: none;
  text-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.go-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 16px;
}
.go-stats div {
  background: #161922;
  color: #f3efe8;
  border-radius: 12px;
  padding: 10px 6px;
}
.go-stats small { display: block; color: #9aa3b8; font-size: 11px; }
.go-stats strong { font-size: 18px; font-family: "Cairo", sans-serif; color: #f3efe8; }
.go-best { color: #ffd166 !important; font-weight: 700; min-height: 22px; }
.tut-steps { text-align: start; color: #c5cbe0; line-height: 1.7; padding-inline-start: 20px; }

.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1c2030;
  color: #f3efe8;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 99px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (min-width: 800px) {
  .menu-hero h1, .load-copy h1 { font-size: 70px; }
  .menu-screen, .sheet-screen { padding-inline: calc(50vw - 240px); }
  .ctrl-btn { width: 76px; height: 76px; }
}

@media (max-width: 389px) {
  .stat-card { width: 31vw; padding: 6px 8px; }
  .stat-card strong { font-size: 16px; }
  .ctrl-btn { width: 60px; height: 60px; }
  .ctrl-action { width: 64px; height: 64px; }
  .menu-hero h1 { font-size: 44px; }
}

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