/* ═══════════════════════════════════════════════════════════
   قهوة جيمز — Shared Game Styles
   All game pages depend on this file.
   ═══════════════════════════════════════════════════════════ */

/* ── CSS TOKENS ── */
:root {
  /* Backgrounds */
  --bg: #050508;
  --bg2: #0a0a10;
  --surface: #0f0f18;
  --surface2: #161622;
  --surface3: #1c1c2e;

  /* Cards (alias surface for games using card naming) */
  --card: #0f0f18;
  --card2: #161622;
  --card3: #1c1c2e;

  /* Accent */
  --accent: #f5c518;
  --accent2: #ff6b35;
  --gold: #e8b84b;
  --gold2: #f5d07a;
  --gold-glow: rgba(232, 184, 75, 0.22);
  --ember: #ff5e3a;
  --ember-glow: rgba(255, 94, 58, 0.18);

  /* Semantic */
  --green: #22c55e;
  --red: #ef4444;
  --blue: #3b82f6;
  --purple: #a855f7;

  /* Text */
  --text: #f0f0fa;
  --text2: #a0a0c0;
  --text3: #606080;
  --muted: #606080;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border2: rgba(255, 255, 255, 0.12);
  --stroke: #030305; /* Solid dark stroke for cartoon UI */

  /* Radii - Chunkier for comic style */
  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
}

/* ── LIGHT THEME OVERRIDES ── */
body.light-theme {
  --bg: #f8fafc;
  --bg2: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --surface3: #e2e8f0;
  
  --card: #ffffff;
  --card2: #f1f5f9;
  --card3: #e2e8f0;
  
  --text: #0f172a;
  --text2: #334155;
  --text3: #475569;
  --muted: #64748b;
  
  --border: rgba(0, 0, 0, 0.1);
  --border2: rgba(0, 0, 0, 0.15);
  --stroke: #334155;
}
body.light-theme::before { display: none; }

/* ── RESET ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  overflow-x: hidden;
  min-height: 100dvh;
}

/* ── AMBIENT BACKGROUND ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(232, 184, 75, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 5% 85%, rgba(255, 94, 58, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse 50% 35% at 95% 75%, rgba(59, 130, 246, 0.04) 0%, transparent 55%);
  pointer-events: none;
}

/* Load fonts if not already loaded */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&family=Tajawal:wght@400;700;900&display=swap');

/* ─────────────────────────────────────────
   SCREEN SYSTEM
   Each "page" is a .screen; only .active shows
   ───────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.2rem;
  position: relative;
  z-index: 1;
  animation: fadeIn 0.35s ease both;
}

.screen.active {
  display: flex;
}

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

/* ─────────────────────────────────────────
   GAME HEADER / BRANDING
   ───────────────────────────────────────── */
.game-logo,
.game-icon {
  font-size: 4rem;
  margin-bottom: 0.6rem;
  filter: drop-shadow(0 4px 24px rgba(245, 197, 24, 0.25));
  animation: bounceIn 0.5s ease both;
}

@keyframes bounceIn {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.game-title {
  font-family: 'Tajawal', sans-serif;
  font-weight: 900;
  font-size: 3rem;
  color: var(--accent);
  -webkit-text-stroke: 2.5px var(--stroke);
  text-shadow: 0 4px 0 var(--stroke);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.game-sub {
  color: var(--text3);
  font-size: 0.95rem;
  line-height: 1.7;
  text-align: center;
  margin-bottom: 2rem;
  max-width: 340px;
}

/* ─────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────── */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
  max-width: 340px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-radius: var(--r-md);
  border: 3px solid var(--stroke);
  box-shadow: 0 6px 0 var(--stroke);
  font-family: 'Cairo', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.1s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  color: var(--text);
  margin-bottom: 6px; /* Offset for the box shadow */
}

.btn:active {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--stroke) !important;
}

.btn:hover {
  filter: brightness(1.1);
}

/* Primary / Gold */
.btn-primary,
.btn-gold {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #050510;
  -webkit-text-stroke: 0.5px rgba(0,0,0,0.5);
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

/* Secondary / Ghost */
.btn-secondary,
.btn-ghost {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover,
.btn-ghost:hover {
  background: var(--surface3);
}

/* Success */
.btn-success {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}

.btn-success:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--stroke) !important;
  pointer-events: none;
}

