/* DUCKOV EXTRACT — original UI, programmatic vector art, no external assets. */
:root {
  --bg: #0d1213;
  --bg-deep: #080c0d;
  --surface: rgba(22, 30, 31, 0.94);
  --surface-solid: #161e1f;
  --surface-2: #1d2728;
  --surface-3: #253132;
  --border: #344244;
  --border-soft: rgba(129, 155, 153, 0.18);
  --text: #e4ece8;
  --text-dim: #9fb1ad;
  --text-faint: #718581;
  --orange: #e7943a;
  --orange-bright: #ffb45b;
  --teal: #69d3c5;
  --red: #e8584f;
  --amber: #ffae42;
  --blue: #3f9eff;
  --green: #7fcf8f;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --hud-top-h: 104px;
  --boss-top: calc(var(--safe-t) + 122px);
  --radius: 2px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --touch-scale: 1;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
html { background: var(--bg-deep); }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
}
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.hidden { display: none !important; }
.accent { color: var(--orange-bright); }
.eyebrow {
  font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase;
  color: var(--orange); font-family: var(--mono);
}
.mono { font-family: var(--mono); }
#app { position: relative; width: 100%; height: 100dvh; overflow: hidden; }
#gameCanvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; background: #101617;
}
code { color: var(--teal); font-family: var(--mono); font-size: .92em; }

