@font-face {
  font-family: 'Anybody';
  src: url('assets/resources/fonts/raw/Anybody-Medium.ttf') format('truetype');
  font-weight: 500;
}
@font-face {
  font-family: 'NotoSC';
  src: url('assets/resources/fonts/raw/NotoSansSC-Medium.otf') format('opentype');
}

:root {
  --bg: #16060f;
  --panel: rgba(30, 13, 21, .92);
  --panel2: #33161f;
  --accent: #ff9f1c;
  --accent2: #e5643c;
  --text: #f4e7d3;
  --dim: #b39a8a;
  --pos: #86e37b;
  --neg: #ec6a5c;
  --gold: #ffd35a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; }
body {
  font-family: 'Anybody', 'NotoSC', system-ui, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-font-smoothing: antialiased;
}
#app { position: absolute; inset: 0; overflow: hidden; user-select: none; -webkit-user-select: none; }
#game-canvas { position: absolute; inset: 0; display: block; background: #000; touch-action: none; }
.hidden { display: none !important; }
body, button, .screen { touch-action: manipulation; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.dim { color: var(--dim); }

/* ---------------------------------------------------------------- loading */
#loading {
  position: absolute; inset: 0; z-index: 50; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #2b0f1c, #08030a 70%);
}
.loading-inner { text-align: center; }
.loading-title { font-size: 64px; letter-spacing: 12px; color: var(--accent); }
.loading-track { width: 380px; height: 12px; margin: 24px auto 0; background: #201018; border-radius: 8px; overflow: hidden; }
#loading-bar { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .15s; }
#loading-text { margin-top: 10px; color: var(--dim); }
/* tap-to-enter gate (touch devices): loading done, waiting for the first tap */
#loading.ready .loading-track { display: none; }
#loading.ready #loading-text { margin-top: 24px; font-size: 18px; letter-spacing: 2px; color: #fff; animation: tapPulse 1.2s ease-in-out infinite; }
@keyframes tapPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- screens */
.screen { position: absolute; inset: 0; z-index: 10; }

/* title */
#screen-title { overflow: hidden; }
.title-bg-wrap { position: absolute; inset: 0; }
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.title-mist {
  position: absolute; left: -2%; bottom: 0; width: 104%; opacity: .55;
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateX(-2%); } to { transform: translateX(2%); } }
.title-logo {
  width: min(560px, 64vw); filter: drop-shadow(0 12px 24px rgba(0,0,0,.6)); margin-bottom: 12px;
}
.title-menu {
  position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px; width: 340px;
}
.title-sub { text-align: center; color: var(--dim); font-size: 14px; }

.menu-btn {
  font-family: inherit; font-size: 20px; padding: 12px 18px; cursor: pointer; width: 100%;
  color: #2a1208; background: linear-gradient(180deg, #ffc06a, #ef7a2d);
  border: 3px solid #5a2412; border-radius: 12px; box-shadow: 0 6px 0 #5a2412;
  transition: transform .08s, box-shadow .08s, filter .1s;
}
.menu-btn.primary { background: linear-gradient(180deg, #ffd98a, #f08a34); }
.menu-btn.small { font-size: 16px; padding: 9px 14px; }
.menu-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #5a2412; }
.menu-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 #5a2412; }
.menu-btn:disabled { filter: grayscale(.7) brightness(.65); cursor: default; transform: none; }
.panel-title { font-size: 32px; margin: 0 0 12px; letter-spacing: 2px; color: var(--accent); }
.panel-sub { color: var(--dim); margin: 0 0 18px; }

/* ---------------------------------------------------------------- character select */
/* Mirrors the recorded difficulty-selection page (frames 8.2 / 9.6): back button
   top-left, page title centred, one wide character card, the starting-weapon
   stack, the danger column on the right and the 0–5 icon row along the bottom. */
#screen-characters { background: rgba(10, 4, 8, .94); display: flex; flex-direction: column; }
.char-back { position: absolute; top: 18px; left: 22px; width: auto; z-index: 2; }
.char-title {
  /* `width: fit-content` keeps the centred heading's box off the back button, so
     the layout audit's overlap test (which compares boxes, not glyphs) stays
     clean at every viewport width. */
  position: relative; z-index: 1;
  margin: 12px auto 8px; width: fit-content; text-align: center; font-size: 40px; letter-spacing: 4px;
  color: #f4e7d3; text-shadow: 0 4px 0 #3a1d28;
}
.char-layout {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns:
    minmax(220px, .78fr) minmax(340px, 1.12fr) minmax(240px, .8fr) minmax(210px, .68fr);
  grid-template-areas: "list detail run danger";
  gap: 16px; padding: 0 24px 96px;
}
.char-list-panel { grid-area: list; overflow: auto; min-height: 0; padding-right: 6px; }
.char-detail-panel { grid-area: detail; }
.char-danger-panel {
  grid-area: danger; background: rgba(8, 6, 10, .88); border: 2px solid #2a2230; border-radius: 12px;
  padding: 16px 18px; overflow: auto; align-self: start; max-height: 100%;
}
.danger-title { margin: 0 0 10px; font-size: 26px; color: #f4e7d3; letter-spacing: 1px; }
.danger-line { font-size: 15px; color: #d9cbb8; line-height: 1.5; }
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 12px; }
.char-card {
  position: relative;
  background: var(--panel); border: 3px solid #3a1d28; border-radius: 12px; padding: 10px; cursor: pointer;
  color: var(--text); font-family: inherit; text-align: center; transition: transform .1s, border-color .1s;
}
.char-card:hover { transform: translateY(-3px); }
.char-card.selected { border-color: var(--accent); background: var(--panel2); }
.char-card.locked { opacity: .45; }
.char-icon img { width: 72px; height: 72px; object-fit: contain; }
.char-name { font-size: 14px; margin-top: 6px; }
.char-stats { font-size: 11px; color: var(--dim); display: flex; flex-direction: column; gap: 1px; margin-top: 4px; }
.char-stats .pos, .char-detail-effects .pos { color: var(--pos); }
.char-stats .neg, .char-detail-effects .neg { color: var(--neg); }
.char-detail-panel {
  background: var(--panel); border-radius: 14px; padding: 18px 22px; display: flex; flex-direction: column; gap: 12px;
  overflow: auto; min-height: 0;
}
.char-detail-name { margin: 0; text-align: center; font-size: 32px; letter-spacing: 2px; color: #f4e7d3; }
.char-detail-row { display: grid; grid-template-columns: 190px 1fr; gap: 18px; align-items: center; }
.char-portrait {
  background: rgba(20, 10, 16, .75); border: 3px solid #4a2430; border-radius: 10px;
  padding: 12px; display: grid; place-items: center;
}
.char-portrait img { width: 150px; height: 150px; object-fit: contain; display: block; }
.char-detail-effects { display: flex; flex-direction: column; gap: 6px; font-size: 17px; }
.char-actions { margin-top: auto; display: flex; gap: 10px; }
.char-run-panel { grid-area: run; display: flex; flex-direction: column; gap: 12px; overflow: auto; min-height: 0; }
.char-weapon-cards { display: flex; flex-direction: column; gap: 10px; }
.char-weapon-card {
  background: rgba(8, 6, 10, .9); border: 2px solid #2a2230; border-radius: 10px; padding: 10px 12px;
}
.char-weapon-card .w-head { display: flex; gap: 10px; align-items: center; }
.char-weapon-card .w-head img {
  width: 56px; height: 56px; object-fit: contain; background: #1c0d13; border-radius: 8px; border: 1px solid #3a1d28;
}
.char-weapon-card .w-name { font-size: 17px; }
.char-weapon-card .w-kind { font-size: 12px; color: #c8b49a; }
.char-weapon-card .w-stats { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.char-weapon-card .w-row { display: flex; justify-content: space-between; gap: 10px; }
.char-weapon-card .w-row > span:first-child { color: #eae2b0; }
.w-scale { color: #7fd18a; font-size: 12px; }
.char-options-block {
  background: rgba(8, 6, 10, .88); border: 2px solid #2a2230; border-radius: 10px; padding: 10px 12px;
}
.char-option {
  width: 100%; font-family: inherit; font-size: 15px; cursor: pointer; padding: 8px 10px; border-radius: 8px;
  color: var(--text); background: #241420; border: 2px solid #3a1d28;
}
.char-option.on { border-color: var(--accent); color: var(--accent); }
.danger-row {
  position: absolute; left: 0; right: 0; bottom: 18px;
  display: flex; justify-content: center; align-items: center; gap: 10px;
}
.danger-icon {
  width: 62px; height: 62px; padding: 0; cursor: pointer; border-radius: 10px;
  background: #1b1219; border: 3px solid #3a1d28; display: grid; place-items: center;
  transition: transform .1s, border-color .1s;
}
.danger-icon img { width: 48px; height: 48px; object-fit: contain; }
.danger-icon:hover { transform: translateY(-2px); }
.danger-icon.selected { border-color: var(--accent); background: #2a1a24; }
.danger-icon.locked { cursor: default; opacity: .55; }
.danger-icon .lock-glyph { font-size: 26px; }

/* ---------------------------------------------------------------- HUD */
#screen-combat { pointer-events: none; }
.hud { position: absolute; inset: 0; padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); display: flex; flex-direction: column; justify-content: space-between; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-block { background: rgba(12, 5, 9, .55); border-radius: 10px; padding: 8px 14px; min-width: 300px; }
.hud-block.right { min-width: 0; text-align: right; }
.hud-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 16px; }
.hud-block.right .hud-row { justify-content: flex-end; }
.hud-wave { font-size: 20px; }
.hud-timer { font-size: 20px; color: var(--accent); }
.hud-materials { font-size: 24px; color: var(--gold); }
.mat-icon {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a3, #e8a92a 60%, #9a6712);
  box-shadow: 0 0 6px rgba(255, 200, 80, .5);
}
.bar { position: relative; height: 16px; background: #1a0c12; border-radius: 9px; overflow: hidden; margin-top: 6px; }
.bar .fill { height: 100%; width: 0%; background: linear-gradient(90deg, #f2b33d, #ffd977); transition: width .12s; }
.bar.hp { width: min(560px, 70vw); height: 22px; margin: 0 auto; }
.bar.hp .fill { background: linear-gradient(90deg, #b3232f, #ef4b4b); }
.bar.xp { width: 100%; height: 22px; }
.bar-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; text-shadow: 0 1px 2px #000; }
.hud-bottom { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-bottom: 6px; }
.weapon-slots { display: flex; gap: 6px; }
.weapon-slot {
  width: 40px; height: 40px; border-radius: 8px; border: 2px solid #4a2430; background: rgba(12,5,9,.6);
  display: grid; place-items: center;
}
.weapon-slot img { width: 32px; height: 32px; object-fit: contain; }
/* Queued things to process (item boxes, level ups). The original keeps them in
   the top-left HUD column (`main.tscn::UI/HUD`, UIThingsToProcessPlayerContainer)
   instead of a badge in the middle of the screen. */
.hud-process { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.hud-process .process-chip {
  position: relative; width: 40px; height: 40px; border-radius: 8px;
  background: rgba(20, 8, 12, .85); border: 2px solid var(--accent);
}
.hud-process .process-chip img { width: 100%; height: 100%; object-fit: contain; }
.hud-process .process-chip .count {
  position: absolute; right: -6px; bottom: -6px; min-width: 18px; height: 18px;
  border-radius: 9px; background: var(--accent); color: #1a0c12; font-size: 12px;
  line-height: 18px; text-align: center; font-weight: 700;
}
.hud-process .process-chip.levels { border-color: var(--gold); }
.hud-process .process-chip.levels .count { background: var(--gold); }

/* Starting-weapon selection (`weapon_selection.gd`). */
.weapon-select-panel { max-width: 1180px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.weapon-select-body { display: grid; grid-template-columns: 1fr 320px; gap: 20px; min-height: 420px; }
.weapon-select-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start; }
.weapon-pick {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px;
  background: rgba(24, 10, 16, .8); border: 2px solid rgba(255, 255, 255, .12);
  border-radius: 10px; color: var(--text); cursor: pointer; font: inherit;
}
.weapon-pick:hover { border-color: rgba(255, 200, 120, .5); }
.weapon-pick.selected { border-color: var(--accent); box-shadow: 0 0 12px rgba(255, 159, 28, .35); }
.weapon-pick img { width: 64px; height: 64px; object-fit: contain; }
.weapon-pick .weapon-pick-name { font-size: 14px; text-align: center; }
.weapon-pick .weapon-pick-kind { font-size: 12px; opacity: .7; }
.weapon-select-detail { background: rgba(24, 10, 16, .8); border-radius: 10px; padding: 14px; font-size: 14px; }
.weapon-select-actions { display: flex; justify-content: space-between; }

/* ---------------------------------------------------------------- shop */
#screen-shop { background: rgba(10, 4, 8, .9); }
.shop-layout { display: grid; grid-template-columns: 1fr 360px; gap: 24px; height: 100%; padding: 24px 28px; }
.shop-main { display: flex; flex-direction: column; min-width: 0; }
.shop-header { display: flex; align-items: center; justify-content: space-between; }
.shop-materials-row { font-size: 26px; color: var(--gold); display: flex; align-items: center; gap: 8px; }
.shop-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 12px 0 20px; flex: 1; min-height: 0; }
/* `shop_item.tscn`: panel card + lock/ban rows below it; only the price buys. */
.shop-item { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.shop-card {
  position: relative; flex: 1; display: flex; flex-direction: column;
  padding: 10px; border: 5px solid #000; border-radius: 8px;
  background: rgba(0, 0, 0, .902); color: #fff; text-align: left;
}
.shop-item.sold .shop-card { opacity: .35; pointer-events: none; }
.shop-head { display: flex; gap: 10px; align-items: flex-start; }
.shop-id { min-width: 0; }
.shop-icon { width: 76px; height: 76px; padding: 5px; border-radius: 8px; background: #1e2022; object-fit: contain; flex: none; }
.shop-name { font-size: 18px; line-height: 1.2; margin: 0 0 2px; }
.shop-kind { font-size: 14px; color: #e6e6e6; }
.shop-price {
  margin-top: auto; align-self: center; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 100px; padding: 6px 14px; border: 0; border-radius: 6px;
  background: rgba(255, 255, 255, .098); color: #e0e0e0; font: inherit; font-size: 23px; cursor: pointer;
}
.shop-price img { width: 22px; height: 22px; object-fit: contain; }
.shop-price:hover:not(:disabled), .shop-price:focus-visible { background: rgba(255, 255, 255, .784); color: #000; outline: 0; }
.shop-price.cant { color: var(--neg); }
.shop-price:disabled { cursor: default; }
.shop-effects { font-size: 15px; color: #e3cfae; margin-top: 8px; line-height: 1.35; }
.shop-actions { display: flex; gap: 12px; justify-content: flex-end; }
.shop-side { background: var(--panel); border-radius: 14px; padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.side-title { font-size: 16px; color: var(--accent); margin: 0 0 8px; letter-spacing: 1px; }
.side-weapons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.side-weapon { position: relative; cursor: pointer; border: 2px solid transparent; border-radius: 8px; padding: 2px; background: rgba(0, 0, 0, .39); }
.side-weapon:hover { border-color: var(--accent); }
.side-weapon img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.side-weapon.empty { cursor: default; border-style: dashed; border-color: #4a2430; background: transparent; opacity: .5; }
/* Selling a weapon is a long press (`SELL_HOLD_MS` in ui.js): the ring around
   the slot shows how much of the hold is done, so a stray click cannot sell. */
.side-weapon.holding { border-color: var(--gold); }
.side-weapon.sold { opacity: .4; }
.sell-ring {
  position: absolute; inset: -2px; border-radius: 8px; pointer-events: none;
  background: conic-gradient(var(--gold) calc(var(--p, 0) * 1turn), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 4px), #000 calc(50% - 3px), #000 50%, transparent calc(50% + 1px));
          mask: radial-gradient(circle, transparent calc(50% - 4px), #000 calc(50% - 3px), #000 50%, transparent calc(50% + 1px));
  opacity: 0;
}
.side-weapon.holding .sell-ring { opacity: .9; }
.upgrade-kind { font-size: 12px; opacity: .7; }
/* Two identical weapons can be merged into the next tier. */
.side-weapon.combineable { border-color: #6fd3a8; box-shadow: 0 0 0 1px rgba(111,211,168,.35) inset; }
.combine-badge { position: absolute; right: -4px; bottom: -4px; width: 20px; height: 20px; padding: 0;
  border: none; border-radius: 50%; background: #6fd3a8; color: #10231c; font-size: 13px; line-height: 20px;
  font-weight: 700; cursor: pointer; }
.combine-badge:hover { background: #9df0c8; }
/* Lock/ban rows below the card (`shop_item.tscn` Top/BottomButtonsContainer).
   Lock is a toggle: pressed style = white 78% bg + black text + locked_icon. */
.shop-card-actions { display: flex; gap: 4px; }
.shop-card-actions button {
  flex: 1; min-height: 36px; display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; border: 0; border-radius: 6px;
  background: rgba(0, 0, 0, .784); color: #fff; font: inherit; font-size: 15px; cursor: pointer;
}
.shop-card-actions button span { flex: 1; text-align: center; }
.shop-card-actions button:hover:not(.disabled), .shop-card-actions button:focus-visible { background: rgba(255, 255, 255, .784); color: #000; outline: 0; }
.key-ico { width: 18px; height: 18px; flex: none; }
.lock-ico { display: none; width: 16px; height: 16px; flex: none; }
.shop-lock.locked { background: rgba(255, 255, 255, .784); color: #000; }
.shop-lock.locked .lock-ico { display: block; }
.shop-ban.disabled { opacity: .42; cursor: default; }
/* weapons keep an invisible ban row so lock rows align across all columns */
.shop-row-ban.placeholder { visibility: hidden; }
.shop-steal { background: #3a2b12; color: #ffcf8a; }
/* Rarity (`item_service.gd` tier colors; dark stylebox backgrounds). */
.shop-card.tier-0, .upgrade-card.tier-0, .reward-card.tier-0 { border-color: #000; background: rgba(0, 0, 0, .902); }
.shop-card.tier-1, .upgrade-card.tier-1, .reward-card.tier-1 { border-color: #5abeff; background: rgba(15, 32, 40, .902); }
.shop-card.tier-2, .upgrade-card.tier-2, .reward-card.tier-2 { border-color: #ad5aff; background: rgba(16, 10, 27, .902); }
.shop-card.tier-3, .upgrade-card.tier-3, .reward-card.tier-3 { border-color: #ff3b3b; background: rgba(36, 9, 9, .902); }
.shop-card.tier-4, .upgrade-card.tier-4, .reward-card.tier-4 { border-color: #ff773b; background: rgba(36, 17, 8, .902); }
.shop-card.tier-5, .upgrade-card.tier-5, .reward-card.tier-5 { border-color: #d0c142; background: rgba(26, 24, 8, .902); }
/* locked overrides the tier border (shop_item.gd::_set_panel_lock_style) */
.shop-card.locked { border-color: #fff; }
/* material_ui.png × Utils.GOLD_COLOR, exact multiply via SVG feComposite */
.mat-green { filter: url(#mat-green); }
.tier-text-0 { color: #fff; }
.tier-text-1 { color: #5abeff; }
.tier-text-2 { color: #ad5aff; }
.tier-text-3 { color: #ff3b3b; }
.tier-text-4 { color: #ff773b; }
.tier-text-5 { color: #d0c142; }
/* IconPanel bg = lerp(dark tier bg, #50c8c8c8, .5) per icon_panel.gd. */
.shop-icon.tier-ico-0, .upgrade-card img.tier-ico-0, .reward-card img.tier-ico-0 { background: rgba(40, 100, 100, .55); }
.shop-icon.tier-ico-1, .upgrade-card img.tier-ico-1, .reward-card img.tier-ico-1 { background: rgba(47, 116, 120, .55); }
.shop-icon.tier-ico-2, .upgrade-card img.tier-ico-2, .reward-card img.tier-ico-2 { background: rgba(48, 105, 114, .55); }
.shop-icon.tier-ico-3, .upgrade-card img.tier-ico-3, .reward-card img.tier-ico-3 { background: rgba(58, 105, 105, .55); }
.shop-icon.tier-ico-4, .upgrade-card img.tier-ico-4, .reward-card img.tier-ico-4 { background: rgba(58, 108, 104, .55); }
.shop-icon.tier-ico-5, .upgrade-card img.tier-ico-5, .reward-card img.tier-ico-5 { background: rgba(53, 112, 104, .55); }
/* Inventory elements: tier color at 25% alpha (black 39% for common). */
.side-weapon.tier-1 { background: rgba(90, 190, 255, .25); }
.side-weapon.tier-2 { background: rgba(173, 90, 255, .25); }
.side-weapon.tier-3 { background: rgba(255, 59, 59, .25); }
.side-weapon.tier-4 { background: rgba(255, 119, 59, .25); }
.side-weapon.tier-5 { background: rgba(208, 193, 66, .25); }
img.inv-t-0 { background: rgba(0, 0, 0, .39); border-color: transparent; }
img.inv-t-1 { background: rgba(90, 190, 255, .25); border-color: transparent; }
img.inv-t-2 { background: rgba(173, 90, 255, .25); border-color: transparent; }
img.inv-t-3 { background: rgba(255, 59, 59, .25); border-color: transparent; }
img.inv-t-4 { background: rgba(255, 119, 59, .25); border-color: transparent; }
img.inv-t-5 { background: rgba(208, 193, 66, .25); border-color: transparent; }
.weapon-dialog { border: 2px solid #4d4d4d; border-radius: 8px; }
.weapon-dialog.tier-1 { border-color: #5abeff; }
.weapon-dialog.tier-2 { border-color: #ad5aff; }
.weapon-dialog.tier-3 { border-color: #ff3b3b; }
.weapon-dialog.tier-4 { border-color: #ff773b; }
.weapon-dialog.tier-5 { border-color: #d0c142; }
.side-hint { font-size: 11px; color: var(--dim); margin: 6px 0 0; }
/* Stat table: header row is 主要 | 次要 and every row is icon + label + value,
   exactly like the recorded shop page (frame-38). */
.side-stats { display: flex; flex-direction: column; font-size: 14px; }
.side-name { font-size: 13px; color: var(--dim); margin: 0 0 8px; }
.pause-character { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.pause-character .side-name { margin: 0; color: #fff; font-size: 16px; }
.pause-portrait { width: 42px; height: 42px; object-fit: contain; }
.side-subtitle { margin: 2px 0 3px; font-size: 12px; color: var(--accent); letter-spacing: 1px; }
.side-traits { display: flex; flex-direction: column; gap: 2px; margin-bottom: 7px; font-size: 12px; color: #eae2b0; }
.side-traits .trait-line { line-height: 1.25; }
.side-stat { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; padding: 1px 0; }
.side-stat-head { color: #c8b49a; font-size: 13px; border-bottom: 1px solid #3a1d28; padding-bottom: 4px; margin-bottom: 4px; }
.side-stat-head span:nth-child(2) { text-align: center; }
.side-stat-head span:nth-child(3) { text-align: right; }
.side-stat .stat-icon { width: 18px; height: 18px; object-fit: contain; display: block; }
.side-stat .label { color: #eae2b0; }
.side-stat .v { color: var(--pos); text-align: right; }
.side-stat .v.neg { color: var(--neg); }
.side-items { display: flex; flex-wrap: wrap; gap: 6px; }
.side-items img { width: 34px; height: 34px; object-fit: contain; background: #1c0d13; border-radius: 6px; border: 1px solid #3a1d28; }
.side-sets { font-size: 12px; color: var(--dim); margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
/* Shop header: title + materials + refresh with the packaged key icon. */
.shop-header { gap: 16px; }
.shop-reroll { display: inline-flex; align-items: center; gap: 6px; width: auto; font-size: 15px; }
.shop-reroll .key-icon { width: 20px; height: 20px; object-fit: contain; }
.shop-inventory-row { display: grid; grid-template-columns: minmax(160px, .8fr) 1.2fr; gap: 20px; margin-bottom: 8px; }
.shop-inventory-block { min-width: 0; }
.shop-inventory-block .side-weapons { grid-template-columns: repeat(auto-fill, 52px); }
.shop-inventory-block .side-weapon img { height: 48px; }
.weapon-popup { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }
.weapon-popup.hidden { display: none !important; }
.weapon-popup-backdrop { position: absolute; inset: 0; border: 0; background: rgba(0, 0, 0, .7); }
.weapon-dialog { position: relative; width: min(700px, 75vw); max-height: min(82vh, 760px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); gap: 5px; }
.weapon-dialog-main, .weapon-dialog-extra { min-width: 0; padding: 15px; border: 2px solid #42434a; border-radius: 6px; background: rgba(5, 5, 7, .98); }
.weapon-dialog-main { display: flex; flex-direction: column; gap: 14px; }
.weapon-dialog .w-head { display: flex; align-items: center; gap: 11px; }
.weapon-dialog .w-head img { width: 70px; height: 70px; padding: 5px; object-fit: contain; background: #202123; border-radius: 6px; }
.weapon-dialog .w-name { font-size: 19px; }
.weapon-dialog .w-kind { color: #e7d7ab; font-size: 14px; }
.weapon-dialog .w-stats { display: flex; flex-direction: column; gap: 3px; font-size: 16px; }
.weapon-dialog .w-row { display: flex; justify-content: flex-start; gap: 10px; }
.weapon-dialog-actions { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.weapon-popup-action { min-height: 37px; border: 0; border-radius: 4px; color: #f4f4f4; background: #111214; font: inherit; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.weapon-popup-action img { width: 18px; height: 18px; object-fit: contain; }
.weapon-popup-action:hover:not(:disabled), .weapon-popup-action:focus-visible { color: #000; background: rgba(255, 255, 255, .784); outline: 0; }
.weapon-popup-action:disabled { opacity: .45; cursor: default; }
.weapon-dialog-extra { align-self: start; min-height: 95px; color: #ddd; font-size: 14px; }

/* Hover card for collected weapons/items (the packaged `ItemPopup`). */
.gear-tooltip {
  position: fixed; z-index: 70; width: min(330px, 82vw); padding: 12px 14px;
  border: 2px solid #42434a; border-radius: 6px; color: #eae2b0;
  background: rgba(5, 5, 7, .98); box-shadow: 0 10px 28px rgba(0, 0, 0, .6);
  pointer-events: none; font-size: 14px;
}
.gear-tooltip.hidden { display: none !important; }
.gear-tooltip .w-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.gear-tooltip .w-head img { width: 44px; height: 44px; object-fit: contain; }
.gear-tooltip .w-name { color: #fff; font-size: 17px; }
.gear-tooltip .w-kind { color: var(--dim); font-size: 12px; }
.gear-tooltip .w-stats { display: flex; flex-direction: column; gap: 3px; }
.gear-tooltip .w-row { display: flex; justify-content: space-between; gap: 12px; }
.gear-tooltip .gear-effect { display: block; color: #f0e7c0; }

/* ---------------------------------------------------------------- upgrade */
#screen-upgrade { background: rgba(10, 4, 8, .92); display: grid; place-items: center; }
.upgrade-panel { text-align: center; max-width: 1100px; }
.upgrade-grid { display: grid; grid-template-columns: repeat(4, 220px); gap: 18px; justify-content: center; }
.upgrade-card {
  background: var(--panel2); border: 3px solid #4a2430; border-radius: 12px; padding: 16px; cursor: pointer;
  min-height: 210px; color: var(--text); font-family: inherit; display: flex; flex-direction: column; align-items: center;
}
.upgrade-card:hover { border-color: var(--accent); transform: translateY(-4px); }
.upgrade-card img { width: 76px; height: 76px; object-fit: contain; }
.upgrade-name { font-size: 16px; margin: 8px 0; }
.upgrade-effects { font-size: 13px; color: var(--dim); }

/* ---------------------------------------------------------------- pause + result */
#screen-paused { background: rgba(8, 3, 6, .78); display: grid; place-items: center; padding: 3vh 3vw; }
.pause-layout {
  width: min(1320px, 94vw); height: min(820px, 90vh);
  display: grid; grid-template-columns: 280px minmax(0, 1fr) minmax(320px, 380px); gap: 18px;
  align-items: stretch;
}
.pause-panel {
  text-align: center; width: auto; align-self: center;
  display: flex; flex-direction: column; gap: 12px;
}
.pause-inventory {
  min-width: 0; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border-radius: 10px; background: rgba(10, 11, 13, .88);
}
.pause-side {
  min-width: 0; min-height: 0; overflow: auto; padding: 16px; border-radius: 10px;
  background: rgba(10, 11, 13, .88);
}
#screen-result { background: rgba(20, 2, 4, .97); display: grid; place-items: center; }
.result-panel { text-align: center; width: 380px; display: flex; flex-direction: column; gap: 12px; }
.result-title { font-size: 52px; margin: 0 0 8px; color: #e5493a; text-shadow: 0 6px 0 #4a120c; }
.result-title.win { color: var(--accent); text-shadow: 0 6px 0 #5a3208; }
.result-stats { color: var(--dim); font-size: 16px; margin-bottom: 12px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%);
  background: rgba(20, 8, 12, .9); color: var(--text); padding: 10px 18px; border-radius: 10px;
  font-size: 15px; z-index: 60; border: 1px solid #4a2430;
}

/* ---------------------------------------------------------------- zones + danger */
.char-zone-block { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #3a1d28; padding-top: 10px; }
.zone-list, .danger-list { display: flex; flex-wrap: wrap; gap: 8px; }
.zone-btn, .danger-btn {
  font-family: inherit; font-size: 14px; padding: 7px 12px; cursor: pointer; color: var(--text);
  background: #1c0d13; border: 2px solid #4a2430; border-radius: 9px; text-align: left;
}
.zone-btn:hover, .danger-btn:hover { border-color: var(--accent); }
.zone-btn.selected, .danger-btn.selected { border-color: var(--accent); background: var(--panel2); color: var(--accent); }
.zone-btn small { display: block; color: var(--dim); font-size: 11px; }
.danger-summary { font-size: 12px; color: var(--dim); min-height: 16px; }
.danger-summary .none { color: var(--dim); opacity: .7; }

/* ---------------------------------------------------------------- boss bar */
.boss-bar {
  position: absolute; left: 50%; top: 74px; transform: translateX(-50%);
  width: min(620px, 60vw); display: flex; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none;
}
.boss-bar .boss-name { font-size: 15px; letter-spacing: 3px; color: #ff8a8a; text-shadow: 0 2px 0 #3a0a0a; }
.bar.boss { width: 100%; height: 18px; margin: 0; border: 2px solid #5c1f24; background: #170a0d; }
.bar.boss .fill { background: linear-gradient(90deg, #7d1220, #d63b3b, #ff7a6b); }
.boss-bar.elite .boss-name { color: #ffb347; }
.boss-bar.elite .bar.boss .fill { background: linear-gradient(90deg, #6b3a08, #ffb347); }

/* ---------------------------------------------------------------- combat banner */
.hud-banner {
  position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%);
  font-size: 42px; letter-spacing: 4px; color: #ff6b6b; text-shadow: 0 6px 0 #3a0a0a;
  pointer-events: none;
}
.hud-banner.elite { color: #ffb347; text-shadow: 0 6px 0 #4a2a05; }
.hud-banner.show { animation: bannerIn .35s ease-out; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.shop-effects .custom { color: #ffcf8a; }
.side-sets .done { color: var(--pos); }
.side-sets > div { display: flex; flex-direction: column; gap: 1px; }
.side-sets .set-bonus { color: #ffcf8a; font-size: 11px; }
.side-sets .pending .set-bonus { color: var(--dim); }

/* ---------------------------------------------------------------- settings */
.options-panel {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(640px, 92vw); display: flex; flex-direction: column; gap: 18px;
  padding: 26px 30px; background: rgba(28, 13, 19, .94); border: 2px solid #4a2430;
  border-radius: 16px;
}
.options-block { display: flex; flex-direction: column; gap: 8px; }
.options-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 12px; font-size: 15px; }
.options-slider { width: 100%; accent-color: var(--accent); }
.options-value { text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.options-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.options-actions .menu-btn.selected { border-color: var(--accent); color: var(--accent); background: var(--panel2); }
.options-save-info { font-size: 13px; color: var(--dim); }
.menu-btn.danger { border-color: #7d2230; color: #ff8a8a; }
.menu-btn.danger:hover { border-color: #ff5a5a; }

/* ---------------------------------------------------------------- result */
.result-stats { display: flex; flex-direction: column; gap: 6px; min-width: 320px; }
.result-row { display: flex; justify-content: space-between; gap: 24px; font-size: 15px; }
.result-label { color: var(--dim); }
.result-value { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- codex */
/* Read-only encyclopedia (public/src/codex.js). Its own screen, dark like the
   other overlays, and it never covers another screen while closed. */
.codex-btn { display: flex; align-items: center; justify-content: center; gap: 10px; }
.codex-btn-icon { width: 26px; height: 26px; object-fit: contain; }

#screen-codex {
  background: radial-gradient(circle at 50% 0%, rgba(44, 17, 29, .97), rgba(8, 3, 10, .99) 68%);
  display: flex; flex-direction: column;
}
.codex-layout { display: flex; flex-direction: column; gap: 10px; height: 100%; padding: 16px 24px 12px; }
.codex-header { display: flex; align-items: center; gap: 16px; }
.codex-title { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 26px; letter-spacing: 3px; }
.codex-title-icon { width: 30px; height: 30px; object-fit: contain; }
.codex-tabs { display: flex; gap: 8px; flex: 1; }
.codex-tab {
  font-family: inherit; font-size: 15px; letter-spacing: 1px; padding: 8px 18px; cursor: pointer;
  color: var(--text); background: #1c0d13; border: 2px solid #4a2430; border-bottom-width: 3px;
  border-radius: 10px; transition: border-color .1s, color .1s, background .1s;
}
.codex-tab:hover { border-color: var(--accent); color: var(--accent); }
.codex-tab.selected { border-color: var(--accent); background: var(--panel2); color: var(--accent); }
.codex-back { width: auto; min-width: 104px; }

.codex-toolbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 13px; color: var(--dim); padding: 2px 2px 8px; border-bottom: 1px solid #3a1d28;
}
.codex-sort { display: flex; align-items: center; gap: 8px; }
.codex-sort-select {
  font-family: inherit; font-size: 14px; color: var(--text); background: #1c0d13;
  border: 2px solid #4a2430; border-radius: 8px; padding: 5px 8px; cursor: pointer;
}
.codex-reverse {
  display: inline-flex; align-items: center; gap: 6px; font-family: inherit; font-size: 14px;
  color: var(--text); background: #1c0d13; border: 2px solid #4a2430; border-radius: 8px;
  padding: 5px 10px; cursor: pointer;
}
.codex-reverse img { width: 16px; height: 16px; object-fit: contain; }
.codex-reverse:hover { border-color: var(--accent); }
.codex-reverse.selected { border-color: var(--accent); color: var(--accent); background: var(--panel2); }
.codex-tiers { display: flex; align-items: center; gap: 6px; }
.codex-tier {
  font-family: inherit; font-size: 13px; padding: 5px 12px; cursor: pointer; color: var(--text);
  background: #1c0d13; border: 2px solid #4a2430; border-radius: 8px;
}
.codex-tier:hover { border-color: var(--accent); color: var(--accent); }
.codex-tier.selected { border-color: var(--accent); background: var(--panel2); color: var(--accent); }
.codex-count { margin-left: auto; letter-spacing: 1px; }

.codex-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 400px; gap: 16px; }
.codex-grid {
  overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(102px, 1fr));
  gap: 10px; align-content: start; padding: 4px 6px 4px 2px;
}
.codex-cell {
  background: var(--panel); border: 2px solid #3a1d28; border-radius: 10px; padding: 8px 6px;
  cursor: pointer; color: var(--text); font-family: inherit; display: flex; flex-direction: column;
  align-items: center; gap: 4px; transition: transform .08s, border-color .08s;
}
.codex-cell:hover { transform: translateY(-2px); border-color: var(--accent); }
.codex-cell.selected { border-color: var(--accent); background: var(--panel2); }
.codex-cell img { width: 48px; height: 48px; object-fit: contain; }
.codex-cell-name { font-size: 11px; line-height: 1.25; text-align: center; }
.codex-cell-sub { font-size: 10px; color: var(--dim); letter-spacing: 1px; }

.codex-detail {
  background: var(--panel); border: 1px solid #3a1d28; border-radius: 14px;
  padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px;
}
.codex-detail-head { display: flex; align-items: center; gap: 14px; }
.codex-detail-icon { width: 76px; height: 76px; object-fit: contain; flex: none; }
.codex-detail-name { font-size: 20px; color: var(--accent); letter-spacing: 1px; }
.codex-detail-sub { font-size: 12px; color: var(--dim); letter-spacing: 1px; margin-top: 2px; }
.codex-section { display: flex; flex-direction: column; gap: 5px; }
.codex-section-title { font-size: 12px; letter-spacing: 2px; color: var(--accent); margin: 0; }
.codex-section-body { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.codex-effect { color: #e3cfae; }
.codex-field { display: grid; grid-template-columns: 92px 1fr auto; gap: 8px; font-size: 13px; align-items: baseline; }
.codex-field-label { color: var(--text); }
.codex-field-key { color: #6f5560; font-size: 11px; font-family: ui-monospace, monospace; }
.codex-field-value { color: var(--accent); font-variant-numeric: tabular-nums; text-align: right; }
.codex-scaling { display: flex; justify-content: space-between; gap: 10px; }
.codex-source {
  margin-top: auto; padding-top: 10px; border-top: 1px solid #3a1d28;
  font-size: 11px; line-height: 1.5; color: var(--dim);
}
.codex-source .unlock { display: block; color: #c9a67f; }
.codex-scene { font-size: 10px; color: #6f5560; word-break: break-all; font-family: ui-monospace, monospace; }

.codex-grid.notice { display: flex; justify-content: center; align-items: flex-start; overflow: auto; padding-top: 18px; }
.codex-notice {
  background: var(--panel); border: 2px dashed #4a2430; border-radius: 14px;
  padding: 26px 30px; width: min(820px, 100%); display: flex; flex-direction: column; gap: 12px;
}
.codex-notice-title { font-size: 22px; color: var(--accent); letter-spacing: 2px; }
.codex-notice p { margin: 0; font-size: 14px; line-height: 1.7; color: var(--text); }
.codex-notice .dim { color: var(--dim); font-size: 12px; }
.codex-body.single { grid-template-columns: 1fr; }

.codex-footer { display: flex; justify-content: space-between; gap: 16px; font-size: 11px; color: var(--dim); letter-spacing: 1px; }
.codex-subtitle { opacity: .9; }
.codex-esc-hint { opacity: .75; }

/* Recorded Abyssal Terrors title menu and character/run selection. */
#screen-title { background: #111a2a; overflow: hidden; }
.title-bg-wrap { position: absolute; inset: 0; overflow: hidden; background: #111a2a; }
.title-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.title-bg { display: none; }
.title-mist-back, .title-mist-mid, .title-mist, .title-post, .title-coral-left, .title-coral-right { display: none; }
.title-vignette { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.title-pirate { position: absolute; left: 20%; top: 23%; width: 31%; height: 51%; object-fit: contain; }
.title-squid { position: absolute; right: 12%; bottom: 4%; width: 40%; height: 47%; object-fit: contain; }
.title-menu { position: absolute; left: 2.4%; top: 23%; bottom: 5%; transform: none; width: min(150px, 16vw); align-items: stretch; gap: 1px; z-index: 2; }
.title-logo { position: absolute; top: -22%; left: 50%; width: min(650px, 60vw); max-height: 22vh; object-fit: contain; transform: translateX(-50%); margin: 0; filter: drop-shadow(0 3px 2px #030711); }
#title-dlc-logo { position: absolute; top: -3%; left: 50%; width: min(650px, 58vw); height: 6vh; object-fit: contain; transform: translateX(-50%); z-index: 3; }
.title-link {
  width: 100%; min-height: 38px; padding: 5px 8px; border: 0; border-radius: 3px;
  color: #f4f5f6; background: rgba(3, 7, 11, .78); font: inherit; font-size: 16px; text-align: left; cursor: pointer;
}
.title-link:hover, .title-link:focus-visible { color: #20252a; background: #eceef0; outline: 0; }
.title-link:disabled { color: #c6c8ca; cursor: default; }
.title-menu > .menu-btn {
  min-height: 38px; width: 100%; margin-top: 1px; padding: 5px 8px; border: 0; border-radius: 3px;
  box-shadow: none; text-align: left; font-size: 16px;
  color: #f4f5f6; background: rgba(3, 7, 11, .78);
}
.title-menu > .menu-btn:hover, .title-menu > .menu-btn:focus-visible {
  transform: none; box-shadow: none; color: #20252a; background: #eceef0;
}
.title-menu .codex-btn { display: flex; align-items: center; justify-content: flex-start; gap: 9px; }
.title-menu .codex-btn-icon { width: 22px; height: 22px; }
.title-sub { margin-top: auto; text-align: left; font-size: 11px; line-height: 1.3; color: #f4f5f6; }
.title-promo { position: absolute; right: 1.8%; bottom: 2.5%; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 2; }
.title-badge { padding: 3px 7px; color: #fff; background: #060a10; font-size: 16px; font-weight: 700; }
.title-promo-link { padding: 4px 7px; border: 0; color: #fff; background: rgba(4, 8, 15, .72); font: inherit; font-size: 16px; text-align: right; }
.title-promo-link:disabled { opacity: 1; }
.title-promo-link:first-of-type { color: #ffe300; }
.title-version { color: #fff; font-size: 11px; }

#screen-characters, #screen-difficulty {
  display: block; overflow: hidden; color: #f5f5f5;
  background: linear-gradient(180deg, rgba(44, 57, 60, .74), rgba(34, 38, 59, .92)),
    url('assets/ui/menus/shop/crash_zone_background.webp') center / cover;
}
.char-back { position: absolute; left: 4.8%; top: 3%; z-index: 3; width: 13%; min-width: 120px; height: 48px; padding: 5px 12px; border: 0; border-radius: 8px; box-shadow: none; color: #fff; background: rgba(0, 0, 0, .72); font-size: 18px; text-align: left; }
.char-back:hover { transform: none; box-shadow: none; color: #fff; background: rgba(0, 0, 0, .9); }
.char-title { position: absolute; left: 50%; top: 2.8%; z-index: 2; margin: 0; transform: translateX(-50%); color: #fff; font-size: 38px; line-height: 1.2; letter-spacing: 0; text-shadow: 0 2px 2px #000; }
.char-layout { position: absolute; inset: 16% 13% 38%; display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(170px, .95fr) minmax(250px, 1fr); grid-template-areas: "detail record options"; gap: 12px; min-height: 0; padding: 0; }
.char-detail-panel { grid-area: detail; min-width: 0; overflow: hidden; padding: 9px 18px; border: 0; border-radius: 4px; background: rgba(20, 24, 35, .38); display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 10px; }
.char-detail-name { margin: 0; color: #fff; font-size: clamp(24px, 2.4vw, 48px); line-height: 1.12; letter-spacing: 0; text-shadow: 0 2px 2px #000; }
.char-detail-row { display: grid; grid-template-columns: minmax(170px, 34%) 1fr; align-items: center; gap: 16px; min-height: 0; }
.char-portrait { aspect-ratio: 1; min-height: 0; padding: 15px; border: 5px solid #090b10; border-radius: 14px; background: rgba(55, 70, 75, .56); box-shadow: 0 0 0 2px rgba(0,0,0,.34) inset; }
.char-portrait img { width: 100%; height: 100%; max-width: 220px; max-height: 220px; object-fit: contain; }
.char-detail-effects { max-height: 100%; overflow: auto; gap: 5px; color: #fff; font-size: clamp(14px, 1.1vw, 23px); line-height: 1.25; text-shadow: 0 1px 2px #000; }
/* Effect-text argument colours: `progress_data.gd` defaults (Color.green/red)
   plus `utils.gd` curse/evolution constants, applied per argument by the
   `effects.js` port of `text.gd::text`. */
.char-detail-effects .pos, .difficulty-effects .pos, .side-traits .pos, .codex-effect .pos, .shop-effects .pos { color: #00ff00; }
.char-detail-effects .neg, .difficulty-effects .neg, .side-traits .neg, .codex-effect .neg, .shop-effects .neg { color: #ff0000; }
.char-detail-effects .curse, .difficulty-effects .curse, .side-traits .curse, .codex-effect .curse, .shop-effects .curse { color: #ca61ff; }
.char-detail-effects .meca, .difficulty-effects .meca, .side-traits .meca, .codex-effect .meca, .shop-effects .meca { color: #5b6ee1; }
.char-detail-effects .mutant, .difficulty-effects .mutant, .side-traits .mutant, .codex-effect .mutant, .shop-effects .mutant { color: #6abe30; }
.char-detail-effects .tracking, .difficulty-effects .tracking, .side-traits .tracking { color: #eae2b0; }
.trait-line { display: flex; align-items: flex-start; gap: 6px; }
.trait-text { flex: 1 1 auto; min-width: 0; }
.trait-text .pos, .trait-text .neg, .trait-text .curse, .trait-text .meca, .trait-text .mutant { white-space: nowrap; }
.eff-ico { width: 15px; height: 15px; object-fit: contain; flex: 0 0 auto; margin-top: 2px; }
.eff-ico[src*="empty"] { visibility: hidden; }
.trait-text .eff-ico { display: inline-block; vertical-align: -3px; margin: 0 1px; }
.character-confirm {
  justify-self: start; align-self: end; width: min(27%, 245px); aspect-ratio: 4.2; border: 0; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #f4f5f6; background: rgba(220,225,234,.13); cursor: pointer; font: inherit; font-size: 20px;
}
.character-confirm img { height: 55%; width: auto; object-fit: contain; opacity: .8; }
.character-confirm:hover:not(:disabled), .character-confirm:focus-visible { background: rgba(255,255,255,.86); outline: 2px solid #fff; }
.character-confirm:disabled { cursor: default; opacity: .35; }
.char-record-panel, .char-options-panel { min-width: 0; min-height: 0; overflow: auto; border-radius: 5px; background: rgba(0, 0, 0, .88); }
.char-record-panel { grid-area: record; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; font-size: 18px; }
.record-mark { width: 48px; height: 54px; object-fit: contain; }
.record-title { font-size: 20px; }
.char-record-panel strong { color: #e4dcad; font-size: 18px; }
.char-record-panel > span:last-child { font-size: 15px; }
.char-options-panel { grid-area: options; padding: 18px 20px; }
.char-options-panel .side-title { margin: 0 0 14px; color: #fff; font-size: 19px; letter-spacing: 0; }
.char-setting { min-height: 56px; margin-bottom: 7px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(5, 7, 11, .88); border-radius: 4px; color: #fff; font-size: 17px; }
.char-setting select { width: 55%; min-width: 0; padding: 8px; border: 0; border-radius: 4px; color: #111; background: #eee; font: inherit; }
.char-setting input[type="checkbox"], .settings-toggle-row input[type="checkbox"] { appearance: none; position: relative; flex: 0 0 58px; width: 58px; height: 28px; margin: 0; border: 0; border-radius: 18px; background: #36383b; cursor: pointer; }
.char-setting input[type="checkbox"]::after, .settings-toggle-row input[type="checkbox"]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #898b8d; transition: left .12s, background .12s; }
.char-setting input[type="checkbox"]:checked, .settings-toggle-row input[type="checkbox"]:checked { background: #d8dadd; }
.char-setting input[type="checkbox"]:checked::after, .settings-toggle-row input[type="checkbox"]:checked::after { left: 33px; background: #fff; }
.character-roster { position: absolute; left: 11%; right: 11%; bottom: 1.2%; height: 34%; min-height: 0; }
.character-roster .side-title { height: 24px; margin: 0 0 6px; color: #fff; font-size: 15px; }
.character-grid { height: calc(100% - 30px); overflow-y: auto; display: grid; grid-template-columns: repeat(18, minmax(42px, 1fr)); grid-auto-rows: minmax(54px, 1fr); align-content: start; gap: 8px; padding: 3px 5px; }
.char-card { min-width: 0; aspect-ratio: 1; padding: 3px; border: 2px solid #090b10; border-radius: 9px; color: #fff; background: rgba(16, 18, 28, .74); }
.char-card:hover { transform: none; border-color: #cfd3d8; }
.char-card.selected { border-color: #fff; background: rgba(243, 243, 243, .94); }
.char-card.locked { opacity: .52; }
.char-icon, .char-icon img { display: grid; width: 100%; height: 100%; place-items: center; }
.char-icon img { object-fit: contain; }

.difficulty-layout {
  position: absolute; left: 10%; right: 9%; top: 9.5%; bottom: 10%;
  display: grid; grid-template-rows: minmax(0, 1.65fr) 200px; gap: 14px;
}
.difficulty-top {
  display: grid; grid-template-columns: minmax(300px, 34%) minmax(0, 1fr);
  gap: 12px; min-width: 0; min-height: 0;
}
.difficulty-top > *, .difficulty-bottom > * { grid-area: auto; }
.difficulty-bottom {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 12px; align-items: end; min-width: 0; min-height: 0;
}
.difficulty-character, .difficulty-weapon-panel, .difficulty-danger-picker, .difficulty-bottom-right {
  min-width: 0; min-height: 0;
}
.difficulty-character {
  display: flex; flex-direction: column; gap: 12px; overflow: auto;
  padding: 16px 18px; border-radius: 4px; background: rgba(20, 24, 35, .42);
}
.difficulty-character .char-detail-name {
  margin: 0; text-align: center; font-size: 28px; letter-spacing: 1px;
}
.difficulty-character .char-detail-row {
  display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 14px;
}
.difficulty-character .char-portrait {
  width: 140px; height: 140px; padding: 8px;
  background: rgba(20, 10, 16, .75); border: 2px solid #4a2430; border-radius: 10px;
}
.difficulty-character .char-portrait img { width: 120px; height: 120px; }
.difficulty-character .char-detail-effects { font-size: 17px; }
.difficulty-character > .menu-btn { display: none; }
.difficulty-weapon-panel {
  display: grid; grid-template-rows: 290px minmax(0, 1fr); gap: 10px;
}
.difficulty-weapon {
  overflow: auto; padding: 12px 14px; background: #050506;
}
.difficulty-weapon .char-weapon-card { padding: 0; border: 0; border-radius: 0; background: transparent; }
.difficulty-weapon .w-head { display: flex; align-items: center; gap: 12px; }
.difficulty-weapon .w-head img { width: 72px; height: 72px; object-fit: contain; }
.difficulty-weapon .w-name { font-size: 19px; }
.difficulty-weapon .w-kind { color: #e7d5a5; }
.difficulty-weapon .w-stats { gap: 4px; margin-top: 12px; font-size: 15px; }
.difficulty-weapon .w-row { justify-content: flex-start; gap: 10px; }
.difficulty-weapon .w-row > span:last-child { color: #eee; }
.difficulty-weapon .weapon-hint { margin: 4px 2px 0; color: #aeb4bf; font-size: 15px; line-height: 1.55; }
/* `item_panel_ui.tscn` random_icon_container: centered 96x96 icon, idle loop
   scales (1,1) -> (0.902,1.258) -> (1,1) over 1.2s. */
.weapon-random-detail { display: grid; place-items: center; min-height: 120px; padding: 12px 0; }
.weapon-random-detail img { width: 96px; height: 96px; animation: random-icon-idle 1.2s ease-in-out infinite; }
@keyframes random-icon-idle { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(.902, 1.258); } }
.difficulty-weapons {
  position: static; left: auto; right: auto; bottom: auto; z-index: auto;
  display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 0;
  overflow: hidden;
}
.difficulty-weapons .side-title {
  margin: 0; color: #fff; font-size: 15px; font-weight: 400; letter-spacing: 0;
  text-shadow: 0 2px 2px #000; opacity: .92;
}
.weapon-tray {
  flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  align-content: start; justify-items: start; gap: 8px; min-width: 0; min-height: 0;
  padding: 2px 4px 6px 2px; overflow-x: hidden; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.3) transparent;
}
.weapon-tray::-webkit-scrollbar { width: 6px; }
.weapon-tray::-webkit-scrollbar-thumb { background: rgba(255,255,255,.28); border-radius: 3px; }
.weapon-tray .weapon-pick {
  width: 100%; max-width: 48px; aspect-ratio: 1; height: auto;
  display: grid; place-items: center; padding: 2px; cursor: pointer;
  color: #fff; background: rgba(16, 18, 28, .82);
  border: 2px solid #090b10; border-radius: 8px;
}
.weapon-tray .weapon-pick:hover { border-color: #cfd3d8; }
.weapon-tray .weapon-pick.selected {
  background: #f3f3f3; border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.weapon-tray .weapon-pick img { width: 100%; height: 100%; object-fit: contain; }
.difficulty-danger-picker {
  display: flex; align-items: flex-end; padding: 0;
}
.danger-row {
  position: static; left: auto; right: auto; bottom: auto; width: 100%; transform: none;
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px;
}
.danger-icon {
  width: 100%; max-width: 72px; height: auto; aspect-ratio: 1; justify-self: center;
  padding: 0; border: 2px solid transparent; border-radius: 9px; background: #201f2b;
}
.danger-icon:hover { border-color: #cfd3d8; }
.danger-icon.selected { border-color: #cf8ae8; box-shadow: 0 0 0 2px rgba(207,138,232,.25); }
.danger-icon img { width: 100%; height: 100%; object-fit: contain; }
.danger-icon.locked { background: rgba(10, 11, 19, .78); }
.difficulty-bottom-right {
  display: grid; grid-template-columns: minmax(0, 1fr) 190px;
  grid-template-rows: 130px 1fr; gap: 10px; height: 200px;
}
.char-danger-panel {
  grid-column: 1; grid-row: 1 / span 2; align-self: end; height: 130px;
  display: flex; flex-direction: column; justify-content: center;
  overflow: auto; padding: 12px 16px; border: 2px solid #a346c7; border-radius: 4px;
  background: rgba(14, 8, 24, .94);
}
.danger-title { color: #bd70dc; font-size: 20px; margin: 0 0 6px; }
.danger-line { color: #fff; font-size: 15px; line-height: 1.5; }
#btn-start-run {
  grid-column: 2; grid-row: 2; align-self: end; width: 100%; height: 54px; margin: 0;
}

/* Recorded combat HUD and queued upgrade / item-box icons. */
.hud { padding: 2.5% 3.2%; }
.hud-top { display: grid; grid-template-columns: minmax(225px, 300px) 1fr minmax(200px, 320px); align-items: start; gap: 10px; }
.hud-block { min-width: 0; padding: 0; border-radius: 0; background: transparent; }
.bar { margin: 0 0 7px; border: 3px solid #08090b; border-radius: 0; background: #36383a; }
.bar.hp { width: 100%; height: 42px; border-color: #08090b; }
.bar.hp .fill { background: #e11017; }
.bar.xp { height: 42px; }
.bar.xp .fill { background: #36d73d; }
.bar-text { justify-content: flex-end; padding: 0 10px; color: #fff; font-size: 19px; text-shadow: 0 2px 2px #000; }
.hud-resource { display: flex; align-items: center; gap: 9px; color: #fff; font-size: 29px; line-height: 1.05; text-shadow: 0 2px #000; }
.mat-icon { width: 30px; height: 30px; flex: none; border-radius: 50%; background: url('assets/items/materials/material_0000.webp') center / contain no-repeat; box-shadow: none; }
.hud-materials { color: #fff; font-size: 29px; }
/* `UIBonusGold`: the banked next-wave doubling pool, bag icon + gold count. */
.hud-bonus { margin-top: 2px; cursor: help; }
.hud-bonus .mat-icon { background-image: url('assets/items/materials/material_bag.webp'); }
.hud-bonus .hud-materials { color: var(--gold); }
.hud-wave-block { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; text-shadow: 0 2px #000; }
.hud-wave { font-size: 27px; line-height: 1.05; }
.hud-timer { color: #fff; font-size: 31px; line-height: 1; }
.hud-timer.urgent { color: #ff2727; }
.hud-process { justify-self: end; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; margin: 0; }
.process-group { display: flex; justify-content: flex-end; gap: 6px; min-height: 48px; }
.process-group:empty { display: none; }
.process-chip { position: relative; width: 48px; height: 48px; border: 0; border-radius: 0; background: transparent; }
.process-portrait { width: 42px; height: 42px; object-fit: contain; }
.process-chip.levels::after { content: '↑'; position: absolute; top: -7px; right: -3px; color: #22f033; font-size: 28px; font-weight: 900; line-height: 1; text-shadow: 0 2px #000; pointer-events: none; }
.process-chip .count { position: absolute; right: -11px; bottom: -5px; min-width: 24px; height: 22px; padding: 0 3px; border-radius: 10px; color: #fff; background: #111; font-size: 16px; line-height: 22px; }
.process-chip.boxes .count { background: #123d12; }
.hud-banner { top: 18%; font-size: 52px; letter-spacing: 0; color: #fff; text-shadow: 0 3px #000, 2px 0 #000, -2px 0 #000; }
.hud-banner.wave-clear { top: 12%; color: #fff; font-size: 88px; }
#screen-combat.wave-cleared::before { content: ''; position: absolute; inset: 0; z-index: 0; background: rgba(0, 0, 0, .47); pointer-events: none; }
#screen-combat.wave-cleared .hud-banner { z-index: 1; }
.boss-bar { top: 13%; }

/* Upgrade, item-box and shop overlays retain the live arena beneath them. */
#screen-upgrade, #screen-itempick, #screen-shop { background: rgba(0, 0, 0, .72); }
.upgrade-layout, .reward-layout { width: 100%; height: 100%; padding: 9% 4.5% 7%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 20%); gap: 18px; }
.upgrade-main, .reward-main { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.upgrade-main .panel-title, .reward-main .panel-title { color: #fff; font-size: 46px; letter-spacing: 0; text-shadow: 0 2px #000; }
.upgrade-main .panel-sub, .reward-main .panel-sub { color: #fff; }
.upgrade-grid { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; justify-content: stretch; }
.upgrade-card, .reward-card { min-width: 0; min-height: 310px; padding: 16px 14px; align-items: stretch; justify-content: flex-start; border: 2px solid #070809; border-radius: 5px; color: #fff; background: rgba(0, 0, 0, .92); text-align: left; }
.upgrade-card:hover, .reward-card:hover { transform: none; border-color: #fff; }
.upgrade-card img, .reward-card img { width: 82px; height: 82px; padding: 5px; border-radius: 5px; background: #202123; object-fit: contain; }
/* inline stat icons inside effect text stay line-sized, not card-icon sized */
.upgrade-card .eff-ico, .reward-card .eff-ico { width: 15px; height: 15px; padding: 0; background: none; border-radius: 0; vertical-align: -2px; margin: 0 1px; }
/* effect_line.tscn: leading 18px icon + 7px gap, lines stack with 4px margins */
.eff-line { display: flex; gap: 7px; align-items: flex-start; margin: 4px 0; }
.eff-line .eff-lead { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.eff-line .eff-text { min-width: 0; }
.upgrade-card .upgrade-name, .reward-card .upgrade-name { margin: 9px 0 3px; font-size: 19px; text-align: left; }
.upgrade-card .upgrade-effects, .reward-card .upgrade-effects { color: #eee; font-size: 16px; line-height: 1.45; }
.upgrade-card .menu-btn, .reward-card .menu-btn { margin-top: auto; }
.upgrade-stats, .reward-stats { min-width: 0; align-self: center; max-height: 100%; overflow: auto; padding: 15px 18px; border-radius: 5px; background: rgba(9, 10, 12, .94); }
.upgrade-stats .side-title, .reward-stats .side-title { margin: 0 0 9px; color: #fff; text-align: center; font-size: 23px; }
.stat-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; text-align: center; }
.stat-tab {
  padding: 5px; border: 0; border-radius: 5px; color: #fff; background: #050607;
  font: inherit; font-size: 15px; cursor: pointer;
}
.stat-tab.active, .stat-tab:hover { color: #111; background: #eee; }
.upgrade-stats .side-stats, .reward-stats .side-stats { display: flex; flex-direction: column; gap: 1px; }
.upgrade-stats .side-stat, .reward-stats .side-stat { grid-template-columns: 22px 1fr auto; gap: 5px; padding: 1px 0; font-size: 14px; }
.upgrade-stats .side-stat-head, .reward-stats .side-stat-head { display: none; }
.upgrade-reroll { width: min(480px, 70%); min-height: 54px; margin-top: 24px; border: 0; border-radius: 5px; color: #fff; background: #08090a; font: inherit; font-size: 19px; }
.upgrade-reroll span { display: inline-block; margin-right: 14px; padding: 3px 9px; border: 2px solid #444; border-radius: 3px; }
.upgrade-reroll:hover:not(:disabled), .upgrade-reroll:focus-visible { color: #000; background: rgba(255, 255, 255, .784); outline: 0; }
.upgrade-reroll:hover:not(:disabled) span, .upgrade-reroll:focus-visible span { color: #111; border-color: #999; }
.reward-layout { grid-template-columns: minmax(0, 1fr) minmax(270px, 24%); }
.reward-grid { display: flex; width: min(420px, 82%); justify-content: center; }
.reward-card { width: 100%; min-height: 300px; }
.reward-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: auto; }
.reward-actions button { min-height: 48px; border: 0; border-radius: 5px; color: #fff; background: #111; font: inherit; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 7px; }
.reward-actions button:first-child { color: #111; background: #eee; }
.reward-actions button kbd { display: inline-block; margin-right: 0; padding: 2px 6px; border: 2px solid #555; border-radius: 3px; background: #222; color: #eee; font: inherit; font-size: 13px; }
.reward-actions button img { width: 20px; height: 20px; object-fit: contain; }
.reward-actions button:first-child kbd { color: #111; background: #ddd; }
/* base_theme.tres Button hover: white 78 % bg, black text (recycle / ban). */
.reward-actions button:hover:not(:disabled), .reward-actions button:focus-visible { color: #000; background: rgba(255, 255, 255, .784); outline: 0; }
.reward-actions button:hover:not(:disabled) kbd, .reward-actions button:focus-visible kbd { color: #111; background: #ddd; border-color: #999; }

#screen-shop { background: rgba(0, 0, 0, .36); }
.shop-layout { grid-template-columns: minmax(0, 1fr) minmax(290px, 22%); gap: 12px; padding: 2.2% 3.2%; }
.shop-header { min-height: 62px; }
.shop-header .panel-title { color: #fff; font-size: 25px; letter-spacing: 0; }
.shop-materials-row { color: #fff; font-size: 30px; text-shadow: 0 2px #000; }
.shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 8px 0 12px; flex: 1 1 60%; }
.shop-card { min-height: 0; padding: 10px; border-width: 5px; border-radius: 8px; }
.shop-icon { width: 76px; height: 76px; padding: 5px; border-radius: 8px; }
.shop-name { margin: 0 0 2px; font-size: 18px; line-height: 1.2; }
.shop-kind { font-size: 14px; letter-spacing: 0; }
.shop-effects { font-size: 15px; line-height: 1.35; }
.shop-price { min-width: 100px; padding: 6px 12px; border-radius: 6px; font-size: 23px; }
.shop-actions { display: flex; justify-content: flex-end; }
.shop-side { min-height: 0; padding: 13px 15px; gap: 10px; border-radius: 5px; background: rgba(10, 11, 13, .88); }
.side-title { letter-spacing: 0; }
.side-stats { font-size: 13px; }
.side-stat { grid-template-columns: 19px minmax(0,1fr) auto; gap: 5px; }
.shop-inventory-row { margin-top: auto; }
.shop-card-actions { gap: 4px; }
.shop-card-actions button { min-height: 36px; gap: 8px; padding: 4px 8px; border-radius: 6px; font-size: 15px; }
.shop-card-actions .shop-lock.locked { background: rgba(255, 255, 255, .784); color: #000; }
.shop-card-actions .shop-ban.disabled { opacity: .42; cursor: default; }

/* Settings overlay follows the recorded tabs / row controls and can sit over combat. */
#screen-options { z-index: 30; background: rgba(0, 0, 0, .94); }
#screen-options.in-run { background: rgba(0, 0, 0, .82); }
.options-panel { position: absolute; inset: 0; width: 100%; height: 100%; padding: 2.5% 4.8% 1.2%; transform: none; display: grid; grid-template-rows: 12% minmax(0, 1fr) 8%; gap: 10px; border: 0; border-radius: 0; background: transparent; }
.options-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; padding-bottom: 9px; border-bottom: 4px solid #73b3d1; }
.options-tab { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 12px; border: 3px solid #08090b; border-radius: 15px 15px 4px 4px; color: #fff; background: #282628; font: inherit; font-size: 21px; font-weight: 700; cursor: pointer; }
.options-tab img { width: 31px; height: 31px; object-fit: contain; }
.options-tab.selected { background: #4f8648; }
.options-content { width: min(950px, 78vw); min-height: 0; margin: 0 auto; padding: 9px 0; overflow: hidden; }
.options-page { width: 100%; height: 100%; min-height: 0; overflow: auto; }
.options-page[data-options-page="audio"] { padding: 7% 0 2%; }
.options-range-row { min-height: 42px; display: grid; grid-template-columns: minmax(160px, 1fr) minmax(140px, 220px) 80px; align-items: center; gap: 14px; color: #fff; font-size: 19px; }
.options-range-row > span:last-child { text-align: right; font-size: 21px; }
.options-slider, .settings-range-static { width: 100%; height: 23px; accent-color: #aaa; }
.settings-toggle-row { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0; padding: 6px 12px; border-radius: 7px; color: #fff; background: rgba(0, 0, 0, .84); font-size: 19px; }
.settings-toggle-row input[type="checkbox"] { margin-right: 8px; }
.settings-scroll { height: 100%; overflow: auto; }
.settings-action, .settings-select-row { width: 100%; min-height: 48px; margin-top: 5px; display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; border: 0; border-radius: 5px; color: #fff; background: #050607; font: inherit; font-size: 18px; }
.settings-action { justify-content: center; cursor: pointer; }
.settings-select-row select { padding: 7px 10px; border: 0; border-radius: 4px; font: inherit; }
.settings-select-row input[type="color"] { width: 56px; height: 30px; padding: 2px; border: 1px solid #777; border-radius: 4px; background: #151619; cursor: pointer; }
.settings-language { display: flex; align-items: center; gap: 8px; margin-top: 14px; color: #fff; }
.settings-mini { padding: 6px 10px; border: 1px solid #777; border-radius: 3px; color: #fff; background: #151619; cursor: pointer; font: inherit; }
.settings-mini.selected { color: #111; background: #eee; }
.settings-mini.danger { margin-top: 7px; color: #ff7272; }
.options-save-info { margin-top: 6px; color: #fff; }
.options-placeholder { padding: 12px; color: #fff; }
.options-footer { display: flex; align-items: end; justify-content: center; border-top: 1px solid rgba(255,255,255,.65); }
.settings-back { width: 32%; min-width: 220px; height: 55px; border: 0; border-radius: 5px; color: #fff; background: #050607; font: inherit; font-size: 21px; cursor: pointer; }
.settings-back span { float: left; margin-left: 15px; }

@media (max-width: 1100px) {
  .char-layout { inset: 14% 3% 39%; grid-template-columns: minmax(0, 1.6fr) minmax(125px, .7fr) minmax(190px, .95fr); gap: 7px; }
  .char-options-panel { padding: 9px; }
  .char-setting { min-height: 42px; font-size: 14px; }
  .character-roster { left: 3%; right: 3%; height: 35%; }
  .character-grid { grid-template-columns: repeat(15, minmax(34px, 1fr)); grid-auto-rows: 1fr; gap: 5px; }
  .difficulty-layout { left: 5%; right: 5%; }
  .pause-layout { grid-template-columns: 220px minmax(0, 1fr) minmax(270px, 320px); gap: 10px; }
  .shop-layout { grid-template-columns: minmax(0, 1fr) minmax(230px, 25%); padding: 2%; }
  .shop-grid { gap: 5px; }
  .shop-card { padding: 7px; }
  .shop-effects { font-size: 12px; }
  .upgrade-layout, .reward-layout { padding: 8% 2%; grid-template-columns: minmax(0, 1fr) minmax(220px, 24%); }
  .upgrade-card, .reward-card { min-height: 250px; padding: 10px; }
}
@media (max-width: 700px) {
  .title-logo { width: 80vw; top: 7%; }
  .title-menu { top: 30%; width: min(145px, 35vw); }
  .title-link, .title-menu > .menu-btn { min-height: 36px; font-size: 15px; }
  .title-promo { right: 2%; bottom: 3%; }
  .title-promo-link { max-width: 42vw; font-size: 12px; }
  .char-title { top: 3%; font-size: 27px; }
  .char-back { top: 2%; min-width: 74px; height: 36px; font-size: 13px; }
  .char-layout { inset: 12% 3% 46%; grid-template-columns: minmax(0, 1fr) minmax(90px, .7fr); grid-template-rows: 1fr 1fr; grid-template-areas: "detail options" "record options"; }
  .char-detail-panel { padding: 6px; }
  .char-detail-row { grid-template-columns: minmax(80px, 36%) 1fr; gap: 7px; }
  .char-detail-effects { font-size: 12px; }
  .char-record-panel { font-size: 12px; gap: 3px; }
  .record-mark { font-size: 30px; }
  .record-title, .char-record-panel strong { font-size: 12px; }
  .char-options-panel { padding: 6px; }
  .char-options-panel .side-title { font-size: 13px; }
  .char-setting { min-height: 32px; padding: 4px; font-size: 10px; }
  .char-setting input[type="checkbox"] { transform: scale(.68); transform-origin: right center; margin-left: -12px; }
  .char-setting select { padding: 4px; font-size: 10px; }
  .character-roster { left: 2%; right: 2%; bottom: 1%; height: 43%; }
  .character-roster .side-title { font-size: 12px; }
  .character-grid { grid-template-columns: repeat(9, minmax(25px, 1fr)); grid-auto-rows: 1fr; gap: 3px; }
  .char-card { padding: 1px; border-width: 1px; }
  .difficulty-layout {
    top: 10%; left: 3%; right: 3%; bottom: 3%;
    grid-template-rows: minmax(0, 1.45fr) 150px; gap: 5px;
  }
  .difficulty-top { grid-template-columns: minmax(0, .7fr) minmax(0, 1.4fr); gap: 5px; }
  .difficulty-bottom { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 5px; }
  .difficulty-character, .difficulty-weapon, .difficulty-danger-picker { padding: 6px; }
  .difficulty-character .char-detail-name { font-size: 13px; }
  .difficulty-character .char-detail-row { grid-template-columns: 58px 1fr; gap: 5px; }
  .difficulty-character .char-portrait { width: 58px; height: 58px; padding: 2px; }
  .difficulty-character .char-portrait img { width: 100%; height: 100%; }
  .difficulty-character .char-detail-effects, .difficulty-weapon .w-stats, .danger-line { font-size: 10px; }
  .difficulty-weapon-panel { grid-template-rows: 132px minmax(0, 1fr); gap: 3px; }
  .difficulty-weapon .w-head img { width: 38px; height: 38px; }
  .difficulty-weapon .w-name, .danger-title { font-size: 12px; }
  .difficulty-weapons { gap: 2px; }
  .difficulty-weapons .side-title { font-size: 11px; }
  .weapon-tray { grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 3px; }
  .weapon-tray .weapon-pick { max-width: 36px; border-width: 1px; }
  .difficulty-weapon .weapon-hint { margin-top: 4px; font-size: 10px; }
  .danger-row { gap: 3px; }
  .danger-icon { width: 100%; height: auto; max-width: 40px; border-width: 1px; }
  .difficulty-bottom-right { grid-template-columns: minmax(0, 1fr) 90px; grid-template-rows: 76px 1fr; gap: 4px; height: 150px; }
  .char-danger-panel { height: 76px; align-self: end; padding: 6px; border-width: 1px; }
  #btn-start-run { height: 36px; font-size: 12px; }
  .pause-layout { grid-template-columns: 180px minmax(0, 1fr); width: 96vw; height: 88vh; gap: 8px; }
  .pause-inventory { display: none; }
  .pause-side { padding: 8px; }
  .pause-panel .menu-btn { font-size: 15px; }
  .hud-top { grid-template-columns: minmax(105px, 32vw) 1fr minmax(80px, 26vw); gap: 4px; }
  .bar.hp { height: 25px; border-width: 2px; }
  .bar.xp { width: min(560px, 70vw); height: 25px; border-width: 2px; margin: 6px auto 0; }
  .hud-resource, .hud-materials { font-size: 18px; }
  .mat-icon { width: 20px; height: 20px; }
  .hud-wave { font-size: 16px; }
  .hud-timer { font-size: 19px; }
  .hud-banner.wave-clear { font-size: 40px; }
  .process-group { gap: 1px; min-height: 29px; }
  .process-chip { width: 29px; height: 29px; }
  .process-portrait { width: 27px; height: 27px; }
  .process-chip.levels::after { font-size: 18px; }
  .process-chip .count { right: -6px; bottom: -4px; min-width: 17px; height: 15px; font-size: 10px; line-height: 15px; }
  .upgrade-layout, .reward-layout { padding: 10% 2% 2%; grid-template-columns: minmax(0, 1fr) minmax(105px, 25%); gap: 5px; }
  .upgrade-main .panel-title, .reward-main .panel-title { font-size: 24px; }
  .upgrade-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upgrade-card, .reward-card { min-height: 0; padding: 6px; }
  .upgrade-card img, .reward-card img { width: 42px; height: 42px; }
  .upgrade-card .upgrade-name, .reward-card .upgrade-name { font-size: 12px; }
  .upgrade-card .upgrade-effects, .reward-card .upgrade-effects { font-size: 10px; }
  .upgrade-stats, .reward-stats { padding: 6px; }
  .upgrade-stats .side-title, .reward-stats .side-title { font-size: 14px; }
  .upgrade-stats .side-stat, .reward-stats .side-stat { grid-template-columns: 13px 1fr auto; gap: 2px; font-size: 9px; }
  .upgrade-stats .stat-icon, .reward-stats .stat-icon { width: 12px; height: 12px; }
  .shop-layout { grid-template-columns: minmax(0, 1fr) minmax(110px, 25%); padding: 2%; gap: 4px; }
  .shop-header { min-height: 32px; gap: 3px; }
  .shop-header .panel-title { font-size: 14px; }
  .shop-materials-row { font-size: 17px; }
  .shop-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0,1fr)); gap: 4px; margin: 4px 0; }
  .shop-icon { width: 36px; height: 36px; }
  .shop-name { font-size: 12px; }
  .shop-kind, .shop-effects { font-size: 9px; }
  .shop-price { min-width: 52px; padding: 3px 5px; font-size: 13px; }
  .shop-card-actions { gap: 2px; margin-top: 3px; }
  .shop-card-actions .shop-lock, .shop-card-actions .shop-ban { min-height: 24px; gap: 3px; padding: 2px; font-size: 9px; }
  .shop-card-actions kbd { min-width: 16px; padding: 0 2px; border-width: 1px; font-size: 8px; }
  .shop-side { padding: 5px; }
  .side-stats { font-size: 9px; }
  .side-stat { grid-template-columns: 12px 1fr auto; gap: 2px; font-size: 8px; }
  .shop-inventory-row { gap: 3px; }
  .shop-inventory-block .side-weapons { grid-template-columns: repeat(3, minmax(25px, 1fr)); }
  .shop-inventory-block .side-weapon img { height: 24px; }
  .options-panel { padding: 3% 2% 1%; grid-template-rows: 14% minmax(0, 1fr) 9%; gap: 4px; }
  .options-tabs { gap: 3px; border-bottom-width: 2px; }
  .options-tab { flex-direction: column; gap: 2px; border-width: 2px; border-radius: 8px 8px 2px 2px; font-size: 10px; }
  .options-tab img { width: 20px; height: 20px; }
  .options-content { width: 92vw; padding: 4px 0; }
  .options-page[data-options-page="audio"] { padding-top: 8%; }
  .options-range-row { min-height: 30px; grid-template-columns: minmax(62px,1fr) minmax(65px,1.5fr) 42px; gap: 4px; font-size: 11px; }
  .options-range-row > span:last-child { font-size: 11px; }
  .settings-toggle-row { min-height: 32px; padding: 4px 6px; font-size: 11px; }
  .settings-toggle-row input[type="checkbox"] { transform: scale(.68); transform-origin: right center; margin-left: -12px; }
  .settings-back { width: 65%; min-width: 0; height: 34px; font-size: 14px; }
  .weapon-dialog { width: min(94vw, 520px); grid-template-columns: minmax(0, 1fr); max-height: 88vh; overflow: auto; }
  .weapon-dialog-extra { min-height: 55px; }
  .weapon-dialog-main, .weapon-dialog-extra { padding: 8px; }
  .weapon-dialog .w-head img { width: 44px; height: 44px; }
  .weapon-dialog .w-name { font-size: 13px; }
  .weapon-dialog .w-stats, .weapon-popup-action { font-size: 11px; }
  .weapon-popup-action { min-height: 29px; }
}

/* Keep the centered title art and the character roster in the viewport frame. */
.title-logo { position: fixed; top: 3.5vh; left: auto; right: 8%; width: 48vw; height: 12vh; max-height: none; transform: none; object-fit: contain; }
.title-menu #title-dlc-logo { position: fixed; top: 16vh; left: auto; right: 8%; width: 48vw; height: 6vh; transform: none; }
.character-roster { position: fixed; left: 11%; right: 11%; bottom: 1.2%; height: 34%; z-index: 5; }
.char-layout { bottom: 38%; }
.char-detail-panel { position: relative; z-index: 1; }
.char-record-panel, .char-options-panel { position: relative; z-index: 1; }
@media (max-width: 700px) {
  .title-logo { top: 4vh; right: 4%; width: 66vw; height: 12vh; }
  .title-menu #title-dlc-logo { top: 16vh; right: 4%; width: 66vw; height: 6vh; }
  .character-roster { left: 2%; right: 2%; bottom: 1%; height: 43%; }
  .char-layout { bottom: 46%; }
}

/* ---------------------------------------------------------------- mobile */
#touch-stick { position: fixed; z-index: 5; pointer-events: none; }
#touch-base {
  position: absolute; width: 124px; height: 124px; margin: -62px 0 0 -62px;
  border: 2px solid rgba(255, 255, 255, .25); border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
#touch-knob {
  position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px;
  border-radius: 50%; background: rgba(255, 255, 255, .4);
}
/* Pause entry for touch devices without 3-point touch reporting; shown only
   in combat via body.touch-menu-btn (set by mobile.js). */
#touch-menu {
  display: none; position: fixed; z-index: 12;
  right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  width: 44px; height: 44px; padding: 0; border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, .25); background: rgba(12, 5, 9, .55);
  color: #fff; place-items: center;
}
#touch-menu svg { width: 20px; height: 20px; fill: currentColor; }
body.touch-menu-btn[data-screen="combat"] #touch-menu { display: grid; }
#rotate-hint {
  position: fixed; inset: 0; z-index: 100; background: #0c0509;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; color: #fff;
}
#rotate-hint .rotate-icon { width: 84px; height: 84px; color: var(--gold); animation: rotateHint 1.6s ease-in-out infinite; }
#rotate-hint p { font-size: 20px; letter-spacing: 2px; }
@keyframes rotateHint { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }

/* Short landscape screens (phones): compact overlays so every button stays
   reachable by touch. Desktop layouts (height > 480px) are untouched. */
@media (max-height: 480px) {
  .shop-layout { grid-template-columns: minmax(0, 1fr) minmax(200px, 24%); gap: 10px; padding: 10px 14px; }
  .shop-header { min-height: 34px; }
  .shop-header .panel-title { font-size: 18px; }
  .shop-materials-row { font-size: 18px; }
  .shop-grid { gap: 6px; margin: 6px 0 8px; }
  .shop-card { padding: 6px; }
  .shop-icon { width: 40px; height: 40px; padding: 3px; }
  .shop-name { font-size: 13px; margin: 2px 0 1px; }
  .shop-kind { font-size: 10px; }
  .shop-effects { font-size: 11px; line-height: 1.25; margin-top: 3px; }
  .shop-price { font-size: 13px; min-width: 0; padding: 1px 8px; }
  .shop-card-actions { gap: 3px; margin-top: 3px; }
  .shop-card-actions .shop-lock, .shop-card-actions .shop-ban, .shop-card-actions .shop-steal { min-height: 24px; font-size: 11px; padding: 2px 6px; gap: 5px; }
  .shop-card-actions kbd { display: none; }
  /* Compact own-weapon/item strip: long-press sell and combine stay usable. */
  .shop-inventory-row { display: flex; gap: 10px; margin-top: 4px; align-items: center; }
  .shop-inventory-block { display: flex; align-items: center; gap: 6px; min-width: 0; }
  .shop-inventory-block .side-title, .side-hint { display: none; }
  .side-weapons { grid-template-columns: repeat(6, 30px); gap: 3px; }
  .side-weapon img { height: 22px; }
  .side-items { flex-wrap: nowrap; overflow-x: auto; max-width: 46vw; }
  .side-items img { width: 22px; height: 22px; }
  .shop-actions .menu-btn { min-height: 38px; padding: 6px 14px; font-size: 15px; }
  .shop-side { padding: 8px 10px; gap: 8px; }
  .side-title { font-size: 13px; margin-bottom: 4px; }
  .side-stats { font-size: 11px; }
  .upgrade-layout, .reward-layout { padding: 10px 14px; gap: 10px; grid-template-columns: minmax(0, 1fr) minmax(180px, 22%); }
  .upgrade-main .panel-title, .reward-main .panel-title { font-size: 24px; }
  .upgrade-main .panel-sub, .reward-main .panel-sub { font-size: 12px; margin: 0 0 6px; }
  .upgrade-card, .reward-card { min-height: 0; padding: 8px; }
  .upgrade-card img, .reward-card img { width: 44px; height: 44px; padding: 3px; }
  .upgrade-card .upgrade-name, .reward-card .upgrade-name { font-size: 14px; margin: 4px 0 2px; }
  .upgrade-card .upgrade-effects, .reward-card .upgrade-effects { font-size: 12px; line-height: 1.3; }
  .upgrade-reroll { min-height: 34px; margin-top: 8px; font-size: 14px; width: min(320px, 70%); }
  .reward-grid { width: min(320px, 90%); }
  .reward-actions button { min-height: 34px; font-size: 14px; }
  .upgrade-stats, .reward-stats { padding: 8px 10px; }
  .upgrade-stats .side-title, .reward-stats .side-title { font-size: 15px; margin-bottom: 5px; }
  .upgrade-stats .side-stat, .reward-stats .side-stat { font-size: 11px; }
  .result-panel { gap: 8px; }
  .result-title { font-size: 28px; margin-bottom: 4px; }
  .result-stats { margin-bottom: 6px; gap: 3px; }
  .result-row { font-size: 12px; }
  .result-panel .menu-btn { padding: 8px 14px; font-size: 15px; }
  .title-menu { top: 20%; }
  .title-link, .title-menu > .menu-btn { min-height: 30px; font-size: 13px; }
  /* HUD: keep the top-left corner clear for player movement. */
  .hud { padding: 8px 10px; }
  .hud-block { min-width: 0; padding: 4px 8px; border-radius: 6px; }
  .bar.hp { width: min(240px, 32vw); height: 14px; margin: 0; }
  /* xp bar mirrors the hp bar's left edge and width; level text overlays it */
  .bar.xp { width: min(240px, 32vw); height: 14px; }
  .bar.xp .bar-text { justify-content: flex-end; padding: 0 6px; }
  .bar-text { font-size: 10px; }
  .hud-materials { font-size: 16px; }
  .hud-wave { font-size: 14px; }
  .hud-timer { font-size: 16px; }
  /* Character select: three-row detail card, record panel hidden, roster becomes
     one horizontally swipeable row of full-size tiles. */
  .char-layout { inset: 12% 3% 26%; grid-template-columns: minmax(0, 1.6fr) minmax(150px, 1fr); grid-template-areas: "detail options"; }
  .char-record-panel { display: none; }
  .char-detail-panel { grid-template-rows: auto minmax(0, 1fr) auto; padding: 6px 10px; gap: 6px; }
  .char-detail-name { font-size: 18px; }
  .char-detail-row { grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
  .char-portrait { padding: 4px; border-width: 2px; }
  .char-portrait img { max-width: 64px; max-height: 64px; }
  .char-detail-effects { font-size: 12px; gap: 2px; }
  .character-confirm { width: auto; min-height: 30px; aspect-ratio: auto; padding: 4px 14px; font-size: 14px; }
  .char-options-panel { padding: 8px 10px; }
  .char-options-panel .side-title { font-size: 13px; margin-bottom: 6px; }
  .char-setting { min-height: 30px; font-size: 12px; }
  .character-roster { height: 78px; left: 2%; right: 2%; }
  .character-roster .side-title { height: 16px; font-size: 11px; margin: 0 0 2px; }
  .character-grid { height: 52px; grid-template-columns: none; grid-template-rows: 46px; grid-auto-flow: column; grid-auto-columns: 46px; overflow-x: auto; overflow-y: hidden; overflow-anchor: none; gap: 4px; }
  /* Difficulty: elastic weapon detail row so the starting-weapon tray survives. */
  .difficulty-layout { top: 8%; bottom: 2%; grid-template-rows: minmax(0, 1fr) 110px; gap: 8px; }
  .difficulty-weapon-panel { grid-template-rows: minmax(0, 1fr) 52px; gap: 4px; }
  .weapon-tray { grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); grid-auto-rows: 40px; overflow-y: auto; }
  .weapon-tray .weapon-pick { padding: 2px; gap: 0; max-width: none; }
  .weapon-tray .weapon-pick img { width: 32px; height: 32px; }
  .weapon-tray .weapon-pick-name, .weapon-tray .weapon-pick-kind { display: none; }
  .difficulty-bottom-right { grid-template-columns: minmax(0, 1fr) 110px; grid-template-rows: 1fr; height: 100%; }
  .char-danger-panel { height: auto; align-self: stretch; }
  #btn-start-run { height: 40px; }
  /* Single row of four cards; the stat side panel moves to shop/pause on phones. */
  .upgrade-layout, .reward-layout { grid-template-columns: minmax(0, 1fr); }
  .upgrade-stats, .reward-stats { display: none; }
  .upgrade-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: none; }
  .shop-effects { max-height: 3.2em; overflow: hidden; }
  .shop-card-actions .shop-lock, .shop-card-actions .shop-ban, .shop-card-actions .shop-steal { min-height: 28px; }
  .pause-side { overflow: auto; }
  .settings-toggle-row { min-height: 36px; font-size: 13px; }
  .options-range-row { min-height: 34px; font-size: 13px; }
  .weapon-dialog { max-height: calc(100vh - 16px); overflow: auto; }
  .weapon-dialog-actions { position: sticky; bottom: 0; background: rgba(10, 11, 13, .95); padding-top: 6px; }
  .weapon-popup-action { min-height: 30px; }
}
@media (max-height: 480px) and (max-width: 700px) {
  .shop-layout { grid-template-columns: minmax(0, 1fr); }
  .shop-side { display: none; }
}
@media (max-height: 360px) {
  .shop-layout { padding: 4px 8px; }
  .shop-header { min-height: 20px; }
  .shop-inventory-row { margin-top: 0; }
  .shop-grid { margin: 2px 0 2px; }
  .shop-actions .menu-btn { min-height: 28px; }
  .shop-card { padding: 5px; }
  .shop-icon { width: 32px; height: 32px; }
  .shop-name { font-size: 12px; }
  .shop-actions .menu-btn { min-height: 30px; padding: 4px 12px; font-size: 13px; }
  .side-weapon img { height: 20px; }
  .side-items img { width: 20px; height: 20px; }
  .upgrade-reroll { min-height: 30px; margin-top: 6px; }
  .character-roster { height: 70px; }
  .character-grid { height: 46px; grid-template-rows: 42px; grid-auto-columns: 42px; }
}

/* ---------------------------------------------------------------- phone landscape */
/* Phone-sized landscape viewports only (<=1024 x 500 CSS px). Desktop windows are
   wider than 1024 or taller than 500 CSS px, so every rule below leaves the PC
   layout untouched. */
@media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  /* Shop and pause have their own top bars; the arena HUD behind them only
     duplicates HP / wave / materials and overlaps those bars. */
  body:has(#screen-shop:not(.hidden)) .hud,
  body:has(#screen-paused:not(.hidden)) .hud { display: none; }

  /* Shared top bar for character and difficulty select. */
  #screen-characters .char-back,
  #screen-difficulty .char-back {
    top: 6px; left: 8px; width: 76px; min-width: 0; height: 30px;
    padding: 2px 10px; font-size: 14px; line-height: 22px; border-radius: 6px;
    display: flex; align-items: center; justify-content: flex-start;
  }
  .char-title { top: 4px; font-size: 23px; line-height: 30px; letter-spacing: 1px; }

  /* ------------------------------------------------ character select */
  .char-layout {
    position: absolute; inset: 42px 8px 84px; display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(180px, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "detail options"; gap: 8px; min-height: 0; padding: 0;
  }
  #screen-characters .char-detail-panel {
    grid-area: detail; min-height: 0; padding: 8px 12px; gap: 6px;
    display: flex; flex-direction: column; border-radius: 8px; overflow: hidden;
  }
  #screen-characters .char-detail-name {
    font-size: 18px; line-height: 1.15; text-align: left;
    text-shadow: 0 2px 2px #000;
  }
  #screen-characters .char-detail-row {
    flex: 1 1 auto; grid-template-columns: 78px minmax(0, 1fr); gap: 10px;
    align-items: center; min-height: 0; overflow: hidden;
  }
  #screen-characters .char-portrait {
    width: 78px; height: 78px; padding: 3px; border-width: 2px; border-radius: 8px;
  }
  #screen-characters .char-portrait img { width: 100%; height: 100%; max-width: none; max-height: none; }
  #screen-characters .char-detail-effects {
    max-height: 100%; overflow: auto; font-size: 12px; line-height: 1.35; gap: 3px;
  }
  .character-confirm {
    margin-top: auto; align-self: stretch; width: 100%; min-height: 34px;
    aspect-ratio: auto; padding: 4px 12px; border-radius: 6px; font-size: 14px;
  }
  .character-confirm img { height: 100%; max-height: 22px; width: auto; }
  .char-record-panel { display: none; }
  .char-options-panel { grid-area: options; min-height: 0; padding: 8px 10px; overflow: auto; }
  .char-options-panel .side-title { margin: 0 0 4px; font-size: 13px; }
  .char-setting { min-height: 34px; margin-bottom: 4px; padding: 3px 8px; font-size: 12px; gap: 8px; }
  .char-setting:last-child { margin-bottom: 0; }
  .char-setting select { padding: 5px 6px; font-size: 12px; }
  .char-setting input[type="checkbox"] {
    flex-basis: 46px; width: 46px; height: 24px;
    transform: scale(.8); transform-origin: right center; margin-left: -12px;
  }
  .char-setting input[type="checkbox"]::after { top: 2px; left: 2px; width: 20px; height: 20px; }
  .char-setting input[type="checkbox"]:checked::after { left: 24px; }
  .character-roster { position: fixed; left: 8px; right: 8px; bottom: 4px; height: 76px; z-index: 5; }
  .character-roster .side-title { height: 16px; margin: 0 0 2px; font-size: 11px; }
  .character-grid {
    height: 54px; grid-template-columns: none; grid-template-rows: 48px;
    grid-auto-flow: column; grid-auto-columns: 48px; gap: 6px;
    overflow-x: auto; overflow-y: hidden; overflow-anchor: none; padding: 0 0 2px;
  }
  .char-card { padding: 1px; border-width: 1px; border-radius: 7px; }

  /* ------------------------------------------------ difficulty select */
  .difficulty-layout {
    position: absolute; inset: 42px 8px 6px; display: grid;
    grid-template-rows: minmax(0, 1fr) 84px; gap: 6px; min-height: 0;
  }
  .difficulty-top {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.45fr);
    gap: 6px; min-height: 0;
  }
  .difficulty-top > *, .difficulty-bottom > * { grid-area: auto; }
  .difficulty-bottom {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 6px; min-height: 0; align-items: stretch;
  }
  .difficulty-character { padding: 6px 8px; gap: 4px; border-radius: 8px; }
  .difficulty-character .char-detail-name { margin: 0; font-size: 15px; line-height: 1.1; text-align: left; letter-spacing: 0; }
  .difficulty-character .char-detail-row {
    flex: 1 1 auto; grid-template-columns: 54px minmax(0, 1fr); gap: 8px;
    align-items: center; align-content: center; min-height: 0; overflow: hidden;
  }
  .difficulty-character .char-portrait {
    width: 54px; height: 54px; padding: 2px; border-width: 2px; border-radius: 8px;
  }
  .difficulty-character .char-portrait img { width: 100%; height: 100%; }
  .difficulty-character .char-detail-effects { max-height: 100%; overflow: auto; font-size: 10px; line-height: 1.3; gap: 2px; }
  .difficulty-weapon-panel { grid-template-rows: minmax(0, 1fr) auto; gap: 4px; min-height: 0; }
  .difficulty-weapon {
    padding: 6px 8px; border-radius: 6px; display: flex; flex-direction: column;
    justify-content: center;
  }
  .difficulty-weapon .w-head { gap: 8px; }
  .difficulty-weapon .w-head img { width: 36px; height: 36px; }
  .difficulty-weapon .w-name { font-size: 14px; line-height: 1.15; }
  .difficulty-weapon .w-kind { font-size: 10px; }
  .difficulty-weapon .w-stats { margin-top: 4px; gap: 2px; font-size: 10px; line-height: 1.3; }
  .weapon-random-detail { min-height: 0; padding: 4px 0; }
  .weapon-random-detail img { width: 54px; height: 54px; }
  .difficulty-weapons { gap: 2px; overflow: hidden; }
  .difficulty-weapons .side-title { font-size: 10px; }
  .weapon-tray {
    flex: none; display: grid; grid-template-columns: none; grid-template-rows: 40px;
    grid-auto-flow: column; grid-auto-columns: 40px; align-content: start;
    gap: 4px; padding: 1px 1px 4px; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .weapon-tray::-webkit-scrollbar { display: none; }
  .weapon-tray .weapon-pick {
    width: 40px; max-width: none; height: 40px; aspect-ratio: auto;
    padding: 2px; border-width: 1px; border-radius: 7px;
  }
  .weapon-tray .weapon-pick img { width: 32px; height: 32px; }
  .difficulty-weapon .weapon-hint { margin-top: 2px; font-size: 9px; line-height: 1.25; }
  .difficulty-danger-picker { align-items: center; padding: 0; }
  .danger-row {
    position: static; width: auto; transform: none; display: flex;
    align-items: center; justify-content: flex-start; gap: 6px;
  }
  .danger-icon {
    width: 40px; max-width: 40px; height: 40px; aspect-ratio: 1;
    border-width: 2px; border-radius: 7px;
  }
  .danger-icon img { width: 100%; height: 100%; }
  .difficulty-bottom-right {
    height: 100%; grid-template-columns: minmax(0, 1fr) 104px;
    grid-template-rows: minmax(0, 1fr); gap: 6px;
  }
  .char-danger-panel {
    grid-column: 1; grid-row: 1; height: 100%; min-height: 0; align-self: stretch;
    padding: 6px 10px; border-width: 1px; border-radius: 6px; overflow: hidden;
  }
  .danger-title { margin: 0 0 3px; font-size: 14px; }
  .danger-line { font-size: 10px; line-height: 1.3; }
  .danger-summary { font-size: 9px; line-height: 1.3; }
  #btn-start-run {
    grid-column: 2; grid-row: 1; height: 100%; min-height: 40px; padding: 4px;
    border-radius: 6px; font-size: 16px; box-shadow: 0 4px 0 #5a2412;
  }

  /* ------------------------------------------------ shop */
  .shop-layout {
    grid-template-columns: minmax(0, 1fr) minmax(200px, 24vw);
    gap: 6px; padding: 8px;
  }
  .shop-main { min-height: 0; overflow: hidden; }
  .shop-header { min-height: 30px; gap: 8px; }
  .shop-header .panel-title { font-size: 16px; }
  .shop-materials-row { gap: 5px; font-size: 17px; }
  .shop-materials-row .mat-icon { width: 16px; height: 16px; }
  #screen-shop .shop-reroll { min-height: 30px; padding: 3px 10px; font-size: 13px; line-height: 1.1; }
  #screen-shop .shop-reroll .key-icon { width: 16px; height: 16px; }
  .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 4px 0 6px; }
  .shop-card { padding: 6px; border-width: 2px; border-radius: 6px; }
  .shop-icon { width: 44px; height: 44px; padding: 3px; }
  .shop-name { margin: 2px 0 1px; font-size: 13px; line-height: 1.2; }
  .shop-kind { font-size: 10px; }
  .shop-effects {
    max-height: 4.6em; overflow: hidden; margin-top: 3px; font-size: 10px; line-height: 1.3;
  }
  .shop-price { min-width: 56px; padding: 2px 8px; border-radius: 4px; font-size: 16px; }
  .shop-card-actions { gap: 3px; margin-top: 4px; }
  .shop-card-actions .shop-lock,
  .shop-card-actions .shop-ban,
  .shop-card-actions .shop-steal {
    min-height: 24px; padding: 2px 6px; border-radius: 4px; font-size: 10px; gap: 5px;
  }
  .shop-card-actions kbd { display: none; }
  .shop-inventory-row {
    display: grid; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr);
    align-items: center; gap: 8px; height: 52px; margin-top: 0;
  }
  .shop-inventory-block .side-title, .side-hint { display: none; }
  .shop-inventory-block .side-weapons { grid-template-columns: repeat(6, 38px); gap: 4px; }
  .shop-inventory-block .side-weapon { padding: 1px; border-radius: 6px; }
  .shop-inventory-block .side-weapon img { height: 32px; }
  .side-items {
    flex-wrap: nowrap; gap: 4px; max-width: 100%;
    overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  }
  .side-items::-webkit-scrollbar { display: none; }
  .side-items img { width: 30px; height: 30px; border-radius: 5px; }
  .shop-actions { gap: 8px; }
  .shop-actions .menu-btn { min-height: 38px; padding: 6px 14px; border-radius: 6px; font-size: 15px; }
  .shop-side { padding: 8px 10px; gap: 8px; border-radius: 6px; }
  .shop-side .side-title { margin-bottom: 4px; font-size: 12px; }
  .shop-side .stat-tabs { gap: 4px; margin-bottom: 4px; }
  .shop-side .stat-tab { padding: 3px; border-radius: 4px; font-size: 11px; }
  .shop-side .side-name { margin-bottom: 4px; font-size: 12px; }
  .shop-side .side-subtitle { margin: 2px 0; font-size: 10px; }
  .shop-side .side-traits { gap: 1px; margin-bottom: 4px; font-size: 10px; }
  .shop-side .side-stats { font-size: 10px; }
  .shop-side .side-stat { grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px; padding: 0; }
  .shop-side .stat-icon { width: 14px; height: 14px; }
  .shop-side .side-sets { font-size: 10px; }

  /* ------------------------------------------------ weapon popup */
  .weapon-popup { padding: 6px; }
  .weapon-dialog {
    width: min(92vw, 560px); max-height: calc(100vh - 12px);
    grid-template-columns: minmax(0, 1fr); gap: 4px; overflow: auto;
  }
  .weapon-dialog-main { gap: 8px; padding: 8px 10px; }
  .weapon-dialog-extra { padding: 8px 10px; }
  .weapon-dialog .w-head { gap: 8px; }
  .weapon-dialog .w-head img { width: 48px; height: 48px; padding: 3px; }
  .weapon-dialog .w-name { font-size: 15px; }
  .weapon-dialog .w-kind { font-size: 12px; }
  .weapon-dialog .w-stats { gap: 2px; font-size: 13px; }
  .weapon-dialog-actions { gap: 4px; }
  .weapon-popup-action { min-height: 32px; font-size: 13px; }
  .weapon-dialog-extra:empty { display: none; }

  /* ------------------------------------------------ pause */
  #screen-paused { padding: 0; }
  .pause-layout {
    width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0;
    padding: 8px; grid-template-columns: 150px minmax(0, 1fr) minmax(210px, 36vw);
    gap: 6px; align-items: stretch;
  }
  .pause-panel { gap: 8px; }
  .pause-panel .panel-title { margin: 0 0 4px; font-size: 22px; }
  .pause-panel .menu-btn { padding: 8px 12px; border-radius: 8px; font-size: 15px; box-shadow: 0 4px 0 #5a2412; }
  .pause-inventory { padding: 8px; gap: 8px; border-radius: 6px; }
  .pause-inventory .side-title { margin-bottom: 4px; font-size: 12px; }
  .pause-inventory .side-weapons { grid-template-columns: repeat(6, 38px); gap: 4px; }
  .pause-inventory .side-weapon { padding: 1px; border-radius: 6px; }
  .pause-inventory .side-weapon img { height: 32px; }
  .pause-inventory .side-items { gap: 4px; }
  .pause-inventory .side-items img { width: 30px; height: 30px; }
  .pause-side { padding: 8px 10px; border-radius: 6px; }
  .pause-character { gap: 8px; margin-bottom: 3px; }
  .pause-portrait { width: 34px; height: 34px; }
  .pause-side .side-name { font-size: 14px; }
  .pause-side .side-subtitle { margin: 2px 0; font-size: 10px; }
  .pause-side .side-traits { gap: 1px; margin-bottom: 4px; font-size: 10px; }
  .pause-side .side-title { margin-bottom: 4px; font-size: 12px; }
  .pause-side .stat-tabs { gap: 4px; margin-bottom: 4px; }
  .pause-side .stat-tab { padding: 3px; border-radius: 4px; font-size: 11px; }
  .pause-side .side-stats { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
  .pause-side .side-stat { grid-template-columns: 14px minmax(0, 1fr) auto; gap: 4px; padding: 0; font-size: 10px; }
  .pause-side .side-stat-head { grid-column: 1 / -1; }
  .pause-side .stat-icon { width: 14px; height: 14px; }
}

/* Phone landscape, part 2: upgrade / item pick, settings overlay, codex. */
@media (max-width: 1024px) and (max-height: 500px) and (orientation: landscape) {
  /* Keep the queued-upgrade icon and its count badge off the right edge. */
  .hud-process { padding-right: 8px; }

  /* ------------------------------------------------ upgrade / item pick */
  .upgrade-layout, .reward-layout {
    padding: 8px 10px; grid-template-columns: minmax(0, 1fr); gap: 6px;
  }
  .upgrade-main .panel-title, .reward-main .panel-title { font-size: 26px; }
  .upgrade-main .panel-sub, .reward-main .panel-sub { margin: 0 0 6px; font-size: 12px; }
  .upgrade-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .upgrade-card, .reward-card { min-height: 0; padding: 8px; }
  .upgrade-card img, .reward-card img { width: 44px; height: 44px; padding: 3px; }
  .upgrade-card .upgrade-name, .reward-card .upgrade-name { margin: 5px 0 2px; font-size: 13px; }
  .upgrade-card .upgrade-effects, .reward-card .upgrade-effects { font-size: 11px; line-height: 1.3; }
  .upgrade-reroll { width: min(320px, 72%); min-height: 34px; margin-top: 8px; font-size: 14px; }
  .reward-grid { width: min(320px, 88%); }
  .reward-actions button { min-height: 36px; font-size: 14px; }
  .upgrade-stats, .reward-stats { display: none; }

  /* ------------------------------------------------ settings overlay */
  #screen-options { padding: 0; }
  .options-panel {
    padding: 6px 10px; grid-template-rows: 44px minmax(0, 1fr) 42px; gap: 6px;
  }
  .options-tabs { gap: 4px; padding-bottom: 4px; border-bottom-width: 2px; }
  .options-tab {
    flex-direction: row; gap: 6px; border-width: 2px; border-radius: 8px; font-size: 13px;
  }
  .options-tab img { width: 20px; height: 20px; }
  .options-content { width: 100%; padding: 3px 0; overflow: hidden; }
  .options-page { overflow: auto; }
  .options-page[data-options-page="audio"] {
    padding: 0; display: grid; grid-template-columns: 1fr 1fr;
    column-gap: 14px; align-content: start;
  }
  .options-page .settings-scroll {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px;
    align-content: start; height: auto; overflow: visible;
  }
  .options-page .settings-language { grid-column: 1 / -1; }
  .options-page .options-save-info { grid-column: 1; }
  .options-page #opt-reset { grid-column: 2; align-self: center; margin: 0; }
  .options-range-row {
    min-height: 30px; grid-template-columns: minmax(72px, 1fr) minmax(64px, 1.3fr) 38px;
    gap: 8px; font-size: 12px;
  }
  .options-range-row > span:last-child { font-size: 12px; }
  .options-slider, .settings-range-static { height: 18px; }
  .settings-toggle-row {
    min-height: 30px; margin: 0; padding: 4px 8px; border-radius: 5px; font-size: 12px; gap: 8px;
  }
  .settings-toggle-row input[type="checkbox"] {
    flex-basis: 46px; width: 46px; height: 24px;
    transform: scale(.8); transform-origin: right center; margin-left: -12px; margin-right: 0;
  }
  .settings-toggle-row input[type="checkbox"]::after { top: 2px; left: 2px; width: 20px; height: 20px; }
  .settings-toggle-row input[type="checkbox"]:checked::after { left: 24px; }
  .settings-action, .settings-select-row { min-height: 32px; margin-top: 0; padding: 4px 8px; font-size: 12px; }
  .settings-select-row select { padding: 4px 6px; font-size: 12px; }
  .settings-select-row input[type="color"] { width: 40px; height: 22px; }
  .settings-language { margin-top: 2px; gap: 6px; font-size: 12px; }
  .settings-mini { padding: 4px 8px; font-size: 12px; }
  .options-save-info { margin-top: 2px; font-size: 11px; }
  .options-footer { border-top-width: 1px; }
  .settings-back { width: min(320px, 42%); min-width: 0; height: 34px; font-size: 15px; }

  /* ------------------------------------------------ codex */
  .codex-layout { padding: 8px 10px 6px; gap: 6px; }
  .codex-header { gap: 8px; }
  .codex-title { gap: 6px; font-size: 18px; letter-spacing: 1px; }
  .codex-title-icon { width: 22px; height: 22px; }
  .codex-tabs { gap: 4px; }
  .codex-tab { padding: 5px 10px; border-width: 2px; border-radius: 7px; font-size: 12px; }
  #screen-codex .codex-back {
    min-width: 64px; width: auto; height: 30px; padding: 2px 10px;
    font-size: 12px; line-height: 1.2; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
  }
  .codex-toolbar { gap: 4px 10px; padding: 2px 0 5px; font-size: 11px; }
  .codex-sort { gap: 5px; }
  .codex-sort-select { padding: 3px 6px; border-radius: 6px; font-size: 11px; }
  .codex-reverse { padding: 3px 8px; border-radius: 6px; font-size: 11px; }
  .codex-reverse img { width: 13px; height: 13px; }
  .codex-tier { padding: 3px 8px; border-radius: 6px; font-size: 11px; }
  .codex-body { grid-template-columns: minmax(0, 1fr) minmax(220px, 38vw); gap: 8px; }
  .codex-grid { grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 6px; padding: 2px; }
  .codex-cell { padding: 3px; border-width: 1px; border-radius: 7px; gap: 2px; }
  .codex-cell img { width: 34px; height: 34px; }
  .codex-cell-name { font-size: 9px; line-height: 1.2; }
  .codex-cell-sub { font-size: 8px; }
  .codex-detail { padding: 8px 10px; gap: 6px; border-radius: 8px; }
  .codex-detail-head { gap: 8px; }
  .codex-detail-icon { width: 44px; height: 44px; }
  .codex-detail-name { font-size: 15px; }
  .codex-detail-sub { margin-top: 1px; font-size: 10px; }
  .codex-section { gap: 3px; }
  .codex-section-title { font-size: 10px; letter-spacing: 1px; }
  .codex-section-body { gap: 2px; font-size: 10px; }
  .codex-field { grid-template-columns: 64px 1fr auto; gap: 5px; font-size: 10px; }
  .codex-field-key { font-size: 9px; }
  .codex-source { padding-top: 5px; font-size: 9px; }
  .codex-footer { font-size: 9px; }
}

/* Narrow phone landscape: drop the side inventory/stat columns so the
   remaining content uses the full width. */
@media (max-width: 760px) and (max-height: 500px) and (orientation: landscape) {
  .shop-layout { grid-template-columns: minmax(0, 1fr); }
  .shop-side { display: none; }
  .pause-layout { grid-template-columns: 156px minmax(0, 1fr); }
  .pause-inventory { display: none; }
  .options-page[data-options-page="audio"],
  .options-page .settings-scroll { column-gap: 8px; }
  .options-tab { font-size: 12px; gap: 4px; }
}

/* Extra-short phone landscape (<=360px tall): tighten the shop cards and the
   pause stats so the action buttons stay inside the viewport. */
@media (max-width: 1024px) and (max-height: 360px) and (orientation: landscape) {
  .shop-header { min-height: 26px; }
  .shop-card { padding: 5px; }
  .shop-card .shop-icon { width: 34px; height: 34px; }
  .shop-name { font-size: 12px; }
  .shop-kind { font-size: 9px; }
  .shop-effects { -webkit-line-clamp: 2; margin-top: 2px; font-size: 9px; line-height: 1.25; }
  .shop-price { min-width: 0; padding: 1px 8px; font-size: 14px; }
  .shop-card-actions { gap: 2px; margin-top: 3px; }
  .shop-card-actions .shop-lock,
  .shop-card-actions .shop-ban,
  .shop-card-actions .shop-steal { min-height: 22px; padding: 1px 4px; font-size: 9px; }
  .shop-inventory-row { height: 44px; }
  .shop-inventory-block .side-weapons { grid-template-columns: repeat(6, 32px); }
  .shop-inventory-block .side-weapon img { height: 26px; }
  .side-items img { width: 26px; height: 26px; }
  .shop-actions .menu-btn { min-height: 32px; padding: 4px 12px; font-size: 13px; }
  .pause-side .side-subtitle, .pause-side .side-traits { display: none; }
  .pause-side .side-name { font-size: 13px; }
}