/* Danger */
.btn-danger {
  background: linear-gradient(135deg, #f87171, #ef4444);
  color: #fff;
}

/* Small */
.btn-sm {
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  border-radius: var(--r-sm);
  border-width: 2.5px;
  box-shadow: 0 4px 0 var(--stroke);
  margin-bottom: 4px;
}
.btn-sm:active {
  transform: translateY(4px);
}

/* ─────────────────────────────────────────
   DIVIDERS
   ───────────────────────────────────────── */
.or-divider,
.or-line {
  text-align: center;
  color: var(--text3);
  font-size: 0.82rem;
  font-weight: 700;
  position: relative;
  padding: 0.2rem 0;
}

.or-divider::before,
.or-divider::after,
.or-line::before,
.or-line::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--border2);
}

.or-divider::before,
.or-line::before { right: 0; }
.or-divider::after,
.or-line::after { left: 0; }

/* ─────────────────────────────────────────
   NAVIGATION
   ───────────────────────────────────────── */
.back-btn {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: var(--surface2);
  border: 2px solid var(--stroke);
  box-shadow: 0 3px 0 var(--stroke);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.45rem 1rem;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.1s, box-shadow 0.1s;
}

.back-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--stroke);
}

.home-link {
  display: inline-block;
  margin-top: 1.5rem;
  color: var(--text3);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s;
}

.home-link:hover {
  color: var(--accent);
}

/* ─────────────────────────────────────────
   PAGE TITLES
   ───────────────────────────────────────── */
.page-title {
  font-family: 'Tajawal', sans-serif;
  font-weight: 900;
  font-size: 2.2rem;
  color: var(--accent);
  -webkit-text-stroke: 1.5px var(--stroke);
  text-shadow: 0 4px 0 var(--stroke);
  margin-bottom: 0.8rem;
  text-align: center;
  line-height: 1.3;
}

.page-sub {
  color: var(--text3);
  font-size: 0.9rem;
  margin-bottom: 1.2rem;
  text-align: center;
}

/* ─────────────────────────────────────────
   FORM FIELDS
   Supports both .input-group and .field
   ───────────────────────────────────────── */
.input-group,
.field {
  width: 100%;
  max-width: 340px;
  margin-bottom: 1rem;
}

.input-label,
.field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 0.45rem;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  background: var(--surface2);
  border: 3px solid var(--stroke);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
  border-radius: var(--r-md);
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: var(--accent);
}

input[type="text"]::placeholder,
input[type="number"]::placeholder,
textarea::placeholder {
  color: var(--text3);
  font-weight: 400;
}

/* ─────────────────────────────────────────
   SETTINGS ROW (round count, timer, etc.)
   ───────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 340px;
  background: var(--surface2);
  border: 3px solid var(--stroke);
  box-shadow: 0 4px 0 var(--stroke);
  border-radius: var(--r-md);
  padding: 0.75rem 1rem;
  margin-bottom: 0.8rem;
}

.setting-label,
.setting-lbl {
  font-size: 0.9rem;
  font-weight: 700;
}

.setting-ctrl {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 900;
  font-size: 1.1rem;
}

.ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--stroke);
  box-shadow: 0 3px 0 var(--stroke);
  background: var(--surface3);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
  margin-bottom: 3px;
}

.ctrl-btn:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 var(--stroke);
  background: var(--accent);
  color: #050510;
}

/* ─────────────────────────────────────────
   ROOM CODE BOX
   Supports both naming conventions
   ───────────────────────────────────────── */
.room-code-box,
.code-box {
  background: var(--surface);
  border: 3px dashed var(--accent);
  border-radius: var(--r-xl);
  padding: 1.2rem 1.8rem;
  text-align: center;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 340px;
  cursor: pointer;
  transition: transform 0.1s;
}

.room-code-box:active,
.code-box:active {
  transform: scale(0.96);
}

.room-code-label,
.code-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text3);
  margin-bottom: 0.5rem;
}

