/* FPV: Last Signal - game shell */
html, body.app { height: 100%; overflow: hidden; overscroll-behavior: none; }
body.app { position: fixed; inset: 0; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; background: #050604; }
#view, #osd { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#osd { pointer-events: none; z-index: 2; }

.screen {
  position: fixed; inset: 0; z-index: 10; display: none;
  padding: calc(var(--s5) + var(--safe-t)) calc(var(--s5) + var(--safe-r)) calc(var(--s5) + var(--safe-b)) calc(var(--s5) + var(--safe-l));
}
.screen.is-active { display: flex; }

/* Boot */
.screen-boot { flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); background: var(--bg); }
.boot-mark { width: 88px; height: 88px; animation: pulse 1.6s ease-in-out infinite; }
.boot-text { margin: 0; font-family: var(--osd); color: var(--muted); font-size: 14px; }
.boot-bar { width: min(260px, 60vw); height: 3px; background: var(--line); }
.boot-bar span { display: block; height: 100%; width: 0; background: var(--amber); transition: width 0.25s; }
@keyframes pulse { 50% { opacity: 0.55; } }

/* Title */
.screen-title { flex-direction: column; justify-content: flex-end; gap: var(--s6);
  background: linear-gradient(90deg, rgba(10, 11, 8, 0.82) 0%, rgba(10, 11, 8, 0.45) 38%, rgba(10, 11, 8, 0) 62%), linear-gradient(0deg, rgba(10, 11, 8, 0.7) 0%, rgba(10, 11, 8, 0) 30%); }
.title-block { max-width: 680px; }
.title-mark { width: 56px; height: 56px; margin-bottom: var(--s4); }
.logotype { display: flex; flex-direction: column; text-transform: none; }
.logotype-fpv { font-family: var(--osd); font-weight: 400; font-size: clamp(18px, 2.4vw, 24px); color: var(--amber); letter-spacing: 0.5em; margin-bottom: 4px; }
.logotype-name { font-size: clamp(46px, 7.2vw, 100px); line-height: 0.95; letter-spacing: -0.01em; text-shadow: 0 2px 30px rgba(0, 0, 0, 0.5); }
.tagline { font-family: var(--display); font-size: clamp(16px, 1.8vw, 20px); color: var(--ink); opacity: 0.86; margin: var(--s3) 0 var(--s5); max-width: 32ch; }
.menu { display: flex; flex-wrap: wrap; align-items: stretch; gap: var(--s2); max-width: 620px; }
.menu .btn { min-width: 0; }
.menu .btn-primary { min-width: 300px; padding-top: 12px; padding-bottom: 12px; margin-bottom: var(--s1); }
.menu-break { flex-basis: 100%; height: 0; }
.title-status { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.6); position: absolute; top: calc(var(--s5) + var(--safe-t)); right: calc(var(--s5) + var(--safe-r)); text-align: right; font-family: var(--osd); font-size: 14px; color: var(--muted); line-height: 1.5; }
.title-status strong { color: var(--ink); font-weight: 400; }

/* Panels */
.screen-panel { align-items: center; justify-content: center; background: rgba(8, 9, 7, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.panel { width: min(860px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--line); padding: var(--s5) var(--s6) var(--s6); overscroll-behavior: contain; touch-action: pan-y; user-select: text; }
.panel-narrow { width: min(480px, 100%); }
.panel-head { display: flex; align-items: center; gap: var(--s4); margin-bottom: var(--s4); }
.panel-head h2 { font-size: 30px; margin-right: auto; }
.panel h2 { font-size: 30px; }
.panel-intro { color: var(--muted); margin: 0 0 var(--s5); max-width: 60ch; }
.stack { display: flex; flex-direction: column; gap: var(--s2); margin-top: var(--s5); }
.stack .btn { width: 100%; }
.credits { margin: 0; font-family: var(--osd); color: var(--muted); }
.credits strong { color: var(--amber); font-weight: 400; font-size: 20px; }

/* Missions list */
.mission-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); }
.mission-list li { background: var(--bg-2); }
.mission-item { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: var(--s4); align-items: center; padding: var(--s3) var(--s4); background: none; border: 0; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.mission-item:hover:not(:disabled) { background: rgba(236, 233, 220, 0.06); }
.mission-item:disabled { cursor: default; opacity: 0.42; }
.mission-num { font-family: var(--osd); font-size: 22px; color: var(--amber); }
.mission-name { font-family: var(--display); font-weight: 600; font-size: 18px; display: block; }
.mission-desc { font-size: 14px; color: var(--muted); display: block; }
.mission-stars { font-size: 16px; letter-spacing: 2px; color: var(--amber); white-space: nowrap; }
.mission-stars .off { color: var(--line-strong); }

/* Hangar */
.upgrades { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s4); }
.upgrade { border: 1px solid var(--line); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s2); }
.upgrade h3 { font-size: 19px; }
.upgrade p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.pips { display: flex; gap: 4px; }
.pips i { width: 26px; height: 6px; background: var(--line); }
.pips i.on { background: var(--amber); }
.upgrade .btn { min-height: 40px; font-size: 15px; }

