/* Цвета берутся из темы Telegram; запасные значения — для открытия в обычном браузере */
:root {
  --fb-bg: #f1f2f6;
  --fb-card: #ffffff;
  --fb-text: #15171c;
  --fb-hint: #8a8f98;
  --fb-accent: #4f6ef7;
  --fb-accent-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fb-bg: #0f1115;
    --fb-card: #1b1e24;
    --fb-text: #eef0f4;
    --fb-hint: #8a8f98;
    --fb-accent: #6d86ff;
  }
}
:root {
  --bg: var(--tg-theme-secondary-bg-color, var(--fb-bg));
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, var(--fb-card)));
  --text: var(--tg-theme-text-color, var(--fb-text));
  --hint: var(--tg-theme-hint-color, var(--fb-hint));
  /* фирменные цвета из логотипа turbal.eng: неоново-розовый на чёрном, жёлтые акценты */
  --accent: #d63d9b;
  --accent-soft: color-mix(in srgb, #e86cc0 18%, transparent);
  --accent-text: #ffffff;
  --brand-black: #121014;
  --brand-pink: #f07cc8;
  --brand-yellow: #f3e04b;
  --ok: #23a55a;
  --bad: #e5484d;
  --warn: #f5a524;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
b, strong { font-weight: 700; }
u { text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
mark { background: var(--accent-soft); color: inherit; padding: 0 3px; border-radius: 4px; }
#app { max-width: 560px; margin: 0 auto; padding: 16px 16px 32px; }
button { font: inherit; color: inherit; }

/* ---------- brand header ---------- */
.brand { display: flex; align-items: center; gap: 14px; background: var(--brand-black); color: #fff; border-radius: 20px; padding: 14px 16px; margin-bottom: 12px; }
.brand img { width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px var(--brand-pink); }
.logo { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin: 0; line-height: 1.1; }
.logo span { color: var(--brand-pink); }
.logo .logo-exam { display: inline-block; vertical-align: middle; font-size: 13px; font-weight: 800; letter-spacing: .3px;
  color: var(--brand-black); background: var(--brand-yellow); border-radius: 8px; padding: 3px 7px; margin-left: 2px; }
.tagline { color: #d9d3dc; margin: 4px 0 0; font-size: 14px; line-height: 1.35; }
.tagline b { color: var(--brand-yellow); }

/* ---------- typography ---------- */
.h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--hint); margin: 22px 4px 8px; }
.title { font-size: 22px; font-weight: 700; margin: 4px 0; }
.hint { color: var(--hint); font-size: 14px; }
.center { text-align: center; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 10px; }
.card.tappable { cursor: pointer; transition: transform .1s; }
.card.tappable:active { transform: scale(.98); }
.card.disabled { opacity: .5; cursor: default; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { text-align: center; padding: 10px 4px; border-radius: 12px; background: var(--bg); }
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 12px; color: var(--hint); }

.block-row { display: flex; align-items: center; gap: 12px; }
.block-emoji { font-size: 28px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--bg); flex-shrink: 0; }
.block-body { flex: 1; min-width: 0; }
.block-title { font-weight: 600; }
.badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); white-space: nowrap; }
.badge.soon { background: var(--bg); color: var(--hint); }

.progress { height: 6px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 6px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* ---------- buttons ---------- */
.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-text); margin-top: 10px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn:focus, .option:focus, .chip:focus { outline: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--card); color: var(--accent); }
.btn.white { background: #fff; color: var(--brand-black); box-shadow: inset 0 0 0 2px var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); }

.action { display: flex; align-items: center; gap: 12px; }
.action .icon { font-size: 22px; }
.action .grow { flex: 1; }
.action .arrow { color: var(--hint); }

.back-link { border: 0; background: none; color: var(--accent); font-size: 17px; padding: 4px 0 12px; cursor: pointer; }

/* ---------- task ---------- */
.task-head { display: flex; justify-content: space-between; align-items: center; color: var(--hint); font-size: 14px; }
.prompt { font-size: 20px; line-height: 1.5; margin: 14px 0 6px; font-weight: 500; }
.gap { display: inline-block; min-width: 56px; border-bottom: 2px solid var(--accent); text-align: center; color: var(--accent); font-weight: 700; padding: 0 4px; }
.gap.ok { color: var(--ok); border-color: var(--ok); }
.gap.bad { color: var(--bad); border-color: var(--bad); }
.base-inline { font-weight: 800; letter-spacing: .5px; color: var(--accent); white-space: nowrap; }
.base { display: inline-block; font-weight: 700; letter-spacing: 1px; font-size: 14px; padding: 4px 10px; border-radius: 8px; background: var(--bg); margin-top: 6px; }

.spoiler { margin-top: 12px; font-size: 15px; color: var(--hint); cursor: pointer; user-select: none; }
.spoiler .label { font-size: 13px; }
.spoiler .text { filter: blur(6px); transition: filter .2s; }
.spoiler.open .text { filter: none; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.option { border: 2px solid transparent; border-radius: 12px; padding: 14px 8px; background: var(--card); font-size: 17px; font-weight: 600; cursor: pointer; transition: transform .1s; }
.option:active { transform: scale(.97); }
/* нечётное число вариантов (4 предлога + «—»): последний во всю ширину */
.options .option:last-child:nth-child(odd) { grid-column: 1 / -1; }
.option.ok { border-color: var(--ok); color: var(--ok); }
.option.bad { border-color: var(--bad); color: var(--bad); }
.option:disabled { cursor: default; }

.input { width: 100%; margin-top: 16px; padding: 14px; border-radius: 12px; border: 2px solid transparent; background: var(--card); color: var(--text); font: inherit; font-size: 18px; outline: none; }
.input:focus { border-color: var(--accent); }
.input.ok { border-color: var(--ok); }
.input.bad { border-color: var(--bad); }

.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; font-size: 15px; }
.feedback.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); }
.feedback.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); }
.feedback > b { display: block; margin-bottom: 2px; }

