/* ==========================================================
   ليلتنا — Couple's Intimacy Game
   Mobile-first, RTL, neon dark theme
   ========================================================== */

:root {
  --bg: #0B0B0F;
  --bg-2: #14141C;
  --bg-3: #1C1C28;
  --text: #F2F2F5;
  --text-dim: #9A9AA8;
  --text-soft: #6E6E80;
  --border: rgba(255, 255, 255, 0.08);

  /* Husband theme — Neon Blue */
  --hue: 210;
  --primary: hsl(var(--hue), 100%, 60%);
  --primary-glow: hsla(var(--hue), 100%, 60%, 0.55);
  --primary-soft: hsla(var(--hue), 100%, 60%, 0.15);
  --primary-deep: hsla(var(--hue), 100%, 60%, 0.06);

  --radius: 18px;
  --radius-sm: 12px;
  --shadow-glow: 0 0 24px var(--primary-glow), 0 0 60px var(--primary-soft);
  --transition: 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Tajawal",
               "Cairo", "Noto Naskh Arabic", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  overscroll-behavior: none;
  font-size: 16px;
  line-height: 1.6;
}

body {
  background: radial-gradient(ellipse at top, var(--primary-deep), var(--bg) 60%);
  transition: background var(--transition);
}

.app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: 540px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ============== SCREEN SYSTEM ============== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 20px;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

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

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============== WELCOME SCREEN ============== */
.welcome-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 24px;
  padding: 16px 0 32px;
  overflow-y: auto;
}

.logo {
  text-align: center;
  user-select: none;
  cursor: pointer;
}

.logo-mark {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  margin: 0 auto 16px;
  background: radial-gradient(circle at 30% 30%, var(--primary), transparent 70%),
              radial-gradient(circle at 70% 70%, var(--primary), transparent 70%);
  background-color: var(--bg-2);
  box-shadow: var(--shadow-glow);
  animation: pulse 3s ease-in-out infinite;
  position: relative;
}

.logo-mark::after {
  content: "♥";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: var(--text);
  text-shadow: 0 0 12px var(--primary);
}

.logo-mark.admin-mark::after {
  content: "⚙";
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 24px var(--primary-glow), 0 0 60px var(--primary-soft); }
  50% { box-shadow: 0 0 32px var(--primary-glow), 0 0 90px var(--primary-soft); }
}

.logo-text {
  font-size: 42px;
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin: 6px 0 0;
}

/* ============== CARD ============== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.add-card {
  margin-bottom: 16px;
}

/* ============== FIELDS ============== */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: all 0.25s ease;
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  background: var(--bg-2);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(0% + 12px) 50%, calc(0% + 18px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-left: 36px;
}

/* ============== SPICE DIAL ============== */
.spice-dial {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dial-title {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0;
  font-weight: 500;
}

.dial-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dial-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 6px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  transition: all 0.25s ease;
}

.dial-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.dial-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 16px var(--primary-soft);
}

.dial-icon {
  font-size: 22px;
}

.dial-name {
  font-weight: 600;
}

/* ============== BUTTONS ============== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary));
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 24px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 0 20px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all 0.25s ease;
  min-height: 54px;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 30px var(--primary-glow), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  font-size: 18px;
  font-weight: 400;
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--text);
}

/* ============== AGE GATE ============== */
.age-gate {
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  margin: 0;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
  margin: 8px 0 0;
}

/* ============== GAME SCREEN ============== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  margin-bottom: 16px;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 100px;
  padding: 8px 16px;
  box-shadow: 0 0 16px var(--primary-soft);
}

.turn-label {
  font-size: 13px;
  color: var(--text-dim);
}

.turn-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.round-counter {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.round-counter span:last-child {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.game-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  min-height: 0;
}

.question-card {
  background: linear-gradient(160deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--primary);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  position: relative;
  box-shadow: 0 0 40px var(--primary-soft), 0 8px 32px rgba(0, 0, 0, 0.4);
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  animation: slideIn 0.4s ease;
}

.tier-badge {
  display: inline-block;
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 100px;
  padding: 6px 16px;
  letter-spacing: 0.02em;
}

.question-text {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  word-wrap: break-word;
}

.game-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 4px;
}

/* ============== ADMIN SCREEN ============== */
.admin-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.admin-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.admin-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 14px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: all 0.25s ease;
}

.tab-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text);
}

.admin-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 4px 16px;
  min-height: 0;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.admin-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding: 4px 0 10px;
  z-index: 1;
}

.stat-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 12px;
  color: var(--text-dim);
}

