@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@300;400;500;700;800;900&display=swap");

/* =============== */
/* Brand variables */
/* =============== */
: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 ====== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Noto Sans Arabic", system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  background: linear-gradient(180deg, #050b16, #0a1628 50%, #050b16);
  background-attachment: fixed;
  color: var(--paper);
  margin: 0;
  padding: calc(80px + env(safe-area-inset-top)) 12px calc(70px + env(safe-area-inset-bottom)) 12px;
  text-align: center;
  position: relative;
  overflow-x: hidden;
}
/* Starfield effect */
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; }
}
body > * {
  position: relative;
  z-index: 2;
}

html { font-family: "Noto Sans Arabic", system-ui, -apple-system, Segoe UI, Arial, sans-serif }
button, input, select, textarea { font: inherit }
::placeholder { font-family: inherit }
button { touch-action: manipulation; }

/* Brand / Nav styles removed - now using shared theme.css */

/* ====== Layout & Progress ====== */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.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;
}

/* ====== 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;
}
.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);
}

/* ====== Question & Grid ====== */
.question {
  font-size: 1.35rem;
  margin: 6px 0 10px;
  color: var(--brand-200);
  font-weight: 900;
  text-shadow: 0 0 20px rgba(0, 212, 232, 0.5), 0 0 40px rgba(0, 212, 232, 0.3);
}
.helper {
  margin: 0 0 12px;
  font-size: 0.98rem;
  color: #d2ebef;
  opacity: 0.95;
}

.grid {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 820px;
  grid-template-columns: 1fr;
  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;
  /* Fill the full viewport height */
  height: 20vh;
  overflow: auto;
  color: var(--paper);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 212, 232, 0.1);

}
.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); }

/* ====== Inline actions ====== */
.actions {
  width: 100%;
  max-width: 820px;
  margin: 12px auto 4px;
  display: grid;
  place-items: center;
}

/* ====== Panels / Dashboard ====== */
.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);
}
.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);
}

.controls-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
@media (min-width: 680px) {
  .controls-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.control {
  background: rgba(0, 30, 50, 0.5);
  border: 2px solid rgba(0, 212, 232, 0.25);
  border-radius: 14px;
  padding: 12px;
  text-align: start;
  backdrop-filter: blur(5px);
}
.control h4 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--brand-300);
}
.control .hint {
  font-size: 0.85rem;
  color: #d2ebef;
  opacity: 0.9;
  margin-bottom: 8px;
}
.row { display: flex; align-items: center; gap: 10px; }
.range { width: 100%; accent-color: var(--brand); }

.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; }

.select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 2px solid rgba(0, 212, 232, 0.25);
  background: rgba(0, 30, 50, 0.5);
  color: var(--paper);
  font-weight: 800;
}

/* ====== Timer chip ====== */
.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);
}

/* ====== 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);
}
.instructions-text {
  color: #ffffff;
}

/* ====== Result text ====== */
.result-text {
  font-size: 1.1rem;
  margin: 12px 0 10px;
  color: var(--brand-200);
}

/* ====== Success Ticket (truck style) ====== */
.ticket-wrap {
  display: grid;
  place-items: center;
  margin: 12px auto 6px;
  max-width: 520px;
}
.ticket {
  position: relative;
  background: #fff;
  color: #122;
  width: 100%;
  aspect-ratio: 7/3;
  border-radius: 16px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}
.ticket:before,
.ticket:after {
  content: "";
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  background: var(--ink-800);
  border-radius: 50%;
  transform: translateY(-50%);
}
.ticket:before { right: -11px; }
.ticket:after { left: -11px; }

.ticket .body {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 12px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f7f7f7);
}
.ticket .stamp {
  border-left: 2px dashed #d7d7d7;
  display: grid;
  place-items: center;
  padding-left: 14px;
}
.ticket .stamp i {
  font-size: 48px;
  color: var(--brand-700);
  animation: truck-bump 1.6s ease infinite;
}
@keyframes truck-bump {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-4px); }
}
.ticket .title {
  font-weight: 900;
  font-size: 1.05rem;
  color: #0e4c50;
  margin: 0 0 6px;
}
.ticket .subtitle { font-weight: 800; color: #188; margin: 0; }
.ticket .brand-line {
  height: 6px;
  background: linear-gradient(90deg, var(--brand), var(--brand-400));
}

/* ====== States ====== */
.state-danger {
  border: 2px dashed #ff6460;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 100, 96, 0.08);
  color: #ffdede;
  margin-top: 10px;
}

/* ====== Print ====== */
@media print {
  body { background: #fff; color: #000; padding: 0; }
  nav, .progress-wrap, #game-container, .close-btn, .btn { display: none !important; }
  .modal { position: static; background: #fff; }
  .modal-content {
    border: none;
    box-shadow: none;
    width: 100%;
    margin: 0;
    padding: 0;
    background: transparent;
    color: #000;
  }
}
/* ====== Fancy Select (Custom Dropdown) ====== */
.select-wrap {
  position: relative;
  width: 100%;
}

.select-native {
  position: absolute !important;
  inset-inline-start: 0;
  inset-block-start: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Trigger (button that shows current value) */
.select-trigger {
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(0, 212, 232, 0.25);
  background: rgba(0, 30, 50, 0.5);
  color: var(--paper);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  transition: 0.2s ease;
}
.select-trigger:focus-visible { outline: none; box-shadow: var(--ring); }
.select-trigger:hover { border-color: var(--brand); }

.select-trigger .value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.select-trigger .chev {
  font-size: 0.95rem;
  opacity: 0.9;
  transition: transform .2s ease;
}

/* Menu */
.select-menu {
  position: absolute;
  z-index: 50;
  inset-inline: 0;
  /* Open upwards above the trigger */
  bottom: calc(100% + 8px);
  background: linear-gradient(180deg, rgba(10, 22, 40, 0.95), rgba(5, 11, 22, 0.95));
  border: 2px solid rgba(0, 212, 232, 0.4);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 212, 232, 0.2);
  padding: 6px;
  display: none;
  max-height: 240px;
  overflow: auto;
  backdrop-filter: blur(15px);
}
.select-wrap.open .select-menu { display: block; }
.select-wrap.open .chev { transform: rotate(180deg); }

/* Option */
.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--paper);
  background: transparent;
  border: 1px solid transparent;
  user-select: none;
}
.select-option:hover,
.select-option[aria-selected="true"] {
  background: rgba(0, 212, 232, 0.15);
  border-color: rgba(0, 212, 232, 0.4);
}
.select-option .tick {
  font-size: 0.95rem;
  color: var(--brand-400);
  visibility: hidden;
}
.select-option[aria-selected="true"] .tick {
  visibility: visible;
}

/* Keyboard focus item */
.select-option[data-focus="true"] {
  outline: none;
  box-shadow: var(--ring);
}

/* Ensure dropdown overlays nicely within .panel */
.control { position: relative; overflow: visible; }