/* =========================================================
   المرادفات — Design tokens
   لوحة الألوان مستوحاة من طاولة لعب ليلية: لباد داكن عميق،
   بطاقات دافئة، ورقاقات ذهبية للنقاط.
   ========================================================= */
:root{
  --bg: #12141c;
  --bg-felt-a: #171a24;
  --bg-felt-b: #0f111a;
  --bg-panel: #1b1f2b;
  --bg-panel-2: #202638;
  --bg-card: #232a3d;
  --bg-card-2: #2a3249;

  --accent-gold: #e8b65c;
  --accent-gold-dim: #b98d3f;
  --accent-teal: #3fbf95;
  --accent-orange: #f2994a;
  --accent-red: #e8574a;

  --text: #f5f1e8;
  --text-dim: #a7adc2;
  --text-faint: #6b7288;

  --border: rgba(245,241,232,0.09);
  --border-strong: rgba(245,241,232,0.16);

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;

  --font-display: 'Cairo', 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  --font-body: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;

  --shadow-card: 0 18px 40px -18px rgba(0,0,0,0.65);
  --shadow-btn: 0 10px 24px -10px rgba(0,0,0,0.55);
}

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

html, body{
  margin:0;
  padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body{
  min-height:100vh;
  min-height:100dvh;
  overflow-x:hidden;
}

h1,h2,h3{
  font-family: var(--font-display);
  margin:0;
}

button, input, select{
  font-family: inherit;
}

/* لباد الطاولة: خلفية متدرجة خفيفة بنقاط دقيقة تعطي إحساس القماش */
.table-felt{
  position:fixed;
  inset:0;
  z-index:0;
  background:
    radial-gradient(circle at 15% 8%, rgba(232,182,92,0.10), transparent 40%),
    radial-gradient(circle at 85% 92%, rgba(63,191,149,0.08), transparent 45%),
    radial-gradient(180deg, var(--bg-felt-a), var(--bg-felt-b));
}

.app{
  position:relative;
  z-index:1;
  max-width: 480px;
  margin: 0 auto;
  min-height:100vh;
  min-height:100dvh;
  padding: 20px 18px 32px;
}

/* ============ شاشات ============ */
.screen{
  display:none;
  animation: fade-up .38s ease both;
}
.screen.is-active{ display:block; }

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

@media (prefers-reduced-motion: reduce){
  .screen, .word-card, .ctrl-btn, .dot{ animation: none !important; transition:none !important; }
}

/* ============ العلامة / الترويسة ============ */
.brand{
  text-align:center;
  padding: 18px 4px 22px;
}
.brand-eyebrow{
  display:inline-block;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--accent-gold);
  background: rgba(232,182,92,0.10);
  border: 1px solid rgba(232,182,92,0.25);
  padding: 4px 12px;
  border-radius: 100px;
  font-weight: 700;
  margin-bottom: 10px;
}
.brand-title{
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(180deg, #fbe8c4, var(--accent-gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub{
  color: var(--text-dim);
  font-size: 14px;
  margin: 8px auto 0;
  max-width: 320px;
  line-height:1.6;
}

/* ============ نموذج الإعداد ============ */
.setup-form{ display:flex; flex-direction:column; gap:16px; }

.field-group.teams-group{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:end;
  gap:10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 16px;
}
.team-field{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.team-field label{ font-size:12px; color: var(--text-dim); font-weight:700; }
.team-field input{
  width:100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 12px;
  color: var(--text);
  font-size: 15px;
  font-weight:700;
  outline:none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.team-a input:focus{ border-color: var(--accent-teal); box-shadow: 0 0 0 3px rgba(63,191,149,0.18); }
.team-b input:focus{ border-color: var(--accent-gold); box-shadow: 0 0 0 3px rgba(232,182,92,0.18); }
.vs-divider{
  color: var(--text-faint);
  font-size: 11px;
  font-weight:800;
  padding-bottom: 12px;
}

.card-panel{
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 18px;
}
.panel-title{
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 14px;
}
.panel-title-row{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:8px;
  margin-bottom: 14px;
}
.panel-title-row .panel-title{ margin-bottom:0; }
.panel-hint{ font-size:11px; color: var(--text-faint); }

.field{ margin-bottom: 14px; }
.field:last-child{ margin-bottom:0; }
.field label{
  display:block;
  font-size: 12px;
  color: var(--text-dim);
  font-weight:700;
  margin-bottom: 6px;
}
.field input[type="number"]{
  width:100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight:700;
  outline:none;
}
.field input[type="number"]:focus{ border-color: var(--accent-gold); box-shadow: 0 0 0 3px rgba(232,182,92,0.18); }

.select-wrap select{
  width:100%;
  appearance:none;
  -webkit-appearance:none;
  background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23a7adc2' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat left 14px center;
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-weight:700;
  outline:none;
}
.select-wrap select:focus{ border-color: var(--accent-gold); box-shadow: 0 0 0 3px rgba(232,182,92,0.18); }

.is-hidden{ display:none !important; }

.categories-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.category-chip{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-s);
  padding: 12px 12px;
  cursor:pointer;
  font-size: 13px;
  font-weight:700;
  color: var(--text-dim);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.category-chip input{
  appearance:none; -webkit-appearance:none;
  width:16px; height:16px;
  border-radius:5px;
  border:1.5px solid var(--border-strong);
  background: var(--bg-panel-2);
  flex:none;
  display:grid;
  place-content:center;
}
.category-chip input:checked{
  background: var(--accent-gold);
  border-color: var(--accent-gold);
}
.category-chip input:checked::after{
  content:"";
  width:5px; height:9px;
  border: solid #1b1f2b;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px,-1px);
}
.category-chip:has(input:checked){
  color: var(--text);
  border-color: var(--accent-gold-dim);
  background: linear-gradient(180deg, rgba(232,182,92,0.14), rgba(232,182,92,0.05));
}
.category-chip .cat-count{
  margin-inline-start:auto;
  font-size:11px;
  color: var(--text-faint);
  font-weight:600;
}
.category-chip.is-skeleton{
  opacity:.45;
  pointer-events:none;
}

.field-error{
  color: var(--accent-red);
  font-size: 12.5px;
  font-weight:700;
  margin: 4px 2px 0;
}

/* ============ الأزرار ============ */
.btn{
  border:none;
  border-radius: var(--radius-m);
  padding: 15px 20px;
  font-size: 16px;
  font-weight: 800;
  cursor:pointer;
  font-family: var(--font-display);
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}
.btn:active{ transform: scale(0.97); }
.btn-block{ width:100%; }
.btn-primary{
  background: linear-gradient(180deg, #f2c675, var(--accent-gold));
  color: #1c1204;
  box-shadow: var(--shadow-btn), inset 0 1px 0 rgba(255,255,255,0.4);
}
.btn-ghost{
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
}
.btn-start{ margin-top: 4px; }

/* ============ شاشة اللعب: HUD ============ */
.hud{
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.hud-team{
  display:flex; flex-direction:column; gap:2px;
  min-width:0;
}
.hud-team-label{ font-size:10.5px; color: var(--text-faint); font-weight:700; }
.hud-team-name{
  font-family: var(--font-display);
  font-size: 16px;
  font-weight:800;
  color: var(--accent-teal);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.hud-score{
  display:flex; flex-direction:column; align-items:center; gap:2px;
}
.hud-score-value{
  font-family: var(--font-display);
  font-size: 26px;
  font-weight:900;
  color: var(--accent-gold);
  line-height:1;
}
.hud-score-label{ font-size:10px; color: var(--text-faint); font-weight:700; }

.hud-gauge{
  display:flex; flex-direction:column; align-items:center; gap:4px;
  justify-self:end;
}
.hud-gauge-ring{
  --pct: 100%;
  width:46px; height:46px;
  border-radius:50%;
  display:grid; place-content:center;
  background: conic-gradient(var(--accent-gold) var(--pct), rgba(255,255,255,0.08) 0);
  transition: background .3s linear;
}
.hud-gauge-ring::before{
  content:"";
}
.hud-gauge-value{
  width:36px; height:36px;
  border-radius:50%;
  background: var(--bg-panel);
  display:grid; place-content:center;
  font-family: var(--font-display);
  font-size:13px;
  font-weight:800;
}
.hud-gauge-label{ font-size:9.5px; color: var(--text-faint); font-weight:700; }
.hud-gauge.is-low .hud-gauge-ring{ background: conic-gradient(var(--accent-red) var(--pct), rgba(255,255,255,0.08) 0); }
.hud-gauge.is-low .hud-gauge-value{ color: var(--accent-red); }

/* ============ بطاقة الكلمة (العنصر المميز) ============ */
.stage{ margin-bottom: 18px; }

.word-card{
  position:relative;
  background: linear-gradient(160deg, var(--bg-card-2), var(--bg-card));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-l);
  padding: 30px 22px 26px;
  text-align:center;
  box-shadow: var(--shadow-card);
  overflow:hidden;
  animation: deal-in .32s cubic-bezier(.2,.9,.3,1.3) both;
}
.word-card::before{
  /* خط تقطيع البطاقة العلوي - إحساس بطاقة لعب فعلية */
  content:"";
  position:absolute;
  top:10px; left:10px; right:10px;
  height:1px;
  background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px);
}
@keyframes deal-in{
  from{ opacity:0; transform: translateY(14px) rotate(-2deg) scale(.97); }
  to{ opacity:1; transform: translateY(0) rotate(0) scale(1); }
}

.word-card-tag{
  position:absolute;
  top:0; left:0;
  background: var(--accent-gold);
  color: #1c1204;
  font-size: 11px;
  font-weight: 800;
  padding: 6px 14px 6px 10px;
  border-radius: 0 0 var(--radius-s) 0;
}
.word-card-eyebrow{
  display:block;
  font-size: 12px;
  color: var(--text-faint);
  font-weight:700;
  margin: 14px 0 6px;
}
.word-card-target{
  font-size: 34px;
  font-weight: 900;
  color: var(--text);
  word-break: break-word;
  margin-bottom: 22px;
}

.taboo-block{
  border-top: 1px dashed var(--border-strong);
  padding-top: 16px;
}
.taboo-title{
  display:block;
  font-size: 11px;
  color: var(--accent-red);
  font-weight: 800;
  letter-spacing: .03em;
  margin-bottom: 10px;
}
.taboo-list{
  list-style:none;
  margin:0; padding:0;
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
}
.taboo-list li{
  background: rgba(232,87,74,0.12);
  border: 1px solid rgba(232,87,74,0.32);
  color: #f6b6ae;
  font-size: 13.5px;
  font-weight:700;
  padding: 6px 12px;
  border-radius: 100px;
}

.mistake-meter{
  margin-top: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 9px 16px;
}
.mistake-meter-label{ font-size:12px; color: var(--text-dim); font-weight:700; }
.mistake-dots{ display:flex; gap:5px; }
.mistake-dots .dot{
  width:8px; height:8px;
  border-radius:50%;
  background: rgba(255,255,255,0.15);
  transition: background .2s ease, transform .2s ease;
}
.mistake-dots .dot.is-lit{
  background: var(--accent-orange);
  transform: scale(1.15);
}
.mistake-meter-count{ font-size:12px; color: var(--text-faint); font-weight:700; }

/* ============ أزرار التحكم ============ */
.controls{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.ctrl-btn{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  border:none;
  border-radius: var(--radius-m);
  padding: 16px 8px;
  cursor:pointer;
  box-shadow: var(--shadow-btn);
  transition: transform .1s ease, filter .1s ease;
}
.ctrl-btn:active{ transform: scale(0.96); }
.ctrl-btn:disabled{ opacity:.35; filter:grayscale(.4); cursor:not-allowed; box-shadow:none; }
.ctrl-icon{ font-size:20px; line-height:1; margin-bottom:2px; }
.ctrl-text{ font-family: var(--font-display); font-size:14.5px; font-weight:800; }
.ctrl-sub{ font-size:11px; opacity:.85; font-weight:700; }

.ctrl-use-word{
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #f2c675, var(--accent-gold));
  color: #1c1204;
  border: none;
}
.ctrl-use-word .ctrl-icon{ margin-bottom:0; font-size:18px; }
.ctrl-use-word.is-hidden{ display:none; }

.ctrl-correct{ background: linear-gradient(180deg, #55d6a8, var(--accent-teal)); color:#062a1e; }
.ctrl-wrong{ background: linear-gradient(180deg, #f7b06e, var(--accent-orange)); color:#3a1c00; }
.ctrl-skip{ background: var(--bg-panel-2); color: var(--text); border: 1px solid var(--border-strong); }
.ctrl-foul{ background: linear-gradient(180deg, #f18075, var(--accent-red)); color:#3a0a05; }

/* ============ ملخص الجولة ============ */
.summary-header{ text-align:center; padding: 14px 4px 18px; }
.summary-team-name{
  font-size: 30px;
  font-weight:900;
  color: var(--accent-teal);
  margin: 8px 0 14px;
}
.summary-round-score{
  display:inline-flex;
  align-items:baseline;
  gap:8px;
  background: var(--bg-panel);
  border:1px solid var(--border);
  padding: 10px 18px;
  border-radius: 100px;
}
.summary-round-value{
  font-family: var(--font-display);
  font-size: 24px;
  font-weight:900;
  color: var(--accent-gold);
}
.summary-round-score span:last-child{ font-size:13px; color: var(--text-dim); font-weight:700; }

.totals-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom: 18px;
}
.total-chip{
  display:flex;
  flex-direction:column;
  gap:4px;
  align-items:center;
  padding: 14px 10px;
  border-radius: var(--radius-m);
  border:1px solid var(--border);
  background: var(--bg-panel);
}
.total-chip-name{
  font-size:12.5px;
  font-weight:700;
  color: var(--text-dim);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width: 100%;
}
.total-chip-value{
  font-family: var(--font-display);
  font-size: 24px;
  font-weight:900;
}
.total-a .total-chip-value{ color: var(--accent-teal); }
.total-b .total-chip-value{ color: var(--accent-gold); }

.words-panel{ margin-bottom: 18px; }
.word-log{
  list-style:none;
  margin:0; padding:0;
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height: 260px;
  overflow-y:auto;
}
.word-log li{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  background: var(--bg-card);
  border-radius: var(--radius-s);
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight:700;
}
.word-log .status-badge{
  font-size: 11px;
  font-weight:800;
  padding: 4px 10px;
  border-radius: 100px;
  flex:none;
}
.status-correct{ background: rgba(63,191,149,0.16); color: var(--accent-teal); }
.status-skip{ background: rgba(167,173,194,0.16); color: var(--text-dim); }
.status-wrong3{ background: rgba(242,153,74,0.16); color: var(--accent-orange); }
.status-foul{ background: rgba(232,87,74,0.16); color: var(--accent-red); }

.summary-actions{ display:flex; flex-direction:column; gap:10px; }

/* ============ نهاية اللعبة ============ */
.over-content{ text-align:center; padding-top: 30px; }
.over-trophy{ font-size: 56px; display:block; margin-bottom: 10px; }
.over-winner{
  font-size: 34px;
  font-weight:900;
  color: var(--accent-gold);
  margin: 10px 0 4px;
}
.over-sub{ color: var(--text-dim); font-size:14px; margin: 0 0 20px; }

/* ============ استجابة أكبر للشاشات ============ */
@media (min-width: 520px){
  .app{ padding-top: 36px; }
  .brand-title{ font-size: 48px; }
}

@media (max-width: 360px){
  .categories-grid{ grid-template-columns: 1fr; }
  .word-card-target{ font-size: 28px; }
}

/* Focus visibility for keyboard users */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, label:focus-within{
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}