.pill-t1 { color: #74C0FC; border-color: #74C0FC; background: rgba(116, 192, 252, 0.1); }
.pill-t2 { color: #FF8CC8; border-color: #FF8CC8; background: rgba(255, 140, 200, 0.1); }
.pill-t3 { color: #FF6B6B; border-color: #FF6B6B; background: rgba(255, 107, 107, 0.1); }

.search-input {
  font-size: 14px;
  padding: 10px 14px;
}

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.q-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  animation: slideIn 0.2s ease;
}

.q-item:hover {
  border-color: var(--primary);
}

.q-tier {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

.q-tier.t1 { color: #74C0FC; border: 1px solid #74C0FC; background: rgba(116, 192, 252, 0.1); }
.q-tier.t2 { color: #FF8CC8; border: 1px solid #FF8CC8; background: rgba(255, 140, 200, 0.1); }
.q-tier.t3 { color: #FF6B6B; border: 1px solid #FF6B6B; background: rgba(255, 107, 107, 0.1); }

.q-text {
  flex: 1;
  color: var(--text);
  word-wrap: break-word;
}

.q-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.q-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.q-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.q-btn.danger:hover {
  border-color: #FF6B6B;
  color: #FF6B6B;
}

.admin-footer {
  display: flex;
  gap: 8px;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}

/* ============== LEVEL SELECTOR (3 strictly-isolated levels) ============== */
.level-selector {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.level-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.level-options:not(.modal-levels) {
  grid-template-columns: 1fr;
}

@media (min-width: 420px) {
  .level-options {
    grid-template-columns: repeat(3, 1fr);
  }
}

.level-btn {
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  transition: all 0.25s ease;
  text-align: center;
  position: relative;
}

.level-btn:hover {
  border-color: var(--primary);
  color: var(--text);
  transform: translateY(-1px);
}

.level-btn.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--text);
  box-shadow: 0 0 18px var(--primary-soft), inset 0 0 0 1px var(--primary);
}

.level-btn[data-level="1"].active {
  background: linear-gradient(135deg, rgba(116, 192, 252, 0.18), rgba(116, 192, 252, 0.08));
  border-color: #74C0FC;
  box-shadow: 0 0 18px rgba(116, 192, 252, 0.35);
}
.level-btn[data-level="1"].active .level-icon { color: #74C0FC; }

.level-btn[data-level="2"].active {
  background: linear-gradient(135deg, rgba(255, 140, 200, 0.18), rgba(255, 140, 200, 0.08));
  border-color: #FF8CC8;
  box-shadow: 0 0 18px rgba(255, 140, 200, 0.4);
}
.level-btn[data-level="2"].active .level-icon { color: #FF8CC8; }

.level-btn[data-level="3"].active {
  background: linear-gradient(135deg, rgba(255, 184, 77, 0.18), rgba(255, 184, 77, 0.08));
  border-color: #FFB84D;
  box-shadow: 0 0 18px rgba(255, 184, 77, 0.4);
}
.level-btn[data-level="3"].active .level-icon { color: #FFB84D; }

.level-icon {
  font-size: 26px;
  line-height: 1;
}

.level-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.level-desc {
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 500;
}

.level-hint {
  font-size: 12px;
  color: var(--text-soft);
  margin: 4px 0 0;
  text-align: center;
  transition: opacity 0.25s ease;
}

.level-hint.hidden {
  opacity: 0;
}

.required-mark {
  color: #FF6B6B;
  font-weight: 700;
}

/* ============== LEVEL STRIP (GAME SCREEN) ============== */
.level-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 100px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  align-self: center;
}

.level-strip-icon {
  font-size: 16px;
}

.level-strip-name {
  color: var(--text);
}

.level-strip-divider {
  color: var(--text-soft);
}

.level-strip-count {
  color: var(--primary);
  font-weight: 700;
}

/* ============== LEVEL BADGE ON QUESTION CARD ============== */
.level-badge {
  display: inline-block;
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  background: var(--primary-soft);
  border: 1px solid var(--primary);
  border-radius: 100px;
  padding: 5px 14px;
  letter-spacing: 0.02em;
  text-align: center;
}

.q-level {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
  flex-shrink: 0;
}

.q-level-1 { color: #74C0FC; border: 1px solid #74C0FC; background: rgba(116, 192, 252, 0.1); }
.q-level-2 { color: #FF8CC8; border: 1px solid #FF8CC8; background: rgba(255, 140, 200, 0.1); }
.q-level-3 { color: #FFB84D; border: 1px solid #FFB84D; background: rgba(255, 184, 77, 0.1); }

.pill-l1 { color: #74C0FC; border-color: #74C0FC; background: rgba(116, 192, 252, 0.1); }
.pill-l2 { color: #FF8CC8; border-color: #FF8CC8; background: rgba(255, 140, 200, 0.1); }
.pill-l3 { color: #FFB84D; border-color: #FFB84D; background: rgba(255, 184, 77, 0.1); }

/* ============== FOOTER ROW (TWO GHOST BUTTONS) ============== */
.footer-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.footer-row .btn-ghost {
  flex: 1;
}

/* ============== MODAL ============== */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal.show {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--primary);
  border-radius: 20px;
  padding: 24px 20px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 0 40px var(--primary-soft), 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-content h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.modal-sub {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.modal-levels {
  grid-template-columns: 1fr;
}

/* ============== FILTER ROW (ADMIN) ============== */
.filter-row {
  display: flex;
  gap: 8px;
}

.level-filter {
  flex: 0 0 40%;
  font-size: 13px;
  padding: 10px 14px;
  padding-left: 32px;
}

.filter-row .search-input {
  flex: 1;
}

/* ============== THEMES ============== */
/* Wife theme — Hot Pink */
.app[data-turn="wife"] {
  --hue: 330;
  --primary: hsl(var(--hue), 90%, 65%);
  --primary-glow: hsla(var(--hue), 90%, 65%, 0.55);
  --primary-soft: hsla(var(--hue), 90%, 65%, 0.15);
  --primary-deep: hsla(var(--hue), 90%, 65%, 0.06);
}

/* ============== TOAST ============== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--primary);
  border-radius: 100px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  box-shadow: 0 0 24px var(--primary-soft);
  transition: transform 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ============== SCROLLBARS ============== */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-soft);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ============== MOBILE TWEAKS ============== */
@media (max-width: 380px) {
  .logo-text { font-size: 36px; }
  .question-text { font-size: 19px; }
  .question-card { padding: 24px 18px; }
  .dial-name { font-size: 12px; }
}

@media (min-width: 768px) {
  .app {
    max-width: 480px;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ============== SAFE AREAS ============== */
@supports (padding: max(0px)) {
  .screen { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .game-header { padding-top: max(12px, env(safe-area-inset-top)); }
}
