/* Приложение за отборите */
html, body { overflow: hidden; overscroll-behavior: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html { height: -webkit-fill-available; }
body { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; user-select: none; }
input { user-select: text; -webkit-user-select: text; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.screen[hidden] { display: none; }
.dark { background: var(--forest); color: var(--cream); }
.cream { background: var(--cream); color: var(--ink); }

/* ---------- вход ---------- */
#scr-login { overflow-y: auto; }
#scr-login .login-body { flex: 1; justify-content: center; }
.mosaic { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: calc(3px + var(--safe-t)) 3px 0; flex: none; }
.mosaic .ph { aspect-ratio: 1; }
.mosaic .ph .no { font-size: 11px; padding: 2px 3px 0; left: 2px; bottom: 2px; }
.mosaic .ph { animation: tileIn .7s both; }
@keyframes tileIn { from { opacity: 0; transform: scale(.94); } }
.login-body { padding: 26px 24px calc(28px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.login-clock { position: relative; z-index: 2; width: 74px; height: 74px; margin-top: -62px; background: var(--forest); border-radius: 50%; padding: 4px; }
.login-title { font-size: 46px; line-height: .95; margin: 4px 0 2px; }
.login-sub { color: var(--gold); font: 500 15px/1.3 "RobotoV"; letter-spacing: .08em; }
#login-form { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; margin-top: 18px; text-align: left; }
.code-input { width: 100%; background: transparent; border: 0; border-bottom: 2px solid var(--gold); color: var(--cream);
  font: 500 30px/1.2 "RobotoV"; letter-spacing: .16em; text-transform: uppercase; padding: 6px 2px 8px; outline: none; text-align: center; }
.code-input::placeholder { color: rgba(253,251,230,.22); }
.consent { display: flex; gap: 12px; align-items: flex-start; font: 400 14px/1.45 "RobotoV"; color: rgba(253,251,230,.82); }
.consent input { appearance: none; -webkit-appearance: none; flex: none; width: 24px; height: 24px; border: 2px solid var(--gold); margin-top: 1px; display: grid; place-content: center; }
.consent input:checked { background: var(--gold); }
.consent input:checked::after { content: ""; width: 10px; height: 6px; border: solid var(--forest); border-width: 0 0 3px 3px; transform: rotate(-45deg) translate(1px,-1px); }
.consent b { color: var(--gold); font-weight: 600; }
.form-err { min-height: 18px; color: #F0A592; font: 500 14px/1.3 "RobotoV"; text-align: center; }

/* ---------- лоби ---------- */
#scr-lobby { overflow-y: auto; }
.lobby-top { display: flex; justify-content: center; padding: calc(28px + var(--safe-t)) 0 0; }
.lobby-clock { width: 110px; height: 110px; animation: breathe 4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); filter: brightness(1.12); } }
.lobby-body { flex: 1; padding: 18px 24px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.lobby-team { font-size: 44px; }
.lobby-school { color: rgba(253,251,230,.7); font-size: 15px; }
.lobby-route { display: flex; gap: 8px; margin: 14px 0 6px; flex-wrap: wrap; justify-content: center; }
.lobby-route .slot { width: 52px; height: 52px; border: 1px solid var(--line-dark); display: grid; place-items: center; font: 400 26px/1 "Izhitsa"; color: var(--gold); }
.lobby-route .slot.base { border-style: dashed; font-size: 12px; font-family: "RobotoV"; letter-spacing: .1em; }
.lobby-wait { margin: 10px 0 6px; }
.lobby-count { font-size: 64px; color: var(--gold); }
.lobby-note { color: rgba(253,251,230,.75); font-size: 15px; line-height: 1.45; max-width: 320px; margin: 6px auto 0; }
.checks { list-style: none; width: 100%; max-width: 380px; margin: 14px 0; border-top: 1px solid var(--line-dark); }
.checks li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line-dark); font-size: 15px; text-align: left; }
.checks li span { flex: 1; }
.checks li em { font-style: normal; color: rgba(253,251,230,.6); font-size: 13px; }
.checks li i { width: 12px; height: 12px; border: 2px solid var(--muted); border-radius: 50%; flex: none; }
.checks li.ok i { background: var(--gold); border-color: var(--gold); }
.checks li.bad i { background: var(--bad); border-color: var(--bad); }
#lobby-prepare { max-width: 380px; }
.lobby-switch { color: rgba(253,251,230,.6); margin-top: 6px; }

/* ---------- игра ---------- */
#map { position: absolute; top: 0; left: 0; right: 0; bottom: calc(var(--sheet-h, 260px) - 2px); background: #EDE8CC; }
.leaflet-container { font-family: "RobotoV", sans-serif; background: #EDE8CC; }
.leaflet-tile-pane { filter: sepia(.32) saturate(.78) hue-rotate(-6deg) contrast(.96) brightness(1.02); }
.leaflet-control-attribution { font-size: 9px !important; background: rgba(253,251,230,.8) !important; }
.leaflet-control-attribution a { color: var(--body) !important; }

.topbar { position: absolute; top: 0; left: 0; right: 0; z-index: 900; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + var(--safe-t)) 14px 10px; border-bottom: 1px solid var(--line-dark); }
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-clock { width: 40px; height: 40px; }
.tb-team { font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; }
.pips { display: flex; gap: 4px; margin-top: 5px; }
.pips i { width: 16px; height: 4px; background: rgba(214,190,120,.25); }
.pips i.done { background: var(--gold); }
.pips i.cur { background: var(--cream); animation: blink 1.4s infinite; }
.pips i.base { width: 8px; }
@keyframes blink { 50% { opacity: .35; } }
.tb-right { text-align: right; }
.tb-timer { font: 500 24px/1 "RobotoV"; color: var(--gold); letter-spacing: .02em; }
.tb-net { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 11px; color: rgba(253,251,230,.7); margin-top: 5px; letter-spacing: .06em; }
.tb-net i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.tb-net.off i { background: #E2604C; animation: blink 1s infinite; }

.fab-col { position: absolute; right: 12px; z-index: 800; top: calc(84px + var(--safe-t)); transition: top .3s; display: flex; flex-direction: column; gap: 8px; }
.fab { width: 46px; height: 46px; background: var(--cream); border: 1.5px solid var(--ink); display: grid; place-items: center; }
.fab svg { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: square; }
.fab.on { background: var(--forest); }
.fab.on svg { stroke: var(--gold); }
.banner { position: absolute; z-index: 950; left: 12px; right: 12px; top: calc(80px + var(--safe-t)); background: var(--forest); color: var(--cream);
  border: 1px solid var(--gold); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; font-size: 14px; }
body.fsb .fab-col { top: calc(150px + var(--safe-t)); }
.banner .btn { min-height: 40px; padding: 0 14px; font-size: 12px; }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 900; background: var(--cream); color: var(--ink);
  border-top: 2px solid var(--ink); padding: 14px 16px calc(12px + var(--safe-b)); box-shadow: 0 -10px 30px rgba(10,30,27,.18);
  transition: transform .35s cubic-bezier(.2,.8,.2,1); }
.sh-head { display: flex; gap: 14px; align-items: center; }
#sh-ph { width: 72px; height: 72px; }
#sh-ph.base { background: var(--forest); display: grid; place-items: center; }
#sh-ph.base img { width: 58px; height: 58px; object-fit: contain; }
.sh-titles { min-width: 0; flex: 1; }
.sh-titles .kicker { color: var(--muted); }
.sh-name { font-size: 27px; margin: 4px 0 3px; line-height: 1.02; }
.sh-years { font: 700 14px/1 "RobotoV"; color: var(--body); letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; padding: 12px; background: var(--forest); color: var(--cream); min-height: 72px; }
.nav-arrow { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border: 1px solid var(--line-dark); }
.nav-arrow svg { width: 36px; height: 36px; fill: none; stroke: var(--gold); stroke-width: 4; stroke-linecap: square; stroke-linejoin: miter; transition: transform .4s; }
.nav-instr { font: 600 17px/1.25 "RobotoV"; }
.nav-sub { font: 400 13px/1.3 "RobotoV"; color: rgba(253,251,230,.7); margin-top: 3px; }
.nav.near { background: var(--gold); color: var(--forest); }
.nav.near .nav-arrow { border-color: rgba(10,30,27,.35); }
.nav.near .nav-arrow svg { stroke: var(--forest); }
.nav.near .nav-sub { color: rgba(10,30,27,.75); }
.sh-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; border-top: 1px solid var(--line); }
.sh-stats > div { padding: 9px 0 0; }
.sh-stats > div + div { border-left: 1px solid var(--line); padding-left: 12px; }
.st-big { font: 600 22px/1.1 "RobotoV"; }
.sh-stats .kicker { font-size: 10px; margin-top: 3px; }
.sh-note { margin-top: 10px; font-size: 13px; line-height: 1.4; color: var(--body); border-left: 3px solid var(--gold); padding-left: 10px; }
.sh-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.linkbtn { font: 500 12px/1 "RobotoV"; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; padding: 8px; text-decoration: underline; text-underline-offset: 3px; }

/* маркери */
.mk { position: relative; width: 44px; height: 44px; outline: 2px solid var(--ink); outline-offset: -1px; background: #cfc9a8; transition: transform .3s; }
.mk img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mk .no { position: absolute; left: 2px; bottom: 2px; font: 400 12px/1 "Izhitsa"; background: var(--forest); color: var(--cream); padding: 2px 3px 0; }
.mk.next { opacity: .9; }
.mk.done img { filter: grayscale(1) contrast(.9); opacity: .7; }
.mk.done::after { content: ""; position: absolute; right: -7px; top: -7px; width: 18px; height: 18px; background: var(--gold) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M4 9.5l3 3 7-7' fill='none' stroke='%230A1E1B' stroke-width='2.4'/%3E%3C/svg%3E") center/14px no-repeat; border: 1.5px solid var(--forest); border-radius: 50%; }
.mk.cur { width: 64px; height: 64px; outline: 3px solid var(--gold); }
.mk.cur::before { content: ""; position: absolute; inset: -10px; border: 2px solid var(--gold); animation: ring 1.8s ease-out infinite; }
@keyframes ring { from { opacity: .9; transform: scale(.85); } to { opacity: 0; transform: scale(1.35); } }
.mk-base { width: 48px; height: 48px; background: var(--forest); display: grid; place-items: center; outline: 2px solid var(--gold); outline-offset: -1px; }
.leaflet-marker-pane .mk-base img { width: 40px !important; height: 40px !important; }
.mk-base.cur::before { content: ""; position: absolute; inset: -10px; border: 2px solid var(--gold); animation: ring 1.8s ease-out infinite; }
.me { position: relative; width: 22px; height: 22px; }
.me .dot { position: absolute; inset: 3px; border-radius: 50%; background: #2E7DD7; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.me .dot::after { content: ""; position: absolute; inset: -9px; border-radius: 50%; background: rgba(46,125,215,.25); animation: ring 2s ease-out infinite; }
.me .cone { position: absolute; left: 50%; top: 50%; width: 0; height: 0; border-left: 16px solid transparent; border-right: 16px solid transparent; border-bottom: 40px solid rgba(46,125,215,.28);
  transform-origin: 50% 0; margin-left: -16px; transform: rotate(180deg); display: none; }
.me.has-heading .cone { display: block; }

/* ---------- въпроси ---------- */
#scr-quiz { overflow-y: auto; padding: calc(18px + var(--safe-t)) 18px calc(16px + var(--safe-b)); }
.qz-head { display: flex; gap: 16px; align-items: center; }
.qz-ph { width: 104px; height: 104px; }
.qz-name { font-size: 32px; margin: 6px 0 4px; line-height: 1; }
#qz-kicker { color: var(--muted); }
.qz-rule { height: 1px; background: var(--line); margin: 18px 0; }
.qz-body { flex: 1; display: flex; flex-direction: column; }
.qz-count { color: var(--muted); }
.qz-q { font: 600 21px/1.35 "RobotoV"; margin: 10px 0 18px; color: var(--ink); }
.qz-opts { display: flex; flex-direction: column; gap: 10px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: 10px 14px 10px 10px; border: 1.5px solid var(--ink); background: #fff8; min-height: 58px; font: 500 17px/1.3 "RobotoV"; transition: background .15s, transform .1s; }
.opt b { flex: none; width: 36px; height: 36px; display: grid; place-items: center; background: var(--forest); color: var(--gold); font: 400 20px/1 "Izhitsa"; }
.opt:active { transform: scale(.99); }
.opt.sel { background: var(--forest); color: var(--cream); }
.opt.sel b { background: var(--gold); color: var(--forest); }
.qz-text { width: 100%; border: 0; border-bottom: 2px solid var(--ink); background: transparent; font: 500 24px/1.3 "RobotoV"; padding: 8px 2px; outline: none; color: var(--ink); }
.qz-hint { font-size: 13px; color: var(--muted); margin-top: 8px; }
.qz-submit { margin-top: 22px; }
.qz-result { text-align: center; padding: 24px 0 8px; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
.stamp { width: 92px; height: 92px; border: 3px solid var(--gold); border-radius: 50%; display: grid; place-items: center; transform: rotate(-12deg); }
.stamp svg { width: 46px; height: 46px; fill: none; stroke: var(--forest); stroke-width: 4; }
.stamp.bad { border-color: var(--bad); }
.stamp.bad svg { stroke: var(--bad); }
.qz-result h3 { font-size: 30px; }
.qz-result p { color: var(--body); font-size: 15px; line-height: 1.45; max-width: 300px; }
.qz-foot { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 18px; }
.qz-foot img { height: 34px; }

/* ---------- финал ---------- */
#scr-finish { overflow-y: auto; }
.fin-body { flex: 1; justify-content: center; padding: calc(36px + var(--safe-t)) 24px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; }
.fin-clock { width: 120px; animation: spin 30s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fin-title { font-size: 46px; line-height: .98; margin: 4px 0; }
.fin-time { font: 500 40px/1 "RobotoV"; color: var(--gold); }
.fin-note { color: rgba(253,251,230,.8); font-size: 15px; line-height: 1.5; max-width: 330px; }
.fin-strip { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; justify-content: center; }
.fin-strip .ph { width: 56px; height: 56px; }

/* ---------- слоеве ---------- */
#watermark { position: fixed; inset: -50%; z-index: 2000; pointer-events: none; opacity: .055; transform: rotate(-24deg); background-repeat: repeat; }
#veil { position: fixed; inset: 0; z-index: 3000; background: var(--forest); display: none; place-items: center; }
#veil img { width: 120px; opacity: .8; }
body.veiled #veil { display: grid; }
.modal { position: fixed; inset: 0; z-index: 2500; background: rgba(10,30,27,.72); display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--cream); color: var(--ink); width: 100%; max-width: 400px; padding: 24px 20px 20px; border-top: 6px solid var(--gold); animation: pop .35s cubic-bezier(.2,1.3,.4,1); }
.modal-card .kicker { color: var(--muted); }
.modal-title { font-size: 30px; margin: 8px 0 10px; }
.modal-text { font-size: 16px; line-height: 1.5; color: var(--body); margin-bottom: 18px; white-space: pre-line; }
.modal.alarm .modal-card { border-top-color: var(--bad); }
.toast { position: fixed; z-index: 2600; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 30px); opacity: 0; background: var(--forest); color: var(--cream);
  padding: 12px 18px; font-size: 14px; border-left: 4px solid var(--gold); transition: .3s; max-width: calc(100% - 32px); pointer-events: none; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
#scr-game:not([hidden]) ~ .toast { bottom: calc(var(--sheet-h, 260px) + 12px); }

@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 460px; transform: translateX(-50%); bottom: 16px; border: 2px solid var(--ink); }
  #map { bottom: 0; }
  .mosaic { grid-template-columns: repeat(11, 1fr); }
}


/* ---------- прибиращ се панел ---------- */
.sh-grip { display: block; width: 100%; height: 22px; margin: -10px 0 4px; position: relative; }
.sh-grip i { position: absolute; left: 50%; top: 8px; width: 44px; height: 4px; margin-left: -22px; background: rgba(14,42,37,.28); border-radius: 2px; }
.sheet.mini { padding-top: 10px; }
.sheet.mini .sh-stats, .sheet.mini .sh-note, .sheet.mini .linkbtn { display: none; }
.sheet.mini .sh-head { gap: 10px; }
.sheet.mini #sh-ph { width: 46px; height: 46px; }
.sheet.mini #sh-ph.base img { width: 38px; height: 38px; }
.sheet.mini .sh-name { font-size: 21px; margin: 2px 0 1px; }
.sheet.mini .sh-years { font-size: 12px; }
.sheet.mini .nav { margin-top: 8px; padding: 8px 10px; min-height: 0; }
.sheet.mini .nav-arrow { width: 40px; height: 40px; }
.sheet.mini .nav-arrow svg { width: 28px; height: 28px; }
.sheet.mini .nav-instr { font-size: 15px; }
.sheet.mini .sh-actions { margin-top: 8px; }
.sheet.mini .nav-sub::after { content: attr(data-mini); }

/* ---------- iPhone ---------- */
.ios-hint { width: 100%; max-width: 380px; border: 1px solid var(--line-dark); padding: 12px 14px; text-align: left; font-size: 14px; line-height: 1.5; color: rgba(253,251,230,.85); margin-bottom: 12px; }
.ios-hint .kicker { margin-bottom: 6px; }
.ios-hint b { color: var(--gold); font-weight: 600; }
.ios-hint svg { width: 18px; height: 18px; vertical-align: -3px; fill: none; stroke: var(--gold); stroke-width: 2; }
.ios .banner { display: none !important; }

/* ---------- хоризонтално ---------- */
#rotate { display: none; position: fixed; inset: 0; z-index: 4000; background: var(--forest); color: var(--cream); flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 20px; }
#rotate img { width: 90px; transform: rotate(-90deg); }
#rotate p { font-size: 28px; }
@media (orientation: landscape) and (max-height: 500px) { #rotate { display: flex; } }

/* ---------- малки екрани ---------- */
@media (max-height: 700px) {
  .topbar { padding: calc(6px + var(--safe-t)) 12px 7px; }
  .tb-clock { width: 32px; height: 32px; }
  .tb-team { font-size: 19px; }
  .tb-timer { font-size: 20px; }
  .tb-net { margin-top: 3px; }
  .fab-col { top: calc(64px + var(--safe-t)); }
  .fab { width: 42px; height: 42px; }
  .sheet { padding: 12px 14px calc(10px + var(--safe-b)); }
  #sh-ph { width: 60px; height: 60px; }
  .sh-name { font-size: 24px; }
  .nav { margin-top: 10px; padding: 10px; min-height: 0; }
  .nav-instr { font-size: 16px; }
  .sh-stats { margin-top: 8px; }
  .st-big { font-size: 19px; }
  .btn { min-height: 48px; }
  .mosaic .ph:nth-child(n+13) { display: none; }
  .login-body { padding-top: 18px; gap: 8px; }
  .login-title { font-size: 40px; }
  #login-form { margin-top: 10px; gap: 12px; }
  .lobby-top { padding-top: calc(16px + var(--safe-t)); }
  .lobby-clock { width: 80px; height: 80px; }
  .lobby-team { font-size: 36px; }
  .lobby-count { font-size: 48px; }
  .checks li { padding: 9px 2px; }
  #scr-quiz { padding-top: calc(12px + var(--safe-t)); }
  .qz-ph { width: 84px; height: 84px; }
  .qz-name { font-size: 27px; }
  .qz-rule { margin: 12px 0; }
  .qz-q { font-size: 19px; margin: 8px 0 14px; }
  .opt { min-height: 52px; font-size: 16px; }
  .fin-title { font-size: 38px; }
  .fin-clock { width: 90px; }
}
@media (max-width: 360px) {
  .kicker { letter-spacing: .14em; font-size: 11px; }
  .login-title { font-size: 36px; }
  .code-input { font-size: 24px; letter-spacing: .1em; }
  .consent { font-size: 13px; }
  .tb-team { max-width: 40vw; }
  .sh-name, .qz-name { font-size: 22px; }
  .qz-ph { width: 70px; height: 70px; }
  .opt { padding: 8px 10px 8px 8px; gap: 10px; }
  .opt b { width: 32px; height: 32px; }
  .lobby-route .slot { width: 44px; height: 44px; font-size: 22px; }
  .st-big { font-size: 17px; }
  .btn { letter-spacing: .1em; padding: 0 14px; }
}
