@font-face {
  font-family: Vazirmatn;
  src: url(fonts/vazirmatn.woff2) format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* Telegram sets --tg-theme-* on <html>. The --fb-* values are only for a normal browser. */
:root {
  --fb-bg: #ffffff; --fb-text: #111111; --fb-hint: #8a8f98; --fb-sec: #f1f2f5;
  --fb-btn: #2b8ae6; --fb-btn-text: #ffffff; --fb-ok: #1fa65a; --fb-mid: #e0a100; --fb-bad: #e04848;
  --bg: var(--tg-theme-bg-color, var(--fb-bg));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  --sec: var(--tg-theme-secondary-bg-color, var(--fb-sec));
  --btn: var(--tg-theme-button-color, var(--fb-btn));
  --btn-text: var(--tg-theme-button-text-color, var(--fb-btn-text));
  --link: var(--tg-theme-link-color, var(--btn));
  --danger: var(--tg-theme-destructive-text-color, var(--fb-bad));
  --ok: var(--fb-ok); --mid: var(--fb-mid); --bad: var(--fb-bad);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --fb-bg: #17212b; --fb-text: #f5f5f5; --fb-hint: #7d8b99; --fb-sec: #232e3c; --fb-btn: #5288c1; }
}

[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 Vazirmatn, Tahoma, system-ui, sans-serif;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }

#app {
  min-height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.center { margin: auto; text-align: center; }
.hint { color: var(--hint); }
.small { font-size: 14px; }
h1, h2 { margin: 0; line-height: 1.3; }
h1 { font-size: 26px; }
h2 { font-size: 17px; font-weight: 700; color: var(--hint); }

#banner {
  position: fixed; inset: 0 0 auto; z-index: 10;
  padding: 6px; text-align: center; font-size: 14px;
  background: var(--sec); color: var(--hint);
}

/* Buttons: min 48px touch target */
.btn {
  min-height: 48px; padding: 10px 18px;
  border: 0; border-radius: var(--radius);
  background: var(--btn); color: var(--btn-text);
  font-weight: 700; cursor: pointer;
}
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: var(--sec); color: var(--text); }
.btn.big { width: 100%; min-height: 56px; font-size: 20px; }
.btn.stop { background: var(--danger); color: #fff; }
#mainbar {
  position: fixed; inset: auto 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg);
}
#mainbar .btn { max-width: 528px; display: block; margin: 0 auto; }

/* Lobby */
.hero { text-align: center; display: grid; gap: 4px; padding-top: 8px; }
.logo { font-size: 48px; line-height: 1; }
.rules { background: var(--sec); border-radius: var(--radius); padding: 10px 14px; text-align: center; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plist li {
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 8px 14px;
  background: var(--sec); border-radius: var(--radius);
  font-size: 20px; font-weight: 600;
}
.plist li.off { opacity: .45; }
.plist .tag { margin-inline-start: auto; font-size: 14px; color: var(--hint); font-weight: 400; }
.seg { display: flex; gap: 8px; }
.seg .btn { flex: 1; }
.seg .btn:not(.on) { background: var(--sec); color: var(--text); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Typing */
.typing { display: flex; flex-direction: column; gap: 14px; }
.typing .top { text-align: center; display: grid; gap: 6px; }
.letter {
  width: 96px; height: 96px; margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--btn); color: var(--btn-text);
  font-size: 60px; font-weight: 800; line-height: 1;
}
.timer { display: flex; align-items: center; gap: 10px; }
.timer .bar { flex: 1; height: 10px; border-radius: 6px; background: var(--sec); overflow: hidden; }
.timer .bar i { display: block; height: 100%; width: 100%; background: var(--btn); border-radius: 6px; margin-inline-start: auto; }
.timer .secs { min-width: 2.2em; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.hurry .bar i { background: var(--danger); }
.timer.hurry .secs { color: var(--danger); }
.stopnote {
  text-align: center; font-weight: 700; color: #fff; background: var(--danger);
  border-radius: var(--radius); padding: 8px;
}
.card { background: var(--sec); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.cat { font-size: 28px; font-weight: 800; text-align: center; }
.answer {
  width: 100%; min-height: 60px; padding: 10px 14px;
  border: 2px solid transparent; border-radius: var(--radius);
  background: var(--bg); font-size: 24px; text-align: center; outline: none;
}
.answer:focus { border-color: var(--btn); }
.answer::placeholder { color: var(--hint); opacity: .6; }
.dots { display: flex; justify-content: center; gap: 4px; }
.dot {
  width: 48px; height: 48px; border: 0; background: none; padding: 0; cursor: pointer;
  display: grid; place-items: center;
}
.dot::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--sec); border: 2px solid var(--hint); }
.dot.done::after { background: var(--btn); border-color: var(--btn); }
.dot.cur::after { transform: scale(1.35); border-color: var(--text); }

/* Results */
.letter.sm { width: 48px; height: 48px; margin: 0; font-size: 28px; flex: none; }
.results { display: flex; flex-direction: column; gap: 14px; }
.vote {
  display: grid; gap: 10px; padding: 14px;
  border-radius: var(--radius); background: var(--sec);
  border: 2px solid var(--mid); font-weight: 600;
}
.vote .seg .btn { font-size: 15px; padding: 8px; }
.scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.scores li {
  display: flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 6px 14px; border-radius: var(--radius); background: var(--sec);
}
.scores li.me { outline: 2px solid var(--btn); }
.scores .rank { width: 1.8em; text-align: center; }
.scores .who { flex: 1; font-weight: 600; }
.scores .plus { color: var(--ok); font-size: 14px; }
.scores b { min-width: 2.5em; text-align: left; font-size: 18px; }
.scores.big li { min-height: 60px; font-size: 20px; }
.catblock { display: grid; gap: 6px; }
.ans {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 48px; padding: 6px 12px; text-align: right;
  border: 0; border-radius: var(--radius); background: var(--sec);
}
.ans.me { outline: 2px solid var(--btn); }
.ans.tap { cursor: pointer; }
.ans.tap:active { opacity: .7; }
.ans .mark { min-width: 3.4em; font-variant-numeric: tabular-nums; }
.ans .word { flex: 1; font-size: 18px; font-weight: 600; display: grid; line-height: 1.3; }
.ans .word small { font-size: 12px; font-weight: 400; color: var(--hint); }
.ans .who { font-size: 14px; color: var(--hint); }

/* How to play */
.help { display: grid; gap: 16px; }
.help h1 { font-size: 28px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--sec); border-radius: var(--radius); padding: 12px 14px; }
.steps .ico { font-size: 24px; line-height: 1.4; }
.example .ex { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.example .ex div { display: grid; background: var(--bg); border-radius: 10px; padding: 6px 4px; }
.example .ex small { color: var(--hint); font-size: 12px; }
