*{box-sizing:border-box}body{margin:0;background:#182c35;color:#fff6df;font-family:system-ui,sans-serif}button,a{-webkit-tap-highlight-color:transparent}button{cursor:pointer;font:inherit}header{height:66px;padding:12px 24px;display:flex;align-items:center;justify-content:space-between;gap:12px;border-bottom:1px solid #ffffff24}header a{color:inherit;text-decoration:none}header div{display:flex;gap:8px}button{border:1px solid #ffffff40;border-radius:24px;padding:10px 16px;color:inherit;background:#ffffff12}button:hover{background:#ffffff25}button:focus-visible,a:focus-visible{outline:3px solid #ffc964;outline-offset:4px}#stageLabel{font-weight:800}main{position:relative;height:calc(100dvh - 66px);min-height:480px;overflow:hidden}canvas{display:block;width:100%;height:100%;image-rendering:pixelated}.hud{position:absolute;top:20px;left:24px;right:24px;display:flex;justify-content:space-between;align-items:center;gap:20px;pointer-events:none}.hud span{background:#182c35e8;padding:10px 16px;border-radius:18px;font-weight:650;max-width:75%}progress{width:180px;accent-color:#e97c6e;height:12px}.overlay{position:absolute;inset:0;display:grid;place-items:center;background:#142b3980;backdrop-filter:blur(5px);padding:20px;overflow:auto}.overlay[hidden]{display:none}.card{width:min(600px,100%);background:#fff8e7;color:#23333a;padding:34px;border:3px solid #23333a;border-radius:28px;box-shadow:8px 9px 0 #23333a;text-align:center}.card h1,.card h2{font-size:clamp(28px,4vw,43px);line-height:1.08;letter-spacing:-1.5px;margin:10px 0 20px}.card p{font-size:17px;line-height:1.55}.card .eyebrow{font-size:12px;text-transform:uppercase;letter-spacing:2px;color:#765b46;font-weight:800}.card button{background:#23333a;color:#fff8e7;border:0;margin:6px;padding:14px 24px;font-weight:750}.card .secondary{background:#e5decd;color:#23333a}.card img.teacher{width:76px;height:76px;border-radius:50%;object-fit:cover;object-position:50% 25%;border:3px solid #edaa72}.card .instruction{font-size:14px;background:#ebe4d4;padding:12px;border-radius:12px}.controls{position:absolute;bottom:22px;left:24px;right:24px;display:flex;justify-content:space-between;pointer-events:none}.controls div{display:flex;gap:10px}.controls button{pointer-events:auto;background:#182c35dc;border:2px solid #fff8e780;min-width:60px;min-height:56px;touch-action:none;user-select:none;font-weight:750}.controls button:active{background:#d57558}.controls #relay{display:none}.facts{text-align:left;font-size:14px;line-height:1.6;padding-left:22px}.card .answers{display:grid}.card .answers button{margin:4px}.feedback{min-height:24px;font-weight:700}@media(max-width:650px){header{padding:8px 12px;height:60px;font-size:12px}header button{padding:8px}#stageLabel{max-width:120px}main{height:calc(100dvh - 60px);min-height:400px}.hud{top:12px;left:12px;right:12px;font-size:12px}.hud span{max-width:78%;padding:8px}progress{width:65px}.card{padding:22px}.card p{font-size:15px}.controls{left:12px;right:12px;bottom:16px}.controls button{padding:10px;min-width:50px}.card h1,.card h2{font-size:29px}}@media(prefers-reduced-motion:reduce){.overlay{backdrop-filter:none}}
/* GTO-inspired red / white / navy athletic identity. */
body{background:#172b45;color:#fff}
header{background:#fff;color:#172b45;border-bottom:3px solid #b73e43}
header button{background:#f4e8e9;color:#993238;border-color:#dcbabc;border-radius:6px}
header button:hover{background:#ead4d5}
header a{font-weight:700}
.hud span{background:#172b45ee;border-radius:6px}
progress{accent-color:#b73e43}
.overlay{background:#172b455c;backdrop-filter:blur(2px)}
.card{background:#fff;color:#172b45;border:0;border-top:6px solid #b73e43;border-radius:10px;box-shadow:0 20px 70px #12203745}
.card h1,.card h2{font-family:"Unbounded","Arial Black",sans-serif;text-transform:uppercase;letter-spacing:-.7px}
body{font-family:"Manrope",system-ui,sans-serif}
.card .eyebrow{color:#a7353b}
.card button{background:#b73e43;color:#fff;border-radius:6px}
.card button:hover{background:#963238}
.card .secondary{background:#e7edf4;color:#172b45}
.card .instruction{background:#f1f4f8;border-radius:6px}
.card img.teacher{border-color:#b73e43}
.controls button{background:#172b45ee;border-radius:10px;border-color:#fff9}
.controls button:active{background:#b73e43}
/* Two independent touch pointers, safe areas and short landscape screens. */
#mascot{width:100px;height:84px;margin:0 auto;image-rendering:pixelated}
#lives{white-space:nowrap;color:#ffadb0;letter-spacing:2px;flex:none;max-width:none}
.hud #hint{max-width:65%}
@media(max-width:450px){.hud{flex-wrap:wrap;gap:6px}.hud #hint{max-width:100%;flex-basis:100%}.hud progress{margin-left:auto}.hud #lives{font-size:16px;padding:5px 12px}}
@media(max-height:500px){#mascot{width:70px;height:58px;float:left;margin-right:10px}}
html,body{overscroll-behavior:none}
main{min-height:0!important}
canvas,.controls{touch-action:none}
.controls{z-index:10;bottom:max(16px,env(safe-area-inset-bottom));left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right))}
.controls button{-webkit-touch-callout:none;min-height:56px}
.overlay{z-index:20;touch-action:pan-y;align-items:safe center;justify-items:center;padding:max(12px,2vh) 16px;overflow:auto}
.card{width:min(600px,100%);max-width:100%;max-height:min(920px,100%);overflow:auto;box-sizing:border-box}
.hud{z-index:5}
header{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
@media(max-height:500px) and (orientation:landscape){
 header{height:48px;font-size:12px;padding-block:5px}
 main{height:calc(100dvh - 48px)}
 .hud{top:8px;font-size:12px}.hud span{padding:5px 10px}
 .controls{bottom:max(7px,env(safe-area-inset-bottom))}
 .controls button{min-height:48px;padding:8px 14px}
 .overlay{padding:10px}.card{padding:16px;width:min(640px,100%)}
 .card h1,.card h2{font-size:24px;margin:6px 0 10px}.card p{font-size:14px;margin:8px 0}.card .instruction{padding:8px}.card button{padding:10px 18px}
}

/* In-app browser gate (Telegram and other chat WebViews) */
@media(max-height:560px){
}

/* ---- Layout v2: PC / tablet / phone scaling ---- */
html,body{height:100%;margin:0;overflow:hidden}
header{
  height:56px;
  display:grid;
  grid-template-columns:auto auto minmax(0,1fr) auto;
  align-items:center;
  gap:10px 14px;
  padding:8px max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));
}
header > a{white-space:nowrap}
#stageLabel{justify-self:center;text-align:center;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}
.header-actions{display:flex;gap:8px;justify-self:end}
.a11y-btn{
  display:inline-flex;align-items:center;gap:7px;margin:0;padding:6px 10px;min-height:36px;
  border:1px solid #dcbabc;border-radius:8px;background:#f4e8e9;color:#993238;
  font:800 12px/1.1 "Manrope",system-ui,sans-serif;cursor:pointer;max-width:220px;
  box-shadow:none;
}
.a11y-btn__icon{display:grid;place-items:center;width:20px;height:20px;flex-shrink:0}
.a11y-btn__icon svg{width:20px;height:20px;display:block}
.a11y-btn__label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.a11y-btn:hover{background:#ead4d5;color:#993238;opacity:1}
.a11y-btn:focus-visible{outline:3px solid #b73e43;outline-offset:3px}

main{
  height:calc(100dvh - 56px);
  min-height:0!important;
  display:grid;
  place-items:center;
  padding:0;
  background:#101c30;
  overflow:hidden;
}
.stage{
  position:relative;
  width:100%;
  height:100%;
  max-width:100%;
  max-height:100%;
  overflow:hidden;
  background:#172b45;
}
canvas{display:block;width:100%;height:100%;image-rendering:pixelated}
.hud{top:14px;left:14px;right:14px;gap:12px}
.hud span{max-width:min(520px,70%)}
.controls{z-index:10;bottom:max(14px,env(safe-area-inset-bottom));left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right))}

/* Desktop / laptop: keep a playable 16:10 stage, hide touch pads (keyboard works). */
@media (min-width:901px) and (hover:hover) and (pointer:fine){
  main{padding:18px}
  .stage{
    width:min(1280px,100%);
    height:min(calc(100dvh - 56px - 36px), calc(min(1280px,100vw - 36px) * 10 / 16));
    aspect-ratio:16 / 10;
    border-radius:14px;
    box-shadow:0 18px 50px #00000055;
  }
  .controls{display:none!important}
  .hud{top:18px;left:20px;right:20px}
  #stageLabel{font-size:15px}
}

/* Large desktops */
@media (min-width:1400px) and (hover:hover) and (pointer:fine){
  .stage{
    width:min(1440px,100%);
    height:min(calc(100dvh - 56px - 36px), calc(min(1440px,100vw - 36px) * 10 / 16));
  }
}

/* Tablets / touch laptops: full stage, keep controls */
@media (max-width:900px),(pointer:coarse){
  main{padding:0}
  .stage{width:100%;height:100%;border-radius:0;box-shadow:none;aspect-ratio:auto}
  .controls{display:flex}
}

@media (max-width:700px){
  header{grid-template-columns:auto auto minmax(0,1fr) auto;height:52px;gap:8px}
  .a11y-btn{padding:6px;max-width:none}
  .a11y-btn__label{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}
  #stageLabel{font-size:12px}
  main{height:calc(100dvh - 52px)}
  .header-actions button{padding:8px 10px;font-size:12px}
}

@media (max-width:450px){
  header{grid-template-columns:auto minmax(0,1fr) auto;height:50px}
  header > a{display:none}
  main{height:calc(100dvh - 50px)}
}

@media (max-height:500px) and (orientation:landscape){
  header{height:44px}
  main{height:calc(100dvh - 44px)}
  .stage{border-radius:0}
  @media (min-width:901px) and (hover:hover) and (pointer:fine){
    main{padding:8px}
    .stage{height:min(calc(100dvh - 44px - 16px), calc(min(1280px,100vw - 16px) * 10 / 16));border-radius:10px}
  }
}

@media (prefers-reduced-motion:reduce){
  .stage{transition:none}
}

/* ---- Fluid type: follows --s / --sw from game.js on resize ---- */
:root{
  --s:1;
  --sw:1;
  --fs-ui:clamp(12px, calc(13.5px * var(--s) * var(--sw)), 16px);
  --fs-hud:clamp(12px, calc(14px * var(--s)), 17px);
  --fs-label:clamp(12px, calc(14px * var(--s) * var(--sw)), 16px);
  --fs-btn:clamp(12px, calc(13px * var(--s)), 15px);
  --fs-card-title:clamp(22px, calc(34px * var(--s)), 42px);
  --fs-card-body:clamp(14px, calc(16.5px * var(--s)), 18px);
  --fs-card-small:clamp(12px, calc(13.5px * var(--s)), 15px);
  --fs-eyebrow:clamp(10px, calc(11.5px * var(--s)), 13px);
}
body{font-size:var(--fs-ui)}
header{font-size:var(--fs-ui)}
#stageLabel{font-size:var(--fs-label)}
.header-actions button,.controls button{font-size:var(--fs-btn)}
.a11y-btn{font-size:clamp(11px, calc(12px * var(--s)), 13px)}
.hud{font-size:var(--fs-hud)}
.hud span{font-size:var(--fs-hud)}
.card h1,.card h2{font-size:var(--fs-card-title)!important;line-height:1.15}
.card p{font-size:var(--fs-card-body)!important}
.card .eyebrow{font-size:var(--fs-eyebrow)!important}
.card .instruction,.card .facts,.card .feedback{font-size:var(--fs-card-small)!important}
.card button{font-size:var(--fs-btn)}

@media (max-width:700px){
  /* Intro typography must fit the screen width, not grow with a tall phone. */
  :root{
    --fs-card-title:clamp(22px,6.5vw,30px);
    --fs-card-body:clamp(14px,4vw,17px);
    --fs-card-small:clamp(12px,3.4vw,14px);
  }
  #stageLabel{font-size:clamp(11px, calc(12.5px * var(--s)), 13px)}
  .header-actions button{font-size:clamp(11px, calc(12px * var(--s)), 13px)}
}
@media (max-height:500px) and (orientation:landscape){
  .card h1,.card h2{font-size:clamp(18px, calc(24px * var(--s)), 28px)!important}
  .card p{font-size:clamp(12px, calc(14px * var(--s)), 15px)!important}
  .hud{font-size:clamp(11px, calc(12px * var(--s)), 13px)}
}

/* ---- Версия для слабовидящих ----
   /a11y/a11y.css рассчитан на текстовые страницы: он обнуляет фоны, высоты и
   overflow у всего содержимого. Для игрового поля это означало холст высотой
   150 px и надписи карточки поверх трибун. Возвращаем полю размеры, а
   карточкам, подсказкам и кнопкам — контрастную подложку и рамку.
   Селекторы намеренно опираются на идентификаторы: спецверсия подключается
   после game.css и пользуется !important. */
html.a11y body #play{height:min(72vh,560px)!important;min-height:320px!important;overflow:hidden!important;padding:0!important}
html.a11y body #play #stage{width:100%!important;height:100%!important;max-width:100%!important;overflow:hidden!important;background:#0d1b2a!important;border:2px solid var(--a11y-line)!important}
html.a11y body #play #game{display:block!important;width:100%!important;height:100%!important}
html.a11y body #overlay{background:var(--a11y-bg)!important;overflow:auto!important;padding:16px!important}
html.a11y body #overlay #card{background:var(--a11y-bg)!important;border:3px solid var(--a11y-line)!important;width:min(680px,100%)!important;padding:20px!important}
html.a11y body #overlay #card button{background:transparent!important;border:2px solid var(--a11y-line)!important;padding:12px 18px!important}
html.a11y body #hud{top:10px!important;left:10px!important;right:10px!important;flex-wrap:wrap!important;gap:8px!important}
html.a11y body #hud span{background:var(--a11y-bg)!important;border:2px solid var(--a11y-line)!important;padding:6px 10px!important;max-width:100%!important}
html.a11y body #controls button{background:var(--a11y-bg)!important;border:2px solid var(--a11y-line)!important;min-height:56px!important}
