/* مندوس — component styles. Every value comes from tokens.css (var(--…)). RTL first. */
.md, .md * { box-sizing: border-box; }
.md { direction: rtl; font-family: var(--font-body); color: var(--ink); -webkit-font-smoothing: antialiased; }
.md-stage { background: var(--bg); padding: var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.md-col { display: flex; flex-direction: column; gap: var(--space-3); }
.md-row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.md :focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Button */
.md-btn { font: inherit; font-size: 17px; line-height: 24px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--button-md); padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1.5px solid transparent; cursor: pointer;
  background: var(--primary); color: var(--on-primary); transition: transform .12s ease, filter .12s ease; }
.md-btn:active { transform: scale(.97); }
.md-btn--lg { min-height: var(--button-lg); width: 100%; font-size: 18px; }
.md-btn--secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.md-btn--ghost { background: transparent; color: var(--primary-ink); padding: 0 var(--space-2); }
.md-btn--danger { background: var(--danger-soft); color: var(--danger); }
.md-btn[disabled], .md-btn.is-disabled { background: var(--surface-sunken); color: var(--ink-muted); border-color: transparent; cursor: not-allowed; }
.md-btn.is-loading { color: transparent; position: relative; }
.md-btn.is-loading::after { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--on-primary); border-inline-start-color: transparent; animation: md-spin .8s linear infinite; }
@keyframes md-spin { to { transform: rotate(-360deg); } }

/* Card + MatchCard */
.md-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-4); }
.md-match { display: flex; align-items: center; gap: var(--space-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-3); min-width: 320px; }
.md-match__thumb { width: 56px; height: 56px; border-radius: var(--radius-sm); flex: none; display: flex; align-items: center; justify-content: center; }
.md-match__thumb svg { width: 28px; height: 28px; }
.md-match__body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.md-match__title { font-size: 16px; line-height: 24px; font-weight: 700; }
.md-match__meta { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-muted); }

/* JoinCode */
.md-code { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md); min-width: 320px; }
.md-code input { flex: 1; font: inherit; font-size: 20px; letter-spacing: 6px; font-weight: 700; border: 0; background: transparent; color: var(--ink); direction: ltr; text-align: right; min-height: 40px; }
.md-code input::placeholder { color: var(--ink-muted); letter-spacing: 0; font-size: 15px; font-weight: 500; }

/* Field */
.md-field { display: flex; flex-direction: column; gap: 6px; min-width: 300px; }
.md-field__label { font-size: 15px; line-height: 22px; font-weight: 700; }
.md-field__input { font: inherit; font-size: 20px; min-height: 56px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 2px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.md-field__input::placeholder { color: var(--ink-muted); }
.md-field__hint { font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink-muted); display: flex; gap: 6px; align-items: center; }
.md-field.is-error .md-field__input { border-color: var(--danger); }
.md-field.is-error .md-field__hint { color: var(--danger); }
.md-field.is-ok .md-field__input { border-color: var(--success); }

/* Chip */
.md-chip { font: inherit; font-size: 15px; font-weight: 700; min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-pill); border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.md-chip[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary-ink); border-color: var(--primary); }

/* Status */
.md-status { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill); font-size: 14px; font-weight: 700; }
.md-status svg { width: 16px; height: 16px; }
.md-status--ok { background: var(--success-soft); color: var(--success); }
.md-status--wait { background: var(--warning-soft); color: var(--warning); }
.md-status--wrong { background: var(--danger-soft); color: var(--danger); }
.md-status--live { background: var(--primary-soft); color: var(--primary-ink); }
.md-status--live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: md-pulse 1.4s ease-in-out infinite; }
@keyframes md-pulse { 50% { opacity: .3; } }

