:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f2f3f7);
  --text: var(--tg-theme-text-color, #111827);
  --muted: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #2f6fed);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(127, 127, 127, .22);
  --ok: #1f9d55; --bad: #d64545;
  --nav-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { padding: 16px 16px 24px; max-width: 560px; margin: 0 auto; }
.boot { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
h1 { font-size: 24px; margin: 4px 0 4px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.card { background: var(--bg2); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 18px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--accent-text); font-weight: 700; cursor: pointer; width: 100%; }
.btn.sec { background: var(--bg2); color: var(--text); }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 10px; font-size: 14px; width: auto; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrapr { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.input, .select, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 11px 12px; outline: none; }
.input:focus { border-color: var(--accent); }
textarea.input { resize: vertical; min-height: 84px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 99px; padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 8px; font-size: 12px; font-weight: 700; background: var(--bg); }
.tag.drop { background: var(--accent); color: var(--accent-text); }

/* bottom navigation */
.nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--bg); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.nav button { flex: 1; height: var(--nav-h); border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; color: var(--muted); cursor: pointer; position: relative; }
.nav button b { font-size: 21px; line-height: 1; }
.nav button.on { color: var(--accent); font-weight: 700; }
.nav .badge { position: absolute; top: 8px; left: calc(50% + 6px); }

/* the wheel */
.wheel-box { position: relative; width: min(100%, 420px); margin: 4px auto 14px; aspect-ratio: 1; }
.wheel-box canvas { width: 100%; height: 100%; display: block; }
.pointer { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); width: 0; height: 0;
  border-left: 16px solid transparent; border-right: 16px solid transparent; border-top: 30px solid var(--text); filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.result { text-align: center; padding: 18px 14px; }
.result .num { font-size: 14px; font-weight: 800; letter-spacing: .04em; color: var(--accent); text-transform: uppercase; }
.result .title { font-size: 24px; font-weight: 800; line-height: 1.2; margin: 8px 0 6px; }
.result .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.pop { animation: pop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }

/* filming: only the wheel and the words, nothing else on screen */
body.film { padding-bottom: 0; }
body.film .nav, body.film .no-film { display: none !important; }
.film-head { display: none; text-align: center; font-size: 26px; font-weight: 900; line-height: 1.15; margin: 8px 0 14px; }
body.film .film-head { display: block; }
body.film .wrap { padding-top: max(18px, env(safe-area-inset-top)); }
.film-x { position: fixed; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg2); font-size: 18px; z-index: 6; opacity: .6; }

/* the timer: full screen */
.timer { position: fixed; inset: 0; background: var(--bg); z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); text-align: center; }
.timer .t-topic { font-size: 18px; font-weight: 700; max-width: 520px; }
.timer .t-digits { font-size: min(30vw, 190px); font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: -.03em; line-height: 1; margin: 18px 0 8px; }
.timer .t-digits.done { color: var(--bad); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.timer .t-bar { width: min(100%, 520px); height: 8px; border-radius: 99px; background: var(--bg2); overflow: hidden; margin-bottom: 22px; }
.timer .t-bar i { display: block; height: 100%; background: var(--accent); transition: width .5s linear; }
.timer .t-acts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: min(100%, 520px); }
.timer .t-close { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; }

/* lists */
.sec-h { display: flex; align-items: center; gap: 8px; padding: 12px 2px 6px; cursor: pointer; }
.sec-h b { font-size: 17px; }
.topic { display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; background: var(--bg2); border-radius: 12px; margin-bottom: 6px; }
.topic.dropped .t-title { color: var(--muted); }
.topic .t-title { flex: 1; min-width: 0; }
.icon { border: 0; background: none; font-size: 18px; padding: 2px 4px; cursor: pointer; color: var(--muted); }
.ep { display: flex; gap: 12px; align-items: flex-start; }
.ep .n { flex: none; min-width: 52px; text-align: center; font-weight: 900; font-size: 20px; color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(20,20,20,.92); color: #fff;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); text-align: center; }
