/* ================================================================
   Штурман · оформление
   Палитра: чернила #1B2233, бумага блокнота #EFE6D2, киноварь #D9442A,
   хвоя #22402C, пыль #D9B98A. Цифры — Oswald, стенограмма — от руки (Caveat),
   текст — Manrope.
   ================================================================ */
:root {
  --ink: #1b2233;
  --paper: #efe6d2;
  --paper-2: #e2d5b9;
  --verm: #d9442a;
  --spruce: #22402c;
  --dust: #d9b98a;
  --light: #f3eee3;
  --muted: #b9b2a4;
  --good: #9fd183;
  --bad: #ff8a6a;
  --panel: rgba(17, 20, 24, 0.8);
  --panel-line: rgba(243, 238, 227, 0.12);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1f17; color: var(--light); font: 15px/1.45 Manrope, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; }
#view { position: fixed; inset: 0; }
#view canvas { display: block; width: 100%; height: 100%; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 55%, rgba(0,0,0,0) 55%, rgba(12,10,8,0.42) 100%); }

/* ---------- стенограмма: блокнот ---------- */
.notes {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%) rotate(-0.6deg);
  min-width: 340px; max-width: min(680px, calc(100vw - 580px)); padding: 10px 18px 8px 30px;
  background:
    repeating-linear-gradient(180deg, transparent 0 27px, rgba(27,34,51,0.11) 27px 28px),
    linear-gradient(180deg, var(--paper), var(--paper-2));
  color: var(--ink); border-radius: 3px 3px 6px 6px; box-shadow: 0 12px 26px rgba(0,0,0,0.32);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.notes::before { /* поля блокнота */
  content: ''; position: absolute; left: 20px; top: 0; bottom: 0; width: 1px; background: rgba(217,68,42,0.55);
}
.notes::after { /* дырочки пружины */
  content: ''; position: absolute; left: 6px; top: 12px; bottom: 12px; width: 7px;
  background: radial-gradient(circle, rgba(27,34,51,0.55) 2.5px, transparent 3px) 0 0 / 7px 16px repeat-y;
}
.notes.is-off { opacity: 0; transform: translateX(-50%) translateY(-12px); }
.notes.is-call .notes__now { animation: call .5s var(--ease); }
@keyframes call { from { transform: translateY(-5px); opacity: .4; } to { transform: none; opacity: 1; } }
.notes__now { display: flex; align-items: center; gap: 4px 12px; flex-wrap: wrap; min-height: 54px; }
.notes__next { font: 600 14px/1.3 Manrope, sans-serif; color: rgba(27,34,51,0.62); margin-top: 2px; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nc { display: inline-flex; align-items: center; gap: 6px; opacity: .45; transition: opacity .3s var(--ease), transform .3s var(--ease); }
.nc.is-now { opacity: 1; }
.nc.is-done { opacity: .28; }
.nc svg { width: 44px; height: 44px; flex: none; }
.nc__t { font: 700 30px/1 Caveat, 'Comic Sans MS', cursive; white-space: nowrap; }
.nc__m { font: 700 22px/1 Caveat, cursive; color: var(--verm); white-space: nowrap; }
.nc__d { font: 600 15px/1 Oswald, sans-serif; color: rgba(27,34,51,0.72); letter-spacing: .02em; }
.nc__in { font: 700 22px/1 Caveat, cursive; color: rgba(27,34,51,0.6); }

/* ---------- время ---------- */
.clock { position: fixed; top: 14px; left: 18px; text-shadow: 0 2px 8px rgba(0,0,0,0.55); }
.clock__label { font: 500 13px/1.2 Oswald, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: rgba(243,238,227,0.85); }
.clock__time { font: 600 46px/1.05 Oswald, sans-serif; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.clock__row { display: flex; gap: 10px; align-items: center; margin-top: 2px; }
.delta { font: 600 16px/1 Oswald, sans-serif; padding: 5px 8px 4px; border-radius: 4px; background: rgba(17,20,24,0.72); font-variant-numeric: tabular-nums; text-shadow: none; }
.delta.is-good { color: var(--good); }
.delta.is-bad { color: var(--bad); }
.cp { font: 500 14px/1 Oswald, sans-serif; letter-spacing: .05em; color: rgba(243,238,227,0.85); }

/* ---------- верхние кнопки ---------- */
.topbar { position: fixed; top: 14px; right: 16px; display: flex; gap: 8px; align-items: flex-start; }
.topbar__badges { position: absolute; top: 50px; right: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ibtn { width: 42px; height: 42px; border: 1px solid var(--panel-line); border-radius: 10px; background: var(--panel); display: grid; place-items: center; cursor: pointer; transition: transform .2s var(--ease), background .2s; }
.ibtn svg { width: 20px; height: 20px; fill: none; stroke: var(--light); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ibtn:hover { background: rgba(40,44,50,0.9); }
.ibtn:active { transform: scale(.94); }
.ibtn:focus-visible, .btn:focus-visible, .crew__card:focus-visible, .tbtn:focus-visible { outline: 2px solid var(--dust); outline-offset: 2px; }
.ibtn.is-off svg { opacity: .45; }
.ibtn.is-off .wave { display: none; }
.badge { font: 500 12px/1 Manrope, sans-serif; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--panel-line); white-space: nowrap; }
.badge--demo { color: var(--dust); }
.badge--cost { font-family: Oswald, sans-serif; letter-spacing: .03em; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- штурман ---------- */
.nav { position: fixed; left: 16px; bottom: calc(18px + var(--safe-b)); width: min(460px, calc(100vw - 32px)); display: flex; gap: 12px; align-items: flex-end; pointer-events: none; }
.nav__face { width: 66px; height: 66px; flex: none; border-radius: 50%; background: #2a2f2a; border: 2px solid rgba(243,238,227,0.85); box-shadow: var(--shadow); overflow: hidden; }
.nav__face svg { width: 100%; height: 100%; display: block; }
.nav__face.is-talk svg .mouth { animation: talk .18s infinite alternate ease-in-out; transform-origin: 50% 70%; transform-box: fill-box; }
@keyframes talk { from { transform: scaleY(.35); } to { transform: scaleY(1.2); } }
.nav__face--sm { width: 34px; height: 34px; border-width: 1.5px; display: inline-block; vertical-align: middle; }
.nav__body { flex: 1; min-width: 0; }
.nav__who { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; text-shadow: 0 1px 6px rgba(0,0,0,0.6); }
.nav__name { font: 700 24px/1 Caveat, cursive; color: var(--paper); }
.nav__role { font: 500 12px/1 Oswald, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: rgba(243,238,227,0.72); }
.nav__think { display: inline-flex; gap: 4px; margin-left: 2px; }
.nav__think i { width: 6px; height: 6px; border-radius: 50%; background: var(--paper); animation: dot 1s infinite var(--ease); opacity: .3; }
.nav__think i:nth-child(2) { animation-delay: .15s; } .nav__think i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.nav__lines { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.line { max-width: 100%; padding: 9px 13px 10px; border-radius: 4px 14px 14px 14px; background: rgba(17,20,24,0.8); color: var(--light); font: 500 16px/1.38 Manrope, sans-serif; box-shadow: var(--shadow); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.line.is-new { animation: lineIn .45s var(--ease); }
.line.is-old { opacity: .55; font-size: 14px; }
.line.is-gone { opacity: 0; transform: translateY(6px); }
.line b { color: var(--dust); font-weight: 600; }
.line--event { background: rgba(239,230,210,0.94); color: var(--ink); }
@keyframes lineIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- приборы ---------- */
.dash { position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); text-align: right; text-shadow: 0 2px 10px rgba(0,0,0,0.55); pointer-events: none; }
.dash__speed { font: 600 68px/0.95 Oswald, sans-serif; font-variant-numeric: tabular-nums; }
.dash__speed small { font: 500 15px/1 Oswald, sans-serif; letter-spacing: .08em; margin-left: 6px; color: rgba(243,238,227,0.8); }
.dash__row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.dash__gear { font: 600 22px/1 Oswald, sans-serif; width: 32px; height: 32px; display: grid; place-items: center; border: 1.5px solid rgba(243,238,227,0.8); border-radius: 6px; text-shadow: none; }
.dash__rpm { width: 150px; height: 8px; background: rgba(17,20,24,0.6); border-radius: 4px; overflow: hidden; }
.dash__rpm i { display: block; height: 100%; width: 100%; transform-origin: left; transform: scaleX(0.1); background: linear-gradient(90deg, var(--dust) 0 70%, var(--verm) 85%); }
.dash__dmg { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; font: 500 12px/1 Oswald, sans-serif; letter-spacing: .07em; text-transform: uppercase; color: rgba(243,238,227,0.8); }
.dash__bar { width: 110px; height: 6px; background: rgba(17,20,24,0.6); border-radius: 3px; overflow: hidden; }
.dash__bar i { display: block; height: 100%; width: 100%; background: var(--verm); transform-origin: left; transform: scaleX(0); transition: transform .4s var(--ease); }

/* ---------- заставка: приборы и стенограмма спрятаны, штурман — справа ---------- */
.clock, .dash, .notes { transition: opacity .4s var(--ease); }
body:not(.is-run) .clock, body:not(.is-run) .dash, body:not(.is-run) .notes { opacity: 0; pointer-events: none; }
body:not(.is-run) .touch, body.is-finish .touch { display: none; }
body.is-finish .dash, body.is-finish .notes { opacity: 0; pointer-events: none; }
body:not(.is-run) .nav { left: auto; right: 24px; width: min(420px, 40vw); flex-direction: row-reverse; }
body:not(.is-run) .nav__who { justify-content: flex-end; }
body:not(.is-run) .nav__lines { align-items: flex-end; }
body:not(.is-run) .line { border-radius: 14px 4px 14px 14px; }

/* ---------- подсказки и отсчёт ---------- */
.recover { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid rgba(243,238,227,0.3); background: var(--panel); color: var(--light); font: 600 15px/1 Oswald, sans-serif; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; box-shadow: var(--shadow); animation: lineIn .35s var(--ease); }
.recover span { margin-left: 8px; font-weight: 500; font-size: 13px; color: var(--muted); letter-spacing: .04em; text-transform: none; }
.recover:hover { background: rgba(40,44,50,0.92); }
.toast { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); padding: 10px 16px; border-radius: 8px; background: var(--panel); border: 1px solid var(--panel-line); font: 500 14px/1.3 Manrope, sans-serif; box-shadow: var(--shadow); animation: lineIn .35s var(--ease); pointer-events: none; }
.countdown { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); font: 700 150px/1 Oswald, sans-serif; color: var(--paper); text-shadow: 0 8px 30px rgba(0,0,0,0.5); pointer-events: none; }
.countdown.is-pop { animation: pop .9s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } 30% { opacity: 1; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -50%) scale(.9); } }

/* ---------- меню ---------- */
.menu { position: fixed; inset: 0; display: flex; align-items: center; padding: 24px 0 24px max(24px, 5vw); background: linear-gradient(90deg, rgba(14,16,14,0.86) 0, rgba(14,16,14,0.62) 34%, rgba(14,16,14,0) 60%); transition: opacity .45s var(--ease); overflow-y: auto; }
.menu.is-hidden { opacity: 0; pointer-events: none; }
.menu__card { width: min(470px, 100%); }
.menu__kicker { margin: 0 0 6px; font: 500 13px/1.2 Oswald, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--dust); }
.menu__title { margin: 0; font: 700 84px/0.95 Oswald, sans-serif; letter-spacing: -.01em; color: var(--paper); text-transform: uppercase; }
.menu__lead { margin: 12px 0 20px; font-size: 16px; line-height: 1.5; color: rgba(243,238,227,0.9); max-width: 430px; }
.menu__h2 { margin: 0 0 10px; font: 500 14px/1 Oswald, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: rgba(243,238,227,0.75); }
.crew { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.crew__card { text-align: left; padding: 10px 10px 11px; border-radius: 10px; border: 1px solid var(--panel-line); background: rgba(17,20,24,0.7); cursor: pointer; transition: transform .25s var(--ease), border-color .25s, background .25s; }
.crew__card:hover { transform: translateY(-2px); background: rgba(30,34,38,0.85); }
.crew__card[aria-checked="true"] { border-color: var(--paper); background: rgba(239,230,210,0.12); }
.crew__card .nav__face { display: block; width: 48px; height: 48px; margin-bottom: 8px; border-width: 1.5px; box-shadow: none; }
.crew__name { display: block; font: 700 23px/1 Caveat, cursive; color: var(--paper); }
.crew__desc { display: block; margin-top: 4px; font-size: 12.5px; line-height: 1.35; color: rgba(243,238,227,0.78); }
.btn { height: 52px; padding: 0 26px; border-radius: 10px; border: 0; cursor: pointer; font: 600 17px/1 Oswald, sans-serif; letter-spacing: .08em; text-transform: uppercase; transition: transform .2s var(--ease), background .2s; }
.btn:active { transform: scale(.97); }
.btn--go { background: var(--verm); color: #fff8ee; box-shadow: 0 8px 20px rgba(0,0,0,0.3); }
.btn--go:hover { background: #e4553a; }
.btn--ghost { background: transparent; border: 1.5px solid rgba(243,238,227,0.6); color: var(--light); }
.btn--ghost:hover { background: rgba(243,238,227,0.08); }
.menu__keys { margin: 16px 0 0; font-size: 13px; color: rgba(243,238,227,0.72); max-width: 430px; }
.menu__keys b { font-weight: 600; color: var(--paper); }
.menu__ai { margin: 8px 0 0; font-size: 13px; color: var(--dust); min-height: 1em; }

/* ---------- итоги ---------- */
.result { position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding: 24px max(24px, 5vw); background: linear-gradient(270deg, rgba(14,16,14,0.88) 0, rgba(14,16,14,0.6) 40%, rgba(14,16,14,0) 68%); overflow-y: auto; }
.result__card { width: min(500px, 100%); }
.result__time { margin: 0; font: 700 76px/1 Oswald, sans-serif; font-variant-numeric: tabular-nums; color: var(--paper); }
.result__delta { margin: 4px 0 14px; font: 500 17px/1.3 Oswald, sans-serif; letter-spacing: .03em; }
.result__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--panel-line); border: 1px solid var(--panel-line); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.stat { background: rgba(17,20,24,0.82); padding: 9px 11px; }
.stat b { display: block; font: 600 22px/1.1 Oswald, sans-serif; color: var(--light); font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.debrief { background: var(--paper); color: var(--ink); border-radius: 4px 14px 14px 14px; padding: 14px 16px 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.debrief__who { display: flex; align-items: center; gap: 8px; font: 700 24px/1 Caveat, cursive; margin-bottom: 6px; }
.debrief__who .nav__think i { background: var(--ink); }
.debrief__text { margin: 0; font: 500 15.5px/1.5 Manrope, sans-serif; min-height: 3em; white-space: pre-wrap; }
.debrief__grade { margin: 10px 0 0; font: 700 26px/1.1 Caveat, cursive; color: var(--verm); }
.result__btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- сенсорное управление ---------- */
.touch { position: fixed; left: 0; right: 0; bottom: 0; height: calc(150px + var(--safe-b)); padding: 0 12px var(--safe-b); display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.touch__steer { pointer-events: auto; position: relative; width: 46%; height: 118px; border-radius: 16px; background: rgba(17,20,24,0.42); border: 1px solid rgba(243,238,227,0.18); display: grid; place-items: center; }
.touch__steer span { position: absolute; bottom: 8px; font: 500 12px/1 Oswald, sans-serif; letter-spacing: .1em; text-transform: uppercase; color: rgba(243,238,227,0.6); }
.touch__knob { width: 56px; height: 56px; border-radius: 50%; background: rgba(243,238,227,0.85); box-shadow: 0 4px 14px rgba(0,0,0,0.35); transform: translateX(0); transition: transform .08s linear; }
.touch__right { pointer-events: auto; display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 44px 70px; gap: 8px; width: 48%; }
.tbtn { border: 1px solid rgba(243,238,227,0.25); border-radius: 14px; background: rgba(17,20,24,0.55); font: 600 13px/1 Oswald, sans-serif; letter-spacing: .08em; cursor: pointer; }
.tbtn--hb { grid-column: 1 / 3; }
.tbtn--gas { background: rgba(217,68,42,0.78); }
.tbtn.is-on { background: rgba(243,238,227,0.85); color: var(--ink); }

.fail { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; background: #1a1f17; color: var(--paper); }
.fail h2 { font: 700 40px/1 Oswald, sans-serif; margin: 0 0 10px; }
.fail p { max-width: 420px; margin: 0 auto; color: rgba(243,238,227,0.8); }

/* ---------- телефон и узкие экраны ---------- */
@media (max-width: 1100px) {
  .notes { max-width: calc(100vw - 32px); min-width: 0; top: 84px; left: 16px; right: 16px; transform: rotate(-0.4deg); }
  .notes.is-off { transform: translateY(-12px); }
}
@media (max-width: 720px) {
  .clock { top: 8px; left: 12px; }
  .clock__label { display: none; }
  .clock__time { font-size: 32px; }
  .clock__row { margin-top: 0; }
  .delta { font-size: 13px; padding: 4px 6px 3px; }
  .cp { font-size: 12px; }
  .topbar { top: 10px; right: 10px; gap: 6px; }
  .topbar__badges { position: fixed; top: 172px; left: 12px; right: auto; align-items: flex-start; }
  .badge--cost { display: none; }
  .badge--demo { font-size: 11px; padding: 6px 8px; }
  .ibtn { width: 40px; height: 40px; }
  #btnCam { display: none; }
  .notes { top: 76px; left: 12px; right: 12px; padding: 6px 12px 6px 26px; }
  .notes::before { left: 16px; }
  .notes::after { left: 4px; }
  .notes__now { min-height: 44px; gap: 2px 8px; }
  .nc svg { width: 32px; height: 32px; }
  .nc__t { font-size: 25px; }
  .nc__m { font-size: 19px; }
  .notes__next { font-size: 12px; }
  .nav { bottom: calc(166px + var(--safe-b)); left: 12px; width: calc(100vw - 24px); }
  .nav__face { width: 48px; height: 48px; }
  .nav__name { font-size: 21px; }
  .line { font-size: 14.5px; padding: 8px 11px 9px; }
  .line.is-old { display: none; }
  .dash { right: 12px; bottom: auto; top: 170px; }
  .dash__speed { font-size: 38px; }
  .dash__speed small { font-size: 12px; }
  .dash__row, .dash__dmg { display: none; }
  .toast { top: 230px; max-width: calc(100vw - 32px); text-align: center; }
  .recover { top: 232px; }
  .menu { align-items: flex-end; padding: 16px 14px calc(16px + var(--safe-b)); background: linear-gradient(0deg, rgba(14,16,14,0.92) 0, rgba(14,16,14,0.8) 58%, rgba(14,16,14,0.1) 100%); }
  .menu__title { font-size: 58px; }
  body:not(.is-run) .nav, body:not(.is-run) .topbar__badges { display: none; }
  .menu__lead { font-size: 14.5px; margin: 8px 0 14px; }
  .crew { gap: 6px; }
  .crew__card { padding: 8px; }
  .crew__desc { font-size: 12px; }
  .menu__keys { display: none; }
  .btn { width: 100%; }
  .result { align-items: flex-end; padding: 14px; background: rgba(14,16,14,0.82); }
  .result__time { font-size: 54px; }
  .result__grid { margin-bottom: 12px; }
  .stat b { font-size: 19px; }
  .countdown { font-size: 110px; }
}
@media (pointer: coarse) {
  .menu__keys { display: none; }
}
