/* Игротека: гуашь на бумаге. Чёрных контуров и жёстких теней нет: панели — листы плотной бумаги с мягкой тенью
 * и неровно обрезанными углами, кнопки — мазки краски, заголовки — оттиск индиго с промахнувшимся жёлтым слоем,
 * как в ризографии. Палитра Т-Образования на гуаши: тёплый жёлтый, индиго вместо чёрного, кремовая бумага. */
:root {
  --ink: #2A2740; --ink2: #4A4566; --paper: #FBF6EA; --paper2: #F1E8D4; --paper3: #E6D9BD;
  --y: #F9CC3C; --y2: #FFDB66; --y-deep: #DB9A22; --portal: #F9CC3C; --portal-hi: #FFF1A8;
  --purple: #3A3852; --bg: #EFE6D3; --bg2: #F7F0E0; --panel: var(--paper); --panel2: #FFF1C9; --text: var(--ink); --muted: #7A7262;
  --muted-l: #7A7262; --red: #D9533F; --pink: #EC97AE; --teal: #4C85C4; --orange: #EC8638; --mint: #77C29A; --accent: var(--y);
  --spring: cubic-bezier(.2, 1.4, .3, 1); --out: cubic-bezier(.16, 1, .3, 1);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --stage: #F3EBD9;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .22 0 0 0 .2 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  /* мазки кисти: крупный шум, вытянутый по горизонтали, — следы щетины на краске */
  --brush: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.012 .16' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .98 0 0 0 0 .92 0 0 0 1.4 -.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  /* мягкая тень листа на бумаге и вдавленная кнопка */
  --lift: inset 0 1px 0 rgba(255,255,255,.7), 0 2px 3px rgba(70,45,20,.14), 0 14px 26px -14px rgba(70,45,20,.5);
  --lift-hi: inset 0 1px 0 rgba(255,255,255,.7), 0 4px 8px rgba(70,45,20,.16), 0 24px 40px -18px rgba(70,45,20,.55);
  --lift-lo: inset 0 1px 0 rgba(255,255,255,.6), 0 1px 2px rgba(70,45,20,.18), 0 7px 12px -7px rgba(70,45,20,.45);
  --press: inset 0 2px 5px rgba(70,45,20,.25), 0 1px 1px rgba(70,45,20,.12);
  /* заливки: жёлтая гуашь и бумага — со светлым мазком сверху, зерном и щетиной */
  --swatch-y: var(--brush), var(--grain), radial-gradient(120% 90% at 22% 18%, rgba(255,244,196,.9), transparent 55%), linear-gradient(165deg, #FBD350, #E7A72B);
  --swatch-paper: var(--grain), radial-gradient(130% 100% at 18% 0%, #FFFDF6, transparent 60%), linear-gradient(170deg, #FBF6EA, #EEE3CB);
  --swatch-ink: var(--brush), var(--grain), radial-gradient(120% 90% at 22% 18%, rgba(110,104,150,.6), transparent 55%), linear-gradient(165deg, #3A3656, #24213A);
  /* углы, обрезанные от руки */
  --cut: 24px 28px 22px 30px / 28px 22px 30px 24px;
  --cut-s: 15px 18px 14px 19px / 18px 14px 19px 15px;
  /* оттиск: индиго с промахнувшимся жёлтым слоем */
  --print: 4px 5px 0 var(--y);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--text); font-family: var(--font); -webkit-font-smoothing: antialiased;
  background: radial-gradient(60% 45% at 10% 0%, rgba(249,204,60,.32), transparent 70%),
    radial-gradient(45% 40% at 96% 28%, rgba(76,133,196,.14), transparent 70%),
    radial-gradient(50% 40% at 30% 100%, rgba(236,151,174,.12), transparent 70%), var(--bg); }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: var(--grain), linear-gradient(rgba(76,133,196,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(76,133,196,.07) 1px, transparent 1px);
  background-size: 220px 220px, 28px 28px, 28px 28px; }
a { color: var(--ink); }
button, input { font: inherit; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.boil { filter: url(#boil); }
/* на телефонах дрожание заголовков выключено: SVG-фильтр с анимацией там дорогой и оставляет следы */
.lite .boil { filter: none; }
@media (pointer: coarse) { .boil { filter: none; } }

/* ----------------------------------------------------------------- кнопки */
.btn { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 12px 20px;
  border-radius: var(--cut-s); border: 0; background: var(--swatch-y); color: var(--ink); font-weight: 900; font-size: 16px; cursor: pointer;
  text-decoration: none; box-shadow: var(--lift-lo); transition: transform .08s, box-shadow .08s, filter .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.04) saturate(1.05); }
.btn:active { transform: translateY(2px); box-shadow: var(--press); }
.btn.ghost { background: var(--swatch-paper); }
.ib { width: 46px; height: 46px; flex: none; display: grid; place-items: center; border-radius: var(--cut-s); border: 0;
  background: var(--swatch-paper); color: var(--text); cursor: pointer; text-decoration: none; box-shadow: var(--lift-lo);
  transition: transform .08s, box-shadow .08s, filter .15s; }
.ib svg { width: 22px; height: 22px; }
.ib:hover { filter: brightness(1.03); }
.ib:active { transform: translateY(2px); box-shadow: var(--press); }
.ib.off { color: #B0A794; }

/* ======================================================================= страница игры */

.game-page { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; }
.game-page, .game-page * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.game-page input, .game-page textarea { -webkit-user-select: text; user-select: text; }
.play { position: fixed; inset: 0; z-index: 1; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr);
  touch-action: none; }
.bar { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 8px; z-index: 3; }
.ttl { flex: 1; min-width: 0; }
.ttl b { display: inline-block; font-size: 20px; font-weight: 900; color: var(--ink); text-shadow: 2px 3px 0 var(--y);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; transform: rotate(-1.5deg); padding: 0 4px; }
.hud { display: grid; justify-items: end; min-width: 84px; padding: 3px 12px 4px; border-radius: var(--cut-s); background: var(--swatch-y); color: var(--ink);
  box-shadow: var(--lift-lo); isolation: isolate; }
/* счёт прыгает в своём слое: иначе Safari на iPhone оставляет на фоне след от увеличенных цифр */
.hud b { font-size: 26px; font-weight: 900; line-height: 1.05; font-variant-numeric: tabular-nums; letter-spacing: -.02em; transform-origin: 100% 50%;
  will-change: transform; backface-visibility: hidden; }
.hud small { font-size: 11px; font-weight: 800; opacity: .65; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud b.pop { animation: pop .25s var(--spring); }
.hud b.big { animation: popBig .55s var(--spring); }
.hud b.beat { color: var(--red); }
@keyframes pop { 40% { transform: scale(1.22) rotate(-4deg); } }
@keyframes popBig { 30% { transform: scale(1.4) rotate(-7deg); } 60% { transform: scale(.94) rotate(3deg); } }
.lives { display: flex; gap: 3px; }
.lives i { width: 26px; height: 26px; color: var(--red); display: grid; place-items: center; transition: transform .3s; will-change: transform;
  filter: drop-shadow(1px 2px 0 rgba(120,40,30,.25)); }
.lives i svg { width: 100%; height: 100%; }
.lives i.lost { color: #D6CCB8; transform: scale(.78) rotate(-10deg); }
.lives i.hit { animation: heartHit .7s var(--out); }
@keyframes heartHit { 0% { transform: scale(1.6); color: #fff; } 25% { transform: scale(.6) rotate(-25deg); } 55% { transform: scale(1) rotate(14deg); } }

.stage { position: relative; display: grid; place-items: center; overflow: hidden; touch-action: none; padding: 8px 16px 16px; }
/* кадр игры — оттиск, наклеенный на кремовое паспарту */
.stage canvas { display: block; border-radius: 16px; background: var(--stage);
  box-shadow: 0 0 0 7px var(--paper), 0 0 0 8px rgba(70,45,20,.1), 0 18px 34px -12px rgba(70,45,20,.55), 0 3px 8px rgba(70,45,20,.18); }

.pad { --pad-cols: repeat(auto-fit, minmax(0, 1fr)); display: grid; grid-template-columns: var(--pad-cols); gap: 9px;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); z-index: 3; }
.pad button { min-width: 0; height: 100%; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; border-radius: var(--cut-s); border: 0; background: var(--swatch-paper); color: var(--text); cursor: pointer;
  box-shadow: var(--lift-lo); touch-action: manipulation; transition: transform .06s, box-shadow .06s, filter .1s; }
.pad button svg { width: 28px; height: 28px; }
.pad button small { font-size: 10px; font-weight: 800; color: var(--muted); line-height: 1; }
.pad button.on { background: var(--swatch-y); color: var(--ink); transform: translateY(2px); box-shadow: var(--press); }
.pad button.on small { color: var(--ink); }
.pad .gap { min-width: 0; }
@media (hover: hover) and (pointer: fine) { .pad { display: none; } }
/* телефон боком: кнопки ложатся по краям поверх сцены */
@media (orientation: landscape) and (max-height: 540px) and (pointer: coarse) {
  .bar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .ib { width: 40px; height: 40px; }
  .pad { position: absolute; left: calc(10px + env(safe-area-inset-left)); right: calc(10px + env(safe-area-inset-right)); bottom: 10px;
    padding: 0; grid-template-columns: var(--pad-cols-wide, var(--pad-cols)); pointer-events: none; }
  .pad button { pointer-events: auto; opacity: .92; min-height: 50px; }
  .stage { padding-bottom: 8px; }
}

/* подсказка при первой игре — бумажная записка */
.coach { position: absolute; top: 14px; left: 50%; z-index: 3; display: flex; align-items: center; gap: 10px; max-width: min(92%, 420px);
  padding: 10px 14px; border-radius: var(--cut-s); background: var(--swatch-paper); color: var(--ink); box-shadow: var(--lift);
  font-weight: 800; font-size: 14px; line-height: 1.3; transform: translateX(-50%); pointer-events: none; }
.coach::after { content: ""; position: absolute; left: 34px; bottom: -11px; width: 18px; height: 12px; background: #F1E7D0;
  clip-path: polygon(0 0, 100% 0, 20% 100%); }
.coach.in { animation: coachIn .5s var(--spring) both, coachOut .4s ease 3.8s both; }
@keyframes coachIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(.7) rotate(-6deg); } }
@keyframes coachOut { to { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(.9); } }
.coach .hand { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--swatch-y); box-shadow: var(--lift-lo); position: relative;
  animation: tapHand 1s ease-in-out infinite; }
.coach .hand::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; border: 3px solid rgba(249,204,60,.8); animation: tapRing 1s ease-out infinite; }
@keyframes tapHand { 50% { transform: scale(.82) translateY(2px); } }
@keyframes tapRing { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.2); opacity: 0; } }

/* оверлеи — листы бумаги поверх сцены */
.ov { position: absolute; inset: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 16px; z-index: 4; }
.ov.start { place-items: end center; padding-bottom: 22px; background: linear-gradient(to bottom, transparent 35%, rgba(42,39,64,.28)); }
.ov.dim { background: rgba(239,230,211,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.lite .ov.dim { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(239,230,211,.92); }
.ov.in.dim { animation: fadeIn .25s ease both; }
.card { position: relative; width: min(440px, 100%); max-height: 100%; overflow: auto; padding: 20px; border-radius: var(--cut); text-align: center;
  background: var(--swatch-paper); color: var(--ink); box-shadow: var(--lift-hi); display: grid; gap: 12px;
  scrollbar-width: none; transform: rotate(-.6deg); touch-action: pan-y; }
.card.small { width: min(320px, 100%); }
.ov.in .card { animation: rise .6s var(--spring) both; }
@keyframes rise { from { opacity: 0; transform: translateY(60px) scale(.8) rotate(4deg); } }
@keyframes fadeIn { from { opacity: 0; } }
.card h1, .card h2 { margin: 0; letter-spacing: -.02em; line-height: 1.05; font-weight: 900; }
.card h1 { font-size: 32px; justify-self: center; padding: 0 .16em; text-shadow: 2px 3px 0 rgba(249,204,60,.9);
  background: radial-gradient(60% 70% at 50% 75%, rgba(249,204,60,.55), transparent 72%); }
.card h2 { font-size: 28px; }
.kicker { justify-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--swatch-ink);
  color: var(--y2); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; transform: rotate(-2deg); box-shadow: var(--lift-lo); }
.kicker i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: blinkDot 1.4s ease-in-out infinite; }
@keyframes blinkDot { 50% { transform: scale(1.6); } }
.lead { margin: 0; color: var(--muted-l); font-size: 15px; font-weight: 600; line-height: 1.45; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; }
.how li { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 4px; border-radius: 12px; background: rgba(230,217,189,.55); }
.kbd { display: inline-flex; gap: 3px; flex: none; }
kbd { min-width: 26px; height: 26px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 7px; background: var(--swatch-paper);
  box-shadow: inset 0 -3px 0 rgba(70,45,20,.18), 0 1px 2px rgba(70,45,20,.2); font: 900 12px var(--font); color: var(--ink); }
.gest { flex: none; padding: 3px 9px; border-radius: 8px; background: var(--swatch-y); font-weight: 900; font-size: 12px; }
.touch-only { display: none; }
@media (hover: none), (pointer: coarse) { .keys-only { display: none; } .touch-only { display: flex; } }
.cta { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 10px; height: 60px;
  border: 0; border-radius: var(--cut-s); background: var(--swatch-y); color: var(--ink); font-size: 21px; font-weight: 900; cursor: pointer;
  box-shadow: var(--lift); animation: ctaWobble 2.2s ease-in-out infinite; transition: transform .08s, box-shadow .08s; }
.cta svg { width: 24px; height: 24px; }
.cta:active { transform: translateY(3px); box-shadow: var(--press); animation: none; }
.cta::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,250,230,.6) 50%, transparent 70%);
  transform: translateX(-100%); animation: shine 2.6s ease-in-out infinite; }
