/*
 * طقطقة — Shared Game Design System
 * Fun, playful, colorful — matches the landing page
 */

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

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

:root {
  /* Game colors */
  --coral: #FF6B6B;
  --purple: #7C4DFF;
  --yellow: #FFD600;
  --teal: #00BFA5;
  --pink: #FF80AB;
  --deep-orange: #FF5722;
  --blue: #448AFF;
  --orange: #FF9100;
  --deep-purple: #651FFF;
  --cyan: #00E5FF;
  --green: #00C853;
  --red: #FF1744;
  --lavender: #B388FF;
  --ocean: #00B8D4;
  --magenta: #E040FB;
  --noir: #2C3E50;

  /* Theme — each game overrides --game-color */
  --game-color: var(--purple);
  --game-color-light: rgba(124,77,255,0.1);

  /* Neutrals */
  --bg: #FFFAF5;
  --card: #FFFFFF;
  --text-dark: #1A1A2E;
  --text-mid: #4A4A6A;
  --text-light: #8888AA;

  /* Typography */
  --font-display: 'Lalezar', cursive;
  --font-body: 'Changa', sans-serif;

  /* Layout */
  --radius: 24px;
  --radius-sm: 16px;
  --radius-xs: 10px;
  --shadow: 0 4px 24px rgba(26,26,46,0.07);
  --shadow-lg: 0 12px 40px rgba(26,26,46,0.13);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-dark);
  overflow-x: hidden;
  line-height: 1.7;
  direction: rtl;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── Game Shell ───────────────────────────────────── */
.game-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Game Header ──────────────────────────────────── */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 50;
}

.game-header-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--game-color);
}

.game-header-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--game-color-light);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--game-color);
  transition: transform 0.2s var(--bounce);
}

.game-header-back:hover { transform: scale(1.1); }

.game-header-score {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Game Body ────────────────────────────────────── */
.game-body {
  flex: 1;
  padding: 24px 20px 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Screen system — show/hide game screens ────────── */
.screen { display: none; width: 100%; max-width: 600px; }
.screen.active { display: flex; flex-direction: column; align-items: center; animation: screen-in 0.4s var(--bounce) both; }

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

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  width: 100%;
  transition: transform 0.3s var(--bounce), box-shadow 0.3s ease;
}

.card:hover { box-shadow: var(--shadow-lg); }
.card + .card { margin-top: 16px; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  padding: 14px 40px;
  border-radius: 60px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.3s ease;
  text-decoration: none;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: translateY(2px); }

.btn-primary {
  background: var(--game-color);
  border-bottom: 4px solid rgba(0,0,0,0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0,0,0,0.2); }
.btn-primary:active { border-bottom-width: 2px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

.btn-secondary {
  background: var(--card);
  color: var(--game-color);
  border: 2px solid var(--game-color-light);
  border-bottom: 4px solid var(--game-color-light);
}

.btn-secondary:hover { background: var(--game-color-light); }

.btn-danger {
  background: var(--coral);
  border-bottom: 4px solid #D84343;
}

.btn-success {
  background: var(--teal);
  border-bottom: 4px solid #009688;
}

.btn-block { width: 100%; }
.btn-lg { font-size: 1.4rem; padding: 18px 48px; }
.btn-sm { font-size: 0.9rem; padding: 10px 24px; }

/* ── Option buttons (for answers) ─────────────────── */
.options { width: 100%; display: flex; flex-direction: column; gap: 12px; }

.option-btn {
  width: 100%;
  padding: 18px 24px;
  background: var(--card);
  border: 2px solid rgba(0,0,0,0.06);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
  cursor: pointer;
  text-align: right;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.option-btn:hover { border-color: var(--game-color); background: var(--game-color-light); }
.option-btn:active { transform: scale(0.97); }

.option-btn.correct {
  background: rgba(0,191,165,0.15);
  border-color: var(--teal);
  color: var(--teal);
}

.option-btn.wrong {
  background: rgba(255,107,107,0.15);
  border-color: var(--coral);
  color: var(--coral);
}

.option-btn.selected {
  border-color: var(--game-color);
  background: var(--game-color-light);
  color: var(--game-color);
}

.option-btn:disabled { pointer-events: none; opacity: 0.7; }

/* ── Timer ────────────────────────────────────────── */
.timer-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--game-color);
  position: relative;
  margin: 16px auto;
}

.timer-ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.timer-ring .track { stroke: rgba(0,0,0,0.06); }
.timer-ring .progress { stroke: var(--game-color); transition: stroke-dashoffset 1s linear; }

.timer-urgent { color: var(--coral); }
.timer-urgent .progress { stroke: var(--coral); }

/* ── Scoreboard ───────────────────────────────────── */
.scoreboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card);
  border-radius: var(--radius-xs);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.score-row.winner {
  background: linear-gradient(135deg, rgba(255,214,0,0.15), rgba(255,145,0,0.1));
  border: 2px solid var(--yellow);
}

