/* ==========================================================================
   كذّاب! — Fake-Answer Party Game
   Design tokens: night-carnival palette, Cairo (display) + Tajawal (body)
   Mobile-first app shell: scrollable content + fixed bottom action bar
   ========================================================================== */

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

:root {
  /* Color */
  --bg: #150d29;
  --bg-alt: #1c1336;
  --surface: #271c46;
  --surface-alt: #33255a;
  --border-soft: rgba(245, 240, 230, 0.10);
  --border-strong: rgba(245, 240, 230, 0.20);

  --accent-gold: #f2b705;
  --accent-gold-dim: #c99a08;
  --accent-pink: #ff3d7f;
  --accent-teal: #2fe6c9;
  --accent-violet: #9b7bff;
  --accent-orange: #ff9142;
  --accent-danger: #ff5470;

  --text: #f6f2ea;
  --text-dim: #bbb0d9;
  --text-faint: #8a7cae;

  /* Type — fluid, mobile-first */
  --font-display: 'Cairo', 'Tajawal', sans-serif;
  --font-body: 'Tajawal', 'Cairo', sans-serif;
  --fs-title: clamp(1.55rem, 5.2vw, 2rem);
  --fs-question: clamp(1.15rem, 4.6vw, 1.5rem);
  --fs-question-lg: clamp(1.3rem, 5.6vw, 1.7rem);
  --fs-pass-name: clamp(1.9rem, 9vw, 2.7rem);

  /* Layout */
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.35);
  --footer-h: 96px;
  --edge: 20px;

  color-scheme: dark;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  position: relative;
}

/* Ambient stage-light glow behind everything — quiet, not distracting */
.stage-lights {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(480px 360px at 12% -4%, rgba(255, 61, 127, 0.20), transparent 60%),
    radial-gradient(420px 320px at 100% 6%, rgba(242, 183, 5, 0.14), transparent 60%),
    radial-gradient(600px 460px at 50% 115%, rgba(47, 230, 201, 0.10), transparent 60%),
    var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-inline: env(safe-area-inset-right) env(safe-area-inset-left);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--edge) 4px;
  flex-shrink: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
}

.wordmark-mask { font-size: 1.4rem; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4)); }

.wordmark-text {
  font-size: 1.3rem;
  letter-spacing: 0.5px;
  color: var(--text);
}

.wordmark-bang { color: var(--accent-pink); }

.header-status {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  padding: 6px 13px;
  border-radius: 999px;
  color: var(--accent-gold);
}

/* ==========================================================================
   Screens — each is a flex column: scrollable content + fixed footer button
   ========================================================================== */

#screens {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.screen {
  display: none;
  width: 100%;
  flex-direction: column;
  min-height: 0;
}

.screen.active {
  display: flex;
  animation: screen-in 340ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px var(--edge) 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.screen-scroll.center {
  justify-content: center;
  text-align: center;
  align-items: center;
}

.screen-footer {
  flex-shrink: 0;
  padding: 12px var(--edge) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 55%, transparent);
}

.eyebrow {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--text-faint);
  margin: 0;
}

.eyebrow-strong {
  color: var(--accent-gold);
  font-weight: 800;
}

.screen-title {
  font-family: var(--font-display);
  font-size: var(--fs-title);
  font-weight: 800;
  margin: 0;
  line-height: 1.25;
}

.screen-sub {
  color: var(--text-dim);
  font-size: 0.93rem;
  line-height: 1.6;
  margin: 0;
  max-width: 46ch;
}

.section-heading {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  margin: 4px 0 0;
  color: var(--text);
}

/* Turn row: eyebrow + progress dots side by side */
.turn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-dots {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.progress-dots .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 200ms ease, transform 200ms ease;
}

.progress-dots .dot.is-done { background: var(--accent-teal); }
.progress-dots .dot.is-current { background: var(--accent-gold); transform: scale(1.3); }

/* ==========================================================================
   Buttons & inputs
   ========================================================================== */

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: transform 110ms ease, box-shadow 120ms ease, filter 120ms ease, opacity 120ms ease;
  min-height: 56px;
  color: var(--text);
  touch-action: manipulation;
}

.btn:active { transform: scale(0.965); }

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

.btn-block { width: 100%; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent-pink), #d61e5f);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 61, 127, 0.32);
}

.btn-primary:not(:disabled):hover { filter: brightness(1.08); }

.btn-gold {
  background: var(--accent-gold);
  color: #201404;
  box-shadow: 0 6px 16px rgba(242, 183, 5, 0.3);
}

.btn-ghost {
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border-soft);
}

.btn-square {
  width: 52px;
  min-height: 52px;
  padding: 0;
  flex-shrink: 0;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.text-input, .answer-textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 14px 16px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.text-input:focus, .answer-textarea:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(242, 183, 5, 0.18);
}

.answer-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.add-player-row {
  display: flex;
  gap: 10px;
}

.hint {
  font-size: 0.82rem;
  color: var(--text-faint);
  margin: 0;
}

/* ==========================================================================
   Players list (setup)
   ========================================================================== */

.players-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  animation: chip-in 220ms ease;
}