/* ---------- result / blitz ---------- */
.big { font-size: 56px; font-weight: 800; line-height: 1; margin: 12px 0 4px; }
.emoji-xl { font-size: 56px; }
.timer { color: var(--text); font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); }
.score-pill { font-weight: 700; padding: 4px 12px; border-radius: 99px; background: var(--card); }
.flash-ok { animation: flash-ok .6s; }
.flash-bad { animation: flash-bad .5s; }
@keyframes flash-ok { 50% { background: color-mix(in srgb, var(--ok) 25%, var(--card)); } }
@keyframes flash-bad { 25%, 75% { transform: translateX(-6px); } 50% { transform: translateX(6px); } }

.leader { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--bg); }
.leader:last-child { border-bottom: 0; }
.leader.me { color: var(--accent); font-weight: 700; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
.chip { border: 0; border-radius: 99px; padding: 6px 12px; background: var(--card); font-size: 14px; white-space: nowrap; cursor: pointer; }
.chip.active { background: var(--accent); color: var(--accent-text); }

/* ---------- игры с картинками ---------- */
.match-board { display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-pic, .match-word { border: 3px solid transparent; border-radius: 14px; background: var(--card); cursor: pointer;
  transition: transform .1s, opacity .3s, border-color .15s; }
.match-pic { height: 88px; padding: 2px; }
.match-pic img { width: 100%; height: 100%; object-fit: contain; display: block; }
.match-word { height: 88px; font-weight: 600; font-size: 15px; padding: 4px 10px; color: var(--text); }
.match-pic:active, .match-word:active { transform: scale(.97); }
.selected { border-color: var(--accent); background: var(--accent-soft); }
.done { opacity: .25; border-color: var(--ok); pointer-events: none; }
.match-pic.bad, .match-word.bad { border-color: var(--bad); animation: flash-bad .4s; }

.memory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.memory-card { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: none; cursor: pointer; perspective: 600px; }
.memory-back, .memory-face { position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center;
  backface-visibility: hidden; transition: transform .35s; }
.memory-back { background: var(--accent); color: var(--accent-text); font-size: 34px; font-weight: 800; }
.memory-face { background: var(--card); transform: rotateY(180deg); padding: 6px; font-weight: 600; font-size: 14px;
  color: var(--text); text-align: center; border: 3px solid transparent; }
.memory-face img { width: 100%; height: 100%; object-fit: contain; }
.memory-card.open .memory-back { transform: rotateY(180deg); }
.memory-card.open .memory-face { transform: rotateY(360deg); }
.memory-card.done { opacity: 1; }
.memory-card.done .memory-face { border-color: var(--ok); opacity: .55; }

.fly-sky { position: relative; height: 190px; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(180deg, #d9ecff, var(--card)); margin-bottom: 4px; }
.fly-pic { position: absolute; top: 25px; width: 140px; height: 140px; left: -150px;
  animation-name: fly; animation-timing-function: linear; animation-fill-mode: forwards; }
.fly-pic.caught { animation-play-state: paused; filter: drop-shadow(0 0 12px var(--ok)); }
@keyframes fly { from { left: -150px; } to { left: 100%; } }
.fly-option { font-size: 15px; padding: 12px 6px; }
.fly-word { position: absolute; top: 70px; left: 0; white-space: nowrap; padding: 10px 18px; border-radius: 99px;
  background: var(--brand-black); color: #fff; font-size: 22px; font-weight: 700; box-shadow: 0 0 0 3px var(--brand-pink);
  animation-name: fly-word; animation-timing-function: linear; animation-fill-mode: forwards; }
.fly-word.caught { animation-play-state: paused; box-shadow: 0 0 0 3px var(--ok), 0 0 16px var(--ok); }
@keyframes fly-word { from { left: 0; transform: translateX(-100%); } to { left: 100%; transform: translateX(0); } }

/* ---------- игры на словообразование ---------- */
.block-title .about { color: var(--accent); font-weight: 600; }
.task-num { color: var(--accent); margin-right: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 13px; color: var(--hint); margin-bottom: 12px; }
.num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.num { border: 2px solid transparent; border-radius: 10px; padding: 10px 0; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--bg); color: var(--text); font-variant-numeric: tabular-nums; }
.num:active { transform: scale(.95); }
.num.done { background: color-mix(in srgb, var(--ok) 18%, var(--card)); color: var(--ok); }
.num.mistake { background: color-mix(in srgb, var(--bad) 15%, var(--card)); border-color: var(--bad); color: var(--bad); }
.streak { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--bg); }
.streak-cat { width: 64px; height: 64px; flex-shrink: 0; }
.streak.lit { background: color-mix(in srgb, var(--brand-pink) 18%, var(--card)); }
.streak.lit .streak-cat { animation: purr 2.4s ease-in-out infinite; }
.streak-days { font-size: 17px; }
.streak-days b { font-size: 24px; color: var(--accent); }
.streak:not(.lit) .streak-days b { color: var(--hint); }
@keyframes purr { 50% { transform: scale(1.06) rotate(-3deg); } }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin-bottom: 8px; }
.topbar .back-link { margin: 0; padding: 4px 0; }
.streak-pill { display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 3px; border-radius: 99px; background: var(--card); }
.streak-pill-cat { width: 30px; height: 30px; }
.streak-pill b { font-size: 16px; color: var(--hint); }
.streak-pill.lit b { color: var(--accent); }
.streak-toast { position: fixed; left: 50%; top: 16px; transform: translateX(-50%); z-index: 50; display: flex; align-items: center; gap: 10px;
  padding: 10px 18px 10px 10px; border-radius: 16px; background: var(--brand-black); color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.3);
  animation: toast-in .35s ease-out; transition: opacity .5s, transform .5s; width: max-content; max-width: calc(100% - 32px); }
