:root {
  --bg: #0a0908;
  --bg2: #110f0c;
  --card: #14110d;
  --ink: #f4efe3;
  --muted: #b3aa96;
  --dim: #7d7564;
  --gold: #d4af37;
  --gold2: #ecd27a;
  --line: rgba(212, 175, 55, 0.2);
  --line2: rgba(244, 239, 227, 0.08);
  --red: #ff6b5b;
  --green: #4cd08a;
  --r: 18px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -200px, rgba(212, 175, 55, 0.16), transparent 70%),
    radial-gradient(700px 400px at 100% 30%, rgba(212, 175, 55, 0.05), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: Tajawal, "Segoe UI", Cairo, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}
a { color: var(--gold2); }
.hidden { display: none !important; }
.gold { color: var(--gold); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1200px; margin: 0 auto; padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: 0.14em; font-size: 15px; direction: ltr; }
.mark { width: 30px; height: 30px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px;
  font-size: 13px; color: var(--muted); background: rgba(212, 175, 55, 0.06);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); display: inline-block; box-shadow: 0 0 0 0 rgba(255, 107, 91, 0.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 107, 91, 0.55); } 70% { box-shadow: 0 0 0 9px rgba(255, 107, 91, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 107, 91, 0); } }

/* ---------- layout ---------- */
.wrap { max-width: 560px; margin: 0 auto; padding: 4px 18px 30px; }
.wrap.wide { max-width: 1200px; }
.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)), var(--card);
  border: 1px solid var(--line2);
  border-radius: var(--r);
  padding: 22px 20px;
  margin: 16px 0;
}
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 14px; font-weight: 700; letter-spacing: 0.02em; }
h1 { font-size: clamp(34px, 9vw, 50px); line-height: 1.15; margin: 4px 0 12px; font-weight: 800; }
h2 { font-size: 23px; line-height: 1.3; margin: 0 0 6px; font-weight: 800; }
h3 { font-size: 18px; margin: 0 0 10px; font-weight: 700; }
.lead { color: var(--muted); font-size: 18px; margin: 0; }
.sub { color: var(--muted); margin: 0 0 16px; font-size: 15px; }
.muted { color: var(--muted); font-size: 14px; }

