/* ---------- menus: printed data cards ---------- */
#screens { position: fixed; inset: 0; pointer-events: none; }
.screen {
  position: absolute; inset: 0; pointer-events: auto; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  display: flex; justify-content: center; align-items: flex-start;
  padding-block: calc(16px + var(--safe-t)) calc(16px + var(--safe-b));
  padding-left: var(--gutter-l); padding-right: var(--gutter-r);
  background: linear-gradient(180deg, rgba(8, 11, 8, 0.72), rgba(8, 11, 8, 0.38) 45%, rgba(8, 11, 8, 0.78));
}
.screen > * { margin-block: 0; }
.screen.center > * { margin-block: auto; }
.paper {
  background:
    repeating-linear-gradient(0deg, rgba(27, 33, 24, 0.035) 0 1px, transparent 1px 4px),
    linear-gradient(170deg, var(--paper), var(--paper-2));
  color: var(--ink); border: 1px solid var(--paper-edge);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.15; text-wrap: balance; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }
[dir="rtl"] .ltr { text-align: right; }

/* A sheet: fixed head (back, title, actions) over a body that scrolls. */
.sheet { width: min(100%, 980px); max-height: 100%; min-width: 0; display: flex; flex-direction: column; }
.sheet.wide { width: min(100%, 1100px); }
.sheet-head {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 14px clamp(14px, 2.4vw, 26px) 10px; border-bottom: 2px solid var(--ink);
}
.sheet-title { flex: 1 1 150px; min-width: 0; }
.sheet-code { display: block; width: fit-content; font: 600 10px var(--f-data); letter-spacing: 0.14em; color: var(--ink-2); direction: ltr; }
.sheet-head h2 { font-size: clamp(21px, 3.6vw, 32px); font-weight: 700; }
.sheet-head p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-inline-start: auto; }
.back { min-height: 44px; padding-inline: 12px 16px; }
.back .arrow { font-size: 24px; line-height: 1; margin-top: -3px; }
[dir="rtl"] .back .arrow { transform: scaleX(-1); }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; padding: 14px clamp(14px, 2.4vw, 26px) 22px; }
.label { font: 600 11px var(--f-data); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); margin: 16px 0 6px; }
[lang="ar"] .label { letter-spacing: 0; }
.label:first-child { margin-top: 0; }
.note { font-size: 13px; color: var(--ink-2); margin: 6px 0 0; }
.note.data { font-family: var(--f-data); font-size: 12px; }