/* Settings */
.settings fieldset { border: 0; border-top: 1px solid var(--line); margin: 0; padding: var(--s4) 0; display: grid; gap: var(--s3); }
.settings legend { font-family: var(--display); font-weight: 600; font-size: 18px; padding: 0 var(--s2) 0 0; }
.settings label { display: grid; gap: 6px; font-size: 15px; }
.settings label.check { display: flex; align-items: center; gap: var(--s3); }
.settings .val { font-family: var(--osd); color: var(--amber); margin-left: 6px; }
.settings input[type="range"] { width: 100%; accent-color: var(--amber); }
.settings input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--amber); }
.settings select { font: inherit; color: var(--ink); background: var(--bg-2); border: 1px solid var(--line-strong); padding: 10px; border-radius: 0; }
.note { color: var(--muted); font-size: 13px; margin: 0; }

/* Briefing */
.screen-briefing { align-items: center; justify-content: center; background: linear-gradient(90deg, rgba(8, 9, 7, 0.86), rgba(8, 9, 7, 0.55)); overflow: auto; touch-action: pan-y; }
.brief { display: grid; grid-template-columns: minmax(260px, 46%) 1fr; gap: var(--s6); width: min(1180px, 100%); align-items: start; user-select: text; }
.brief-map { position: relative; }
.brief-map canvas { width: 100%; height: auto; aspect-ratio: 1; display: block; border: 1px solid var(--line-strong); background: #000; }
.map-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin: var(--s2) 0 0; font-size: 13px; color: var(--muted); }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.lg-op::before { background: var(--ink); }
.lg-tgt::before { background: var(--amber); }
.lg-aa::before { background: var(--red); }
.lg-ew::before { background: #b07cff; }
.brief-chapter { margin: 0 0 var(--s2); font-family: var(--osd); color: var(--amber); font-size: 15px; }
.brief-text h2 { font-size: clamp(32px, 4.4vw, 56px); margin-bottom: var(--s4); }
.brief-radio { min-height: 140px; font-family: var(--osd); font-size: 15px; line-height: 1.6; color: var(--ink); }
.brief-radio p { margin: 0 0 var(--s3); max-width: 62ch; }
.brief-radio b { color: var(--amber); font-weight: 400; margin-right: 10px; }
.brief-objective { font-family: var(--display); font-weight: 600; font-size: 19px; border-left: 3px solid var(--amber); padding-left: var(--s3); margin: var(--s4) 0; max-width: 52ch; }
.brief-cond { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--s3) var(--s4); margin: 0 0 var(--s5); }
.brief-cond div { border-top: 1px solid var(--line); padding-top: 6px; }
.brief-cond dt { font-size: 13px; color: var(--muted); }
.brief-cond dd { margin: 0; font-family: var(--osd); font-size: 17px; }
.brief-actions { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; }
.brief-actions .btn-primary { min-width: 200px; }
.brief-controls { color: var(--muted); font-size: 14px; margin: var(--s4) 0 0; max-width: 62ch; }

