*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
:root {
  --grass-1: #12502f;
  --grass-2: #0f4628;
  --chalk: #f4f7f2;
  --ink: #0b1d13;
  --board: #101418;
  --amber: #ffb524;
  --red: #e5484d;
  --sky: #7cc4ff;
  --mute: #9fb3a7;
  --card: rgba(9, 22, 15, 0.86);
  --line: rgba(244, 247, 242, 0.18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --score: "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  /* System fonts with good Arabic coverage on Windows, macOS/iOS, Android and Linux (no web fonts loaded). */
  --arabic: "Segoe UI", "Geeza Pro", "Arabic UI Text", "SF Arabic", "Noto Kufi Arabic", "Noto Sans Arabic", Tahoma, "Dubai", sans-serif;
  color-scheme: dark;
}
html, body { margin: 0; min-height: 100%; }
body { background: var(--grass-2); color: var(--chalk); font-family: var(--font); font-size: 17px; line-height: 1.4; }

.pitch {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 50% 38%, transparent 0 118px, rgba(244,247,242,.10) 119px 121px, transparent 122px),
    linear-gradient(to bottom, transparent calc(38% - 1px), rgba(244,247,242,.10) calc(38% - 1px) calc(38% + 1px), transparent calc(38% + 1px)),
    repeating-linear-gradient(to bottom, var(--grass-1) 0 64px, var(--grass-2) 64px 128px);
}
.wrap { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: 14px max(14px, env(safe-area-inset-left)) 40px; display: flex; flex-direction: column; gap: 14px; }