/* title screen */
.title { width: min(100%, 1080px); display: grid; gap: 22px; }
.title-mark { display: grid; gap: 4px; }
.title-mark h1 { font-size: clamp(64px, 15vw, 150px); font-weight: 700; color: var(--hud); letter-spacing: -0.01em; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7); line-height: 1.2; }   /* room for the Arabic vowel marks above the letters */
.title-mark .tag { font: 500 clamp(15px, 2.4vw, 22px) var(--f-display); color: var(--amber); }
.title-mark .pitch { max-width: 46ch; color: var(--hud-dim); margin: 6px 0 0; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8); }
.title-menu { display: grid; gap: 10px; justify-items: start; }
.title-row { display: flex; flex-wrap: wrap; gap: 8px; }
.title-menu .btn { color: var(--hud); border-color: rgba(242, 239, 227, 0.55); background: rgba(10, 13, 10, 0.45); backdrop-filter: blur(3px); min-width: 140px; }
.title-menu .btn:hover { background: var(--hud); color: var(--ink); border-color: var(--hud); }
.title-menu .btn.primary { background: var(--pencil); border-color: var(--pencil); color: #fff7ee; }
.title-menu .btn.primary:hover { background: #8f2413; border-color: #8f2413; color: #fff7ee; }
.title-menu .btn.big { min-width: min(100%, 360px); min-height: 58px; flex-direction: column; align-items: flex-start; gap: 0; padding: 8px 22px; font-size: 19px; text-align: start; }
.btn.big small { font: 400 13px var(--f-body); opacity: 0.88; }
.title-foot { font: 400 12px var(--f-data); color: var(--hud-dim); direction: ltr; text-align: start; }

/* campaign */
.campaign { display: grid; gap: 20px; }
.row-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; text-align: start;
  padding: 10px 14px; cursor: pointer; background: rgba(255, 255, 255, 0.16); border: 1px solid var(--rule); border-inline-start: 5px solid var(--olive);
  color: var(--ink); width: 100%; border-radius: 0; transition: background 0.12s;
}
.row-card:hover { background: rgba(255, 255, 255, 0.42); }
.row-card .code, .stage .code { font: 600 12px var(--f-data); color: var(--ink-2); direction: ltr; }
.row-card h3 { font-size: 18px; font-weight: 700; }
.row-card p { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; }
.row-card .meta { font: 600 12px var(--f-data); color: var(--ink-2); text-align: end; direction: ltr; white-space: nowrap; }
.stars { color: var(--pencil); font-size: 16px; letter-spacing: 2px; direction: ltr; white-space: nowrap; }
.stars i { color: var(--rule); font-style: normal; }
.chapter-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; border-bottom: 1px solid var(--rule); padding-bottom: 6px; margin-bottom: 10px; }
.chapter-head h3 { font-size: 20px; font-weight: 700; }
.ch-no { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding-inline: 4px; margin-inline-end: 8px; background: var(--ink); color: var(--paper); font: 600 12px var(--f-data); direction: ltr; vertical-align: 2px; }
.ch-stars { margin-inline-start: auto; font: 600 12px var(--f-data); color: var(--ink-2); direction: ltr; unicode-bidi: isolate; }
.chapter-head p { flex: 1 1 100%; margin: 0; font-size: 13px; color: var(--ink-2); }
.stages { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 8px; }
.stage {
  display: grid; gap: 5px; align-content: start; text-align: start; min-width: 0; padding: 10px 12px; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); border: 1px solid var(--rule); border-inline-start: 5px solid var(--olive); border-radius: 0; color: var(--ink);
}
.stage:hover { background: rgba(255, 255, 255, 0.42); }
.stage-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; }
.stage h4 { font-size: 17px; font-weight: 700; }
.stage .roster-line { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; font-size: 12.5px; color: var(--ink-2); }
.stage .meta { display: flex; flex-wrap: wrap; gap: 0 10px; font: 400 11px var(--f-data); color: var(--ink-2); }
.stage .meta span { unicode-bidi: isolate; direction: ltr; }   /* weapon names and ranges stay left-to-right inside Arabic */
.stage.done { border-inline-start-color: var(--good); }
.stage.next { border-color: var(--pencil); border-inline-start-width: 5px; background: rgba(255, 255, 255, 0.45); box-shadow: 0 0 0 1px var(--pencil); }
.next-tag { font: 600 11px var(--f-body); background: var(--pencil); color: #fff7ee; padding: 0 7px; border-radius: 2px; }
.stage.locked { cursor: not-allowed; background: repeating-linear-gradient(135deg, rgba(27, 33, 24, 0.07) 0 6px, transparent 6px 12px); border-inline-start-color: var(--rule); }
.stage.locked h4, .stage.locked .roster-line, .stage.locked .meta { opacity: 0.55; }
.stage .why { font-size: 12px; color: var(--ink-2); }
.stage.shake { animation: shake 0.28s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.lock { position: relative; display: inline-block; width: 14px; height: 10px; margin-top: 7px; background: var(--ink-2); border-radius: 2px; }
.lock::before { content: ""; position: absolute; left: 2px; top: -7px; width: 6px; height: 8px; border: 2px solid var(--ink-2); border-bottom: 0; border-radius: 5px 5px 0 0; }

/* enemy tier pips */
.pips { display: inline-flex; gap: 3px; }
.pip { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font: 700 11px var(--f-data); color: #fff; line-height: 1; vertical-align: middle; }
.pip.t1 { background: #587a3a; }
.pip.t2 { background: var(--amber); color: var(--ink); }
.pip.t3 { background: var(--pencil); }

/* briefing */
.weapons .label:first-child { margin-top: 0; }
.wgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.wcard {
  position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; padding: 8px; text-align: start; cursor: pointer;
  background: rgba(255, 255, 255, 0.16); border: 1.5px solid var(--rule); border-radius: 2px; color: var(--ink);
}
.wcard:hover { background: rgba(255, 255, 255, 0.4); }
.wcard[aria-pressed="true"], .atab[aria-pressed="true"] { border-color: var(--ink); background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1.5px var(--ink); }
.wcard[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 6px; inset-inline-start: 6px; width: 20px; height: 20px; display: grid; place-items: center; background: var(--ink); color: var(--paper); font-size: 13px; border-radius: 50%; }
.thumb { display: block; width: 100%; height: auto; aspect-ratio: 336 / 120; background: rgba(27, 33, 24, 0.07); border-radius: 1px; }
.wname { font: 700 14px var(--f-display); line-height: 1.2; direction: ltr; unicode-bidi: isolate; text-align: left; }
.wcart { font: 400 10.5px var(--f-data); color: var(--ink-2); direction: ltr; unicode-bidi: isolate; text-align: left; overflow-wrap: anywhere; }
[dir="rtl"] .wname, [dir="rtl"] .wcart { text-align: right; }
.rec { position: absolute; top: 6px; inset-inline-end: 6px; z-index: 1; background: var(--pencil); color: #fff7ee; font: 600 10px var(--f-body); padding: 1px 6px; border-radius: 2px; }
.rec.inline { position: static; margin-inline-start: 8px; background: var(--olive); vertical-align: middle; }
.bars { display: grid; gap: 3px; margin-top: 4px; }
.bar { display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: center; gap: 6px; font-size: 10.5px; line-height: 1.2; color: var(--ink-2); }
.bar i { display: block; height: 7px; background: rgba(27, 33, 24, 0.14); border-radius: 1px; }
.bar b { display: block; height: 100%; background: var(--good); border-radius: 1px; }
.bar.cost b { background: var(--pencil); }
.legend-note { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; min-height: 26px; }
.chips span { direction: ltr; unicode-bidi: isolate; font: 500 12px var(--f-data); padding: 2px 8px; background: rgba(27, 33, 24, 0.09); border-radius: 2px; }
.sidearm { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr); gap: 12px; align-items: center; margin-top: 10px; padding: 8px 10px; border: 1.5px dashed var(--rule); }
.sidearm .note { margin: 2px 0 0; }
.brief-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 28px; margin-top: 4px; }
.brief-grid > * { min-width: 0; }
.brief-text { margin: 0; }
.objectives { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.objectives li { padding-inline-start: 22px; position: relative; }
.objectives li::before { content: ""; position: absolute; inset-inline-start: 2px; top: 0.45em; width: 11px; height: 11px; border: 2px solid var(--ink); }
.roster .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.roster .counts { margin: 6px 0 0; font-size: 14px; }
.dcards { display: grid; gap: 6px; }
.dcard { display: grid; gap: 1px; min-height: 48px; padding: 7px 12px; text-align: start; cursor: pointer; background: transparent; color: var(--ink); border: 1.5px solid var(--rule); border-radius: 2px; }
.dcard b { font: 700 15px var(--f-display); }
.dcard span { font-size: 12.5px; color: var(--ink-2); line-height: 1.4; }
.dcard:hover { background: rgba(255, 255, 255, 0.35); }
.dcard[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.dcard[aria-pressed="true"] span { color: rgba(217, 207, 178, 0.88); }
.cond { margin: 0; column-width: 175px; column-gap: 22px; font-size: 13px; }
.cond > div { display: flex; justify-content: space-between; gap: 8px; break-inside: avoid; padding: 2px 0; border-bottom: 1px dotted var(--rule); }
.cond .wide { column-span: all; }
.cond dt { color: var(--ink-2); }
.cond dd { margin: 0; font-family: var(--f-data); font-weight: 600; font-variant-numeric: tabular-nums; unicode-bidi: plaintext; text-align: end; }
dl.spec { display: grid; grid-template-columns: minmax(0, auto) minmax(0, 1fr); gap: 3px 16px; margin: 0; font-size: 14px; }
dl.spec dt { color: var(--ink-2); }
dl.spec dd { margin: 0; font-family: var(--f-data); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; unicode-bidi: plaintext; overflow-wrap: anywhere; }
[dir="rtl"] dl.spec dd { text-align: left; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  unicode-bidi: plaintext; flex: 1 1 0; min-width: fit-content; min-height: 44px; padding: 6px 8px; cursor: pointer; background: transparent; color: var(--ink);
  border: 1.5px solid var(--rule); border-radius: 2px; font-family: var(--f-display); font-size: 14px;
}
.seg button:hover { background: rgba(255, 255, 255, 0.35); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* armory */
.atabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-bottom: 14px; }
.atab { display: grid; gap: 2px; padding: 5px 6px 6px; cursor: pointer; background: rgba(255, 255, 255, 0.16); border: 1.5px solid var(--rule); border-radius: 2px; color: var(--ink); font: 600 11px var(--f-data); direction: ltr; text-align: center; }
.atab:hover { background: rgba(255, 255, 255, 0.4); }
.arm-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 30px; }
.arm-grid > * { min-width: 0; }
.picture { padding: 6px; border: 1px solid var(--rule); background: rgba(27, 33, 24, 0.06); }
.picture .thumb { background: none; }
.arm-name { font: 700 26px var(--f-display); margin-top: 10px; direction: ltr; unicode-bidi: isolate; text-align: left; }
[dir="rtl"] .arm-name { text-align: right; }
.arm-desc { color: var(--ink-2); margin: 4px 0 10px; max-width: 60ch; }

/* guide */
.tabs { margin-bottom: 14px; }
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 16px 28px; }
.guide article { min-width: 0; border-top: 1px solid var(--rule); padding-top: 10px; }
.guide h3 { font-size: 18px; margin-bottom: 4px; }
.guide p { margin: 0; font-size: 14px; color: var(--ink); }
.guide .table-wrap { margin-top: 8px; }
.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 4px 26px; margin-top: 6px; font-size: 14px; }
.keys div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px dotted var(--rule); padding: 3px 0; }
.keys kbd { font: 600 12px var(--f-data); unicode-bidi: isolate; white-space: nowrap; }   /* dir=auto: key names read left-to-right, translated mouse buttons right-to-left */
.touch-keys div { display: grid; grid-template-columns: minmax(84px, 0.32fr) minmax(0, 1fr); align-items: baseline; gap: 2px 12px; padding: 5px 0; }
.touch-keys b { font: 600 13.5px var(--f-display); }
.touch-keys span { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.keys-section + .keys-section { margin-top: 12px; }

/* settings */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px 36px; }
.group { display: grid; gap: 14px; align-content: start; min-width: 0; }
.group h3 { font-size: 17px; border-bottom: 1px solid var(--rule); padding-bottom: 4px; }
.field { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 6px 12px; align-items: start; }
.field > * { min-width: 0; }
.field label, .field .lbl { font-weight: 500; padding-top: 10px; }
.ctl { display: grid; gap: 4px; }
.ctl.slide { grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.val { font: 600 12px var(--f-data); min-width: 46px; text-align: end; direction: ltr; }
.hint { margin: 0; font-size: 12px; color: var(--ink-2); }
input[type="range"] { width: 100%; accent-color: var(--pencil); height: 44px; margin: 0; }

/* pause */
.pause-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px 28px; }
.stack { display: grid; gap: 8px; align-content: start; }

/* debrief */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px 12px; margin-bottom: 14px; }
.stat { border-top: 2px solid var(--ink); padding-top: 4px; min-width: 0; }
.stat span { display: block; font-size: 12px; color: var(--ink-2); }
.stat b { font: 600 22px var(--f-data); font-variant-numeric: tabular-nums; direction: ltr; display: block; }
[dir="rtl"] .stat b { text-align: right; }
.result-title { font-size: clamp(24px, 4.4vw, 40px); font-weight: 700; }
.result-title.fail { color: var(--pencil); }
.notices { margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 4px; }
.notices li { padding: 6px 12px; font-weight: 500; border-inline-start: 4px solid var(--olive); background: rgba(63, 78, 49, 0.13); }
.shotlog summary { cursor: pointer; margin: 16px 0 8px; font: 600 11px var(--f-data); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); min-height: 44px; padding-block: 12px 0; box-sizing: border-box; }
.table-wrap { overflow-x: auto; max-height: 34vh; border: 1px solid var(--rule); }
table.log { border-collapse: collapse; width: 100%; font: 400 12.5px var(--f-data); font-variant-numeric: tabular-nums; direction: ltr; }
table.log th, table.log td { padding: 4px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--rule); }
table.log th { position: sticky; top: 0; background: var(--paper-2); font-weight: 600; font-family: var(--f-body); }
table.log td:nth-child(2), table.log th:nth-child(2) { text-align: left; font-family: var(--f-body); }
table.log tr.miss td { color: var(--pencil); }
table.tier-table { direction: inherit; font-family: var(--f-body); font-size: 13px; }
.tier-table th, .tier-table td, .tier-table td:nth-child(2), .tier-table th:nth-child(2) { text-align: start; white-space: normal; font-family: var(--f-body); }