.score-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.score-points {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--game-color);
}

/* ── Player Setup ─────────────────────────────────── */
.player-input-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 12px;
}

.player-input-row input {
  flex: 1;
  padding: 14px 18px;
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: var(--radius-xs);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  background: var(--card);
  color: var(--text-dark);
  direction: rtl;
  outline: none;
  transition: border-color 0.2s ease;
}

.player-input-row input:focus { border-color: var(--game-color); }

.player-input-row input::placeholder { color: var(--text-light); }

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--game-color-light);
  color: var(--game-color);
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
}

.player-chip .remove {
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.player-chip .remove:hover { opacity: 1; }

.players-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

/* ── Big text display (question, word, etc) ────────── */
.big-text {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 3rem);
  text-align: center;
  line-height: 1.4;
  color: var(--text-dark);
  padding: 20px 0;
}

.mega-text {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 6rem);
  text-align: center;
  line-height: 1;
  color: var(--game-color);
}

/* ── Labels & badges ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-game { background: var(--game-color-light); color: var(--game-color); }
.badge-success { background: rgba(0,191,165,0.12); color: var(--teal); }
.badge-danger { background: rgba(255,107,107,0.12); color: var(--coral); }

.label {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 8px;
  text-align: center;
}

/* ── Divider ──────────────────────────────────────── */
.divider { width: 100%; height: 1px; background: rgba(0,0,0,0.06); margin: 20px 0; }

/* ── Spacers ──────────────────────────────────────── */
.sp-xs { height: 8px; }
.sp-sm { height: 16px; }
.sp-md { height: 24px; }
.sp-lg { height: 40px; }

/* ── Text utilities ───────────────────────────────── */
.text-center { text-align: center; }
.text-game { color: var(--game-color); }
.text-muted { color: var(--text-light); }
.text-sm { font-size: 0.85rem; }
.font-display { font-family: var(--font-display); }
.fw-bold { font-weight: 700; }

/* ── Flex utilities ───────────────────────────────── */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.w-full { width: 100%; }

/* ── Round indicator (for round counter) ──────────── */
.round-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}

.round-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0,0,0,0.1);
  transition: all 0.3s var(--bounce);
}

.round-dot.active { background: var(--game-color); transform: scale(1.3); }
.round-dot.done { background: var(--teal); }

/* ── Animations ───────────────────────────────────── */
@keyframes pop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes bounce-in {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.1); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(100vh) rotate(720deg); }
}

.anim-pop { animation: pop 0.4s var(--bounce) both; }
.anim-shake { animation: shake 0.5s ease; }
.anim-bounce { animation: bounce-in 0.5s var(--bounce) both; }
.anim-slide { animation: slide-up 0.5s var(--bounce) both; }
.anim-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* ── Confetti container ───────────────────────────── */
.confetti-piece {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  border-radius: 3px;
  animation: confetti-fall 2s ease-out forwards;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 480px) {
  .game-body { padding: 16px 16px 90px; }
  .card { padding: 22px 18px; }
  .btn { font-size: 1rem; padding: 12px 32px; }
  .btn-lg { font-size: 1.2rem; padding: 14px 40px; }
  .big-text { font-size: clamp(1.5rem, 5vw, 2.2rem); }
  .option-btn { padding: 14px 18px; font-size: 1rem; }
}
