:root {
  --gold: #e6bd5b;
  --glass: rgba(9, 20, 36, .66);
  --line: rgba(230, 189, 91, .45);
  --txt: #f7f1e1;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #0b1a2b; color: var(--txt);
  font-family: Tajawal, "Segoe UI", Tahoma, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

/* ---------- header ---------- */
.top {
  position: fixed; z-index: 5; inset-inline: 12px; top: max(10px, env(safe-area-inset-top));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none;
}
.who, .ttl {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}
.who { padding: 8px 20px; display: flex; flex-direction: column; line-height: 1.35; }
.who b { font-size: clamp(18px, 3.6vw, 26px); font-weight: 800; color: var(--gold); }
.who span { font-size: clamp(12px, 2.4vw, 15px); opacity: .9; }
.ttl { padding: 8px 16px; text-align: left; direction: rtl; line-height: 1.35; }
.ttl h1 { margin: 0; font-size: clamp(15px, 2.8vw, 20px); font-weight: 800; }
.ttl span { font-size: 12px; opacity: .8; }
.ttl time { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- 3D labels ---------- */
#labels { position: fixed; inset: 0; z-index: 3; pointer-events: none; overflow: hidden; }
.lbl {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; will-change: transform;
  font: 700 13px Tajawal, Tahoma, sans-serif; color: #fff; white-space: nowrap;
  background: var(--glass); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px 4px 10px;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; gap: 6px; transition: opacity .25s;
}
.lbl::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(230, 189, 91, .3); }
.lbl:hover, .lbl:focus-visible { background: rgba(230, 189, 91, .9); color: #1b1405; outline: none; }
.lbl.off { opacity: 0; pointer-events: none; }

/* ---------- info card ---------- */
#card {
  position: fixed; z-index: 6; bottom: calc(78px + env(safe-area-inset-bottom)); inset-inline: 12px; margin-inline: auto;
  max-width: 440px; padding: 16px 18px 16px 44px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35); animation: rise .35s ease both;
}
#card h2 { margin: 0 0 6px; font-size: 20px; color: var(--gold); }
#card p { margin: 0; font-size: 15px; line-height: 1.85; }
#card .x {
  position: absolute; top: 8px; left: 10px; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: transparent; color: var(--txt); font-size: 20px; line-height: 1; cursor: pointer;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- dock ---------- */
.dock {
  position: fixed; z-index: 6; bottom: max(12px, env(safe-area-inset-bottom)); inset-inline: 0; margin-inline: auto;
  width: fit-content; max-width: calc(100vw - 20px); display: flex; gap: 6px; padding: 6px;
  overflow-x: auto; scrollbar-width: none; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}
.dock::-webkit-scrollbar { display: none; }
.dock button {
  flex: none; font: 700 14px Tajawal, Tahoma, sans-serif; color: var(--txt); cursor: pointer;
  background: transparent; border: 0; border-radius: 99px; padding: 9px 14px; white-space: nowrap;
  transition: background .2s, color .2s;
}
.dock button:hover { background: rgba(255, 255, 255, .12); }
.dock button.on { background: var(--gold); color: #1b1405; }
.dock i { width: 1px; background: var(--line); margin: 6px 2px; flex: none; }

#hint {
  position: fixed; z-index: 4; top: 50%; inset-inline: 0; margin: 0 auto; width: fit-content; pointer-events: none;
  background: var(--glass); border: 1px solid var(--line); border-radius: 99px; padding: 8px 18px; font-size: 14px;
  transition: opacity .8s; transform: translateY(120px);
}
#hint.gone { opacity: 0; }
.note { position: fixed; z-index: 2; bottom: 14px; inset-inline-start: 14px; font-size: 12px; opacity: .65; }

/* ---------- loader ---------- */
#loader {
  position: fixed; z-index: 20; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(circle at 50% 40%, #16355c, #0b1a2b 70%); transition: opacity .6s;
}
#loader.done { opacity: 0; pointer-events: none; }
#loader i { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(230, 189, 91, .25); border-top-color: var(--gold); animation: spin 1s linear infinite; }
#loader p { margin: 0; font-size: 17px; max-width: 80vw; text-align: center; line-height: 1.7; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .ttl span { display: none; }
  .ttl { padding: 8px 14px; }
  .dock button { padding: 9px 12px; font-size: 13px; }
}
@media (max-width: 900px) { .note { display: none; } }
/* wide screens: keep the card off the 3D focus point */
@media (min-width: 901px) { #card { inset-inline: auto 18px; margin-inline: 0; width: 360px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