@media (min-width: 480px) {
  .wgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 720px) {
  .wgrid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .brief-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .atabs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .arm-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pause-grid { grid-template-columns: minmax(0, 260px) minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .field { grid-template-columns: minmax(0, 1fr); }
  .field label, .field .lbl { padding-top: 0; }
  .row-card { grid-template-columns: auto minmax(0, 1fr); }
  .row-card .meta { grid-column: 1 / -1; text-align: start; }
  .sidearm { grid-template-columns: minmax(0, 96px) minmax(0, 1fr); }
}
@media (max-height: 520px) {
  .screen { padding-block: calc(8px + var(--safe-t)) calc(8px + var(--safe-b)); }
  .sheet-head { padding: 8px clamp(14px, 2.4vw, 26px) 6px; gap: 6px 12px; }
  .sheet-head h2 { font-size: 22px; }
  .sheet-head p, .sheet-code { display: none; }
  .sheet.debrief .sheet-head p { display: block; }   /* the reason a mission failed must stay visible */
  .sheet-body { padding-top: 10px; padding-bottom: 14px; }
  .title-mark h1 { font-size: clamp(44px, 17vh, 100px); }
  .title-menu .btn { min-width: 112px; padding-inline: 12px; }
  .title-mark .pitch { display: none; }
  .title { gap: 12px; }
  .stat b { font-size: 18px; }
  .table-wrap { max-height: 40vh; }
}
@media (prefers-reduced-motion: reduce) {
  .stage.shake { animation: none; }
}