/* scoreboard header */
.board { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--board); border: 2px solid #2a3138; border-radius: 6px; padding: 8px 12px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--score); font-weight: 800; font-size: 24px; letter-spacing: 3px; color: var(--chalk); text-decoration: none; line-height: 1; }
.brand-mark { flex: none; border-radius: 5px; }
.brand-ar { font-family: var(--arabic); font-weight: 700; font-size: 22px; letter-spacing: 0; color: var(--amber); padding-left: 8px; border-left: 2px solid #2a3138; }
.board-r { font-family: var(--score); font-weight: 700; font-size: 18px; color: var(--amber); letter-spacing: 1px; text-align: right; }

.screen { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px; backdrop-filter: blur(2px); }
.card.center { align-items: center; text-align: center; }
.kicker { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--amber); }
h1 { margin: 0; font-size: 24px; line-height: 1.2; }
h2 { margin: 0; font-size: 23px; line-height: 1.25; }
.small-h { font-size: 18px; color: var(--mute); font-weight: 600; }
.rules { margin: 0; padding-left: 20px; color: #dbe5de; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.lbl { font-size: 13px; color: var(--mute); }

input { width: 100%; font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 8px; border: 2px solid var(--line); background: rgba(0,0,0,.35); color: var(--chalk); outline: none; }
input:focus { border-color: var(--amber); }
.code-in { text-transform: uppercase; letter-spacing: 6px; font-family: var(--score); font-weight: 800; text-align: center; }

.btn { font: inherit; font-weight: 700; border: 0; border-radius: 8px; padding: 12px 16px; cursor: pointer; background: var(--amber); color: var(--ink); }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { font-size: 19px; padding: 14px 16px; width: 100%; }
.btn.ghost { background: transparent; color: var(--chalk); border: 2px solid var(--line); }
.btn.ghost:hover { border-color: var(--chalk); }
.btn.small { padding: 8px 12px; font-size: 15px; align-self: center; }
.link { background: none; border: 0; color: var(--mute); text-decoration: underline; cursor: pointer; font: inherit; font-size: 14px; }
.row { display: flex; gap: 10px; }
.row > .btn.big { flex: 1; }
.or { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.err { margin: 0; min-height: 1.2em; color: #ff8d90; font-size: 15px; }
.note { text-align: center; color: var(--mute); margin: 0; }

.code { font-family: var(--score); font-weight: 800; font-size: 54px; letter-spacing: 12px; color: var(--amber); background: var(--board); padding: 4px 8px 4px 20px; border-radius: 6px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 2px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 15px; padding: 10px 4px; background: transparent; color: var(--chalk); border: 0; cursor: pointer; }
.seg button + button { border-left: 2px solid var(--line); }
.seg button.on { background: var(--chalk); color: var(--ink); font-weight: 700; }
.seg.locked button { cursor: default; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.plist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,.04); border-radius: 6px; }
.plist .shirt { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; font-family: var(--score); font-weight: 800; font-size: 14px; color: var(--ink); flex: none; }
.plist .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .tagx { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: 1px; }
.plist .off { opacity: .45; }
.plist.compact li { padding: 6px 10px; }
.status { font-size: 13px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.status.thinking { color: var(--mute); }
.status.scored { color: #7ff0a8; }
.status.out { color: #ff8d90; }

.meta { display: flex; justify-content: space-between; align-items: center; color: var(--mute); font-size: 14px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.pill { font-size: 12px; padding: 3px 8px; border-radius: 99px; border: 1px solid var(--line); color: var(--chalk); }
.clock { height: 8px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; }
.clock div { height: 100%; width: 100%; background: var(--amber); transform-origin: left; }
.clock.hurry div { background: var(--red); }
.feedback { min-height: 1.4em; font-weight: 700; font-size: 17px; }
.feedback.hit { color: #7ff0a8; }
.feedback.miss { color: #ff8d90; }

.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,.05); border-left: 5px solid var(--mute); animation: pop .35s ease both; }
.results li.t1 { border-left-color: #b9c4bd; }
.results li.t2 { border-left-color: var(--sky); }
.results li.t3 { border-left-color: var(--amber); }
.results li.t4 { border-left-color: #ff6bd5; }
.results .who { font-weight: 700; }
.results .pts { font-family: var(--score); font-weight: 800; font-size: 22px; grid-row: span 2; align-self: center; }
.results .what { color: #dbe5de; font-size: 15px; }
.results .fin { font-weight: 700; }
.results .bon { color: var(--amber); font-size: 13px; font-weight: 700; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
.missed { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.missed li { font-size: 14px; padding: 5px 9px; border-radius: 99px; background: rgba(255,255,255,.06); border: 1px solid var(--line); }
.missed li small { color: var(--mute); margin-left: 4px; }

.table { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; counter-reset: pos; width: 100%; }
.table li { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,.04); counter-increment: pos; }
.table li::before { content: counter(pos); font-family: var(--score); font-weight: 800; width: 1.4em; color: var(--mute); }
.table li .nm { flex: 1; text-align: left; }
.table li .sc { font-family: var(--score); font-weight: 800; font-size: 18px; color: var(--amber); }
.table li.me { outline: 2px solid var(--amber); }
.big-table li { padding: 10px 12px; font-size: 18px; }
.big-table li:first-child { background: rgba(255,181,36,.16); }
#winner { font-size: 28px; }

.foot { display: flex; justify-content: space-between; align-items: center; }
.conn { font-size: 13px; color: var(--mute); }
.conn.bad { color: #ff8d90; }

/* Admin answer key (only rendered for the ?admin= client) */
.admin-key { margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; font-size: 13px; line-height: 1.5; max-height: 40vh; overflow-y: auto; }
.admin-key .ak-h { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 4px; }
.admin-key .ak-row { margin: 3px 0; }
.admin-key .ak-row b { margin-right: 6px; }
.admin-key .t4 b { color: #ff6bd5; } .admin-key .t3 b { color: #7cc4ff; } .admin-key .t2 b { color: #7ff0a8; } .admin-key .t1 b { opacity: .8; }

.toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100% - 32px); margin: 0; padding: 10px 16px; border-radius: 10px; background: #2a1416; color: #ffd0d2; border: 1px solid #ff8d90; font-size: 15px; z-index: 10; }
.toast[hidden] { display: none; }

/* ---------- site chrome shared by the game and the public pages ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.ar { font-family: var(--arabic); }
.board-link { font-family: var(--score); font-weight: 700; font-size: 16px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink); background: var(--amber); padding: 6px 12px; border-radius: 6px; text-decoration: none; }
.board-link:hover { filter: brightness(1.06); }
a { color: var(--amber); }
a:focus-visible, .btn:focus-visible, button:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

.about h2 { font-size: 21px; }
.about h3 { margin: 4px 0 0; font-size: 16px; color: var(--chalk); }
.about p:not(.kicker) { margin: 0; color: #dbe5de; font-size: 15px; }
.about ul.rules { list-style: disc; }

.site-foot { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; font-size: 14px; color: #c9d6cd; display: flex; flex-direction: column; gap: 8px; }
.site-foot p { margin: 0; }
.foot-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.foot-links a { color: var(--chalk); font-weight: 600; }
.foot-links a:hover { color: var(--amber); }

/* ---------- public pages (terms, privacy, pricing ...) ---------- */
.doc { gap: 10px; font-size: 16px; line-height: 1.55; color: #dbe5de; }
.doc h1 { font-size: 28px; color: var(--chalk); }
.doc h2 { font-size: 19px; color: var(--chalk); margin-top: 12px; }
.doc h3 { margin: 8px 0 0; font-size: 17px; color: var(--chalk); display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.doc p, .doc ul { margin: 0; }
.doc ul { padding-left: 22px; display: flex; flex-direction: column; gap: 4px; }
.doc b { color: var(--chalk); }
.doc .updated { font-size: 14px; color: var(--mute); }
.doc .lead { font-size: 18px; color: var(--chalk); }
.doc .note-left { color: #c9d6cd; font-size: 15px; }
.contact-email { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.soon { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink); background: var(--amber); padding: 2px 8px; border-radius: 99px; }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 4px 0; }
.plan { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 6px; }
.plan h3 { margin: 0; font-size: 16px; }
.plan .price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; }
.plan .amount { font-family: var(--score); font-weight: 800; font-size: 28px; color: var(--amber); }
.plan .per { font-size: 14px; color: #c9d6cd; }
.plan .plan-note { font-size: 13px; color: #c9d6cd; }
.plan ul { padding-left: 18px; font-size: 14px; }
