@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
  /* Ministry of Hajj and Umrah Theme */
  --bg-primary: #F5EFE6;
  --bg-secondary: #EBE4DA;
  --bg-card: #FFFFFF;
  --border-subtle: #DCD2C3;
  --border-focus: #C89B60;
  
  --accent: #C89B60; /* Gold */
  --accent-hover: #B48850;
  --accent-surface: #FDF9F1;
  
  --success: #2A7B6B;
  --danger: #D34545;
  
  --gold: #C89B60;
  --silver: #9BA0A6;
  --bronze: #C48247;

  --text-main: #113D36; /* Dark Green */
  --text-muted: #4B5563;
  --text-faint: #9CA3AF;
  
  --brand-primary: #113D36;
  --brand-dark: #0C2E28;

  --font: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-tech: 'Cairo', sans-serif;
  
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 4px 16px rgba(17,61,54,0.08);
  --shadow-lg: 0 8px 32px rgba(17,61,54,0.12);
  
  /* Gold gradient for buttons */
  --gold-gradient: linear-gradient(135deg, #D4A964 0%, #C89B60 50%, #B48850 100%);
  --green-gradient: linear-gradient(135deg, #1A4A40 0%, #113D36 50%, #0C2E28 100%);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: var(--bg-primary);
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-main);
  direction: ltr;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  position: relative;
}

/* ===== ORNAMENTAL TOP BORDER ===== */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gold-gradient);
  z-index: 9999;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ===== APP CONTAINER ===== */
#app {
  position: relative;
  z-index: 1;
  max-width: 500px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* ===== WIDE SCREEN LAYOUT ===== */
@media (min-width: 768px) {
  #app {
    max-width: 700px;
  }
}

@media (min-width: 1200px) {
  #app {
    max-width: 860px;
  }
}

/* ===== JOIN SCREEN ===== */
.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 24px;
  text-align: center;
  animation: fadeIn 0.4s ease-out;
  position: relative;
}

.brand-logo-tl {
  position: fixed;
  left: 20px;
  top: 20px;
  height: 48px;
  max-width: 120px;
  object-fit: contain;
  z-index: 100;
}

.join-logo {
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: var(--shadow);
}

.join-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--brand-primary);
}

.join-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
  line-height: 1.6;
}

.join-input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 16px;
  text-align: center;
  outline: none;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.join-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,155,96,0.15);
}

.join-input::placeholder {
  color: var(--text-faint);
}

.join-btn {
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--gold-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(200,155,96,0.3);
}

.join-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(200,155,96,0.4);
}

.join-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.join-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.join-count {
  margin-top: 24px;
  color: var(--text-faint);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.join-count .dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
}

/* ===== HEADER ===== */
.app-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 4px; /* below the ornamental border */
  z-index: 50;
  background: rgba(245,239,230,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.header-logo {
  height: 38px;
  max-width: 90px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary);
}

.header-info {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-info .dot {
  width: 5px;
  height: 5px;
  background: var(--success);
  border-radius: 50%;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  padding: 24px 20px 100px;
  overflow-y: auto;
}

/* ===== SECTIONS ===== */
.section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.section.active {
  display: block;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 50px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent-surface);
  color: var(--accent);
  margin-bottom: 16px;
  border: 1px solid rgba(200,155,96,0.3);
}

/* ===== POLL OPTIONS ===== */
.poll-question {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 24px;
  line-height: 1.5;
  color: var(--brand-primary);
}

.poll-option {
  position: relative;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.poll-option:hover:not(.disabled) {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(200,155,96,0.15);
}

.poll-option.voted {
  border-color: var(--accent);
  background: var(--accent-surface);
}

.poll-option.disabled {
  cursor: default;
  pointer-events: none;
}

.poll-option-bar {
  position: absolute;
  inset: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(200,155,96,0.12) 0%, rgba(200,155,96,0.06) 100%);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.poll-option-content {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.poll-option-text {
  font-size: 15px;
  font-weight: 500;
}

.poll-option-pct {
  font-family: var(--font-tech);
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-primary);
  opacity: 0;
  transition: var(--transition);
}

.poll-option.show-results .poll-option-pct {
  opacity: 1;
}

.poll-total {
  text-align: center;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ===== QUIZ ===== */
.quiz-header {
  text-align: center;
  margin-bottom: 24px;
}

.quiz-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
}

.quiz-progress-dot {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--border-subtle);
  transition: var(--transition);
}

.quiz-progress-dot.done {
  background: var(--accent);
}

.quiz-progress-dot.current {
  background: var(--text-muted);
}

