/* Shift booth games: shared shell.
   Tokens come from the live platform (src/styles/figma-theme.css) and the logo SVG. */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: block;
  src: url("../assets/fonts/plex-arabic-400-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: block;
  src: url("../assets/fonts/plex-arabic-400-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-21FF, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: block;
  src: url("../assets/fonts/plex-arabic-500-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: block;
  src: url("../assets/fonts/plex-arabic-500-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-21FF, U+2212; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: block;
  src: url("../assets/fonts/plex-arabic-700-arabic.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: block;
  src: url("../assets/fonts/plex-arabic-700-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+20AC, U+2190-21FF, U+2212; }

:root {
  --navy: #0E1F3A;
  --logo-blue: #076CFB;
  --primary: #3B5EF5;
  --primary-strong: #1F45E8;
  --primary-soft: #F0F3FF;
  --primary-wash: #E3E9FF;
  --text: #3A3B3F;
  --text-2: #707070;
  --surface: #FFFFFF;
  --muted: #F5F6F8;
  --border: #EDEDED;
  --border-strong: #D9DCE3;
  --good: #16A34A;
  --good-soft: #DCFCE7;
  --warn: #F59E0B;
  --warn-soft: #FEF3C7;
  --bad: #E5484D;
  --bad-soft: #FDE8E8;
  --absent: #8B9099;
  --radius: 0.75rem;
  --radius-lg: 1.1rem;
  --shadow: 0 1px 2px rgba(14,31,58,.06), 0 4px 16px rgba(14,31,58,.06);
  --shadow-lg: 0 8px 40px rgba(14,31,58,.18);
  --ease: cubic-bezier(.2,.8,.2,1);
  --spring: cubic-bezier(.34,1.56,.64,1);
  --font: "Plex Arabic", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* One dial sizes the whole UI: 14px on a phone, ~22px on a 1080p TV, capped on 4K. */
html { font-size: clamp(14px, calc(0.9vmin + 0.55vmax), 30px); }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--muted);
  -webkit-font-smoothing: antialiased;
  /* Kiosk: no selection, no callouts, no bounce, no double-tap zoom. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
}
img { -webkit-user-drag: none; user-select: none; pointer-events: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus { outline: none; }
button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ---------- App frame ---------- */
.app { height: 100%; display: flex; flex-direction: column; }
.topbar {
  flex: none; display: flex; align-items: center; gap: 0.75rem;
  padding: 0.7rem 1.2rem; background: var(--surface); border-bottom: 1px solid var(--border);
  min-height: 4.2rem;
}
.topbar .logo { height: 1.9rem; width: auto; flex: none; }
.topbar .sep { width: 1px; height: 1.8rem; background: var(--border-strong); flex: none; }
.topbar .title { min-width: 0; flex: 1; }
.topbar .title h1 { margin: 0; font-size: 1.35rem; font-weight: 700; color: var(--navy); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .title p { margin: 0.1rem 0 0; font-size: 0.85rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .stats { display: flex; gap: 0.5rem; flex: none; }
.stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 4.4rem; padding: 0.3rem 0.7rem; border-radius: var(--radius); background: var(--muted);
}
.stat b { font-size: 1.2rem; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { font-size: 0.7rem; color: var(--text-2); line-height: 1.2; }
.stat.pop b { animation: pop .35s var(--spring); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 3.1rem; padding: 0 1.2rem; border-radius: var(--radius);
  font-weight: 700; font-size: 1rem; white-space: nowrap;
  transition: transform .12s var(--ease), background-color .2s, color .2s, opacity .2s;
}
.btn:active { transform: scale(.96); }
.btn svg { width: 1.25em; height: 1.25em; flex: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 10px rgba(59,94,245,.3); }
.btn-primary:active { background: var(--primary-strong); }
.btn-ghost { background: var(--muted); color: var(--navy); }
.btn-ghost:active { background: var(--primary-wash); }
.btn-outline { background: var(--surface); color: var(--navy); box-shadow: inset 0 0 0 2px var(--border-strong); }
.btn-icon { width: 3.1rem; padding: 0; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn-lg { min-height: 3.8rem; font-size: 1.2rem; padding: 0 1.8rem; border-radius: var(--radius-lg); }

.stage { flex: 1; min-height: 0; position: relative; display: flex; }
.stage > .play { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1rem; gap: 1rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; top: 5.4rem; left: 50%; transform: translate(-50%, -1rem); opacity: 0;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 1.1rem;
  padding: 0.7rem 1.4rem; border-radius: 999px; box-shadow: var(--shadow-lg);
  transition: opacity .2s, transform .25s var(--spring); pointer-events: none; z-index: 60; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: var(--good); }
.toast.bad { background: var(--bad); }

/* ---------- Sheets (result, help, idle) ---------- */
.scrim {
  position: fixed; inset: 0; background: rgba(14,31,58,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.scrim.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: min(34rem, 100%); max-height: 100%; overflow: auto;
  background: var(--surface); border-radius: 1.4rem; box-shadow: var(--shadow-lg);
  padding: 2rem 1.8rem 1.6rem; text-align: center;
  transform: translateY(1.5rem) scale(.96); transition: transform .35s var(--spring);
}
.scrim.show .sheet { transform: none; }
.sheet .badge-logo { height: 2.2rem; margin: 0 auto 1rem; display: block; }
.sheet h2 { margin: 0 0 0.4rem; font-size: 1.9rem; color: var(--navy); line-height: 1.25; }
.sheet p { margin: 0 0 0.6rem; font-size: 1.05rem; color: var(--text-2); line-height: 1.6; }
.sheet .big-num { font-size: 3.4rem; font-weight: 700; color: var(--primary); line-height: 1.1; margin: 0.6rem 0 0.2rem; font-variant-numeric: tabular-nums; }
.sheet .facts { display: flex; justify-content: center; gap: 0.6rem; margin: 1rem 0 0.4rem; flex-wrap: wrap; }
.sheet .facts .stat { min-width: 6rem; padding: 0.6rem 0.8rem; }
.sheet .actions { display: flex; gap: 0.7rem; justify-content: center; margin-top: 1.4rem; flex-wrap: wrap; }
.sheet .actions .btn { flex: 1 1 10rem; }
.sheet .reveal { margin: 0.8rem 0 0; padding: 0.8rem; border-radius: var(--radius); background: var(--primary-soft); color: var(--navy); font-weight: 700; font-size: 1.2rem; }
.sheet ul.rules { text-align: start; margin: 0.8rem 0 0; padding: 0 1.2rem; color: var(--text); line-height: 1.7; font-size: 1.05rem; }
.sheet .new-best { display: inline-block; margin-top: 0.4rem; padding: 0.25rem 0.8rem; border-radius: 999px; background: var(--warn-soft); color: #92400E; font-weight: 700; font-size: 0.9rem; }
.sheet .cta { margin-top: 1rem; font-size: 0.95rem; color: var(--navy); }

/* ---------- Confetti ---------- */
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; }

/* ---------- On-screen keyboard ---------- */
.kbd { width: min(100%, 52rem); display: flex; flex-direction: column; gap: 0.45rem; direction: ltr; }
.kbd[data-lang="ar"] { direction: rtl; }
.kbd .row { display: flex; gap: 0.4rem; justify-content: center; }
.kbd .key {
  flex: 1 1 0; max-width: 4.4rem; min-width: 0; height: 3.5rem; border-radius: 0.6rem;
  background: var(--surface); color: var(--navy); font-size: 1.35rem; font-weight: 700;
  box-shadow: 0 1px 0 var(--border-strong), inset 0 0 0 1px var(--border);
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s, background-color .25s, color .25s;
}
.kbd .key:active { transform: scale(.92); background: var(--primary-wash); }
.kbd .key.wide { flex: 1.6 1 0; max-width: 7rem; font-size: 1rem; }
.kbd .key svg { width: 1.5rem; height: 1.5rem; }
.kbd .key.s-correct { background: var(--primary); color: #fff; box-shadow: none; }
.kbd .key.s-present { background: var(--warn); color: #fff; box-shadow: none; }
.kbd .key.s-absent { background: var(--absent); color: #fff; box-shadow: none; opacity: .75; }

/* ---------- Idle warning ---------- */
.idle-count { font-size: 4rem; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- Motion ---------- */
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-0.5rem); } 40% { transform: translateX(0.5rem); } 60% { transform: translateX(-0.35rem); } 80% { transform: translateX(0.35rem); } }
@keyframes rise { from { opacity: 0; transform: translateY(0.8rem); } to { opacity: 1; transform: none; } }
@keyframes bounce-in { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.shake { animation: shake .45s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Narrow portrait: tighten the top bar */
@media (max-aspect-ratio: 3/4) {
  .topbar { padding: 0.6rem 0.8rem; gap: 0.5rem; }
  .topbar .sep, .topbar .title p { display: none; }
  .topbar .logo { height: 1.5rem; }
  .stat { min-width: 3.4rem; padding: 0.25rem 0.5rem; }
}
@media (max-width: 520px) {
  .topbar .title { visibility: hidden; }
  .topbar .btn-label { display: none; }
  .topbar .retry { width: 3.1rem; padding: 0; }
}

/* ---------- Leaderboard entry inside the result sheet ---------- */
.sheet.wide { width: min(48rem, 100%); }
.lb-entry { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.lb-entry p { margin: 0.6rem 0 0.5rem; color: var(--navy); font-weight: 700; }
.lb-made {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.45rem 1rem; border-radius: 999px;
  background: var(--warn-soft); color: #92400E; font-weight: 700; font-size: 1.1rem; animation: bounce-in .45s var(--spring);
}
.lb-made svg { width: 1.4rem; height: 1.4rem; }
.lb-made.done { margin-top: 0.8rem; }
.lb-name {
  min-height: 3.6rem; margin: 0 auto 0.8rem; width: min(100%, 26rem); border-radius: var(--radius);
  background: var(--muted); box-shadow: inset 0 0 0 2px var(--primary);
  display: flex; align-items: center; justify-content: center; gap: 2px;
  font-size: 1.7rem; font-weight: 700; color: var(--navy); white-space: pre;
}
.lb-name .caret { width: 2px; height: 1.8rem; background: var(--primary); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lb-kbd { display: flex; justify-content: center; }
.lb-kbd .kbd { width: 100%; }
.lb-kbd .key { height: 3.1rem; font-size: 1.2rem; }
.kbd .key.space { flex: 0 1 60%; max-width: none; font-size: 1rem; color: var(--text-2); }

/* ---------- Ready screen for timed games ---------- */
.ready { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; text-align: center; margin: auto; padding: 1rem; }
.ready h2 { margin: 0; font-size: 2.4rem; color: var(--navy); }
.ready p { margin: 0; font-size: 1.15rem; color: var(--text-2); max-width: 36rem; line-height: 1.6; }
.ready-go { min-height: 5rem; padding: 0 3.5rem; font-size: 1.6rem; border-radius: 1.4rem; }
.ready-count { margin: auto; font-size: 9rem; font-weight: 700; color: var(--primary); animation: bounce-in .5s var(--spring); }
.timebar { width: min(100%, 50rem); height: 0.8rem; border-radius: 999px; background: var(--border); overflow: hidden; flex: none; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--primary); border-radius: inherit; transform-origin: right center; }
[dir="ltr"] .timebar i { transform-origin: left center; }
.timebar.low i { background: var(--bad); }
.plus { position: fixed; font-weight: 700; color: var(--good); font-size: 2rem; pointer-events: none; animation: float 0.9s var(--ease) forwards; z-index: 40; }
.plus.minus { color: var(--bad); }
@keyframes float { to { transform: translateY(-3rem); opacity: 0; } }