.room-code-val,
.code-val {
  font-family: 'Tajawal', monospace;
  font-weight: 900;
  font-size: 2.4rem;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  user-select: all;
}

/* ─────────────────────────────────────────
   CARDS
   ───────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 3px solid var(--stroke);
  box-shadow: 0 5px 0 var(--stroke);
  border-radius: var(--r-lg);
  padding: 1rem;
  width: 100%;
  max-width: 340px;
  margin-bottom: 1.2rem;
}

.card-title,
.card-top {
  font-size: 0.9rem;
  font-weight: 800;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-top .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ─────────────────────────────────────────
   PLAYER ROWS
   Supports both .player-av/.player-nm and .p-av/.p-nm
   ───────────────────────────────────────── */
.player-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 2px dashed var(--border2);
}

.player-row:last-child {
  border-bottom: none;
}

.player-av,
.p-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface3);
  border: 2px solid var(--stroke);
  box-shadow: 0 2px 0 var(--stroke);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.player-nm,
.p-nm {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ─────────────────────────────────────────
   BADGES
   ───────────────────────────────────────── */
.badge {
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.badge-host {
  background: rgba(245, 197, 24, 0.12);
  color: var(--accent);
  border: 1px solid rgba(245, 197, 24, 0.2);
}

.badge-ready {
  background: rgba(34, 197, 94, 0.1);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

/* ─────────────────────────────────────────
   TIMER
   ───────────────────────────────────────── */
.timer {
  font-family: 'Tajawal', monospace;
  font-weight: 900;
  font-size: 2.2rem;
  color: var(--text);
  -webkit-text-stroke: 1.5px var(--stroke);
  text-shadow: 0 4px 0 var(--stroke);
  transition: color 0.3s;
}

.timer.warn {
  color: #f59e0b;
}

.timer.danger {
  color: var(--red);
  animation: timerPulse 0.6s infinite alternate;
}

@keyframes timerPulse {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0.7; transform: scale(1.05); }
}

/* ─────────────────────────────────────────
   TOAST NOTIFICATION
   ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface3);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--r-md);
  padding: 0.7rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  z-index: 999;
  transition: bottom 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.toast.show {
  bottom: 2rem;
}

/* ─────────────────────────────────────────
   RESULT SCREEN
   ───────────────────────────────────────── */
.result-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.result-icon {
  font-size: 4.5rem;
  margin-bottom: 0.6rem;
  animation: bounceIn 0.5s ease both;
}

.result-title {
  font-family: 'Tajawal', sans-serif;
  font-weight: 900;
  font-size: 2.4rem;
  color: var(--accent);
  -webkit-text-stroke: 1.5px var(--stroke);
  text-shadow: 0 4px 0 var(--stroke);
  margin-bottom: 0.6rem;
}

.result-sub {
  color: var(--text3);
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
  line-height: 1.6;
}

.info-block {
  background: var(--surface2);
  border: 3px solid var(--stroke);
  box-shadow: 0 4px 0 var(--stroke);
  border-radius: var(--r-md);
  padding: 0.9rem 1.2rem;
  width: 100%;
  margin-bottom: 0.8rem;
  text-align: center;
}

.info-block-lbl {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text3);
  margin-bottom: 0.35rem;
}

.info-block-val {
  font-weight: 800;
  font-size: 1.1rem;
}

/* ─────────────────────────────────────────
   WAITING DOTS ANIMATION
   ───────────────────────────────────────── */
.dots::after {
  content: '';
  animation: dotsAnim 1.4s steps(4) infinite;
}

@keyframes dotsAnim {
  0%  { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ─────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────── */
@media (max-width: 480px) {
  .screen {
    padding: 1.5rem 1rem;
  }

  .game-title {
    font-size: 1.8rem;
  }

  .game-sub {
    font-size: 0.88rem;
  }

  .room-code-val,
  .code-val {
    font-size: 2rem;
    letter-spacing: 4px;
  }

  .btn {
    padding: 0.85rem 1.2rem;
    font-size: 0.95rem;
  }
}

@media (max-width: 360px) {
  .game-logo,
  .game-icon {
    font-size: 3rem;
  }

  .game-title {
    font-size: 1.5rem;
  }

  .page-title {
    font-size: 1.4rem;
  }
}