@keyframes ctaWobble { 0%, 100% { transform: rotate(-1deg); } 50% { transform: rotate(1.2deg) scale(1.02); } }
@keyframes shine { 55%, 100% { transform: translateX(100%); } }
.meta { margin: 0; color: var(--muted-l); font-size: 13px; font-weight: 600; }
.meta b { color: var(--ink); }
.col { display: grid; gap: 10px; }

.ov.count { pointer-events: none; }
.ov.count b { display: grid; place-items: center; width: 170px; height: 170px; font-size: 104px; font-weight: 900; color: var(--ink);
  text-shadow: 5px 6px 0 rgba(255,244,196,.95); background: var(--swatch-y); filter: drop-shadow(0 12px 18px rgba(70,45,20,.4));
  clip-path: polygon(50% 0, 61% 18%, 82% 8%, 80% 30%, 100% 36%, 85% 52%, 98% 70%, 76% 74%, 74% 96%, 56% 84%, 42% 100%, 36% 80%, 14% 90%, 18% 68%,
    0 60%, 16% 46%, 4% 26%, 26% 24%, 26% 4%, 42% 16%); }
.ov.count b.tick { animation: countTick .45s var(--spring); }
@keyframes countTick { from { transform: scale(2) rotate(-20deg); opacity: 0; } }