@keyframes chip-in {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: #14102a;
  font-family: var(--font-display);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.avatar-c0 { background: var(--accent-teal); }
.avatar-c1 { background: var(--accent-gold); }
.avatar-c2 { background: var(--accent-pink); color: #2a0714; }
.avatar-c3 { background: var(--accent-violet); color: #f6f2ea; }
.avatar-c4 { background: var(--accent-orange); }
.avatar-c5 { background: #6fd1ff; }

.player-chip-name {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-remove-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  touch-action: manipulation;
}

.player-remove-btn:hover { color: var(--accent-danger); }

.rounds-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 2px;
}

.rounds-label { font-weight: 500; color: var(--text-dim); }

.segmented {
  display: flex;
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

.segment-btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
  touch-action: manipulation;
}

.segment-btn.is-active {
  background: var(--accent-gold);
  color: #201404;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stepper-value {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  min-width: 1.6ch;
  text-align: center;
}

/* ==========================================================================
   Question card
   ========================================================================== */

.question-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 20px 18px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-question);
  line-height: 1.5;
  margin: 0;
  box-shadow: var(--shadow-card);
}

.question-card-lg {
  font-size: var(--fs-question-lg);
  padding: 26px 20px;
}

/* ==========================================================================
   Pass-the-phone screen
   ========================================================================== */

.pass-inner { gap: 8px; }

.pass-icon {
  font-size: 2.8rem;
  margin-bottom: 2px;
  animation: pass-bounce 1.6s ease-in-out infinite;
}

.trophy-icon { animation: trophy-spin 2.4s ease-in-out infinite; }

@keyframes pass-bounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(-4deg); }
}

@keyframes trophy-spin {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  50% { transform: rotate(6deg) scale(1.06); }
}

.pass-name {
  font-family: var(--font-display);
  font-size: var(--fs-pass-name);
  font-weight: 800;
  color: var(--accent-gold);
  margin: 0;
  word-break: break-word;
}

/* ==========================================================================
   Voting — "who wrote it" matching cards
   ========================================================================== */

.match-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.match-card {
  background: var(--surface);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: option-in 300ms both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: border-color 140ms ease;
}

@keyframes option-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.match-card.is-answered { border-color: rgba(47, 230, 201, 0.4); }

.match-card-text {
  margin: 0;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.98rem;
  line-height: 1.6;
}

.match-card.is-own {
  opacity: 0.55;
  background: var(--surface-alt);
}

.match-card-own-tag {
  display: inline-block;
  margin-inline-start: 6px;
  font-size: 0.75rem;
  color: var(--accent-pink);
  font-weight: 700;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.85rem;
  border: 2px solid var(--border-soft);
  background: var(--surface-alt);
  color: var(--text-dim);
  padding: 9px 15px;
  min-height: 40px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 130ms ease, background 130ms ease, color 130ms ease, opacity 130ms ease;
  touch-action: manipulation;
}

.chip-btn:active:not(.chip-disabled) { transform: scale(0.95); }

.chip-btn.chip-selected {
  border-color: var(--accent-gold);
  background: rgba(242, 183, 5, 0.16);
  color: var(--accent-gold);
  font-weight: 700;
}

.chip-btn.chip-disabled {
  opacity: 0.32;
  cursor: not-allowed;
  text-decoration: line-through;
}

.vote-assign-hint {
  text-align: center;
}

/* ==========================================================================
   Results screen
   ========================================================================== */

.real-answer-seal {
  background: radial-gradient(circle at 30% 20%, rgba(242,183,5,0.18), var(--surface));
  border: 2px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  text-align: center;
  animation: seal-stamp 460ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: var(--shadow-card);
}

@keyframes seal-stamp {
  0%   { opacity: 0; transform: scale(1.5) rotate(-8deg); }
  60%  { opacity: 1; transform: scale(0.97) rotate(2deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.seal-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.74rem;
  letter-spacing: 0.5px;
  color: #201404;
  background: var(--accent-gold);
  border-radius: 999px;
  padding: 4px 14px;
  margin-bottom: 8px;
}

.real-answer-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.5;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.result-item.is-real {
  border-color: var(--accent-teal);
  background: rgba(47, 230, 201, 0.08);
}

.result-item-text {
  font-weight: 500;
  line-height: 1.55;
  margin: 0;
}

.result-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.result-item-owner { color: var(--accent-pink); font-weight: 700; }
.result-item-votes { color: var(--text-dim); }

/* ==========================================================================
   Leaderboard
   ========================================================================== */

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}

.leaderboard-item.rank-1 {
  border-color: var(--accent-gold);
  background: rgba(242, 183, 5, 0.1);
}

.leaderboard-rank {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--text-faint);
  min-width: 1.8ch;
  text-align: center;
  flex-shrink: 0;
}

.leaderboard-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.leaderboard-item.rank-1 .leaderboard-rank { color: var(--accent-gold); }

.leaderboard-name {
  flex: 1;
  font-weight: 500;
  text-align: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--accent-teal);
  flex-shrink: 0;
}

.leaderboard-delta {
  font-size: 0.75rem;
  color: var(--text-faint);
  min-width: 3ch;
  text-align: end;
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive: larger phones & desktop
   ========================================================================== */

@media (min-width: 640px) {
  body {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-y: auto;
  }
  .app-shell {
    max-width: 460px;
    width: 100%;
    height: 92vh;
    height: 92dvh;
    margin-top: 4vh;
    border-radius: 28px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