/* Team badge */
.md-team { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 36px; padding: 0 var(--space-3) 0 var(--space-2); border-radius: var(--radius-pill); font-size: 15px; font-weight: 700; }
.md-team svg { width: 18px; height: 18px; }
.md-team--1 { background: var(--team-1); color: var(--on-team-1); } .md-team--2 { background: var(--team-2); color: var(--on-team-2); }
.md-team--3 { background: var(--team-3); color: var(--on-team-3); } .md-team--4 { background: var(--team-4); color: var(--on-team-4); }
.md-team--5 { background: var(--team-5); color: var(--on-team-5); } .md-team--6 { background: var(--team-6); color: var(--on-team-6); }

/* Avatar */
.md-avatar { position: relative; width: var(--avatar); height: var(--avatar); border-radius: var(--radius-pill); display: inline-flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; flex: none; }
.md-avatar__mark { position: absolute; top: -6px; inset-inline-start: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--bg); display: flex; align-items: center; justify-content: center; color: var(--primary-ink); }
.md-avatar__mark svg { width: 13px; height: 13px; }
.md-avatar.is-away { opacity: .45; }
.md-avatar.is-away::after { content: ""; position: absolute; bottom: 0; inset-inline-end: 0; width: 12px; height: 12px; border-radius: 50%; background: var(--ink-muted); border: 2px solid var(--bg); }
.md-player { display: flex; align-items: center; gap: var(--space-3); min-width: 260px; }
.md-player__name { font-size: 16px; font-weight: 700; } .md-player__role { font-size: 13px; color: var(--ink-muted); font-weight: 500; }

/* Timer */
.md-timer { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 44px; padding: 0 var(--space-3) 0 var(--space-2); border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--line); }
.md-timer__ring { width: 30px; height: 30px; transform: scaleX(-1); }
.md-timer__ring circle { fill: none; stroke-width: 4; }
.md-timer__track { stroke: var(--surface-sunken); } .md-timer__bar { stroke: var(--primary); stroke-linecap: round; }
.md-timer__num { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1; direction: ltr; }
.md-timer.is-urgent { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.md-timer.is-urgent .md-timer__bar { stroke: var(--danger); }

/* Segmented */
.md-seg { display: inline-flex; padding: 4px; gap: 4px; border-radius: var(--radius-pill); background: var(--surface-sunken); }
.md-seg button { font: inherit; font-size: 15px; font-weight: 700; min-height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-pill); border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; }
.md-seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-card); }

/* Toggle */
.md-toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: var(--touch-min); min-width: 300px; font-size: 16px; font-weight: 500; }
.md-toggle__sw { position: relative; width: 52px; height: 32px; border-radius: var(--radius-pill); background: var(--line-strong); border: 0; cursor: pointer; flex: none; }
.md-toggle__sw::after { content: ""; position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); transition: right .15s ease; }
.md-toggle__sw[aria-checked="true"] { background: var(--primary); }
.md-toggle__sw[aria-checked="true"]::after { right: 24px; background: var(--on-primary); }

/* Sheet */
.md-sheet { width: 360px; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-sheet); padding: var(--space-3) var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.md-sheet__handle { width: 40px; height: 5px; border-radius: var(--radius-pill); background: var(--line-strong); align-self: center; }
.md-sheet__title { font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 32px; }
.md-sheet__text { font-size: 16px; line-height: 26px; color: var(--ink-muted); }

/* Toast */
.md-toast { display: inline-flex; align-items: center; gap: var(--space-2); min-height: 48px; padding: 0 var(--space-4); border-radius: var(--radius-pill); background: var(--ink); color: var(--bg); font-size: 15px; font-weight: 700; box-shadow: var(--shadow-sheet); }
.md-toast svg { width: 18px; height: 18px; }