/* конец игры */
.medal-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.medal { width: 76px; height: 88px; position: relative; flex: none; }
.medal svg { width: 100%; height: 100%; filter: drop-shadow(2px 6px 6px rgba(70,45,20,.35)); }
.ov.in .medal { animation: medalIn .9s var(--spring) .15s both, medalSwing 2.4s ease-in-out 1.1s infinite; transform-origin: 50% 0; }
@keyframes medalIn { from { transform: translateY(-60px) scale(.3) rotate(-40deg); opacity: 0; } }
@keyframes medalSwing { 50% { transform: rotate(6deg); } }
.medal-txt { display: grid; text-align: left; gap: 2px; }
.medal-txt b { font-size: 20px; font-weight: 900; }
.medal-txt span { font-size: 13px; font-weight: 700; color: var(--muted-l); }
.medal.t0 + .medal-txt b { color: var(--muted-l); }
.score-box { display: grid; justify-items: center; gap: 2px; }
.cap { font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--muted-l); }
.big { font-size: 68px; font-weight: 900; line-height: 1; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums;
  text-shadow: var(--print); }
.ribbon { position: relative; margin-top: 10px; padding: 10px 22px; font-weight: 900; font-size: 15px; color: var(--ink); z-index: 0;
  animation: ribbon .8s var(--spring) .55s both, ribbonBeat 1.1s ease-in-out 1.4s infinite; }
