:root {
  --bg: #0b1130;
  --bg-soft: #131a45;
  --card-bg: #1a2358;
  --card-bg-2: #212c68;
  --gold: #d9b25c;
  --gold-light: #f0dca4;
  --text: #f4f2ea;
  --text-muted: #a9b0d4;
  --border: #2c3670;
  --danger: #e57373;
  --success: #7fd99a;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }

.hidden { display: none !important; }
.screen { display: none; }
.screen.active { display: block; }

/* ---------- LOADING ---------- */
#screen-loading.active { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.loading-box { text-align: center; color: var(--text-muted); }
.spinner {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 4px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- ONBOARDING ---------- */
#screen-onboarding.active { display: flex; align-items: center; min-height: 100vh; padding: 24px 20px; }
.onboarding-card {
  background: var(--card-bg); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 32px 24px; width: 100%; text-align: center;
}
.onboarding-emoji { margin-bottom: 8px; color: var(--gold-light); }
.onboarding-emoji svg { width: 52px; height: 62px; }
.icon-rosary { width: 20px; height: 24px; vertical-align: middle; display: inline-block; }
.onboarding-card h1 { margin: 0 0 6px; font-size: 24px; color: var(--gold-light); }
.tagline { color: var(--text-muted); margin: 0 0 18px; font-size: 14px; }
.verse {
  margin: 0 0 22px; padding: 14px 16px; border-left: 3px solid var(--gold);
  background: rgba(217, 178, 92, 0.08); border-radius: 8px; text-align: left;
  font-style: italic; font-size: 13px; color: var(--text-muted);
}
.verse cite { display: block; margin-top: 6px; font-style: normal; font-size: 12px; color: var(--gold); }

.lang-switch { display: flex; gap: 8px; margin-bottom: 18px; }
.lang-btn {
  flex: 1; padding: 10px; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--text); border-radius: 8px; font-weight: 600; cursor: pointer;
}
.lang-btn.active { background: var(--gold); color: var(--bg); border-color: var(--gold); }

.field-label { display: block; text-align: left; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }

/* ---------- FORM ELEMENTS ---------- */
input, select, textarea {
  font-size: 15px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; color: var(--text); background: var(--bg-soft); width: 100%; margin-bottom: 16px;
}
textarea { resize: vertical; min-height: 60px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }

.btn { border: none; border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn-primary { background: var(--gold); color: var(--bg); }
.btn-primary:active { background: var(--gold-light); }
.btn-secondary { background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); }
.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }
.btn-lang {
  background: var(--bg-soft); color: var(--gold-light); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px; font-weight: 700; cursor: pointer; font-size: 13px;
}

.form-error { color: var(--danger); font-size: 13px; margin: 0; min-height: 16px; }
.form-success { color: var(--success); font-size: 13px; margin: 8px 0 0; min-height: 16px; }
.card-form { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }

/* ---------- MAIN APP ---------- */
#screen-main.active { display: block; padding-bottom: 78px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; background: var(--bg-soft); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 700; font-size: 17px; color: var(--gold-light); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.btn-admin-link {
  background: none; border: none; color: var(--text-muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; padding: 4px 2px;
  opacity: 0.6;
}
.btn-admin-link:active { opacity: 1; }

#main-content { padding: 18px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-subtitle { color: var(--text-muted); font-size: 13px; margin: -8px 0 16px; }

h2 { color: var(--gold-light); font-size: 19px; margin: 0 0 4px; }
h3 { color: var(--text); font-size: 15px; margin: 22px 0 10px; }

/* ---------- HOME ---------- */
.live-counter-card {
  background: radial-gradient(circle at top, var(--card-bg-2), var(--card-bg));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px 18px; text-align: center; margin-bottom: 16px; position: relative;
}
.pulse-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--success);
  margin: 0 auto 10px; box-shadow: 0 0 0 rgba(127, 217, 154, 0.6); animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(127, 217, 154, 0.6); }
  70% { box-shadow: 0 0 0 14px rgba(127, 217, 154, 0); }
  100% { box-shadow: 0 0 0 0 rgba(127, 217, 154, 0); }
}
.live-counter-num { font-size: 40px; font-weight: 800; color: var(--gold-light); line-height: 1; }
.live-counter-label { color: var(--text-muted); font-size: 13px; margin-top: 6px; }

.session-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; text-align: center;
}
.session-card-live { border-color: var(--gold); }
.session-card-title { font-weight: 700; margin-bottom: 6px; }
.live-badge { color: var(--gold-light); }
.session-card-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 12px; }
.countdown { font-size: 32px; font-weight: 800; color: var(--gold-light); margin: 6px 0; font-variant-numeric: tabular-nums; }

.mystery-today-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center; margin-bottom: 14px;
}
.mystery-today-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.mystery-today-icon { font-size: 30px; margin: 6px 0; }
.mystery-today-name { font-weight: 700; color: var(--gold-light); }

.family-check { display: flex; flex-direction: row; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); font-weight: 500; }
.family-check input { width: auto; margin: 0; }