/* Prologue */
.prologue p:not(.brief-chapter) { font-size: 17px; line-height: 1.65; color: #d6d3c5; max-width: 52ch; }
.prologue h2 { margin-bottom: var(--s4); }

/* Debrief */
.debrief-reason { color: var(--muted); margin: var(--s2) 0 var(--s3); }
.stars { display: flex; gap: var(--s2); margin: var(--s3) 0; }
.stars svg { width: 38px; height: 38px; }
.score-table { width: 100%; border-collapse: collapse; font-family: var(--osd); font-size: 15px; }
.score-table td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.score-table td:last-child { text-align: right; }
.score-table tr.total td { font-size: 19px; color: var(--amber); border-bottom: 0; padding-top: 10px; }
.score-table tr.neg td:last-child { color: #ff8f7c; }
.debrief-rank { color: var(--muted); margin: var(--s3) 0 0; }

/* In-flight */
.radio { position: fixed; z-index: 4; left: calc(max(5vw, 18px) + var(--safe-l)); top: calc(max(6vh, 16px) + 92px + var(--safe-t)); width: min(420px, 60vw); display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.radio p { margin: 0; padding: 6px 10px; background: rgba(5, 6, 4, 0.62); font-family: var(--osd); font-size: 14px; line-height: 1.4; color: var(--ink); border-left: 2px solid var(--amber); animation: radioIn 0.25s ease-out; }
.radio p b { color: var(--amber); font-weight: 400; margin-right: 8px; }
.radio p.out { opacity: 0; transition: opacity 0.6s; }
@keyframes radioIn { from { transform: translateX(-12px); opacity: 0; } }
.toast { position: fixed; z-index: 60; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); padding: 10px 16px; background: var(--bg-2); border: 1px solid var(--line-strong); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.toast.show { opacity: 1; }
.pause-btn { position: fixed; z-index: 6; top: calc(max(6vh, 16px) + 112px + var(--safe-t)); right: calc(max(5vw, 18px) + var(--safe-r)); width: 44px; height: 44px; border: 1px solid var(--line-strong); background: rgba(5, 6, 4, 0.45); display: flex; align-items: center; justify-content: center; gap: 5px; cursor: pointer; }
.pause-btn span { width: 4px; height: 16px; background: var(--ink); }
.touch { position: fixed; inset: 0; z-index: 3; }
.stick-zone { position: absolute; top: 25%; bottom: 0; touch-action: none; }
.stick-zone[data-stick="left"] { left: 0; width: 50%; }
.stick-zone[data-stick="right"] { right: 0; width: 50%; }
.stick-base, .stick-knob { position: absolute; left: 0; top: 0; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity 0.15s; }
.stick-base { width: 130px; height: 130px; margin: -65px 0 0 -65px; border: 2px solid rgba(236, 233, 220, 0.45); background: rgba(0, 0, 0, 0.15); }
.stick-knob { width: 56px; height: 56px; margin: -28px 0 0 -28px; background: rgba(236, 233, 220, 0.55); border: 2px solid rgba(0, 0, 0, 0.4); }
.stick-zone.active .stick-base, .stick-zone.active .stick-knob { opacity: 1; }
.stick-hint { position: absolute; bottom: calc(18% + var(--safe-b)); left: 50%; transform: translateX(-50%); font-family: var(--osd); font-size: 13px; color: rgba(236, 233, 220, 0.6); white-space: nowrap; padding: 26px 30px; border: 1px dashed rgba(236, 233, 220, 0.25); border-radius: 50%; pointer-events: none; }
.touch.hints-off .stick-hint, .stick-zone.active .stick-hint { display: none; }
.touch-btn { position: absolute; right: calc(20px + var(--safe-r)); top: 42%; width: 74px; height: 74px; border-radius: 50%; border: 2px solid var(--green); background: rgba(10, 30, 5, 0.4); color: var(--green); font-family: var(--osd); font-size: 15px; z-index: 2; touch-action: none; }
.rotate-hint { position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(16px + var(--safe-b)); padding: var(--s4); background: var(--panel); border: 1px solid var(--line-strong); display: flex; align-items: center; gap: var(--s4); justify-content: space-between; }
.rotate-hint[hidden] { display: none; }
.rotate-hint p { margin: 0; font-size: 15px; }

/* Share dialog */
.share-dialog { background: var(--bg-2); color: var(--ink); border: 1px solid var(--line-strong); padding: var(--s5); width: min(440px, calc(100vw - 32px)); }
.share-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.share-dialog h2 { font-size: 24px; margin-bottom: var(--s3); }
.share-text { color: var(--muted); margin: 0 0 var(--s4); }
.share-links { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-bottom: var(--s3); }
.share-links .btn { width: 100%; font-size: 15px; min-height: 42px; }

body.is-flying .screen-title, body.is-flying .title-status { display: none; }

@media (max-width: 860px) {
  .brief { grid-template-columns: 1fr; gap: var(--s4); }
  .brief-map { max-width: 420px; }
  .screen-briefing { align-items: flex-start; }
}
@media (max-height: 820px) { .title-mark { display: none; } }
@media (max-height: 640px) {
  .screen { padding: calc(12px + var(--safe-t)) calc(16px + var(--safe-r)) calc(12px + var(--safe-b)) calc(16px + var(--safe-l)); }
  .screen-title { gap: var(--s3); }
  .logotype-name { font-size: 44px; }
  .tagline { margin: 6px 0 var(--s3); }
  .menu .btn { min-height: 40px; padding: 8px 18px 8px 14px; font-size: 15px; }
  .menu .btn-primary { min-width: 0; }
  .menu-break { display: none; }
  .menu .btn-quiet { padding-left: 4px; }
  .btn-label { font-size: 17px; }
  .brief { grid-template-columns: 38% 1fr; }
  .brief-map { max-width: none; }
  .brief-radio { min-height: 0; font-size: 13px; }
  .brief-text h2 { font-size: 30px; margin-bottom: 8px; }
  .panel { padding: var(--s4); }
  .radio { width: min(360px, 46vw); }
  .radio p { font-size: 12px; }
}
@media (max-width: 520px) {
  .menu .btn-primary { min-width: 0; flex: 1 1 100%; }
  .menu .btn:not(.btn-primary):not(.btn-quiet) { flex: 1 1 40%; }
  .title-block { max-width: none; }
  .panel { padding: var(--s4); }
  .mission-item { grid-template-columns: 34px 1fr auto; gap: var(--s3); }
  .title-status { font-size: 12px; }
}