.ribbon::before, .ribbon::after { content: ""; position: absolute; z-index: -1;
  clip-path: polygon(0 50%, 8% 20%, 4% 0, 22% 10%, 34% 0, 46% 12%, 58% 0, 68% 12%, 82% 0, 90% 18%, 100% 14%, 94% 42%, 100% 62%, 92% 78%,
    98% 100%, 78% 90%, 64% 100%, 52% 88%, 38% 100%, 26% 88%, 10% 100%, 10% 78%, 0 70%); }
.ribbon::before { inset: 0; background: rgba(70,45,20,.22); transform: translate(3px, 4px); }
.ribbon::after { inset: 0; background: var(--swatch-y); }
@keyframes ribbon { from { transform: scale(0) rotate(-20deg); } }
@keyframes ribbonBeat { 50% { transform: scale(1.08) rotate(-2deg); } }
.note { margin: 0; color: var(--muted-l); font-size: 14px; font-weight: 600; line-height: 1.45; min-height: 20px; }
.nick-inline { display: flex; gap: 8px; }
.nick-inline input, .me input { flex: 1; min-width: 0; height: 50px; padding: 0 14px; border-radius: 14px; border: 0;
  background: #FFFCF4; color: var(--ink); font-size: 16px; font-weight: 700;
  box-shadow: inset 0 2px 5px rgba(70,45,20,.2), inset 0 0 0 1.5px rgba(70,45,20,.12); }