/* ---------- hero + countdown ---------- */
.hero { padding: 18px 0 2px; text-align: center; }
.count { text-align: center; border-color: var(--line); }
.count .label { margin: 0 0 12px; color: var(--muted); font-weight: 700; }
.clock { display: flex; justify-content: center; align-items: flex-start; gap: 8px; }
.unit { min-width: 84px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px 6px; }
.unit b { display: block; font-size: 44px; line-height: 1; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.unit span { display: block; font-size: 12px; color: var(--dim); margin-top: 6px; }
.sep { font-style: normal; font-size: 36px; color: var(--gold); line-height: 1.4; }
.when { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.live { margin: 12px 0 0; color: var(--gold2); font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.count.is-live { border-color: rgba(212, 175, 55, 0.55); box-shadow: 0 0 40px rgba(212, 175, 55, 0.12); }
.entries { margin: 10px 0 0; color: var(--gold2); font-weight: 700; font-size: 15px; }

/* ---------- winner ---------- */
.winner {
  text-align: center; border-color: rgba(212, 175, 55, 0.6);
  background: radial-gradient(500px 220px at 50% 0, rgba(212, 175, 55, 0.22), transparent 70%), var(--card);
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.16);
  animation: rise 0.7s ease-out;
}
.winner h2 { font-size: clamp(32px, 9vw, 46px); color: var(--gold2); margin: 6px 0 8px; }
.wmeta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 8px; }
.wmeta span:not(:empty) { border: 1px solid var(--line); border-radius: 99px; padding: 3px 12px; font-size: 14px; color: var(--ink); }
.wnote { color: var(--muted); margin: 0 0 6px; font-size: 14px; }
.wmsg { margin: 10px 0 0; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---------- form ---------- */
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.field small { color: var(--dim); font-weight: 500; }
input, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink);
  background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(244, 239, 227, 0.14);
  border-radius: 12px; padding: 12px 14px; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: #6f6858; }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.18); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: 18px 52%, 24px 52%; background-size: 6px 6px; background-repeat: no-repeat; }
[dir="ltr"] select, select[dir="ltr"] { background-position: calc(100% - 24px) 52%, calc(100% - 18px) 52%; }
option { background: #15120e; color: var(--ink); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bad input, .bad select { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 107, 91, 0.15); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 6px 0 14px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 3px 0 0; flex: 0 0 auto; accent-color: var(--gold); padding: 0; }
.check.bad span { color: var(--red); }
.hp { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; border: 0 !important; overflow: hidden !important; clip: rect(0 0 0 0); clip-path: inset(50%); opacity: 0; pointer-events: none; }
.err { color: var(--red); font-weight: 700; margin: 0 0 12px; font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border: 0; border-radius: 14px; padding: 15px 18px;
  font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; text-decoration: none;
  color: #17140b; background: linear-gradient(180deg, #ecd27a, #d4af37);
  box-shadow: 0 10px 30px rgba(212, 175, 55, 0.22);
  transition: transform 0.08s, filter 0.15s, opacity 0.15s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid rgba(244, 239, 227, 0.18); box-shadow: none; }
.btn.small { width: auto; font-size: 14px; padding: 8px 14px; border-radius: 10px; }
.btn.gold { background: linear-gradient(180deg, #f3dc8c, #d4af37); }
.btn.armed { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }
.link { background: none; border: 0; color: var(--dim); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 6px; margin-top: 4px; }

.ticket { text-align: center; }
.tnum { font-size: 54px; font-weight: 800; margin: 2px 0; color: var(--gold2); line-height: 1.1; }
.ticket p { margin: 0 0 6px; }

.next { border-color: var(--line); }
.next p { color: var(--muted); }

.rules ol { margin: 0; padding-inline-start: 22px; color: var(--muted); font-size: 15px; }
.rules li { margin: 4px 0; }

.foot { text-align: center; color: var(--dim); font-size: 13px; padding: 10px 20px 40px; max-width: 560px; margin: 0 auto; }
.foot p { margin: 4px 0; }
.foot a { color: var(--muted); }
.is-admin .foot, .is-admin .pill { display: none; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -16px; width: 8px; height: 14px; border-radius: 2px; animation-name: fall; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes fall { to { transform: translateY(112vh) rotate(760deg); } }

/* ---------- admin ---------- */
#admin { font-family: system-ui, "Segoe UI", Tajawal, sans-serif; font-size: 15px; }
#admin input, #admin select { font-size: 15px; }
.login { max-width: 420px; margin: 40px auto; }
.login form { display: flex; gap: 10px; }
.login .btn { width: auto; padding: 12px 20px; font-size: 16px; }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.bar h2, .bar h3 { margin: 0; }
.bar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bar input[type="search"] { max-width: 360px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 16px 0; }
.stat { background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font-size: 30px; font-weight: 800; color: var(--gold2); line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .card { margin: 0; }
.line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 6px; }
.actions .btn { width: auto; font-size: 15px; padding: 11px 16px; }
.wadmin { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; }
.wadmin .big { font-size: 20px; font-weight: 800; color: var(--gold2); }
.wadmin dl { display: grid; grid-template-columns: 110px 1fr; gap: 3px 10px; margin: 8px 0 0; color: var(--ink); }
.wadmin dt { color: var(--muted); }
.wadmin dd { margin: 0; word-break: break-word; }
.tag { display: inline-block; border-radius: 99px; padding: 1px 9px; font-size: 12px; font-weight: 700; }
.tag.on { background: rgba(76, 208, 138, 0.15); color: var(--green); }
.tag.off { background: rgba(244, 239, 227, 0.08); color: var(--muted); }
.tag.lead { background: rgba(212, 175, 55, 0.14); color: var(--gold2); }
.tag.x { background: rgba(255, 107, 91, 0.14); color: var(--red); }
.tablewrap { overflow: auto; margin-top: 12px; border: 1px solid var(--line2); border-radius: 12px; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
th { position: sticky; top: 0; background: #1a1611; color: var(--muted); font-weight: 600; z-index: 1; }
tr.is-winner td { background: rgba(212, 175, 55, 0.12); }
tr.is-x td { opacity: 0.5; }
td a { color: var(--ink); }
td .btn { padding: 5px 10px; font-size: 12px; }

@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .unit { min-width: 74px; }
  .unit b { font-size: 38px; }
  .row2 { grid-template-columns: 1fr; gap: 0; }
  h2 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  .dot, .winner { animation: none; }
}