/* ---------------- Shared chrome ---------------- */
.panel-skin {
  background: linear-gradient(160deg, rgba(26, 36, 37, .96), rgba(15, 21, 22, .94));
  border: 1px solid var(--border-soft);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255,255,255,.035);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border: 1px solid var(--border);
  background: linear-gradient(180deg, #273233, #1a2324); color: var(--text);
  border-radius: var(--radius); font-weight: 700; font-size: 14px; line-height: 1.2;
  transition: background .14s ease, border-color .14s ease, transform .1s ease;
  touch-action: manipulation;
}
.btn:hover { border-color: #54666a; background: #2a3738; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #16110a; border-color: var(--orange);
  background: linear-gradient(180deg, #ffc46d, #e7943a);
  box-shadow: 0 0 0 1px rgba(255, 190, 98, .12), 0 8px 24px rgba(231, 148, 58, .18);
}
.btn-primary:hover { background: linear-gradient(180deg, #ffd48f, #f2a247); border-color: #ffd28a; }
.btn-ghost { background: transparent; }
.btn-small { min-height: 44px; padding: 8px 12px; font-size: 13px; }
.btn-large { padding: 18px 20px; }
.btn-danger-ghost { border-color: rgba(232, 88, 79, .42); color: #f6a39b; background: rgba(80, 28, 26, .25); }
.btn-danger-ghost:hover { background: rgba(105, 34, 30, .45); border-color: var(--red); }
.btn-tile { justify-content: space-between; text-align: left; min-height: 62px; }
.btn-tile span, .btn-large span { font-size: 17px; }
.btn-tile small, .btn-large small { font-weight: 500; color: var(--text-dim); font-size: 12px; }
.btn-primary small { color: rgba(22, 17, 10, .72); }
.keycap {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px;
  padding: 0 6px; border: 1px solid #687678; border-bottom-width: 2px; background: #202b2c;
  border-radius: 3px; font-family: var(--mono); font-size: 12px; color: #eaf0eb;
}
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; font-size: 11px; font-weight: 800; border-radius: 2px; white-space: nowrap; }
.status-badge.danger { color: #ffd9d3; background: #7b2c27; border: 1px solid #e8584f; animation: pulseSoft 1s infinite; }
.status-badge.warn { color: #2b1c08; background: var(--amber); }
.status-badge.broken { color: #ffe1dc; background: rgba(124, 41, 35, .8); border: 1px solid var(--red); }
.dev-pill {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 6px; background: #5d2d88; border: 1px solid #c89cff; color: #f1e4ff;
  font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: .05em; border-radius: 2px;
}
.dev-inline { font-style: normal; color: #e4c6ff; font-family: var(--mono); margin-left: 6px; font-size: 12px; }
.inline-warning { border-left: 3px solid var(--red); background: rgba(105, 35, 30, .35); color: #ffcfc8; padding: 9px 12px; font-size: 13px; margin-top: 12px; }
.inline-note { border-left: 3px solid var(--orange); background: rgba(104, 70, 25, .25); color: #ffe0b1; padding: 10px 12px; font-size: 13px; margin: 12px 0; }

/* ---------------- HUD ---------------- */
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; font-size: 14px; }
.hud-top {
  position: absolute; left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px);
  top: calc(var(--safe-t) + 8px);
  display: grid; grid-template-columns: minmax(220px, 1fr) minmax(250px, 1.1fr) minmax(156px, .66fr);
  gap: 8px; align-items: start;
}
.vitals-panel { padding: 8px 10px; max-width: 380px; }
.vital-row { display: grid; grid-template-columns: 16px auto minmax(68px, 1fr) auto; align-items: center; gap: 6px; height: 24px; position: relative; }
.vital-row + .vital-row { margin-top: 3px; }
.vital-row.compact .vital-track { display: none; }
.vital-row.compact { grid-template-columns: 16px auto auto; justify-content: start; gap: 7px; }
.vital-row.compact .vital-value { color: var(--text); }
.vital-row > .status-badge { display: none !important; }
.vital-icon { color: var(--teal); font-size: 13px; text-align: center; }
.armor-row .vital-icon { color: #8db6e7; }
.vital-label { font-size: 12px; color: var(--text-dim); font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.vital-label.danger { color: #ff9a90; }
.vital-label.broken { color: #ff9a90; }
.vital-track { position: relative; height: 8px; background: #101718; border: 1px solid #2d3a3c; overflow: hidden; }
.vital-track::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 24%, rgba(0,0,0,.4) 24% 25%); }
.vital-fill { height: 100%; width: 100%; transition: width .16s linear, background-color .2s; }
.health-fill { background: linear-gradient(90deg, #51a375, #8fd28a); }
.health-fill.low { background: linear-gradient(90deg, #a02f2b, #ee675c); }
.armor-fill { background: linear-gradient(90deg, #3f6b9a, #7aafe0); }
.armor-fill.zero { background: #3a2525; }
.vital-value { font-family: var(--mono); font-size: 12px; color: var(--text); white-space: nowrap; }
.vitals-panel.hit { animation: hitFlash .24s linear; }
.dev-indicators { display: flex; gap: 4px; min-height: 0; margin-top: 3px; }
.dev-indicators:empty { display: none; }
.threat-panel { padding: 8px 10px; min-width: 0; }
.threat-line { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.threat-line b { font-family: var(--mono); color: var(--text); font-size: 13px; }
.threat-label { color: var(--teal); font-weight: 800; font-size: 12px; border: 1px solid rgba(105,211,197,.3); padding: 2px 5px; }
.threat-label.mid { color: #ffd27d; border-color: rgba(255,174,66,.4); }
.threat-label.high { color: #ff9e72; border-color: rgba(255,110,80,.48); }
.threat-label.max { color: #ffd4cf; border-color: var(--red); background: rgba(120,34,30,.45); }
.carry-label { margin-left: auto; }
.carry-label b { color: var(--amber); }
.threat-track { position: relative; height: 11px; margin-top: 8px; background: #111819; border: 1px solid #334044; overflow: hidden; }
.threat-fill {
  height: 100%; width: 6%;
  background: linear-gradient(90deg, #4fa977 0%, #b4c663 42%, #ffae42 72%, #e8584f 100%);
  box-shadow: 0 0 16px rgba(232, 88, 79, .3);
  transition: width .2s linear;
}
.threat-track .tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0,0,0,.55); }
.threat-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: 11px; color: var(--text-faint); }
#raidClock { font-family: var(--mono); color: var(--text-dim); white-space: nowrap; }
.extract-panel { padding: 8px 10px; min-width: 0; }
.extract-chance { font-size: 12px; color: var(--text-dim); display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.extract-chance b { color: var(--teal); font-family: var(--mono); font-size: 16px; }
.extract-guide { display: flex; align-items: center; gap: 7px; margin-top: 5px; font-family: var(--mono); font-size: 12px; color: var(--text); }
.guide-arrow { display: inline-block; color: var(--teal); font-size: 15px; transform-origin: 50% 50%; transition: transform .2s linear; }
#minimap { display: block; width: 100%; height: 52px; margin-top: 5px; border: 1px solid #344245; background: #0b1111; image-rendering: auto; }
.boss-hud {
  position: absolute; top: var(--boss-top); left: 50%; transform: translateX(-50%);
  width: min(480px, 46vw); padding: 6px 10px 7px;
  background: linear-gradient(180deg, rgba(35, 21, 20, .96), rgba(18, 13, 13, .94));
  border: 1px solid rgba(232, 88, 79, .58); box-shadow: 0 5px 25px rgba(0,0,0,.5);
}
.boss-heading { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 800; letter-spacing: .03em; }
.boss-skull { color: var(--red); }
.boss-tag { margin-left: auto; color: #ffcfc8; font-size: 10px; border: 1px solid rgba(232,88,79,.5); padding: 1px 4px; }
.boss-track { margin-top: 4px; height: 8px; background: #2b1614; border: 1px solid #4d2925; overflow: hidden; }
.boss-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8c2927, #ef6459); transition: width .12s linear; }
.boss-numbers { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 10px; color: #e3b7ae; margin-top: 3px; }
.loot-chip {
  position: absolute; top: calc(var(--boss-top) + 66px); left: 50%; transform: translateX(-50%);
  padding: 5px 10px; background: rgba(68, 43, 15, .92); border: 1px solid rgba(255,174,66,.7);
  color: #ffdca5; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.interact-prompt {
  position: absolute; left: calc(var(--safe-l) + 12px); bottom: calc(var(--safe-b) + 112px);
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  background: rgba(10, 17, 17, .88); border: 1px solid rgba(105,211,197,.42);
  color: #d9f4ec; font-size: 13px; font-weight: 700; max-width: 260px;
}
.extract-progress {
  position: absolute; left: 50%; bottom: calc(var(--safe-b) + 112px); transform: translateX(-50%);
  width: min(380px, 44vw); padding: 9px 11px;
  background: rgba(10, 20, 19, .92); border: 1px solid rgba(105,211,197,.55);
}
.extract-progress-head { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: #cde9e1; }
.extract-progress-head b { font-family: var(--mono); color: var(--teal); }
.extract-progress-track { height: 7px; margin-top: 6px; background: #122220; border: 1px solid #2c4944; overflow: hidden; }
#extractProgressFill { height: 100%; width: 0; background: linear-gradient(90deg, #3f8277, #93eee0); }
.weapon-hud {
  position: absolute; left: calc(var(--safe-l) + 10px); bottom: calc(var(--safe-b) + 10px);
  width: 258px; padding: 8px 10px 9px;
}
.weapon-topline { display: flex; align-items: center; gap: 7px; min-width: 0; }
.weapon-type { color: var(--orange); font-size: 10px; font-weight: 800; letter-spacing: .1em; border: 1px solid rgba(231,148,58,.35); padding: 1px 4px; white-space: nowrap; }
#weaponName { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.weapon-state { margin-left: auto; font-size: 10px; color: var(--text-dim); white-space: nowrap; }
.ammo-line { display: flex; align-items: baseline; gap: 7px; margin-top: 2px; }
.ammo-big { font-family: var(--mono); font-size: 22px; color: #f7f1df; letter-spacing: .02em; }
.ammo-big.low b { color: var(--amber); }
.ammo-sep { color: var(--text-faint); margin: 0 2px; }
#reserveValue { font-size: 16px; color: var(--text-dim); }
.ammo-label { font-size: 10px; color: var(--text-faint); align-self: flex-end; padding-bottom: 3px; }
.ammo-line .status-badge { margin-left: auto; }
.reload-track { height: 4px; background: #101718; border: 1px solid #2a3638; margin-top: 3px; overflow: hidden; }
#reloadFill { height: 100%; width: 0; background: var(--teal); }
.weapon-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; color: var(--text-faint); font-size: 10px; }
#weaponAttachments { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#weaponSlots { font-family: var(--mono); color: var(--text-dim); }
.hud-bottom-right { position: absolute; right: calc(var(--safe-r) + 10px); bottom: calc(var(--safe-b) + 10px); display: flex; gap: 5px; align-items: center; }
.fps-mini { color: var(--text-faint); font-family: var(--mono); font-size: 10px; }
.hit-flash .vital-row { animation: hitFlash .3s linear; }
@keyframes hitFlash {
  0%, 100% { background: transparent; }
  20% { background: rgba(232, 88, 79, .38); }
  45% { background: rgba(255, 190, 110, .18); }
}
@keyframes pulseSoft { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* Touch layer */
.touch-layer {
  display: none; position: absolute; z-index: 30; pointer-events: none;
  inset: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
}
.touch-device.in-game .touch-layer { display: block; }
.stick {
  position: absolute; width: calc(132px * var(--touch-scale)); height: calc(132px * var(--touch-scale));
  transform: translate(-50%, -50%); border-radius: 50%;
  touch-action: none; pointer-events: auto;
  background: radial-gradient(circle, rgba(30,43,43,.45), rgba(10,16,17,.18) 68%, transparent 70%);
  border: 2px solid rgba(151, 182, 177, .32);
  box-shadow: inset 0 0 26px rgba(0,0,0,.35);
}
.stick::before { content: ""; position: absolute; inset: 13%; border-radius: 50%; border: 1px dashed rgba(160,192,186,.18); }
.stick.is-active { border-color: rgba(105,211,197,.65); background: radial-gradient(circle, rgba(35,62,59,.54), rgba(10,16,17,.2) 70%, transparent 71%); }
.stick-ring { position: absolute; inset: 25%; border-radius: 50%; border: 1px solid rgba(160,192,186,.13); }
.stick-knob {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 38% 32%, #536a66, #263634);
  border: 2px solid rgba(185, 220, 210, .5);
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
}
.stick.is-active .stick-knob { background: radial-gradient(circle at 38% 32%, #7ea69e, #31514b); border-color: var(--teal); }
.stick-caption { position: absolute; left: 50%; bottom: -20px; transform: translateX(-50%); font-size: 11px; color: rgba(201,224,219,.7); white-space: nowrap; letter-spacing: .03em; }
.touch-actions { position: absolute; right: calc(var(--safe-r) + 10px); top: 40%; display: grid; grid-template-columns: repeat(2, minmax(56px, auto)); gap: 8px; pointer-events: auto; }
.touch-btn {
  min-width: 56px; min-height: 52px; padding: 6px 10px; font-size: 13px; font-weight: 800;
  color: #dfece7; background: rgba(22, 34, 34, .8); border: 1px solid rgba(145, 175, 169, .36);
  border-radius: 4px; touch-action: none;
}
.touch-btn:active, .touch-btn.is-down { background: rgba(105,211,197,.28); border-color: var(--teal); transform: scale(.98); }
.touch-pause { color: #ffd3c8; border-color: rgba(232,88,79,.35); }
.rotate-notice {
  display: none; position: fixed; inset: 0; z-index: 500; flex-direction: column; align-items: center; justify-content: center;
  background: #0b1112; text-align: center; padding: 28px; color: var(--text);
}
.rotate-notice .rotate-icon { font-size: 44px; color: var(--orange); margin-bottom: 12px; }
.rotate-notice strong { font-size: 22px; }
.rotate-notice p { color: var(--text-dim); max-width: 360px; line-height: 1.6; font-size: 14px; }
@media (orientation: portrait) {
  .in-game .rotate-notice { display: flex; }
}

/* ---------------- Main menu ---------------- */
.screen {
  position: absolute; inset: 0; z-index: 40; background: var(--bg);
  overflow: hidden;
}
.menu-screen {
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 22px) calc(var(--safe-r) + 30px) calc(var(--safe-b) + 14px) calc(var(--safe-l) + 30px);
  background:
    radial-gradient(ellipse at 78% 8%, rgba(231,148,58,.13), transparent 37%),
    radial-gradient(ellipse at 12% 88%, rgba(105,211,197,.09), transparent 38%),
    linear-gradient(120deg, #0e1415, #101718 52%, #0b1011);
  overflow-y: auto;
}
.menu-bg-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: .36;
  background-image: linear-gradient(rgba(116,146,144,.09) 1px, transparent 1px), linear-gradient(90deg, rgba(116,146,144,.09) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, transparent, #000 22%, #000 74%, transparent);
}
.menu-bg-grid::after {
  content: ""; position: absolute; left: 0; right: 0; top: 46%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(231,148,58,.22), transparent);
}
.menu-header { position: relative; display: flex; align-items: center; gap: 18px; flex-shrink: 0; }
.brand-mark { width: 64px; height: 64px; border: 1px solid rgba(231,148,58,.35); padding: 7px; background: rgba(15,21,22,.8); }
.brand-mark svg { width: 100%; height: 100%; }
.menu-brandtext { min-width: 0; }
.menu-brandtext .eyebrow { margin-bottom: 4px; }
.menu-brandtext h1 {
  margin: 0; font-size: clamp(28px, 3.1vw, 45px); line-height: 1; letter-spacing: -.04em;
  font-weight: 900; color: #f1f3ec;
}
.menu-brandtext h1 span { color: var(--orange); font-weight: 500; }
.tagline { margin: 7px 0 0; color: var(--text-dim); font-size: 13px; letter-spacing: .02em; }
.menu-wallet {
  margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  border-left: 1px solid var(--border); padding-left: 20px; min-width: 132px;
}
.menu-wallet strong { color: var(--amber); font-family: var(--mono); font-size: 22px; }
.menu-wallet span:last-child { font-size: 11px; color: var(--text-faint); }
.menu-main {
  position: relative; flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(260px, .64fr) minmax(420px, 1.1fr);
  gap: clamp(20px, 4vw, 64px); align-items: center; padding: 22px 0;
}
.main-actions { display: flex; flex-direction: column; gap: 9px; max-width: 360px; }
.main-actions .btn-primary { min-height: 76px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; position: relative; overflow: hidden; }
.main-actions .btn-primary::after {
  content: "→"; position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 26px; color: #32200d;
}
.main-actions .btn-tile { border-color: rgba(123,148,145,.24); background: rgba(18,27,28,.66); }
.briefing { padding: clamp(18px, 2.4vw, 28px); max-width: 660px; position: relative; border-left: 2px solid rgba(231,148,58,.65); }
.briefing-head { display: flex; justify-content: space-between; align-items: center; }
.blip { width: 7px; height: 7px; background: var(--teal); border-radius: 50%; box-shadow: 0 0 14px var(--teal); }
.briefing h2 { margin: 14px 0 9px; font-size: clamp(24px, 2.8vw, 38px); line-height: 1.1; letter-spacing: -.03em; }
.briefing > p { margin: 0; color: var(--text-dim); line-height: 1.7; font-size: 14px; max-width: 58ch; }
.brief-list { list-style: none; margin: 22px 0; padding: 0; display: grid; gap: 1px; background: var(--border-soft); }
.brief-list li { display: grid; grid-template-columns: 74px 1fr; gap: 14px; background: rgba(16,23,24,.86); padding: 10px 12px; }
.brief-list b { color: var(--orange); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.brief-list span { font-size: 12px; color: var(--text-dim); line-height: 1.55; }
.controls-hint { border-top: 1px solid var(--border-soft); padding-top: 12px; color: var(--text-faint); font-size: 11px; line-height: 1.6; }
.controls-hint b { color: var(--text-dim); }
.menu-foot { margin-top: 14px; display: flex; justify-content: space-between; color: var(--text-faint); font-family: var(--mono); font-size: 10px; letter-spacing: .06em; }
.menu-footer {
  display: flex; justify-content: space-between; gap: 20px; padding-top: 10px;
  border-top: 1px solid rgba(109,132,130,.16); color: #5e716e; font-size: 10px; flex-shrink: 0;
}
@media (max-width: 860px) {
  .menu-main { grid-template-columns: 1fr; align-items: start; overflow: auto; }
  .main-actions { max-width: none; }
  .briefing { display: none; }
  .menu-wallet { padding-left: 10px; min-width: 100px; }
  .menu-wallet strong { font-size: 18px; }
  .brand-mark { width: 50px; height: 50px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu-screen { padding-top: calc(var(--safe-t) + 12px); padding-bottom: calc(var(--safe-b) + 8px); }
  .brand-mark { width: 46px; height: 46px; }
  .menu-brandtext h1 { font-size: 26px; }
  .tagline { font-size: 12px; }
  .menu-main { padding: 10px 0; grid-template-columns: minmax(230px, .8fr) minmax(340px, 1.2fr); }
  .main-actions { gap: 6px; }
  .main-actions .btn-primary { min-height: 60px; }
  .btn-tile { min-height: 46px; }
  .briefing { padding: 15px; }
  .briefing h2 { font-size: 22px; margin: 8px 0 6px; }
  .briefing > p { font-size: 12px; line-height: 1.45; }
  .brief-list { margin: 10px 0; }
  .brief-list li { padding: 7px 9px; grid-template-columns: 60px 1fr; }
  .brief-list span { font-size: 11px; line-height: 1.4; }
  .menu-footer { font-size: 9px; }
  .controls-hint { font-size: 10px; }
}

/* ---------------- Panel screens ---------------- */
.panel-screen {
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 12px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 12px) calc(var(--safe-l) + 16px);
  background:
    radial-gradient(ellipse at 90% 0%, rgba(231,148,58,.08), transparent 40%),
    linear-gradient(145deg, #101718, #0c1213);
}
.screen-head {
  display: flex; align-items: center; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.screen-head h2 { margin: 2px 0 0; font-size: 24px; letter-spacing: -.03em; }
.screen-head .back-btn { margin-left: 0; }
.head-stats { margin-left: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; justify-content: flex-end; }
.wallet-chip, .capacity-chip {
  display: inline-flex; align-items: center; min-height: 36px; padding: 5px 10px;
  border: 1px solid var(--border); background: rgba(13,20,21,.66);
  font-family: var(--mono); font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.wallet-chip b { color: var(--amber); font-size: 15px; margin-left: 4px; }
.screen-body { flex: 1; min-height: 0; padding-top: 12px; }
.warehouse-layout, .market-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr); gap: 12px; height: 100%; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .8fr); gap: 12px; height: 100%; overflow-y: auto; padding-right: 2px; touch-action: pan-y; }
.list-column, .detail-column { min-height: 0; display: flex; flex-direction: column; }
.list-column { padding: 12px; }
.detail-column { padding: 16px; overflow-y: auto; touch-action: pan-y; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 9px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.filter-group { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  min-height: 44px; padding: 7px 12px; font-size: 12px; font-weight: 700;
  color: var(--text-dim); background: #172021; border: 1px solid #2e3b3d; border-radius: 2px;
}
.chip.active { color: #17130b; background: var(--orange); border-color: var(--orange); }
.sort-label { display: flex; align-items: center; gap: 7px; color: var(--text-faint); font-size: 12px; }
select, input[type="text"], input[type="password"], input[type="number"] {
  min-height: 44px; background: #101819; border: 1px solid var(--border); border-radius: 2px;
  padding: 8px 10px; color: var(--text); outline: none;
}
select:focus, input:focus { border-color: var(--teal); }
.item-list { flex: 1; min-height: 0; overflow-y: auto; touch-action: pan-y; padding: 6px 2px 6px 0; scrollbar-color: #3d4e50 #111818; }
.item-row {
  display: grid; grid-template-columns: 4px 38px minmax(120px, 1fr) auto auto; gap: 10px; align-items: center;
  min-height: 56px; padding: 7px 10px; margin-bottom: 5px;
  background: rgba(20, 29, 30, .72); border: 1px solid rgba(100,125,122,.16);
  transition: border-color .12s, background .12s; text-align: left;
}
.item-row:hover, .item-row.selected { border-color: rgba(105,211,197,.46); background: rgba(30,44,44,.9); }
.market-row { cursor: pointer; }
.market-detail-card { width: min(620px, 100%); }
.item-row .rarity-line { align-self: stretch; border-radius: 1px; }
.item-row .item-glyph {
  width: 36px; height: 36px; border: 1px solid #3b4a49; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-family: var(--mono); font-size: 16px; background: #101818;
}
.item-row .item-main { min-width: 0; }
.item-row .item-name { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .item-sub { color: var(--text-faint); font-size: 11px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-row .item-price { font-family: var(--mono); color: var(--amber); font-size: 13px; text-align: right; white-space: nowrap; }
.item-row .item-qty { color: var(--text-dim); font-family: var(--mono); font-size: 11px; text-align: right; white-space: nowrap; }
.rarity-line { display: block; width: 4px; min-height: 34px; align-self: stretch; }
.rarity-tag { display: inline-flex; align-items: center; padding: 1px 4px; border: 1px solid currentColor; font-size: 9px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.rarity-common { color: #b9c5c9; }
.rarity-rare { color: #65b9ff; }
.rarity-legendary { color: #ffbe63; }
.boss-mini { font-size: 9px; border: 1px solid #a26d2d; color: #ffcd80; padding: 1px 3px; }
.checkbox-cell { display: flex; align-items: center; justify-content: center; width: 28px; height: 44px; }
.checkbox-cell input { width: 20px; height: 20px; accent-color: var(--orange); }
.empty-list { color: var(--text-faint); padding: 30px 10px; text-align: center; line-height: 1.7; font-size: 13px; border: 1px dashed rgba(119,142,138,.2); }
.list-footer { border-top: 1px solid var(--border-soft); padding-top: 9px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; flex-shrink: 0; }
.selection-info { color: var(--text-dim); font-size: 12px; font-family: var(--mono); }
.footer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-detail { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 200px; text-align: center; color: var(--text-dim); }
.empty-detail .empty-icon { font-size: 34px; color: #405351; margin-bottom: 8px; }
.empty-detail p { margin: 0 0 5px; font-size: 14px; }
.empty-detail small { color: var(--text-faint); font-size: 12px; max-width: 240px; line-height: 1.6; }
.detail-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--border-soft); padding-bottom: 10px; }
.detail-head h3 { margin: 4px 0 2px; font-size: 20px; line-height: 1.2; }
.detail-head .rarity-tag { font-size: 10px; padding: 2px 6px; }
.detail-value { font-family: var(--mono); color: var(--amber); font-size: 22px; white-space: nowrap; }
.detail-title-sub { font-size: 12px; color: var(--text-faint); }
.detail-table { width: 100%; border-collapse: collapse; margin: 14px 0; }
.detail-table th, .detail-table td { border-bottom: 1px solid rgba(108,133,130,.14); padding: 7px 2px; text-align: left; font-size: 12px; vertical-align: top; }
.detail-table th { color: var(--text-faint); font-weight: 600; width: 38%; }
.detail-table td { color: var(--text); }
.attachment-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.attach-chip { font-size: 10px; color: var(--teal); border: 1px solid rgba(105,211,197,.32); padding: 2px 5px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.detail-note { color: var(--text-faint); font-size: 11px; line-height: 1.6; margin-top: 12px; border-top: 1px solid var(--border-soft); padding-top: 10px; }
.stash-law { display: flex; gap: 10px; align-items: flex-start; color: var(--text-dim); font-size: 12px; line-height: 1.55; }

/* Market */
.tag { font-size: 10px; color: var(--teal); border: 1px solid rgba(105,211,197,.35); padding: 2px 6px; vertical-align: middle; margin-left: 6px; letter-spacing: 0; }
.market-ribbon {
  flex-shrink: 0; display: flex; gap: 18px; overflow-x: auto; white-space: nowrap;
  padding: 8px 2px 4px; color: var(--text-faint); font-size: 11px; border-bottom: 1px solid rgba(108,133,130,.12);
}
.market-ribbon span:first-child { color: var(--teal); }
.dev-note { color: #cfadf7; }
.market-toolbar { justify-content: space-between; }
.market-row { grid-template-columns: 4px 38px minmax(120px, 1fr) auto auto auto auto; }
.market-price { text-align: right; min-width: 76px; }
.market-price small { display: block; color: var(--text-faint); font-size: 9px; margin-top: 2px; }
.price-buy { color: var(--amber); font-family: var(--mono); font-size: 13px; }
.price-sell { color: #8ea9a2; font-family: var(--mono); font-size: 11px; }
.stock-tag { font-family: var(--mono); font-size: 10px; color: var(--text-faint); white-space: nowrap; }
.buy-btn { min-width: 64px; min-height: 44px; }
.market-notes h3 { margin: 0 0 10px; font-size: 18px; }
.market-notes dl { margin: 0 0 12px; }
.market-notes dt { color: var(--orange); font-size: 11px; font-weight: 800; margin-top: 10px; }
.market-notes dd { margin: 3px 0 0; color: var(--text-dim); font-size: 12px; line-height: 1.6; }
.market-mini { border-top: 1px solid var(--border-soft); padding-top: 12px; margin-top: 7px; display: flex; justify-content: space-between; align-items: baseline; }
.market-mini strong { font-family: var(--mono); font-size: 16px; }
.market-buy-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.dev-price-flag { color: #d4b3f7; font-family: var(--mono); font-size: 9px; }

/* Settings */
.settings-column, .settings-side { display: flex; flex-direction: column; gap: 12px; }
.settings-section { padding: 16px; }
.settings-section h3 { margin: 0; font-size: 17px; }
.section-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.section-desc { color: var(--text-faint); font-size: 12px; line-height: 1.6; margin: 6px 0 12px; }
.keybind-list { display: grid; gap: 5px; }
.keybind-row { display: grid; grid-template-columns: minmax(100px, 1fr) auto auto; gap: 8px; align-items: center; min-height: 48px; border-bottom: 1px solid rgba(108,133,130,.12); }
.keybind-row .kb-label { font-size: 13px; font-weight: 700; }
.keybind-btn {
  min-width: 102px; min-height: 44px; font-family: var(--mono); font-size: 12px; font-weight: 700;
  background: #172122; border: 1px solid #3b4a4b; color: var(--text); padding: 6px 9px;
}
.keybind-btn.capturing { border-color: var(--orange); color: var(--orange-bright); animation: pulseSoft .8s infinite; }
.keybind-note { color: var(--text-faint); font-size: 10px; text-align: right; min-width: 70px; }
.segmented { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; color: var(--text-dim); font-size: 12px; margin-bottom: 9px; }
.segmented span { margin-right: 4px; }
.segmented button { min-height: 44px; min-width: 44px; background: #172122; border: 1px solid #334243; color: var(--text-dim); padding: 6px 12px; }
.segmented button.active { background: var(--orange); border-color: var(--orange); color: #1b140b; font-weight: 800; }
.layout-editor {
  position: relative; height: 190px; overflow: hidden;
  background-image: linear-gradient(rgba(120,150,145,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(120,150,145,.08) 1px, transparent 1px);
  background-size: 26px 26px; background-color: #0c1414;
  border: 1px solid #2e3b3d; touch-action: none;
}
.layout-editor .layout-safe { position: absolute; inset: 11px 11px 18px; border: 1px dashed rgba(231,148,58,.4); }
.layout-editor > small { position: absolute; left: 8px; bottom: 4px; color: var(--text-faint); font-size: 9px; }
.layout-handle {
  position: absolute; width: 54px; height: 54px; transform: translate(-50%, -50%);
  border-radius: 50%; border: 2px solid var(--teal); background: rgba(24,45,43,.9);
  color: #d9f4ed; font-size: 9px; display: flex; align-items: center; justify-content: center; text-align: center;
  cursor: grab; touch-action: none; user-select: none;
}
.layout-handle:active { cursor: grabbing; border-color: var(--orange); background: rgba(58,44,26,.92); }
.layout-handle.left { left: 16%; top: 72%; }
.layout-handle.right { left: 82%; top: 72%; }
.toggle-grid { display: grid; gap: 2px; margin-top: 9px; }
.switch-line { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text-dim); font-size: 13px; border-bottom: 1px solid rgba(108,133,130,.1); cursor: pointer; }
.switch-line input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--teal); }
.switch-line input[type="range"] { margin-left: auto; width: 150px; accent-color: var(--orange); }
.about-card { position: sticky; top: 0; }
.about-list { display: grid; grid-template-columns: 70px 1fr; gap: 5px 10px; font-size: 12px; color: var(--text-dim); }
.about-list dt { color: var(--text-faint); }
.about-list dd { margin: 0; }
.version-text { font-family: var(--mono); color: var(--text-dim); border-bottom: 1px dotted #445655; cursor: default; user-select: none; padding: 0 2px; }
.about-card > p { color: var(--text-faint); font-size: 12px; line-height: 1.6; }
.save-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.fineprint { color: var(--text-faint); font-size: 10px; line-height: 1.55; margin: 12px 0 0; }
.dev-section { margin-top: 14px; border-top: 1px solid rgba(180, 135, 220, .25); padding-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.controls-legend h3 { margin-bottom: 8px; }
.controls-legend p { margin: 6px 0; color: var(--text-dim); font-size: 12px; line-height: 1.6; }

/* ---------------- Modals ---------------- */
.modal-layer {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 18px) calc(var(--safe-l) + 18px);
  background: rgba(4, 8, 9, .82); backdrop-filter: blur(5px);
  overflow-y: auto; touch-action: pan-y;
}
.modal-card {
  width: min(480px, 100%); max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 28px);
  overflow-y: auto; touch-action: pan-y;
  background: linear-gradient(160deg, #1c2728, #11191a);
  border: 1px solid #415456; box-shadow: 0 30px 80px rgba(0,0,0,.65);
  padding: 20px; position: relative;
}
.modal-card::before { content: ""; position: absolute; left: 0; top: 0; width: 44px; height: 2px; background: var(--orange); }
.modal-card h2 { margin: 5px 0 4px; font-size: 25px; line-height: 1.2; }
.modal-card > p { color: var(--text-dim); line-height: 1.6; font-size: 13px; }
.modal-actions, .end-actions, .pause-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 16px; }
.modal-actions .btn, .end-actions .btn { flex: 1 1 auto; }
.pause-card { width: min(420px, 100%); }
.pause-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.pause-stats div { border: 1px solid var(--border-soft); padding: 8px; background: rgba(11,18,18,.4); }
.pause-stats dt { color: var(--text-faint); font-size: 10px; }
.pause-stats dd { margin: 3px 0 0; font-family: var(--mono); font-size: 14px; }
.pause-actions { flex-direction: column; }
.pause-actions .btn { width: 100%; }
.end-layer { align-items: flex-start; }
.end-card { width: min(900px, 100%); margin: auto; }
.end-head { display: flex; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--border-soft); padding-bottom: 12px; }
.end-head h2 { font-size: clamp(26px, 3.5vw, 38px); margin: 2px 0 4px; }
.end-head p { margin: 0; color: var(--text-dim); font-size: 13px; line-height: 1.5; }
.end-stamp {
  align-self: flex-start; flex-shrink: 0; border: 2px solid var(--teal); color: var(--teal);
  font-family: var(--mono); font-weight: 900; font-size: 13px; padding: 7px 10px; transform: rotate(-3deg);
  letter-spacing: .08em;
}
.end-stamp.bad { border-color: var(--red); color: #ff9a90; }
.dev-flag { margin-top: 10px; background: rgba(81,42,110,.35); border: 1px solid rgba(196,151,233,.45); color: #e1c9f6; padding: 7px 10px; font-size: 11px; font-family: var(--mono); }
.end-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(240px, .75fr); gap: 14px; margin-top: 12px; }
.end-manifest h3, .manifest-list + h3 { margin: 0 0 6px; font-size: 14px; }
.end-manifest h3 span { color: var(--text-faint); font-size: 11px; font-weight: 500; }
.manifest-list { max-height: 340px; overflow-y: auto; touch-action: pan-y; border-top: 1px solid var(--border-soft); }
.manifest-row {
  display: grid; grid-template-columns: 4px minmax(100px, 1fr) auto auto; gap: 8px; align-items: center;
  padding: 7px 4px; border-bottom: 1px solid rgba(108,133,130,.12); min-height: 43px; text-align: left;
}
.manifest-row .m-name { font-size: 12px; font-weight: 700; line-height: 1.3; }
.manifest-row .m-sub { color: var(--text-faint); font-size: 8px; margin-top: 2px; }
.manifest-row .m-qty { font-family: var(--mono); color: var(--text-dim); font-size: 10px; }
.manifest-row .m-total { font-family: var(--mono); color: var(--amber); font-size: 11px; text-align: right; }
.manifest-row.discard { opacity: .5; background: rgba(120,35,32,.14); }
.manifest-row.selectable { cursor: pointer; }
.manifest-row.selectable input { width: 20px; height: 20px; accent-color: var(--red); }
.summary-dl { margin: 0; display: grid; gap: 1px; }
.summary-dl dt { color: var(--text-faint); font-size: 10px; padding-top: 7px; }
.summary-dl dd { margin: 2px 0 0; font-family: var(--mono); font-size: 14px; color: var(--text); border-bottom: 1px solid rgba(108,133,130,.12); padding-bottom: 6px; }
.end-lost { margin-top: 12px; color: #ffb2a9; background: rgba(104,34,30,.25); border-left: 3px solid var(--red); padding: 8px 10px; font-size: 11px; line-height: 1.5; }
.capacity-card { width: min(650px, 100%); }
.capacity-bar { display: flex; justify-content: space-between; gap: 10px; border: 1px solid var(--border); background: rgba(9,15,15,.5); padding: 8px 10px; font-size: 11px; margin: 10px 0; }
.capacity-bar span:first-child { font-family: var(--mono); color: var(--amber); }
.manifest-row .select-discard { width: 20px; height: 20px; accent-color: var(--red); }
#modalRoot:empty { display: none; }
#modalRoot .modal-layer { z-index: 150; }
.password-card { width: min(400px, 100%); }
.password-card input { width: 100%; margin: 9px 0 2px; font-family: var(--mono); letter-spacing: .28em; }
.password-error { min-height: 20px; color: #ffb1a7; font-size: 12px; margin: 6px 0 0; }
.password-lock { color: #ffcf90; font-family: var(--mono); font-size: 12px; min-height: 18px; margin-top: 6px; }
.password-hint { color: var(--text-faint); font-size: 10px; line-height: 1.5; margin-top: 8px; }
.password-actions { display: flex; gap: 7px; }
.password-actions .btn { flex: 1; }

/* Toast */
.toast-root { position: fixed; z-index: 1000; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, calc(100vw - 24px)); }
.toast {
  background: rgba(12, 20, 20, .96); border: 1px solid #4b615e; color: #dfeee9;
  padding: 8px 12px; font-size: 12px; line-height: 1.4; box-shadow: 0 8px 25px rgba(0,0,0,.5);
  animation: toastIn .18s ease-out; max-width: 100%;
}
.toast.warn { border-color: var(--orange); color: #ffe2b5; }
.toast.bad { border-color: var(--red); color: #ffc7c0; }
.toast.good { border-color: var(--teal); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* Dev */
.dev-floating-btn, .dev-floating {
  position: fixed; z-index: 55; left: calc(var(--safe-l) + 10px); top: calc(var(--safe-t) + 10px);
  border: 1px solid #c08cf0; background: rgba(65,32,88,.92); color: #f0ddff;
  font-family: var(--mono); font-size: 10px; font-weight: 800; padding: 7px 8px; border-radius: 2px;
}
.dev-floating { pointer-events: none; }
.dev-floating-btn { pointer-events: auto; cursor: pointer; }
.dev-layer { z-index: 120; align-items: flex-start; }
.dev-window {
  width: min(1100px, 100%); max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 26px);
  display: flex; flex-direction: column; background: #11191a; border: 1px solid #8b60ac;
  box-shadow: 0 30px 90px rgba(0,0,0,.75);
}
.dev-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 15px; border-bottom: 1px solid #53386b; background: linear-gradient(90deg, rgba(64,34,83,.38), transparent); }
.dev-head h2 { margin: 3px 0 0; font-size: 20px; }
.dev-head-actions { display: flex; align-items: center; gap: 7px; }
.dev-body { overflow-y: auto; padding: 12px 15px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; touch-action: pan-y; }
.dev-block { border: 1px solid rgba(131, 96, 167, .3); background: rgba(8,15,15,.45); padding: 10px; min-width: 0; }
.dev-block h3 { margin: 0 0 8px; color: #d8b8f6; font-size: 13px; letter-spacing: .05em; }
.dev-readout { font-family: var(--mono); font-size: 10px; line-height: 1.65; color: #aebfb9; white-space: pre-wrap; overflow-wrap: anywhere; }
.dev-readout .k { color: #e1c6f8; }
.dev-readout .v { color: #dfece7; }
.dev-readout .bad { color: #ff9d8d; }
.dev-toggle-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.dev-toggle-row label { display: flex; gap: 6px; align-items: center; min-height: 38px; font-size: 11px; color: #bdcfc9; }
.dev-toggle-row input { width: 18px; height: 18px; accent-color: #b47ce0; }
.dev-button-grid { display: flex; flex-wrap: wrap; gap: 5px; }
.dev-button-grid .btn { min-height: 36px; font-size: 11px; padding: 6px 9px; flex: 1 1 auto; }
.dev-inline-form { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; margin-top: 9px; font-size: 11px; color: #b9cac5; }
.dev-inline-form label { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.dev-inline-form input[type="range"] { width: 130px; accent-color: #b47ce0; }
.dev-inline-form select { min-height: 36px; font-size: 11px; max-width: 170px; }
.dev-foot { padding: 8px 15px; border-top: 1px solid #3d2a50; color: #8c739e; font-size: 10px; line-height: 1.5; flex-shrink: 0; }

/* ---------------- Responsive HUD and screens ---------------- */
@media (max-width: 1100px) {
  .hud-top { grid-template-columns: minmax(210px, 1fr) minmax(240px, 1.05fr) minmax(140px, .62fr); }
  #minimap { height: 44px; }
  .warehouse-layout, .market-layout, .settings-layout { grid-template-columns: minmax(0, 1.2fr) minmax(270px, .82fr); }
}
@media (max-height: 520px), (max-width: 760px) {
  :root { --hud-top-h: 66px; --boss-top: calc(var(--safe-t) + 72px); }
  body { font-size: 14px; }
  .hud { font-size: 14px; }
  .hud-top { left: calc(var(--safe-l) + 6px); right: calc(var(--safe-r) + 6px); top: calc(var(--safe-t) + 5px); gap: 5px; grid-template-columns: minmax(182px, 1fr) minmax(190px, 1.1fr) minmax(112px, .62fr); }
  .vitals-panel, .threat-panel, .extract-panel { padding: 5px 7px; }
  .vital-row { grid-template-columns: 14px auto minmax(42px, 1fr) auto; gap: 4px; height: 21px; }
  .vital-label { font-size: 11px; }
  .vital-value { font-size: 10px; }
  .status-badge { font-size: 10px; padding: 1px 4px; }
  .threat-line { font-size: 11px; gap: 5px; }
  .threat-foot { font-size: 10px; margin-top: 2px; }
  .threat-track { margin-top: 4px; height: 8px; }
  #minimap { display: none; }
  .extract-panel { display: flex; flex-direction: column; justify-content: center; }
  .extract-chance { font-size: 11px; }
  .extract-chance b { font-size: 14px; }
  .extract-guide { margin-top: 7px; font-size: 11px; }
  .boss-hud { width: min(320px, 45vw); padding: 3px 7px; }
  .boss-heading { font-size: 11px; gap: 4px; }
  .boss-track { height: 6px; margin-top: 2px; }
  .boss-numbers { font-size: 9px; margin-top: 2px; }
  .loot-chip { top: calc(var(--boss-top) + 47px); font-size: 10px; padding: 3px 7px; }
  .weapon-hud { width: 220px; padding: 6px 8px; bottom: calc(var(--safe-b) + 6px); left: calc(var(--safe-l) + 6px); }
  #weaponName { font-size: 13px; }
  .weapon-type { font-size: 9px; }
  .ammo-big { font-size: 18px; }
  #reserveValue { font-size: 13px; }
  .weapon-state, .ammo-label, .weapon-meta { font-size: 9px; }
  .interact-prompt { bottom: calc(var(--safe-b) + 86px); font-size: 11px; padding: 5px 7px; max-width: 210px; }
  .extract-progress { bottom: calc(var(--safe-b) + 86px); width: min(330px, 42vw); padding: 6px 8px; }
  .extract-progress-head { font-size: 10px; }
  .stick { width: calc(116px * var(--touch-scale)); height: calc(116px * var(--touch-scale)); }
  .stick-knob { width: 40px; height: 40px; }
  .stick-caption { font-size: 10px; bottom: -17px; }
  .touch-actions { top: 27%; grid-template-columns: repeat(2, minmax(52px, auto)); gap: 6px; }
  .touch-btn { min-width: 52px; min-height: 48px; font-size: 12px; }
  .screen-head { padding-bottom: 8px; gap: 8px; }
  .screen-head h2 { font-size: 20px; }
  .head-stats { gap: 5px; }
  .panel-screen { padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 8px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 8px); }
  .screen-body { padding-top: 7px; }
  .warehouse-layout, .market-layout { grid-template-columns: minmax(0, 1.35fr) minmax(240px, .75fr); gap: 7px; }
  .settings-layout { grid-template-columns: minmax(0, 1.2fr) minmax(240px, .8fr); gap: 7px; }
  .list-column, .detail-column, .settings-section { padding: 9px; }
  .filter-group { gap: 3px; }
  .chip { min-height: 44px; padding: 5px 8px; font-size: 11px; }
  .item-list { padding-top: 4px; }
  .item-row { min-height: 50px; grid-template-columns: 3px 28px minmax(100px, 1fr) auto auto; gap: 6px; padding: 5px 6px; }
  .item-row .item-glyph { width: 28px; height: 28px; font-size: 12px; }
  .item-row .item-name { font-size: 12px; }
  .item-row .item-sub { font-size: 10px; }
  .item-row .item-price { font-size: 11px; }
  .market-row { grid-template-columns: 3px 28px minmax(100px, 1fr) auto auto auto auto; }
  .btn-small { min-height: 44px; font-size: 12px; }
  .btn { min-height: 44px; }
  .keybind-row { min-height: 44px; }
  .keybind-btn { min-height: 44px; min-width: 86px; font-size: 11px; }
  .keybind-note { font-size: 9px; min-width: 50px; }
  .screen-head .eyebrow { font-size: 9px; }
  .wallet-chip, .capacity-chip { min-height: 32px; font-size: 10px; padding: 3px 6px; }
  .wallet-chip b { font-size: 13px; }
  .end-card { padding: 13px; }
  .end-head h2 { font-size: 24px; }
  .end-grid { grid-template-columns: minmax(0, 1.3fr) minmax(200px, .75fr); gap: 8px; }
  .manifest-list { max-height: 220px; }
  .manifest-row { min-height: 36px; padding: 4px 3px; }
  .summary-dl dd { font-size: 12px; }
  .modal-card { padding: 14px; }
  .dev-body { grid-template-columns: 1fr 1fr; gap: 7px; padding: 8px; }
  .dev-readout { font-size: 9px; }
  .dev-foot { font-size: 9px; padding: 6px 9px; }
}
@media (max-height: 430px) and (orientation: landscape) {
  .hud-top { grid-template-columns: minmax(174px, 1fr) minmax(174px, 1.06fr) minmax(100px, .58fr); }
  .vital-row { height: 20px; }
  .weapon-hud { width: 205px; }
  .boss-hud { width: min(290px, 42vw); }
  .stick { width: calc(108px * var(--touch-scale)); height: calc(108px * var(--touch-scale)); }
  .touch-actions { top: 25%; }
  .menu-main { grid-template-columns: minmax(230px, .8fr) minmax(310px, 1.2fr); }
  .brief-list { display: none; }
}
@media (max-width: 900px) {
  .warehouse-layout, .market-layout { grid-template-columns: 1fr; overflow-y: auto; touch-action: pan-y; }
  .list-column { min-height: 300px; }
  .detail-column { max-height: none; }
  .settings-layout { grid-template-columns: 1fr; overflow-y: auto; }
  .settings-side { padding-bottom: 20px; }
  .about-card { position: static; }
  .end-grid { grid-template-columns: 1fr; }
  .menu-footer { display: none; }
}
@media (max-width: 680px) {
  .menu-screen { padding-left: calc(var(--safe-l) + 16px); padding-right: calc(var(--safe-r) + 16px); }
  .menu-brandtext h1 { font-size: 27px; }
  .menu-wallet { min-width: 82px; }
  .menu-wallet strong { font-size: 16px; }
  .brand-mark { width: 42px; height: 42px; }
  .tagline { display: none; }
  .screen-head { flex-wrap: wrap; }
  .head-stats { margin-left: 0; width: 100%; justify-content: flex-start; }
  .screen-head .back-btn { min-height: 44px; }
  .toolbar { align-items: stretch; }
  .sort-label { margin-left: auto; }
  .market-ribbon { gap: 10px; }
  .hud-top { grid-template-columns: minmax(162px, 1fr) minmax(160px, 1.06fr) minmax(96px, .56fr); }
  .threat-foot span:first-child { display: none; }
  .touch-actions { top: 34%; }
}
@media (max-width: 560px) {
  .vitals-panel { padding: 4px 5px; }
  .vital-label { display: none; }
  .vital-row { grid-template-columns: 13px minmax(32px, 1fr) auto; gap: 3px; }
  .vital-icon { font-size: 11px; }
  .vital-value { font-size: 9px; }
  .threat-line .carry-label { display: none; }
  .extract-panel { padding: 4px 5px; }
  .hud-bottom-right { display: none; }
  .weapon-hud { width: 190px; }
  .touch-actions { grid-template-columns: repeat(2, 48px); }
  .touch-btn { min-width: 48px; min-height: 46px; padding: 4px; font-size: 11px; }
  .item-row .item-sub { max-width: 190px; }
  .end-manifest .manifest-row { grid-template-columns: 3px minmax(85px, 1fr) auto auto; }
  .keybind-row { grid-template-columns: minmax(80px, 1fr) auto; }
  .keybind-note { display: none; }
  .screen-head h2 { font-size: 19px; }
}
@media (pointer: coarse) {
  .btn { min-height: 48px; }
  .chip { min-height: 44px; }
  .touch-btn { min-height: 50px; }
}
/* Text-size preference: scales the primary readable UI typography. */
.screen-head h2 { font-size: calc(24px * var(--ui-font-scale, 1)); }
.screen .section-desc, .screen .controls-legend p, .screen .market-notes dd,
.screen .about-card > p, .screen .fineprint { font-size: calc(12px * var(--ui-font-scale, 1)); }
.screen .item-name { font-size: calc(14px * var(--ui-font-scale, 1)); }
.screen .item-sub { font-size: calc(11px * var(--ui-font-scale, 1)); }
.screen .detail-table th, .screen .detail-table td { font-size: calc(12px * var(--ui-font-scale, 1)); }
.screen .btn, .screen .chip { font-size: calc(13px * var(--ui-font-scale, 1)); }
.modal-card p, .manifest-row .m-name { font-size: calc(13px * var(--ui-font-scale, 1)); }

/* Compact landscape HUD: keeps all required panels out of the central 40% and
   moves the weapon block away from the virtual joysticks on touch screens. */
@media (max-height: 520px), (max-width: 760px) {
  :root { --boss-top: calc(var(--safe-t) + 66px); }
  .hud-top { top: calc(var(--safe-t) + 4px); }
  .vitals-panel, .threat-panel, .extract-panel { padding: 4px 6px; }
  .vital-row { height: 22px; grid-template-columns: 14px auto minmax(38px, 1fr) auto; gap: 4px; }
  .vital-label { font-size: 14px; }
  .vital-value { font-size: 14px; }
  .threat-line { font-size: 14px; }
  .threat-line b { font-size: 14px; }
  .threat-foot { display: none; }
  .threat-track { height: 8px; margin-top: 5px; }
  .extract-chance { font-size: 14px; }
  .extract-chance b { font-size: 16px; }
  .extract-guide { font-size: 14px; margin-top: 5px; }
  .boss-hud { width: min(330px, 48vw); padding: 1px 7px; }
  .boss-heading { font-size: 14px; line-height: 1.15; gap: 4px; }
  .boss-track { height: 6px; margin-top: 2px; }
  .boss-numbers { display: none; }
  .loot-chip { top: calc(var(--boss-top) + 29px); font-size: 14px; padding: 3px 7px; }
  .touch-device.in-game .weapon-hud {
    left: 50%; transform: translateX(-50%); width: 240px;
    bottom: calc(var(--safe-b) + 6px); padding: 6px 8px;
  }
  #weaponName { font-size: 14px; }
  .weapon-type { font-size: 14px; }
  .ammo-big { font-size: 20px; }
  #reserveValue { font-size: 14px; }
  .weapon-state, .ammo-label, .weapon-meta { font-size: 14px; }
  .status-badge { font-size: 12px; }
  .keycap { font-size: 14px; }
  .interact-prompt {
    left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 104px);
    font-size: 14px; padding: 6px 9px; max-width: 250px;
  }
  .extract-progress {
    left: 50%; transform: translateX(-50%); bottom: auto; top: calc(var(--boss-top) + 61px);
    width: min(330px, 52vw); padding: 6px 8px;
  }
  .extract-progress-head { font-size: 14px; }
  .stick-caption { font-size: 14px; bottom: -20px; }
  .touch-btn { min-width: 54px; min-height: 50px; font-size: 14px; }
  .touch-actions { gap: 6px; }
  .hud-bottom-right { display: none; }
}

/* Touch-screen readability floor for interactive screens (HUD micro-labels stay compact
   to keep the central play area clear). */
@media (pointer: coarse), (max-width: 900px) {
  .screen .chip,
  .screen .btn,
  .screen .sort-label,
  .screen select,
  .screen input,
  .screen .item-name,
  .screen .item-sub,
  .screen .item-price,
  .screen .item-qty,
  .screen .section-desc,
  .screen .market-notes dd,
  .screen .about-card p,
  .screen .controls-legend p,
  .modal-card p,
  .modal-card .fineprint,
  .manifest-row .m-name,
  .manifest-row .m-qty,
  .manifest-row .m-total,
  .password-error,
  .password-lock,
  .toast { font-size: 14px; }
  .screen .eyebrow { font-size: 14px; }
  .dev-button-grid .btn, .dev-inline-form select, .dev-inline-form input { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