/* TV */
.md-tv { background: var(--tv-bg); color: var(--tv-ink); font-family: var(--font-body); padding: 28px 36px; border-radius: 14px; position: relative; overflow: hidden; }
.md-tv-scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.md-tv-score { background: var(--tv-surface); border-radius: 18px; padding: 16px 20px; display: flex; flex-direction: column; gap: 6px; border-top: 8px solid; }
.md-tv-score__name { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.md-tv-score__name svg { width: 22px; height: 22px; }
.md-tv-score__pts { font-family: var(--font-display); font-weight: 700; font-size: 56px; line-height: 1.1; }
.md-tv-score__delta { font-size: 18px; color: var(--tv-ink-muted); font-weight: 500; }
.md-tv-score.is-lead .md-tv-score__delta { color: var(--tv-ink); }
.md-tv-win { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 36px; border-radius: 14px; position: relative; overflow: hidden; }
.md-tv-win__time { font-size: 22px; opacity: .9; font-weight: 500; }
.md-tv-win__title { font-family: var(--font-display); font-weight: 700; font-size: 72px; line-height: 1.15; }
.md-tv-win__answer { font-family: var(--font-display); font-weight: 700; font-size: 40px; }
.md-tv-win__pts { font-size: 22px; font-weight: 500; }
.md-tv-win .dot { position: absolute; border-radius: 50%; }

/* ===== Personality components (direction A, horizontal slips) ===== */
/* Hero box ("the night chest") */
.md-hero { background: var(--hero); color: var(--hero-ink); border-radius: 30px; padding: 20px 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.md-hero__title { margin: 0 4px 4px; font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 38px; }
/* PickSlip */
.md-pick { position: relative; min-height: 84px; border-radius: 20px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; overflow: hidden; box-shadow: 0 8px 18px rgba(10, 14, 40, .3); }
.md-pick:nth-child(odd) { transform: rotate(-1.5deg); } .md-pick:nth-child(even) { transform: rotate(1.5deg); }
.md-pick__shape { position: absolute; width: 110px; height: 110px; left: 40px; top: -14px; opacity: .22; }
.md-pick__text { flex: 1; min-width: 0; position: relative; }
.md-pick__title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-family: var(--font-display); font-weight: 700; font-size: 22px; line-height: 28px; }
.md-pick__facts { display: block; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-pick__go { position: relative; width: 48px; height: 48px; border-radius: 50%; background: var(--slip); color: var(--slip-ink); display: flex; align-items: center; justify-content: center; flex: none; }
.md-pick__go svg { width: 18px; height: 18px; transform: scaleX(-1); }
.md-pick--more { background: transparent; box-shadow: none; border: 2px dashed var(--hero-muted); color: var(--hero-ink); min-height: 56px; font-weight: 800; transform: none !important; }
.md-pick--make { background: transparent; box-shadow: none; border: 2px dashed var(--hero-muted); color: var(--hero-muted); justify-content: center; text-align: center; transform: none !important; flex-direction: column; gap: 2px; font-size: 14px; }
.md-pick--make b { color: var(--hero-ink); font-size: 16px; }
@media (prefers-reduced-motion: reduce) { .md-pick { transform: none !important; } }
.md-lite .md-pick { transform: none !important; box-shadow: none; }
/* RoomTicket */
.md-ticket { position: relative; display: flex; border-radius: 24px; background: var(--hero); color: var(--hero-ink); min-width: 340px; }
.md-ticket::before, .md-ticket::after { content: ""; position: absolute; left: 118px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); }
.md-ticket::before { top: -11px; } .md-ticket::after { bottom: -11px; }
.md-ticket__main { flex: 1; padding: 16px 18px; }
.md-ticket__label { font-size: 13px; font-weight: 700; color: var(--hero-muted); }
.md-ticket__code { font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 54px; letter-spacing: 8px; direction: ltr; text-align: right; }
.md-ticket__stub { width: 130px; display: flex; align-items: center; justify-content: center; border-left: 2px dashed var(--hero-muted); padding: 14px; }
.md-ticket__qr { background: #FFFFFF; padding: 7px; border-radius: 10px; line-height: 0; }
.md-ticket__tv { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 800; background: var(--slip); color: var(--slip-ink); }
/* NameTag */
.md-nametag { width: 300px; background: var(--slip); color: var(--slip-ink); border-radius: 18px; overflow: hidden; box-shadow: 0 14px 30px rgba(26, 26, 46, .18); transform: rotate(-2deg); }
.md-nametag__band { background: var(--primary); color: var(--on-primary); text-align: center; padding: 10px 0 8px; font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.md-nametag__name { margin: 0 22px; padding: 16px 0 10px; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 44px; line-height: 52px; border-bottom: 2px dashed var(--line-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.md-nametag__name--long { font-size: 30px; }
.md-nametag__colors { display: flex; justify-content: center; gap: 10px; padding: 14px 0 16px; }
.md-nametag__colors i { width: 30px; height: 30px; border-radius: 50%; }
.md-nametag__colors i[aria-checked="true"] { box-shadow: 0 0 0 3px var(--slip), 0 0 0 6px var(--slip-ink); }
/* PaperSlip + Stamp */
.md-paper { position: relative; width: 320px; background: var(--slip); color: var(--slip-ink); border-radius: 8px; padding: 22px 16px 18px; transform: rotate(-2deg); box-shadow: 0 12px 28px rgba(27, 33, 64, .16); text-align: center; }
.md-paper::before { content: ""; position: absolute; top: -9px; right: 50%; margin-right: -30px; width: 60px; height: 18px; background: var(--team-3); opacity: .85; border-radius: 3px; transform: rotate(3deg); }
.md-paper__body { font-family: var(--font-display); font-weight: 700; font-size: 52px; line-height: 64px; display: flex; justify-content: center; gap: 28px; }
.md-paper__hint { font-size: 13px; font-weight: 500; color: #5E5E74; }
.md-stamp { position: absolute; left: -8px; top: -16px; transform: rotate(-12deg); border: 4px solid currentColor; border-radius: 14px; padding: 2px 14px; font-family: var(--font-display); font-weight: 700; font-size: 26px; line-height: 34px; background: rgba(255, 255, 255, .7); }
.md-stamp--ok { color: #1F7A4D; } .md-stamp--wrong { color: #B42318; }
/* TeamTakeover */
.md-take { position: relative; overflow: hidden; border-radius: 0 0 34px 34px; padding: 16px 18px 24px; min-width: 340px; }
.md-take__shape { position: absolute; width: 170px; height: 170px; left: -30px; top: -20px; opacity: .16; }
.md-take__kicker { position: relative; font-size: 14px; font-weight: 700; opacity: .92; }
.md-take__team { position: relative; font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 40px; }
.md-take--1 { background: var(--team-1); color: var(--on-team-1); } .md-take--2 { background: var(--team-2); color: var(--on-team-2); }
.md-take--3 { background: var(--team-3); color: var(--on-team-3); } .md-take--4 { background: var(--team-4); color: var(--on-team-4); }
.md-take--5 { background: var(--team-5); color: var(--on-team-5); } .md-take--6 { background: var(--team-6); color: var(--on-team-6); }
[data-theme="halawa-dark"] .md-take { color: #FFFFFF; }
[data-theme="halawa-dark"] .md-take--1 { background: var(--team-1-deep); } [data-theme="halawa-dark"] .md-take--2 { background: var(--team-2-deep); }
[data-theme="halawa-dark"] .md-take--3 { background: var(--team-3-deep); } [data-theme="halawa-dark"] .md-take--4 { background: var(--team-4-deep); }
[data-theme="halawa-dark"] .md-take--5 { background: var(--team-5-deep); } [data-theme="halawa-dark"] .md-take--6 { background: var(--team-6-deep); }
/* Podium */
.md-podium { display: flex; align-items: flex-end; gap: 8px; height: 220px; min-width: 340px; }
.md-podium__step { flex: 1; border-radius: 18px 18px 8px 8px; display: flex; flex-direction: column; align-items: center; padding-top: 12px; gap: 2px; position: relative; overflow: hidden; }
.md-podium__rank { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 40px; }
.md-podium__name { font-size: 15px; font-weight: 700; } .md-podium__pts { font-size: 13px; font-weight: 800; }
.md-podium__rest { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