.quiz-timer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.quiz-timer-circle {
  width: 72px;
  height: 72px;
  position: relative;
}

.quiz-timer-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.quiz-timer-circle .track {
  fill: none;
  stroke: var(--border-subtle);
  stroke-width: 4;
}

.quiz-timer-circle .fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 226;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

.quiz-timer-circle .fill.danger {
  stroke: var(--danger);
}

.quiz-timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-tech);
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-primary);
}

.quiz-timer-num.danger {
  color: var(--danger);
}

.quiz-question-text {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 24px;
  line-height: 1.5;
}

.quiz-option {
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.quiz-option:hover:not(.disabled) {
  border-color: var(--accent);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: var(--accent-surface);
}

.quiz-option.correct {
  border-color: var(--success);
  background: #E8F5F0;
}

.quiz-option.wrong {
  border-color: var(--danger);
  background: #FDECEC;
}

.quiz-option.disabled {
  pointer-events: none;
}

.quiz-option.reveal-correct {
  border-color: var(--success);
}

.quiz-feedback {
  text-align: center;
  padding: 20px;
  margin-top: 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  animation: fadeIn 0.3s ease;
  box-shadow: var(--shadow);
}

.quiz-feedback.correct {
  border-color: var(--success);
  background: #E8F5F0;
}

.quiz-feedback.wrong {
  border-color: var(--danger);
  background: #FDECEC;
}

.quiz-feedback .points {
  font-family: var(--font-tech);
  font-size: 24px;
  font-weight: 700;
  margin-top: 8px;
  display: block;
  color: var(--accent);
}

.quiz-waiting {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 15px;
}

.quiz-waiting .icon {
  font-size: 40px;
  margin-bottom: 16px;
  display: block;
}

/* ===== LEADERBOARD ===== */
.leaderboard-list {
  list-style: none;
}

.lb-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.lb-item.rank-1 { border-color: var(--gold); background: var(--accent-surface); }
.lb-item.rank-2 { border-color: var(--silver); }
.lb-item.rank-3 { border-color: var(--bronze); }

.lb-rank {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-family: var(--font-tech);
  font-size: 14px;
  font-weight: 700;
  background: var(--bg-primary);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.rank-1 .lb-rank { background: var(--gold); color: #FFFFFF; border-color: var(--gold); }
.rank-2 .lb-rank { background: var(--silver); color: #FFFFFF; border-color: var(--silver); }
.rank-3 .lb-rank { background: var(--bronze); color: #FFFFFF; border-color: var(--bronze); }

.lb-name {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

.lb-score {
  font-family: var(--font-tech);
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary);
}

.lb-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-faint);
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.lb-myscore {
  text-align: center;
  padding: 20px;
  margin-bottom: 24px;
  background: var(--bg-card);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  box-shadow: var(--shadow);
}

.lb-myscore .score-val {
  font-family: var(--font-tech);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-top: 8px;
}

/* ===== Q&A ===== */
.qna-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.qna-anon-label {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-faint);
  cursor: pointer;
  user-select: none;
}

.qna-input {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.qna-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,155,96,0.15);
}

.qna-input::placeholder {
  color: var(--text-faint);
}

.qna-submit {
  padding: 14px 20px;
  background: var(--gold-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(200,155,96,0.25);
}

.qna-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(200,155,96,0.35);
}

.qna-list {
  list-style: none;
}

.qna-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.qna-item.top-question {
  border-color: var(--accent);
  background: var(--accent-surface);
}

.qna-vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  min-width: 48px;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  font-family: var(--font-tech);
  font-size: 13px;
  font-weight: 700;
}

.qna-vote-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.qna-vote-btn.upvoted {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-surface);
}

.qna-vote-btn .arrow {
  font-size: 14px;
}

.qna-content {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.qna-text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 6px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
}

.qna-author {
  font-size: 12px;
  color: var(--text-faint);
}

.qna-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-faint);
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}

@media (min-width: 501px) {
  .bottom-nav {
    left: 0;
    right: 0;
    margin: 0 auto;
    max-width: 500px;
  }
}

@media (min-width: 768px) {
  .bottom-nav {
    max-width: 700px;
  }
}

@media (min-width: 1200px) {
  .bottom-nav {
    max-width: 860px;
  }
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.nav-item:hover {
  color: var(--text-muted);
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  width: 24px;
  height: 24px;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.nav-label {
  font-size: 12px;
  font-weight: 600;
}

/* ===== STATUS MESSAGES ===== */
.status-msg {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.status-msg .icon {
  font-size: 32px;
  display: block;
  margin-bottom: 16px;
  color: var(--accent);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}