@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;700;800;900&display=swap");

/* ============================================================= */
/* SPL Cosmic Theme                                               */
/* Shared styling inspired by the SPL Blood experience           */
/* ============================================================= */
:root {
  --brand: #00d4e8;        /* Bright Cyan */
  --ink: #0a1628;          /* Deep navy blue */

  --brand-100: #e6f9fd;
  --brand-200: #b3f0f9;
  --brand-300: #80e7f5;
  --brand-400: #4ddef1;
  --brand-600: #00bdd4;
  --brand-700: #00a6bf;

  --ink-700: #0d1f36;
  --ink-800: #091324;
  --ink-900: #050b16;

  --paper: #ffffff;
  --paper-2: #f0f8fa;

  --radius: 16px;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(0, 212, 232, 0.4);
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

/* ====== Base Reset ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
html {
  font-family: "Noto Sans Arabic", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
}
body {
  margin: 0;
  padding: 12px;
  font-family: inherit;
  background: linear-gradient(180deg, #050b16, #0a1628 50%, #050b16);
  background-attachment: fixed;
  color: var(--paper);
  text-align: center;
  position: relative;
  overflow-x: hidden;
}
body > * {
  position: relative;
  z-index: 2;
}
button, input, select, textarea { font: inherit; }
::placeholder { font-family: inherit; }
button { touch-action: manipulation; }

/* ====== Starfield Backdrop ====== */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20% 30%, white, transparent),
    radial-gradient(2px 2px at 60% 70%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(255,255,255,0.7), transparent),
    radial-gradient(2px 2px at 90% 60%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 33% 80%, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 15% 90%, rgba(255,255,255,0.4), transparent);
  background-size: 200% 200%, 150% 150%, 300% 300%, 250% 250%, 180% 180%, 220% 220%, 280% 280%;
  background-position: 0% 0%, 20% 20%, 40% 40%, 60% 60%, 80% 80%, 10% 90%, 70% 30%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.6;
  animation: twinkle 120s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

/* ====== Decorative Globe ====== */
.globe-decoration {
  position: fixed;
  bottom: -50px;
  right: -50px;
  width: 350px;
  height: 350px;
  z-index: 0;
  opacity: 0.6;
  pointer-events: none;
  animation: float-globe 6s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(0, 212, 232, 0.3));
}
.globe-decoration img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: rotate-slow 60s linear infinite;
  display: block;
}

@keyframes float-globe {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(5deg); }
}

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
  .globe-decoration {
    width: 250px;
    height: 250px;
    bottom: -30px;
    right: -30px;
  }
}

/* ====== Branding ====== */
.navbar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 calc(12px + env(safe-area-inset-left, 0px)) 0 calc(12px + env(safe-area-inset-right, 0px));
  z-index: 25;
  pointer-events: none;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}
/* First brand-lockup (SPL) always stays on left */
.navbar .brand-lockup:first-child {
  position: absolute;
  left: calc(12px + env(safe-area-inset-left, 0px));
  right: auto !important;
}
/* Second brand-lockup (UPU) always stays on right */
.navbar .brand-lockup:last-child {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right, 0px));
  left: auto !important;
}
.logo {
  width: 120px;
  height: auto;
  filter: drop-shadow(0 0 15px rgba(0, 212, 232, 0.4)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.2));
  animation: logo-pulse 3s ease-in-out infinite;
}
.logo-upu {
  width: 190px;
  height: auto;
  filter: drop-shadow(0 0 10px rgba(0, 212, 232, 0.3)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

@keyframes logo-pulse {
  0%, 100% {
    filter: drop-shadow(0 0 15px rgba(0, 212, 232, 0.4)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.2));
  }
  50% {
    filter: drop-shadow(0 0 25px rgba(0, 212, 232, 0.6)) drop-shadow(0 2px 10px rgba(0, 0, 0, 0.2));
  }
}

.hero {
  display: grid;
  gap: 6px;
  margin: 24px 0 8px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 900;
  letter-spacing: 0.2px;
}
.hero p {
  margin: 0;
  color: var(--brand-300);
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* ====== Buttons ====== */
.btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 16px 18px;
  font-weight: 900;
  cursor: pointer;
  transition: 0.2s ease;
  width: 100%;
  max-width: 520px;
  color: inherit;
  background: rgba(0, 20, 40, 0.4);
}
.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.btn.primary {
  background: var(--brand);
  color: var(--ink-900);
  box-shadow: 0 0 30px rgba(0, 212, 232, 0.4);
}
.btn.primary:disabled,
.btn.primary[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
.btn.primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 0 40px rgba(0, 212, 232, 0.6), 0 5px 20px rgba(0, 0, 0, 0.3);
}
.btn.ghost {
  background: rgba(0, 212, 232, 0.1);
  color: var(--brand-200);
  border-color: rgba(0, 212, 232, 0.4);
}
.btn.ghost:hover {
  border-color: var(--brand);
  box-shadow: 0 0 20px rgba(0, 212, 232, 0.3);
  background: rgba(0, 212, 232, 0.2);
}

/* ====== Bottom Navigation (Language Toggle) ====== */
.bottom-nav {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: calc(12px + env(safe-area-inset-left, 0px));
  z-index: 30;
  pointer-events: none;
}
.bottom-nav > * {
  pointer-events: auto;
}

/* Hide back/home link */
.back-link {
  display: none !important;
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 232, 0.35);
  background: rgba(0, 212, 232, 0.14);
  color: var(--brand-200);
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(0, 212, 232, 0.16);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  pointer-events: auto;
}
.lang-toggle:hover {
  background: rgba(0, 212, 232, 0.22);
  box-shadow: 0 10px 34px rgba(0, 212, 232, 0.24), 0 6px 16px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}