.nick-inline input:focus, .me input:focus { outline: none; box-shadow: inset 0 2px 5px rgba(70,45,20,.2), 0 0 0 4px rgba(249,204,60,.7); }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acts .btn { padding: 12px 10px; }

.lb { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; text-align: left; font-size: 15px; }
.lb li { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 12px 14px 11px 15px; background: rgba(230,217,189,.5);
  font-variant-numeric: tabular-nums; animation: rowIn .5s var(--spring) calc(var(--i, 0) * 50ms + .25s) both; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-30px) rotate(-3deg); } }
.lb .n { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--paper);
  box-shadow: var(--lift-lo); font-size: 13px; font-weight: 900; }
.lb li[data-top="1"] .n { background: var(--swatch-y); }
.lb li[data-top="2"] .n { background: var(--grain), linear-gradient(160deg, #EEF0F4, #C7CDD8); }
.lb li[data-top="3"] .n { background: var(--grain), linear-gradient(160deg, #F2B98C, #D18450); }
.lb .nick { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.lb b { font-weight: 900; }
.lb li.me { background: var(--swatch-y); box-shadow: var(--lift-lo); }
.lb li.empty { justify-content: center; color: var(--muted-l); font-weight: 700; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }

@media (max-width: 520px) {
  .bar { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .ttl b { font-size: 16px; }
  .ib { width: 42px; height: 42px; }
  .hud { min-width: 70px; padding: 2px 10px 3px; }
  .hud b { font-size: 21px; }
  .lives i { width: 21px; height: 21px; }
  .card { padding: 16px; }
  .card h1 { font-size: 26px; }
  .ov.start .lead { display: none; }
  .ov.start .card { gap: 10px; }
  .cta { height: 54px; font-size: 19px; }
  .big { font-size: 56px; }
  .stage { padding: 6px 14px 14px; }
}
@media (max-width: 420px) { .ttl { display: none; } .hud { margin-left: auto; } }
/* низкий экран (телефон боком): карточки компактнее, подсказки — только на старте игры */
@media (max-height: 520px) {
  .ov { padding: 8px; }
  .ov.start { padding-bottom: 8px; }
  .ov.start .lead, .ov.start .how { display: none; }
  .card { padding: 12px 14px; gap: 8px; }
  .card h1 { font-size: 24px; }
  .cta { height: 48px; font-size: 18px; }
  .big { font-size: 46px; }
  .medal { width: 56px; height: 66px; }
  .lb li { padding: 5px 10px; }
  .coach { top: 6px; font-size: 13px; padding: 6px 10px; }
}
@media (max-width: 340px) {
  .bar { gap: 6px; }
  .ib { width: 36px; height: 36px; }
  .hud { min-width: 0; }
  .hud small { display: none; }
  .lives i { width: 16px; height: 16px; }
}

/* ======================================================================= игротека */

.hub-page { min-height: 100dvh; overflow-x: hidden; }
.bgfx { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bgfx svg { position: absolute; width: var(--s, 48px); height: var(--s, 48px); opacity: .55;
  transform: translate(calc(var(--mx, 0) * var(--p, 10px)), calc(var(--my, 0) * var(--p, 10px))); transition: transform .6s var(--out); }
.bgfx svg g { animation: drift var(--d, 9s) ease-in-out var(--dl, 0s) infinite alternate; transform-origin: center; transform-box: fill-box; }
@keyframes drift { from { transform: translateY(-12px) rotate(-10deg); } to { transform: translateY(14px) rotate(12deg); } }
.wrap { position: relative; z-index: 1; max-width: 1160px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 20px calc(40px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.top .grow { flex: 1; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 800; }
.back:hover { color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--swatch-paper); color: var(--ink);
  box-shadow: var(--lift-lo); text-decoration: none; font-weight: 900; font-size: 14px; transform: rotate(1.5deg); }
.pill svg { width: 18px; height: 18px; }
.pill:active { transform: translateY(2px) rotate(1.5deg); box-shadow: var(--press); }

.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 24px; align-items: center; margin: 0 0 30px; }
.hero .kicker { justify-self: start; }
.hero h1 { margin: 16px 0 14px; font-size: clamp(40px, 6.4vw, 100px); font-weight: 900; line-height: .9; letter-spacing: -.03em; text-transform: uppercase;
  white-space: nowrap; }
/* буквы — оттиск индиго, под ним промахнувшийся слой: жёлтый у «ИГРО», голубой у «ТЕКА» */
.hero h1 .l { display: inline-block; color: var(--ink); text-shadow: .06em .07em 0 var(--y); transform: rotate(var(--r, 0deg));
  animation: letterIn .8s var(--spring) calc(var(--i) * 55ms + .1s) both, letterBob 2.6s ease-in-out calc(var(--i) * 130ms + 1s) infinite alternate; }
.hero h1 .l.g { text-shadow: .06em .07em 0 #9CC3E6; }
@keyframes letterIn { from { transform: translateY(-80px) rotate(-30deg) scale(.4); opacity: 0; } }
@keyframes letterBob { to { transform: translateY(-6px) rotate(calc(var(--r, 0deg) * -1)); } }
.hero p { margin: 0 0 16px; color: var(--muted); font-size: 17px; font-weight: 600; line-height: 1.5; max-width: 540px; }
.portal-box { position: relative; aspect-ratio: 4 / 3; border-radius: var(--cut); overflow: hidden; background: #FFF1C9;
  box-shadow: 0 0 0 8px var(--paper), 0 0 0 9px rgba(70,45,20,.1), 0 24px 40px -18px rgba(70,45,20,.55); transform: rotate(1.2deg); cursor: pointer; }
.portal-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.portal-box .hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%) rotate(-2deg); padding: 5px 12px; border-radius: 999px;
  background: var(--swatch-paper); color: var(--ink); box-shadow: var(--lift-lo); font-size: 12px; font-weight: 900; white-space: nowrap; pointer-events: none; }
.me { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px; border-radius: var(--cut);
  background: var(--swatch-paper); color: var(--ink); box-shadow: var(--lift); transform: rotate(-.6deg); max-width: 540px; }
.me > div { min-width: 0; }
.ava { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 24px; color: var(--ink);
  background: var(--grain), radial-gradient(70% 60% at 30% 25%, rgba(255,250,230,.7), transparent 60%), linear-gradient(135deg, var(--a1, #F9CC3C), var(--a2, #EC8638));
  box-shadow: var(--lift-lo); }
.ava.bump { animation: popBig .5s var(--spring); }
.me label { display: block; font-size: 13px; font-weight: 800; color: var(--muted-l); margin-bottom: 6px; }
.me .row { display: flex; gap: 8px; }
.me .btn { flex: none; padding: 0 16px; }
.me .err { grid-column: 1 / -1; color: var(--red); font-size: 13px; font-weight: 800; }

.cards { display: grid; gap: 26px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); perspective: 1200px; }
.gcard { --rx: 0deg; --ry: 0deg; position: relative; display: grid; grid-template-rows: auto 1fr; border-radius: var(--cut); overflow: hidden;
  background: var(--swatch-paper); color: var(--ink); text-decoration: none; box-shadow: var(--lift);
  transform: rotateX(var(--rx)) rotateY(var(--ry)) rotate(var(--tilt, 0deg)); transition: transform .3s var(--out), box-shadow .3s;
  animation: cardIn .8s var(--spring) calc(var(--i, 0) * 90ms + .2s) both; }
.gcard:nth-child(odd) { --tilt: -.8deg; }
.gcard:nth-child(even) { --tilt: .8deg; }
@keyframes cardIn { from { opacity: 0; transform: translateY(50px) scale(.9) rotate(4deg); } }
.gcard:hover, .gcard:focus-visible { box-shadow: var(--lift-hi); outline: none; }
/* превью — оттиск на листе: светлые поля вокруг, как у наклеенной картинки */
.gcard .shot { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--stage); margin: 10px 10px 0;
  border-radius: 16px 19px 15px 20px / 19px 15px 20px 16px; box-shadow: inset 0 0 0 1px rgba(70,45,20,.08); }
.gcard .shot canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; transition: transform .6s var(--out); }
.gcard:hover .shot canvas { transform: scale(1.05); }
.gcard .shot::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(400px circle at var(--px, 50%) var(--py, 0%), rgba(255,250,230,.22), transparent 45%); opacity: 0; transition: opacity .3s; }
.gcard:hover .shot::after { opacity: 1; }
.playchip { position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 8px; padding: 8px 15px; border-radius: 999px;
  background: var(--swatch-y); color: var(--ink); box-shadow: var(--lift-lo); font-weight: 900; font-size: 15px;
  transform: translateY(16px) scale(.85) rotate(-4deg); opacity: 0; transition: transform .35s var(--spring), opacity .25s; }
.playchip svg { width: 16px; height: 16px; }
.gcard:hover .playchip, .gcard:focus-visible .playchip { transform: rotate(-3deg); opacity: 1; }
@media (hover: none) { .playchip { transform: rotate(-3deg); opacity: 1; padding: 6px 12px; } }
.gcard .live { position: absolute; left: 12px; top: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--swatch-ink); color: var(--paper); font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; opacity: 0; transition: opacity .3s; }
.gcard .live i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: blinkDot 1.1s infinite; }
.gcard.playing .live { opacity: 1; }
.gcard .body { padding: 14px 18px 18px; display: grid; gap: 6px; align-content: start; }
.gcard h2 { margin: 0; font-size: 23px; font-weight: 900; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.gcard h2::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  box-shadow: inset -2px -3px 0 rgba(42,39,64,.18), inset 2px 2px 0 rgba(255,255,255,.4); }
.gcard p { margin: 0; color: var(--muted-l); font-size: 14px; font-weight: 600; line-height: 1.45; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: rgba(230,217,189,.6);
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.chip svg { width: 16px; height: 16px; }
.chip.lead { background: var(--swatch-y); }
.md { width: 14px; height: 14px; border-radius: 50%; flex: none; background: #CFC6E6;
  box-shadow: inset -2px -2px 0 rgba(42,39,64,.2), inset 1px 1px 0 rgba(255,255,255,.5); }
.md.t1 { background: #E39A64; }
.md.t2 { background: #DCE0E8; }
.md.t3 { background: #F9CC3C; }
.md.t4 { background: #B7E3EE; }

.hall { margin-top: 48px; padding: 20px; border-radius: var(--cut); background: var(--swatch-paper); color: var(--ink); box-shadow: var(--lift-hi); }
.hall-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.hall h2 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; transform: rotate(-1deg);
  text-shadow: 2px 3px 0 rgba(249,204,60,.9); }
.hall h2 svg { width: 32px; height: 32px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; border: 0; background: var(--swatch-paper);
  color: var(--ink); font-weight: 900; font-size: 14px; cursor: pointer; box-shadow: var(--lift-lo); transition: transform .08s, box-shadow .08s; }
.tab i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: inset -1px -2px 0 rgba(42,39,64,.2); }
.tab[aria-selected="true"] { background: var(--swatch-y); transform: translateY(2px); box-shadow: var(--press); }
.hall .lb li { animation-delay: calc(var(--i, 0) * 40ms); }
.hall .players { color: var(--muted-l); font-size: 13px; font-weight: 700; margin-top: 12px; }
.foot { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 30px; line-height: 1.6; text-align: center; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .hero h1 { font-size: clamp(36px, 12.5vw, 104px); }
  .hero p { font-size: 15px; }
  .portal-box { aspect-ratio: 16 / 10; }
}
@media (max-width: 760px) {
  .wrap { padding-left: 16px; padding-right: 16px; }
  .hall { padding: 14px; }
  .hall h2 { font-size: 24px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 2px 8px; margin: 0 -2px; }
  .tab { flex: none; }
}
@media (max-width: 380px) { .me { grid-template-columns: 1fr; } .ava { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .gcard { transform: none !important; }
  .boil { filter: none; }
}