.streak-toast b { font-size: 17px; }
.streak-toast.hide { opacity: 0; transform: translate(-50%, -20px); }
.streak-toast-cat { width: 48px; height: 48px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -20px) scale(.9); } }
.game-about { color: var(--accent); font-weight: 600; margin: 2px 0 6px; }
.wf-card { padding: 22px 16px; }
.wf-base { font-size: 26px; font-weight: 800; margin-bottom: 6px; overflow-wrap: anywhere; }
.wf-base mark { padding: 0 2px; }
.wf-base mark.ok { background: color-mix(in srgb, var(--ok) 25%, transparent); }
.wf-base mark.bad { background: color-mix(in srgb, var(--bad) 25%, transparent); }
.wf-gap { color: var(--accent); letter-spacing: 1px; }
.holes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.hole { height: 72px; border-radius: 50% / 40%; background: radial-gradient(ellipse at 50% 80%, #3a2a33, var(--brand-black));
  display: grid; place-items: center; overflow: hidden; }
.mole { border: 0; border-radius: 12px; padding: 10px 6px; min-width: 76%; font-size: 18px; font-weight: 800; cursor: pointer;
  background: var(--brand-pink); color: var(--brand-black); animation: pop .18s ease-out; }
.mole.ok { background: var(--ok); color: #fff; }
.mole.bad { background: var(--bad); color: #fff; animation: flash-bad .3s; }
@keyframes pop { from { transform: translateY(70%) scale(.6); } to { transform: none; } }
.spell-row { display: flex; gap: 8px; align-items: stretch; }
.spell-row .input { flex: 1; }
.spell-row .btn { width: 64px; margin-top: 16px; font-size: 20px; }

/* ---------- promo / gate / admin ---------- */
.promo { border: 2px solid var(--accent); background: linear-gradient(160deg, var(--accent-soft), var(--card) 55%); }
.promo .title { font-size: 20px; }
.promo ul { padding-left: 0; list-style: none; margin: 10px 0 0; }
.promo li { margin: 8px 0; }
.price { font-weight: 800; color: var(--accent); white-space: nowrap; }
.gate { text-align: center; padding: 28px 18px; }
.gate img { width: 96px; height: 96px; border-radius: 50%; }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-top: 10px; }
.table-row { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--bg); cursor: pointer; }
.table-row:last-child { border-bottom: 0; }
.table-row .grow { flex: 1; min-width: 0; }
.muted { color: var(--hint); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.search { width: 100%; padding: 12px 14px; border-radius: 12px; border: 0; background: var(--card); color: var(--text); font: inherit; margin-bottom: 10px; outline: none; }

.loader { display: grid; place-items: center; min-height: 60vh; color: var(--hint); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--card); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