.lang-toggle:focus-visible {
  outline: none;
  box-shadow: var(--ring), 0 6px 28px rgba(0, 212, 232, 0.16);
}
.back-link:focus-visible {
  outline: none;
  box-shadow: var(--ring), 0 6px 28px rgba(0, 212, 232, 0.16);
}
.back-link__icon {
  font-size: 1.05rem;
  line-height: 1;
}
.back-link__label {
  font-size: 0.95rem;
}

@media (max-width: 560px) {
  .back-link {
    gap: 6px;
    padding: 9px 12px;
    font-size: 0.9rem;
  }
  .back-link__icon {
    font-size: 1rem;
  }
  .logo {
    width: 100px;
  }
  .logo-upu {
    width: 90px;
  }
}

/* ====== Progress ====== */
.progress-wrap {
  width: 100%;
  max-width: 820px;
  margin: 6px auto 14px;
  display: grid;
  gap: 8px;
}
.progress-bar {
  width: 100%;
  height: 10px;
  background-color: rgba(0, 30, 50, 0.6);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(0, 212, 232, 0.2);
}
.progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-400));
  transition: width 0.35s ease;
}
.progress-label {
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--brand-300);
  font-size: 0.95rem;
}

/* ====== Cards ====== */
.grid {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 820px;
  grid-template-columns: repeat(1, minmax(0, 1fr));
}
.card {
  background: rgba(0, 20, 40, 0.6);
  border: 2px solid rgba(0, 212, 232, 0.3);
  border-radius: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: 0.3s ease;
  overflow: hidden;
  color: var(--paper);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 212, 232, 0.1);
  text-decoration: none;
}
.card:hover {
  transform: translateY(-3px);
  border-color: var(--brand);
  box-shadow: 0 12px 40px rgba(0, 212, 232, 0.25), inset 0 0 20px rgba(0, 212, 232, 0.1);
}
.card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 30px rgba(0, 212, 232, 0.5), var(--ring);
  background: rgba(0, 212, 232, 0.15);
}
.card .emoji { font-size: 1.8rem; }
.card .label { font-weight: 900; color: var(--brand-200); }
.card .hint {
  color: #9fd;
  opacity: 0.85;
  font-size: 0.9rem;
}

/* ====== Panels & Surfaces ====== */
.panel {
  width: 100%;
  max-width: 820px;
  background: rgba(0, 20, 40, 0.6);
  border: 2px solid rgba(0, 212, 232, 0.3);
  border-radius: 16px;
  padding: 16px;
  margin: 8px auto;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 212, 232, 0.15);
  text-align: center;
}
.panel-title {
  margin: 0 0 12px;
  font-weight: 900;
  color: var(--brand-200);
  font-size: 1.15rem;
  text-shadow: 0 0 15px rgba(0, 212, 232, 0.4);
}
.panel-subtle {
  color: #d2ebef;
  opacity: 0.9;
}

/* ====== Chips & Badges ====== */
.timer-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(0, 212, 232, 0.15);
  border: 1px solid rgba(0, 212, 232, 0.4);
  font-weight: 900;
  color: var(--brand-200);
  box-shadow: 0 0 20px rgba(0, 212, 232, 0.2);
}

.badge {
  display: inline-block;
  font-weight: 900;
  font-size: 0.8rem;
  padding: 6px 8px;
  border-radius: 999px;
  color: var(--ink-900);
  background: var(--brand-300);
}
.badge.danger { color: #fff; background: #d94b4b; }
.badge.ok { color: #0d3; background: #c8f7d1; }

/* ====== Modals ====== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 130;
  background: rgba(12, 24, 26, 0.6);
  backdrop-filter: blur(4px);
}
.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: linear-gradient(180deg, rgba(10, 22, 40, 0.95), rgba(5, 11, 22, 0.95));
  color: var(--paper);
  width: min(92%, 560px);
  margin: 0;
  padding: 22px;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 212, 232, 0.2);
  border: 2px solid rgba(0, 212, 232, 0.4);
  backdrop-filter: blur(15px);
}
.modal-content.welcome { border-color: transparent; }
.close-btn {
  position: absolute;
  left: 12px;
  top: 10px;
  background: transparent;
  border: none;
  color: var(--brand-300);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  border-radius: 8px;
}
.close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.welcome-title {
  margin: 6px 0 8px;
  font-weight: 900;
  color: var(--brand-200);
  text-shadow: 0 0 20px rgba(0, 212, 232, 0.5);
  font-size: 1.8rem;
}
.welcome-text {
  line-height: 1.9;
  font-weight: 700;
  margin: 8px 0 18px;
  color: var(--brand-200);
}

/* ====== Utility ====== */
.result-text {
  font-size: 1.1rem;
  margin: 12px 0 10px;
  color: var(--brand-200);
}
.state-danger {
  border: 2px dashed #ff6460;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 100, 96, 0.08);
  color: #ffdede;
  margin-top: 10px;
}

.actions {
  width: 100%;
  max-width: 820px;
  margin: 12px auto 6px;
  display: grid;
  place-items: center;
  gap: 10px;
}

@media (max-width: 768px) {
  .logo {
    width: 120px;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    padding: 0;
  }
  nav,
  .progress-wrap,
  .btn,
  .modal,
  .close-btn {
    box-shadow: none !important;
  }
}