/* ---------- COMMUNITY ---------- */
.community-summary { color: var(--gold-light); font-weight: 700; margin-bottom: 14px; }
.community-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.community-item {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; display: flex; align-items: center; gap: 8px;
}
.community-item .flag { font-size: 22px; }
.community-item .info { display: flex; flex-direction: column; }
.community-item .country-name { font-size: 12px; color: var(--text-muted); }
.community-item .country-count { font-weight: 700; color: var(--gold-light); }
.community-item .live-tick { width: 8px; height: 8px; border-radius: 50%; background: var(--success); margin-left: auto; animation: pulse 1.8s infinite; }

/* ---------- LISTS / CARDS ---------- */
.cards-list { display: flex; flex-direction: column; gap: 10px; }
.empty-msg { color: var(--text-muted); font-size: 13px; text-align: center; padding: 20px 0; }
.intention-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.intention-card .cat { font-size: 12px; color: var(--gold); font-weight: 700; }
.intention-card .txt { font-size: 14px; margin-top: 4px; }
.intention-card .meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ---------- STATS ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-align: center; }
.stat-num { font-size: 30px; font-weight: 800; color: var(--gold-light); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.badges-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.badge-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  text-align: center; opacity: 0.4;
}
.badge-card.unlocked { opacity: 1; border-color: var(--gold); }
.badge-icon { font-size: 26px; margin-bottom: 6px; }
.badge-name { font-size: 12px; font-weight: 700; color: var(--text); }
.badge-desc { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* ---------- DONATE ---------- */
.donate-list { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 10px; }
.donate-list li {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; font-size: 14px; display: flex; align-items: center; gap: 10px;
}
.donate-note { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* ---------- BOTTOM NAV ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  display: flex; background: var(--bg-soft); border-top: 1px solid var(--border); z-index: 10;
}
.nav-btn {
  flex: 1; background: none; border: none; color: var(--text-muted); padding: 10px 4px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.nav-btn span { font-size: 18px; }
.nav-btn em { font-style: normal; font-size: 10px; }
.nav-btn.active { color: var(--gold-light); }

/* ---------- ROSARY GUIDED SCREEN ---------- */
#screen-rosary.active { display: flex; flex-direction: column; min-height: 100vh; }
.rosary-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.rosary-progress-wrap { flex: 1; }
.rosary-progress-bar { height: 6px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.rosary-progress-fill { height: 100%; background: var(--gold); width: 0%; transition: width 0.3s; }
.rosary-progress-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-align: center; }

.rosary-live-strip { text-align: center; font-size: 12px; color: var(--text-muted); padding: 8px; background: rgba(217,178,92,0.06); }

.rosary-body { flex: 1; padding: 24px 22px; display: flex; flex-direction: column; justify-content: center; text-align: center; overflow-y: auto; }
.rosary-icon { font-size: 46px; margin-bottom: 10px; }
.rosary-step-title { font-size: 20px; font-weight: 700; color: var(--gold-light); margin-bottom: 6px; }
.rosary-mystery-set { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px; }
.rosary-reflection { font-size: 13px; color: var(--text-muted); font-style: italic; margin-bottom: 18px; }
.rosary-prayer-text { font-size: 16px; line-height: 1.6; color: var(--text); max-width: 380px; margin: 0 auto; }

.bead-row { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.bead { width: 14px; height: 14px; border-radius: 50%; background: var(--border); }
.bead.done { background: var(--gold); }

.leader-box { margin-top: 18px; padding: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; }
.leader-box p { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.leader-current { font-size: 13px; color: var(--gold-light); font-weight: 600; }

.rosary-complete-icon { font-size: 60px; margin-bottom: 12px; }

.rosary-footer { display: flex; gap: 10px; padding: 16px 18px; background: var(--bg-soft); border-top: 1px solid var(--border); align-items: center; }
.rosary-footer .btn { flex: 1; }
.rosary-sync-info { flex: 1; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ---------- ADMIN ---------- */
.btn-link-back {
  background: none; border: none; color: var(--gold); font-size: 13px; font-weight: 600;
  cursor: pointer; padding: 0 0 16px; display: block;
}
.admin-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.admin-panel-header h2 { margin: 0; }
.admin-panel-header .btn { flex: none; padding: 8px 14px; font-size: 13px; }
#btn-clear-old-intentions { margin-bottom: 22px; }
.admin-intention-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.admin-intention-card .admin-intention-body { flex: 1; min-width: 0; }
.admin-intention-card .cat { font-size: 12px; color: var(--gold); font-weight: 700; }
.admin-intention-card .txt { font-size: 14px; margin-top: 4px; word-break: break-word; }
.admin-intention-card .meta { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.btn-delete-intention {
  flex: none; background: rgba(229, 115, 115, 0.12); color: var(--danger); border: 1px solid var(--danger);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 700; cursor: pointer;
}

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card-bg-2); color: var(--text); border: 1px solid var(--gold);
  padding: 12px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none;
  transition: all 0.25s; z-index: 100; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
