:root {
  --navy: #0b1d3a;
  --navy-2: #12294f;
  --gold: #ffc247;
  --sky: #63b7f5;
  --green: #35d07f;
  --red: #ff5c72;
  --text: #f3f7ff;
  --radius: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, sans-serif;
  line-height: 1.7;
  overscroll-behavior: none;
}

#game { position: fixed; inset: 0; }

canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* ============ HUD ============ */
.hud {
  position: absolute;
  inset-inline: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px clamp(10px, 2vw, 20px);
  padding-top: max(10px, env(safe-area-inset-top));
  flex-wrap: nowrap;
  pointer-events: none;
}

.hud-box {
  background: rgba(11, 29, 58, .62);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.hud-label { font-size: 12px; opacity: .78; white-space: nowrap; }

.score-box strong {
  font-family: "Baloo Bhaijaan 2", system-ui, sans-serif;
  font-size: 22px;
  color: var(--gold);
  letter-spacing: .5px;
}

.seats { display: flex; gap: 4px; }
.seat {
  width: 12px; height: 16px; border-radius: 4px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .25);
  transition: background .15s, transform .15s;
}
.seat.on { background: var(--green); transform: translateY(-2px); border-color: #9cf3c8; }

.fuel {
  width: clamp(70px, 16vw, 130px); height: 12px;
  background: rgba(255, 255, 255, .18);
  border-radius: 99px; overflow: hidden;
}
.fuel-fill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, #ffd479, #ff9f43);
  border-radius: 99px;
  transition: width .2s linear, background .3s;
}
.fuel-fill.low { background: linear-gradient(90deg, #ff8080, #ff4d6d); }

.lives { display: flex; gap: 4px; font-size: 16px; line-height: 1; }
.lives span { filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.lives span.off { opacity: .25; filter: grayscale(1); }

.icon-btn {
  pointer-events: auto;
  margin-inline-start: auto;
  width: 42px; height: 42px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(11, 29, 58, .62);
  backdrop-filter: blur(8px);
  color: #fff; font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.icon-btn + .icon-btn { margin-inline-start: 0; }
.icon-btn:active { transform: scale(.94); }

/* ============ الرسايل ============ */
.toast {
  position: absolute;
  inset-inline: 0;
  top: 22%;
  text-align: center;
  font-family: "Baloo Bhaijaan 2", system-ui, sans-serif;
  font-size: clamp(20px, 5vw, 34px);
  color: #fff;
  text-shadow: 0 4px 14px rgba(0, 0, 0, .55);
  pointer-events: none;
  animation: pop .45s ease;
}
@keyframes pop {
  0% { transform: scale(.7) translateY(12px); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ============ الشاشات ============ */
.screen {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(120% 100% at 50% 0%, rgba(18, 41, 79, .82), rgba(5, 13, 28, .93));
  backdrop-filter: blur(3px);
  z-index: 5;
  overflow: auto;
}

.card {
  width: min(560px, 100%);
  background: linear-gradient(180deg, rgba(23, 47, 86, .96), rgba(11, 25, 48, .96));
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 32px);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  margin: auto;
}
.card.small { width: min(360px, 100%); }

.logo { font-size: clamp(42px, 10vw, 62px); line-height: 1; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-9px) } }

h1, h2 {
  font-family: "Baloo Bhaijaan 2", system-ui, sans-serif;
  font-size: clamp(26px, 6vw, 40px);
  margin: 6px 0 4px;
  color: var(--gold);
}

.tag { opacity: .85; font-size: clamp(14px, 3.4vw, 16px); max-width: 44ch; margin: 0 auto; }

.how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 20px 0;
  text-align: start;
}
.how-item {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon title" "icon desc";
  gap: 0 10px;
  align-items: center;
}
.how-item span { grid-area: icon; font-size: 24px; }
.how-item b { grid-area: title; color: #fff; font-size: 14px; }
.how-item small { grid-area: desc; opacity: .75; font-size: 12.5px; line-height: 1.5; }

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 20px;
  font-family: "Baloo Bhaijaan 2", system-ui, sans-serif;
  font-size: 19px;
  cursor: pointer;
  transition: transform .12s, filter .2s;
  margin-top: 10px;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, #ffd06b, #f5a623); color: #3a2400; box-shadow: 0 10px 24px rgba(245, 166, 35, .28); }
.btn.ghost { background: rgba(255, 255, 255, .08); color: #fff; border: 1px solid rgba(255, 255, 255, .16); }

.best { margin-top: 12px; font-size: 14px; opacity: .7; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0 6px;
}
.stats div {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  padding: 12px 6px;
}
.stats span { display: block; font-size: 12px; opacity: .75; }
.stats strong { font-family: "Baloo Bhaijaan 2", system-ui, sans-serif; font-size: 24px; color: var(--gold); }

@media (max-width: 560px) {
  .hud-label { display: none; }
  .hud { gap: 5px; padding: 7px; }
  .hud-box { padding: 5px 8px; min-height: 34px; border-radius: 11px; }
  .score-box strong { font-size: 18px; }
  .seat { width: 8px; height: 12px; border-radius: 3px; }
  .seats { gap: 3px; }
  .fuel { width: 52px; height: 9px; }
  .lives { font-size: 12px; gap: 2px; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; border-radius: 11px; }
}
@media (max-width: 380px) {
  .lives-box { display: none; }
}
