/* ---------- fonts (vendored, OFL) ---------- */
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/plex-arabic-400.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/plex-arabic-600.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/plex-arabic-700.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(/fonts/plex-latin-400.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(/fonts/plex-latin-600.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(/fonts/plex-latin-700.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F, U+2190-2193, U+2212; }
@font-face { font-family: 'Baloo Bhaijaan'; font-weight: 800; font-display: swap; src: url(/fonts/baloo-arabic-800.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Baloo Bhaijaan'; font-weight: 800; font-display: swap; src: url(/fonts/baloo-latin-800.woff2) format('woff2'); unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  --bg: #0A1433;
  --panel: #101D4A;
  --panel-2: #172760;
  --line: #22346E;
  --ink: #14224F;
  --red: #E0453A;
  --red-d: #B5322A;
  --red-l: #F07A70;
  --green: #2E9E5B;
  --green-d: #217A45;
  --green-l: #5CC287;
  --cream: #FBF6D9;
  --gold: #F6C445;
  --grey: #C9CED9;
  --muted: #9AA6C8;
  --white: #FFFFFF;
  --font: 'Plex Arabic', 'Geeza Pro', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --display: 'Baloo Bhaijaan', 'Plex Arabic', 'Geeza Pro', system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; cursor: pointer; }
.num { font-feature-settings: 'tnum'; direction: ltr; unicode-bidi: isolate; }

/* ---------- connection dot ---------- */
.conn { display: inline-flex; align-items: center; gap: .4em; font-size: 15px; color: var(--muted); font-weight: 600; }
.conn::before { content: ''; width: .7em; height: .7em; border-radius: 50%; background: #E9A23B; box-shadow: 0 0 0 3px #E9A23B33; }
.conn.on::before { background: #3FD07A; box-shadow: 0 0 0 3px #3FD07A33; }

/* ---------- hex board svg ---------- */
.hexboard { display: block; width: 100%; height: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.hexboard .tri-red { fill: var(--red); }
.hexboard .tri-green { fill: var(--green); }
.hexboard .cell polygon { fill: var(--white); stroke: var(--ink); stroke-linejoin: round; transition: fill .35s ease; }
.hexboard .cell text {
  font-family: var(--display); font-weight: 800; fill: var(--ink);
  text-anchor: middle; dominant-baseline: central; pointer-events: none; transition: fill .35s ease;
}
.hexboard .cell.red polygon { fill: var(--red); }
.hexboard .cell.green polygon { fill: var(--green); }
/* a won cell is pure colour — the letter leaves with it (Abu Nasser 2026-10-17) */
.hexboard .cell text { transition: opacity .35s ease; }
.hexboard .cell.red text, .hexboard .cell.green text { fill: var(--white); opacity: 0; }
.hexboard .cell.active polygon { fill: var(--grey); animation: activePulse 1.4s ease-in-out infinite; }
.hexboard .cell.active.open polygon { animation: openPulse .8s ease-in-out infinite; }
/* the team that rang: its colour breathes into grey and back until the answer is judged (Abu Nasser 2026-10-17) */
.hexboard .cell.active.buzz-red polygon { fill: var(--red); animation: buzzRed 1.1s ease-in-out infinite; }
.hexboard .cell.active.buzz-green polygon { fill: var(--green); animation: buzzGreen 1.1s ease-in-out infinite; }
.hexboard .cell.winpath polygon { stroke: var(--gold); }
.hexboard .cell.red.winpath polygon { animation: winRed 1s ease-in-out infinite; }
.hexboard .cell.green.winpath polygon { animation: winGreen 1s ease-in-out infinite; }
.hexboard .outline { fill: none; stroke: var(--ink); stroke-linejoin: round; }
.hexboard.tappable .cell { cursor: pointer; }
/* hover only where a real pointer hovers — on the iPad and the Flip a tap left a «sticky» pale cell behind */
@media (hover: hover) { .hexboard.tappable .cell:not(.red):not(.green):not(.active):hover polygon { fill: #EEF1F8; } }

@keyframes activePulse { 0%,100% { fill: var(--grey); } 50% { fill: #AEB5C4; } }
@keyframes openPulse { 0%,100% { fill: #FFE7A3; } 50% { fill: var(--gold); } }
@keyframes buzzGreen { 0%,100% { fill: var(--green); } 50% { fill: var(--grey); } }
@keyframes buzzRed { 0%,100% { fill: var(--red); } 50% { fill: var(--grey); } }
@keyframes winRed { 0%,100% { fill: var(--red); } 50% { fill: var(--red-l); } }
@keyframes winGreen { 0%,100% { fill: var(--green); } 50% { fill: var(--green-l); } }

/* ---------- modal & pin pad ---------- */
.modal-back { position: fixed; inset: 0; background: #050a1ecc; display: none; align-items: center; justify-content: center; z-index: 80; }
.modal-back.show { display: flex; }
.modal { background: var(--panel); border: 2px solid var(--line); border-radius: 22px; padding: 28px; width: min(520px, 92vw); text-align: center; box-shadow: 0 30px 80px #0008; }
.modal h3 { margin: 0 0 10px; font-size: 28px; }
.modal p { margin: 0 0 22px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }

.pinpad { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.pinpad h3 { margin: 0; font-size: 26px; }
.pinpad .dots { display: flex; gap: 14px; direction: ltr; }
.pinpad .dots i { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--muted); }
.pinpad .dots i.f { background: var(--gold); border-color: var(--gold); }
.pinpad .keys { display: grid; grid-template-columns: repeat(3, 84px); gap: 12px; direction: ltr; }
.pinpad .keys button { height: 72px; border-radius: 18px; border: 0; background: var(--panel-2); color: var(--white); font-size: 30px; font-weight: 700; }
.pinpad .keys button:active { background: var(--line); }
.pinpad .msg { min-height: 24px; color: var(--red-l); font-weight: 600; }
.pinpad.shake { animation: shake .4s; }
@keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 16px; padding: 0 18px; min-height: 56px; font-size: 21px; font-weight: 700;
  color: var(--white); background: var(--panel-2); display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  transition: transform .08s ease, filter .15s ease, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .32; cursor: default; transform: none; }
.btn.primary { background: var(--gold); color: #1B1A0E; }
.btn.ok { background: var(--green); }
.btn.bad { background: var(--red); }
.btn.ghost { background: transparent; border: 2px solid var(--line); }
.btn.on { outline: 3px solid var(--gold); outline-offset: -3px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(140%); background: #2A1220; border: 2px solid var(--red); color: #fff; padding: 12px 22px; border-radius: 14px; font-size: 18px; font-weight: 600; z-index: 90; transition: transform .25s ease; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }
