:root {
  --bg0: #04070f;
  --obsidian: rgba(9, 13, 24, 0.90);
  --gold: #fbbf24;
  --gold-dim: rgba(251, 191, 36, 0.48);
  --cyan: #38bdf8;
  --emerald: #34d399;
  --violet: #818cf8;
  --coral: #fb7185;
  --crimson: #e11d48;
  --text: #f8fafc;
  --muted: #94a3b8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --qa-h: 36px;
  --modal-backdrop-pad: 18px;
  --modal-card-max-h: 92%;
  --modal-card-pad: 20px 24px;
  --boon-stage-cols: 320px 1fr;
  --shop-stage-cols: 280px 1fr;
  --stage-gap: 22px;
  --stage-align: center;
  --portrait-w: 300px;
  --portrait-h: 390px;
  --arch-name-size: 22px;
  --boon-list-gap: 12px;
  --boon-card-pad: 14px 18px;
  --shop-card-pad: 12px 14px;
  --modal-grid-cols: repeat(auto-fit, minmax(240px, 1fr));
  --shop-grid-cols: repeat(auto-fit, minmax(220px, 1fr));
  --patch-card-pad: 14px;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  touch-action: none;
}

html:not([data-qa-enabled="true"]) #qa-deck,
html[data-capacitor-native="true"] #qa-deck,
html[data-windows-app="true"] #qa-deck,
html[data-hearthiq-hosted="true"] #qa-deck {
  display: none !important;
}

/* QA Studio Bar */
.qa-deck {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(4, 7, 15, 0.95);
  border-bottom: 1px solid var(--gold-dim);
  font-size: 12px;
}

.qa-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  gap: 8px;
}

.qa-brand { display: flex; align-items: center; gap: 8px; }
.qa-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.qa-sub { color: var(--muted); }
.qa-actions { display: flex; align-items: center; gap: 8px; }

.qa-pill {
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: Consolas, monospace;
}

.qa-btn,
.qa-chip {
  background: rgba(15, 23, 42, 0.92);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
}

.qa-chip.is-active {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.18);
  color: var(--gold);
}

.qa-deck.is-collapsed .qa-drawer { display: none; }
.qa-drawer {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}
.qa-group { display: flex; align-items: center; gap: 6px; }

/* Stage */
.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg0);
}

html[data-device="iphone"] body,
html[data-device="ipad"] body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #02040a;
}

html[data-device="iphone"] .game-shell {
  width: 844px;
  height: 390px;
  border: 2px solid var(--gold-dim);
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}

html[data-device="ipad"] .game-shell {
  width: 1024px;
  height: 768px;
  border: 2px solid var(--gold-dim);
  border-radius: 16px;
}

#iso-canvas { display: block; width: 100%; height: 100%; }

/* Top HUD & Monumental Boss Bar */
.hud-top {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  right: calc(16px + var(--safe-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 12;
}

html:not([data-qa-enabled="true"]) .hud-top {
  top: calc(10px + var(--safe-top));
}

html[data-qa-enabled="true"]:not([data-capacitor-native="true"]):not([data-windows-app="true"]):not([data-device="iphone"]) .hud-top {
  top: calc(var(--qa-h, 36px) + 6px + var(--safe-top));
}

html[data-capacitor-native="true"] .hud-top,
html[data-windows-app="true"] .hud-top,
html[data-device="iphone"] .hud-top {
  top: calc(10px + var(--safe-top));
}

.hades-banner {
  background: linear-gradient(180deg, rgba(12, 16, 28, 0.92), rgba(7, 10, 19, 0.85));
  border: 1.5px solid var(--gold-dim);
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  padding: 7px 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.hades-banner-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--gold);
}

.hades-banner-sub {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

/* Boss Bar */
.boss-hud {
  flex: 1;
  max-width: 560px;
  background: linear-gradient(180deg, rgba(19, 10, 18, 0.94), rgba(8, 10, 18, 0.90));
  border: 1.5px solid rgba(251, 113, 133, 0.72);
  padding: 8px 16px;
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 100%, 0 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(225, 29, 72, 0.25);
}

.hades-banner.is-hidden { display: none; }
.boss-hud.is-hidden { display: none; }

.boss-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 5px;
}

.boss-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ffe4e6;
}

.boss-sub {
  font-family: Consolas, monospace;
  font-size: 10px;
  color: var(--gold);
}

.boss-hp-track {
  position: relative;
  height: 12px;
  background: rgba(5, 8, 17, 0.95);
  border: 1px solid rgba(251, 191, 36, 0.5);
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #9f1239, #fb7185, #fbbf24);
  transition: width 0.08s linear;
}

.boss-notch {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, 0.7);
}

.boss-invariants {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

.boss-invariants.is-hidden { display: none; }

.inv-pill {
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 3px;
}

.inv-pill.is-pass {
  color: var(--emerald);
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.45);
}

.inv-pill.is-fail {
  color: var(--coral);
  background: rgba(251, 113, 133, 0.22);
  border: 1px solid rgba(251, 113, 133, 0.8);
}

/* Top-Right Currencies + Hub Buttons */
.hud-right-top {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-left: auto;
  pointer-events: auto;
}

.hades-currencies {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--obsidian);
  border: 1.5px solid var(--gold-dim);
  padding: 6px 14px;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
}

.curr-item { display: flex; flex-direction: column; align-items: flex-end; }
.curr-label { font-size: 9px; font-family: Consolas, monospace; color: var(--muted); }
.curr-val { font-size: 16px; font-family: Consolas, monospace; }
.text-gold { color: var(--gold); }
.text-emerald { color: var(--emerald); }
.text-coral { color: var(--coral); }

.icon-btn {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--gold-dim);
  color: var(--text);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover {
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.16);
}

.hub-quick-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.btn-hades {
  background: rgba(9, 13, 24, 0.92);
  border: 1.5px solid var(--gold-dim);
  color: var(--text);
  padding: 6px 12px;
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn-hades:hover:not(:disabled) { transform: translateY(-1px); background: rgba(251, 191, 36, 0.18); }
.btn-hades:disabled { cursor: not-allowed; }
.btn-cyan { border-color: var(--cyan); color: var(--cyan); }
.btn-emerald { border-color: var(--emerald); color: var(--emerald); }
.btn-violet { border-color: var(--violet); color: #c4b5fd; }
.btn-gold { border-color: var(--gold); color: var(--gold); }
.btn-coral { border-color: var(--coral); color: var(--coral); }

/* Left-Edge Vertical Boon Icon Strip */
.boon-strip {
  position: absolute;
  left: calc(14px + var(--safe-left));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10;
  pointer-events: auto;
  cursor: pointer;
}

.boon-badge {
  position: relative;
  width: 40px;
  height: 40px;
  background: var(--obsidian);
  border: 1.5px solid var(--cyan);
  transform: rotate(45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.boon-strip:hover .boon-badge {
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.4);
}

.boon-badge svg {
  transform: rotate(-45deg);
  width: 20px;
  height: 20px;
  display: block;
}

.boon-badge > span:not(.boon-lvl-pill) {
  transform: rotate(-45deg);
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
}

.boon-lvl-pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.72);
  color: #fde68a;
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.4px;
}

.boon-badge .boon-lvl-pill {
  position: absolute;
  bottom: -7px;
  right: -7px;
  transform: rotate(-45deg);
  padding: 1px 4px;
  font-size: 9px;
  background: #090d18;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
}

.boon-badge.is-unsafe { border-color: var(--coral); background: rgba(45, 10, 22, 0.9); }

/* Bottom-Left Hades Player Frame */
.hades-player-hud {
  position: absolute;
  left: calc(16px + var(--safe-left));
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, rgba(9, 13, 24, 0.94), rgba(13, 21, 40, 0.86));
  border: 1.5px solid var(--gold-dim);
  padding: 10px 18px 10px 12px;
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 100%, 0 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.65);
  min-width: 340px;
  z-index: 12;
  pointer-events: none;
}

.portrait-medallion {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: #080d1a;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
  overflow: hidden;
  flex-shrink: 0;
}

.hud-portrait { width: 100%; height: 100%; object-fit: contain; }
.player-bars { flex: 1; }
.player-meta-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 5px; }
.hud-gen-title { font-family: Georgia, "Times New Roman", serif; font-size: 12px; font-weight: 700; color: var(--gold); }

.hud-risk {
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 3px;
}
.hud-risk.is-safe { color: var(--emerald); background: rgba(52, 211, 153, 0.16); border: 1px solid rgba(52, 211, 153, 0.45); }
.hud-risk.is-risk { color: var(--coral); background: rgba(251, 113, 133, 0.25); border: 1px solid rgba(251, 113, 133, 0.75); }

.hp-track-hades {
  position: relative;
  height: 16px;
  background: rgba(5, 8, 17, 0.95);
  border: 1.5px solid var(--gold-dim);
  overflow: hidden;
}

.hp-trail-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #f8fafc;
}

.hp-fill-hades {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, #be123c, #e11d48 55%, #fb7185);
}

.hp-label-hades {
  position: relative;
  z-index: 2;
  display: block;
  text-align: center;
  line-height: 14px;
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px #000;
}

.resource-row-hades {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
}

.cast-diamonds { display: flex; gap: 7px; align-items: center; }

.cast-gem {
  width: 13px;
  height: 13px;
  transform: rotate(45deg);
  border: 1.5px solid var(--gold);
  background: rgba(15, 23, 42, 0.9);
}

.cast-gem.is-full {
  background: radial-gradient(circle, #fef08a, #f59e0b);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.85);
}

.defiance-pips {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.defiance-pips:empty { display: none; }
.defiance-pip {
  font-size: 13px;
  line-height: 1;
  color: var(--coral);
  text-shadow: 0 0 8px rgba(251, 113, 133, 0.8);
}
.defiance-pip.is-spent {
  opacity: 0.28;
  color: var(--muted);
  text-shadow: none;
}

.call-gauge-wrap { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 72px; }
.call-track { flex: 1; height: 7px; background: rgba(5, 8, 17, 0.9); border: 1px solid rgba(52, 211, 153, 0.45); }
.call-fill { height: 100%; background: linear-gradient(90deg, var(--cyan), var(--emerald)); transition: width 0.1s linear; }
.call-text { font-family: Consolas, monospace; font-size: 10px; font-weight: 800; color: var(--emerald); }

/* Bottom-Right Desktop Skill Dock */
.desktop-skillbar {
  position: absolute;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  z-index: 12;
  pointer-events: auto;
}

.skill-slot {
  background: var(--obsidian);
  border: 1.5px solid var(--gold-dim);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.skill-slot:hover {
  transform: translateY(-2px);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.skill-slot.skill-mode-btn {
  border-color: rgba(56, 189, 248, 0.65);
  background: rgba(11, 20, 38, 0.94);
}

.skill-slot kbd { font-family: Consolas, monospace; font-size: 10px; font-weight: 800; color: var(--gold); }
.skill-slot span { font-size: 11px; font-weight: 700; color: var(--text); }
.skill-slot em { font-style: normal; font-family: Consolas, monospace; font-size: 10px; color: var(--emerald); }

/* Touch Controls */
.touch-layer { position: absolute; inset: 0; display: none; pointer-events: none; z-index: 10; }
.touch-layer.is-visible { display: block; }
html.has-touch-controls .desktop-skillbar,
html[data-device="iphone"] .desktop-skillbar { display: none !important; }

.touch-joy-zone { position: absolute; left: 0; top: 80px; bottom: 0; width: 42%; pointer-events: auto; }
.touch-joy-ring {
  position: absolute;
  left: 84px;
  bottom: calc(126px + var(--safe-bottom));
  width: 104px;
  height: 104px;
  margin-left: -52px;
  margin-top: -52px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: rgba(8, 13, 24, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}
.touch-joy-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #7dd3fc, #38bdf8);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.65);
}

.touch-buttons {
  position: absolute;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 58px);
  gap: 8px;
  pointer-events: auto;
}

.tbtn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(8, 13, 24, 0.88);
  border: 2px solid var(--gold);
  color: var(--text);
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tbtn.is-pressed { transform: scale(0.92); background: rgba(251, 191, 36, 0.25); }
.tbtn-fire { grid-column: 3; border-color: var(--cyan); color: var(--cyan); width: 68px; height: 68px; }
.tbtn-violet { border-color: var(--violet); color: #c4b5fd; }
.tbtn-emerald { border-color: var(--emerald); color: var(--emerald); }
.tbtn-amber { border-color: var(--gold); color: var(--gold); }
.tbtn-call { border-color: #34d399; color: #fef08a; background: rgba(6, 78, 59, 0.85); }

html[data-device="iphone"] .hades-banner { display: none; }
html[data-device="iphone"] .hades-player-hud { min-width: 245px; padding: 6px 10px; bottom: 8px; left: 8px; }
html[data-device="iphone"] .portrait-medallion { width: 42px; height: 42px; }
html[data-device="iphone"] .boon-strip { display: none; }
html[data-device="iphone"] .touch-joy-ring { bottom: 112px; left: 72px; width: 88px; height: 88px; margin-left: -44px; margin-top: -44px; }

/* First-Run Onboarding Banner */
.onboarding-tip {
  position: absolute;
  left: 50%;
  bottom: calc(118px + var(--safe-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 7px 14px;
  background: rgba(9, 13, 24, 0.92);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  font-size: 12px;
  color: #e2e8f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  z-index: 14;
  pointer-events: auto;
}
.onboarding-tip.is-hidden { display: none; }
.onboarding-tip kbd {
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 4px;
  padding: 1px 5px;
}
.onboarding-dismiss {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.onboarding-dismiss:hover { color: var(--text); }

/* Live Accessibility Audio Captions */
.audio-captions {
  position: absolute;
  top: calc(128px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  pointer-events: none;
  max-width: min(540px, calc(100% - 32px));
  padding: 6px 14px;
  background: rgba(6, 10, 20, 0.92);
  border: 1.5px solid var(--gold-dim);
  border-radius: 999px;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  color: #fef08a;
  letter-spacing: 0.4px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.68);
  word-break: break-word;
}
.audio-captions.is-hidden { display: none; }
html[data-qa-enabled="true"]:not([data-capacitor-native="true"]):not([data-windows-app="true"]):not([data-device="iphone"]) .audio-captions {
  top: calc(var(--qa-h, 36px) + 124px + var(--safe-top));
}

/* Full-Screen Hades Architect Boon & Station Modals */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 50%, rgba(15, 23, 42, 0.82), rgba(2, 4, 10, 0.94));
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--modal-backdrop-pad);
  z-index: 35;
}
.modal-backdrop.is-hidden { display: none; }

.modal-card {
  width: min(1060px, 98%);
  max-height: var(--modal-card-max-h);
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(11, 15, 29, 0.97), rgba(6, 9, 18, 0.98));
  border: 2px solid var(--gold-dim);
  padding: var(--modal-card-pad);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.85), 0 0 36px rgba(56, 189, 248, 0.16);
}

/* Iconic Hades Boon Split Layout */
.boon-stage {
  display: grid;
  grid-template-columns: var(--boon-stage-cols);
  gap: var(--stage-gap);
  align-items: var(--stage-align);
}

.architect-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.architect-portrait {
  width: var(--portrait-w);
  height: var(--portrait-h);
  object-fit: contain;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.9));
}

.architect-plate {
  width: 100%;
  background: rgba(5, 8, 17, 0.94);
  border: 1.5px solid var(--gold);
  padding: 10px 14px;
  margin-top: -12px;
}

.architect-name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--arch-name-size);
  font-weight: 800;
  letter-spacing: 2px;
}

.architect-sub {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--gold);
  margin-top: 2px;
}

.architect-quote {
  margin: 10px 0 0;
  font-style: italic;
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.4;
}

.duo-banter {
  margin-top: 10px;
  padding: 8px 12px;
  width: 100%;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.14), rgba(56, 189, 248, 0.10));
  border: 1px solid rgba(251, 191, 36, 0.52);
  border-radius: 6px;
  font-size: 12px;
  font-style: italic;
  color: #fef3c7;
  line-height: 1.4;
}

.boon-list {
  display: flex;
  flex-direction: column;
  gap: var(--boon-list-gap);
}

.boon-offer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(90deg, rgba(16, 24, 44, 0.95), rgba(10, 15, 28, 0.90));
  border: 2px solid var(--cyan);
  padding: var(--boon-card-pad);
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}

.boon-offer-card:hover {
  transform: translateX(6px);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
}

.boon-offer-card.is-rare { border-color: var(--violet); }
.boon-offer-card.is-epic { border-color: var(--emerald); }
.boon-offer-card.is-duo {
  border-color: var(--gold);
  background: linear-gradient(90deg, rgba(40, 29, 10, 0.95), rgba(16, 15, 28, 0.92));
}
.boon-offer-card.is-legendary {
  border-color: #f59e0b;
  background: linear-gradient(90deg, rgba(66, 39, 8, 0.96), rgba(34, 19, 10, 0.94));
  box-shadow: 0 0 26px rgba(251, 191, 36, 0.42), inset 0 0 18px rgba(251, 191, 36, 0.16);
}
.boon-offer-card.is-legendary:hover {
  box-shadow: 0 0 34px rgba(251, 191, 36, 0.65), inset 0 0 22px rgba(251, 191, 36, 0.24);
}
.boon-offer-card.is-unsafe {
  border-color: var(--coral);
  background: linear-gradient(90deg, rgba(46, 12, 24, 0.95), rgba(18, 9, 18, 0.92));
}

.boon-offer-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.boon-icon-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(5, 9, 20, 0.9);
  border: 1.5px solid var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
}

.boon-icon-wrap svg { width: 24px; height: 24px; display: block; }

.boon-hotkey {
  position: absolute;
  top: -7px;
  left: -7px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #0f172a;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: Consolas, monospace;
  font-size: 10px;
  font-weight: 800;
}

.boon-rarity { font-family: Consolas, monospace; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; }
.boon-name { font-family: Georgia, "Times New Roman", serif; font-size: 18px; font-weight: 700; color: #ffffff; margin: 3px 0; }
.boon-desc { font-size: 13px; color: #cbd5e1; }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 20px; color: var(--gold); letter-spacing: 1px; }
.modal-head .btn-coral {
  padding: 7px 16px;
  min-height: 34px;
  background: rgba(45, 12, 24, 0.92);
  color: #ffe4e6;
  border-color: var(--coral);
  font-size: 12px;
  flex-shrink: 0;
}
.modal-head .btn-coral:hover { background: rgba(225, 29, 72, 0.35); }

.modal-grid { display: grid; grid-template-columns: var(--modal-grid-cols); gap: 12px; }

.patch-card {
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid var(--gold-dim);
  padding: var(--patch-card-pad);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
}
.patch-card.is-unsafe { border-color: rgba(251, 113, 133, 0.8); background: rgba(38, 12, 24, 0.85); }
.patch-card .btn-hades { white-space: nowrap; font-size: 11px; padding: 7px 10px; }
.patch-tag { font-family: Consolas, monospace; font-size: 11px; font-weight: 800; color: var(--emerald); }
.patch-card.is-unsafe .patch-tag { color: var(--coral); }
.patch-title { font-size: 16px; font-weight: 800; color: var(--text); }
.patch-desc { font-size: 13px; color: var(--muted); line-height: 1.4; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* Run Summary Breakdown */
.run-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.run-stat-cell {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.28);
  padding: 10px 12px;
}
.run-stat-label {
  font-family: Consolas, monospace;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.run-stat-val {
  margin-top: 4px;
  font-family: Consolas, monospace;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

/* Pause, Settings & Boon Codex */
.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
}
.pause-actions .btn-hades {
  text-align: left;
  padding: 11px 16px;
  font-size: 13px;
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.22);
}
.settings-row label { font-size: 13px; font-weight: 700; color: var(--text); flex: 1; cursor: pointer; }
.settings-sub { font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.settings-slider-wrap { display: flex; align-items: center; gap: 10px; }
.settings-slider-wrap input[type="range"] { accent-color: var(--cyan); width: 160px; }
.settings-row input[type="checkbox"] { accent-color: var(--cyan); width: 22px; height: 22px; flex-shrink: 0; cursor: pointer; }
.settings-val { font-family: Consolas, monospace; font-size: 12px; color: var(--gold); min-width: 40px; text-align: right; }

.controls-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.controls-ref-card {
  background: rgba(8, 13, 24, 0.88);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.55;
  color: #cbd5e1;
}
.controls-ref-card h4 {
  margin: 0 0 6px;
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.8px;
}

.codex-section-title {
  margin: 14px 0 8px;
  font-family: Consolas, monospace;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 1px;
}

/* 3-Tab Codex, Affinity & Lore, Run Chronicle */
.codex-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.25);
}

.codex-tab {
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  color: var(--muted);
  padding: 7px 14px;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.6px;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.codex-tab:hover {
  color: var(--text);
  border-color: var(--gold-dim);
}

.codex-tab.is-active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(251, 191, 36, 0.16);
}

.codex-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.codex-stat-pill {
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 8px 10px;
}

.codex-stat-pill span {
  display: block;
  font-family: Consolas, monospace;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.codex-stat-pill strong {
  display: block;
  margin-top: 2px;
  font-family: Consolas, monospace;
  font-size: 14px;
  color: var(--text);
}

.affinity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.affinity-card {
  background: rgba(15, 23, 42, 0.88);
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.affinity-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.affinity-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  object-position: top center;
  background: #050811;
  border: 1.5px solid var(--gold-dim);
  flex-shrink: 0;
}

.affinity-bar {
  height: 7px;
  background: rgba(5, 8, 17, 0.95);
  border: 1px solid rgba(251, 191, 36, 0.35);
  overflow: hidden;
  border-radius: 999px;
}

.affinity-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
}

.lore-entry {
  padding: 7px 10px;
  background: rgba(8, 13, 24, 0.82);
  border-left: 2px solid var(--gold);
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.4;
}

.lore-entry.is-locked {
  border-left-color: rgba(148, 163, 184, 0.35);
  color: var(--muted);
  font-style: italic;
}

.keepsake-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(8, 13, 24, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.38);
  border-radius: 6px;
}
.keepsake-info { min-width: 0; flex: 1; }
.keepsake-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.keepsake-name { font-size: 12px; font-weight: 800; color: var(--gold); }
.keepsake-desc { font-size: 11px; color: #cbd5e1; margin-top: 2px; line-height: 1.3; }
.keepsake-equip-btn { flex-shrink: 0; }

.chronicle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chronicle-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-left: 3px solid var(--coral);
  font-size: 12px;
}

.chronicle-row.is-victory {
  border-left-color: var(--emerald);
}

.chronicle-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #cbd5e1;
  font-family: Consolas, monospace;
  font-size: 11px;
}

.chronicle-cause {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

/* Null-Ptr Cache Shop & Pom of Compression */
.shop-stage {
  display: grid;
  grid-template-columns: var(--shop-stage-cols);
  gap: var(--stage-gap);
  align-items: start;
}

.shop-grid {
  display: grid;
  grid-template-columns: var(--shop-grid-cols);
  gap: 10px;
}

.shop-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.shop-icon-wrap {
  width: 36px;
  height: 36px;
}
.shop-item-title {
  font-size: 15px;
}

.shop-item-card {
  background: linear-gradient(180deg, rgba(16, 24, 44, 0.95), rgba(9, 13, 24, 0.92));
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  padding: var(--shop-card-pad);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.shop-item-card.is-sold {
  opacity: 0.55;
  border-color: rgba(148, 163, 184, 0.3);
}

.pom-level-delta {
  display: inline-block;
  margin: 2px 0 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.45);
  font-family: Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  color: #fde68a;
}

.is-gp-focus {
  outline: 2px solid var(--gold) !important;
  outline-offset: 2px;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.45) !important;
}

/* Rotate-to-Landscape Mobile Portrait Overlay */
.rotate-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(15, 23, 42, 0.94), rgba(4, 7, 15, 0.98));
  backdrop-filter: blur(10px);
}
.rotate-card {
  max-width: 340px;
  padding: 24px 20px;
  text-align: center;
  background: rgba(9, 13, 24, 0.95);
  border: 2px solid var(--gold-dim);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
}
.rotate-icon {
  color: var(--cyan);
  margin-bottom: 10px;
}
.rotate-card h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  color: var(--gold);
  letter-spacing: 1.2px;
}
.rotate-card p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.45;
  color: #cbd5e1;
}

/* Minimum 44x44 Touch Targets for Touch / Coarse Pointer Devices */
html.has-touch-controls #btn-mute,
html.has-touch-controls #btn-boons,
html.has-touch-controls #btn-pause,
html.has-touch-controls .boon-offer-card button,
html.has-touch-controls .shop-item-card button,
html.has-touch-controls .codex-tab,
html.has-touch-controls #m-close,
html.has-touch-controls .patch-card .btn-hades,
html.has-touch-controls #btn-reroll-boon,
html.has-touch-controls #set-assist-mode,
html.has-touch-controls #set-mouse-mode,
html.has-touch-controls #set-touch-aim,
html.has-touch-controls .settings-row label,
html.has-touch-controls .keepsake-equip-btn,
html.has-touch-controls .modal-footer .btn-hades,
html.has-touch-controls #rotate-dismiss {
  min-width: 44px;
  min-height: 44px;
}

html.has-touch-controls .settings-row label {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (pointer: coarse) {
  #btn-mute,
  #btn-boons,
  #btn-pause,
  .boon-offer-card button,
  .shop-item-card button,
  .codex-tab,
  #m-close,
  .patch-card .btn-hades,
  #btn-reroll-boon,
  #set-assist-mode,
  #set-mouse-mode,
  #set-touch-aim,
  .settings-row label,
  .keepsake-equip-btn,
  .modal-footer .btn-hades,
  #rotate-dismiss {
    min-width: 44px;
    min-height: 44px;
  }
  .settings-row label {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .settings-row input[type="checkbox"] {
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 920px), (pointer: coarse) {
  .hades-player-hud {
    min-width: 245px;
    padding: 6px 10px;
    bottom: calc(8px + var(--safe-bottom));
    left: calc(8px + var(--safe-left));
  }
  .portrait-medallion { width: 42px; height: 42px; }
  .touch-joy-ring {
    bottom: calc(112px + var(--safe-bottom));
    left: 72px;
    width: 88px;
    height: 88px;
    margin-left: -44px;
    margin-top: -44px;
  }
  .onboarding-tip { font-size: 11px; padding: 6px 12px; }
}

@media (max-width: 860px) {
  .boon-strip { display: none; }
  .chronicle-row { grid-template-columns: 1fr; }
  .chronicle-cause { text-align: left; }
}

@media (max-width: 680px) and (min-height: 481px) {
  :root {
    --boon-stage-cols: 1fr;
    --shop-stage-cols: 1fr;
    --portrait-w: 150px;
    --portrait-h: 185px;
  }
}

/* Compact 2-Column Modals for iPhone 844x390 & Short Landscape Screens */
html[data-device="iphone"] {
  --modal-backdrop-pad: 4px;
  --modal-card-max-h: 98%;
  --modal-card-pad: 8px 12px;
  --boon-stage-cols: 118px 1fr;
  --shop-stage-cols: 118px 1fr;
  --stage-gap: 10px;
  --stage-align: start;
  --portrait-w: 96px;
  --portrait-h: 124px;
  --arch-name-size: 14px;
  --boon-list-gap: 6px;
  --boon-card-pad: 7px 10px;
  --shop-card-pad: 5px 8px;
  --modal-grid-cols: repeat(2, minmax(0, 1fr));
  --shop-grid-cols: repeat(3, minmax(0, 1fr));
  --patch-card-pad: 8px 10px;
}

@media (max-height: 480px) {
  :root {
    --modal-backdrop-pad: 4px;
    --modal-card-max-h: 98%;
    --modal-card-pad: 8px 12px;
    --boon-stage-cols: 118px 1fr;
    --shop-stage-cols: 118px 1fr;
    --stage-gap: 10px;
    --stage-align: start;
    --portrait-w: 96px;
    --portrait-h: 124px;
    --arch-name-size: 14px;
    --boon-list-gap: 6px;
    --boon-card-pad: 7px 10px;
    --shop-card-pad: 5px 8px;
    --modal-grid-cols: repeat(2, minmax(0, 1fr));
    --shop-grid-cols: repeat(3, minmax(0, 1fr));
    --patch-card-pad: 8px 10px;
  }
  .hades-banner { display: none; }
  .boon-strip { display: none; }
  .hud-right-top { gap: 5px; }
  .hades-currencies { padding: 4px 10px; gap: 10px; }
  .hub-quick-btns { max-width: 560px; gap: 5px; }
  .hud-top .btn-hades { padding: 4px 9px; font-size: 10px; }
  .audio-captions { top: calc(114px + var(--safe-top)); font-size: 11px; padding: 4px 12px; }
  .onboarding-tip {
    bottom: calc(88px + var(--safe-bottom));
    max-width: min(370px, calc(100% - 380px));
    font-size: 11px;
    padding: 5px 10px;
    text-align: center;
  }
  .modal-head { margin-bottom: 6px; gap: 8px; }
  .modal-head h2 { font-size: 15px; }
  .architect-plate { padding: 4px 6px; margin-top: -6px; }
  .architect-sub { font-size: 9px; }
  .architect-quote {
    font-size: 11px;
    line-height: 1.25;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .duo-banter { font-size: 10px; padding: 4px 6px; margin-top: 4px; }
  .boon-offer-card { gap: 10px; }
  .boon-icon-wrap { width: 34px; height: 34px; }
  .boon-icon-wrap svg { width: 18px; height: 18px; }
  .boon-rarity { font-size: 9px; }
  .boon-name { font-size: 14px; margin: 1px 0; }
  .boon-desc { font-size: 11px; line-height: 1.25; }
  .modal-grid, .shop-grid { gap: 6px; }
  .patch-card, .shop-item-card { gap: 4px; }
  .patch-title { font-size: 13px; }
  .patch-desc { font-size: 11px; line-height: 1.25; }
  .modal-footer { margin-top: 6px; gap: 6px; }
  .shop-stage .modal-head { margin-bottom: 4px; }
  .shop-stage .modal-footer { margin-top: 6px; }
  .shop-item-head { gap: 6px; margin-bottom: 3px; }
  .shop-icon-wrap { width: 26px; height: 26px; }
  .shop-icon-wrap svg { width: 15px; height: 15px; }
  .shop-item-card .patch-tag { font-size: 9px; line-height: 1.1; }
  .shop-item-title { font-size: 12px; line-height: 1.15; }
  .shop-item-card .patch-desc {
    font-size: 10px;
    line-height: 1.18;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .shop-item-card button { padding: 4px 6px; font-size: 10px; }
}

html[data-device="iphone"] .hud-right-top { gap: 5px; }
html[data-device="iphone"] .hades-currencies { padding: 4px 10px; gap: 10px; }
html[data-device="iphone"] .hub-quick-btns { max-width: 560px; gap: 5px; }
html[data-device="iphone"] .hud-top .btn-hades { padding: 4px 9px; font-size: 10px; }
html[data-device="iphone"] .audio-captions { top: calc(114px + var(--safe-top)); font-size: 11px; padding: 4px 12px; }
html[data-device="iphone"] .onboarding-tip {
  bottom: calc(88px + var(--safe-bottom));
  max-width: min(370px, calc(100% - 380px));
  font-size: 11px;
  padding: 5px 10px;
  text-align: center;
}
html[data-device="iphone"] .modal-head { margin-bottom: 6px; gap: 8px; }
html[data-device="iphone"] .modal-head h2 { font-size: 15px; }
html[data-device="iphone"] .architect-plate { padding: 4px 6px; margin-top: -6px; }
html[data-device="iphone"] .architect-sub { font-size: 9px; }
html[data-device="iphone"] .architect-quote {
  font-size: 11px;
  line-height: 1.25;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
html[data-device="iphone"] .duo-banter { font-size: 10px; padding: 4px 6px; margin-top: 4px; }
html[data-device="iphone"] .boon-offer-card { gap: 10px; }
html[data-device="iphone"] .boon-icon-wrap { width: 34px; height: 34px; }
html[data-device="iphone"] .boon-icon-wrap svg { width: 18px; height: 18px; }
html[data-device="iphone"] .boon-rarity { font-size: 9px; }
html[data-device="iphone"] .boon-name { font-size: 14px; margin: 1px 0; }
html[data-device="iphone"] .boon-desc { font-size: 11px; line-height: 1.25; }
html[data-device="iphone"] .modal-grid,
html[data-device="iphone"] .shop-grid { gap: 6px; }
html[data-device="iphone"] .patch-card,
html[data-device="iphone"] .shop-item-card { gap: 4px; }
html[data-device="iphone"] .patch-title { font-size: 13px; }
html[data-device="iphone"] .patch-desc { font-size: 11px; line-height: 1.25; }
html[data-device="iphone"] .modal-footer { margin-top: 6px; gap: 6px; }
html[data-device="iphone"] .shop-stage .modal-head { margin-bottom: 4px; }
html[data-device="iphone"] .shop-stage .modal-footer { margin-top: 6px; }
html[data-device="iphone"] .shop-item-head { gap: 6px; margin-bottom: 3px; }
html[data-device="iphone"] .shop-icon-wrap { width: 26px; height: 26px; }
html[data-device="iphone"] .shop-icon-wrap svg { width: 15px; height: 15px; }
html[data-device="iphone"] .shop-item-card .patch-tag { font-size: 9px; line-height: 1.1; }
html[data-device="iphone"] .shop-item-title { font-size: 12px; line-height: 1.15; }
html[data-device="iphone"] .shop-item-card .patch-desc {
  font-size: 10px;
  line-height: 1.18;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
html[data-device="iphone"] .shop-item-card button { padding: 4px 6px; font-size: 10px; }

/* Tablet Portrait Orientation (768x1024 & Narrow Portrait Modals) */
@media (min-width: 601px) and (max-width: 900px) and (orientation: portrait) {
  :root {
    --modal-backdrop-pad: 14px;
    --modal-card-max-h: 90%;
    --modal-card-pad: 16px 18px;
    --boon-stage-cols: 1fr;
    --shop-stage-cols: 1fr;
    --stage-gap: 14px;
    --stage-align: start;
    --portrait-w: 164px;
    --portrait-h: 208px;
    --arch-name-size: 18px;
    --boon-list-gap: 10px;
    --boon-card-pad: 12px 14px;
    --shop-card-pad: 10px 12px;
    --modal-grid-cols: repeat(2, minmax(0, 1fr));
    --shop-grid-cols: repeat(2, minmax(0, 1fr));
    --patch-card-pad: 12px;
  }
  html[data-device="ipad"] .game-shell,
  html[data-device="iphone"] .game-shell {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .hud-top {
    left: calc(12px + var(--safe-left));
    right: calc(12px + var(--safe-right));
    gap: 10px;
    align-items: flex-start;
  }
  .hades-banner {
    max-width: 45%;
    padding: 6px 16px;
  }
  .hades-banner-title { font-size: 13px; }
  .hades-banner-sub { font-size: 10px; }
  .boss-hud {
    flex: 1 1 300px;
    min-width: 0;
    max-width: 430px;
    padding: 7px 14px;
  }
  .boss-title-row { flex-wrap: wrap; gap: 2px 8px; }
  .boss-name { font-size: 13px; }
  .boss-invariants { flex-wrap: wrap; gap: 4px; }
  .inv-pill { font-size: 9px; padding: 2px 6px; }
  .hud-right-top {
    flex-shrink: 0;
    max-width: 53%;
    gap: 6px;
  }
  .hades-currencies {
    gap: 10px;
    padding: 5px 10px;
  }
  .hub-quick-btns {
    gap: 5px;
    max-width: 370px;
    justify-content: flex-end;
  }
  .btn-hades {
    padding: 6px 10px;
    font-size: 10px;
  }
  .audio-captions {
    top: calc(140px + var(--safe-top));
    max-width: min(500px, calc(100% - 32px));
  }
  html[data-qa-enabled="true"]:not([data-capacitor-native="true"]):not([data-windows-app="true"]):not([data-device="iphone"]) .audio-captions {
    top: calc(var(--qa-h, 36px) + 136px + var(--safe-top));
  }
  .hades-player-hud {
    left: calc(12px + var(--safe-left));
    bottom: calc(12px + var(--safe-bottom));
    min-width: 245px;
    max-width: 320px;
    padding: 8px 12px;
  }
  .touch-joy-ring {
    left: 74px;
    bottom: calc(118px + var(--safe-bottom));
  }
  .touch-buttons {
    right: calc(14px + var(--safe-right));
    bottom: calc(14px + var(--safe-bottom));
    grid-template-columns: repeat(3, 56px);
    gap: 8px;
  }
  .tbtn { width: 56px; height: 56px; font-size: 10px; }
  .tbtn-fire { width: 64px; height: 64px; }
  .desktop-skillbar {
    right: calc(12px + var(--safe-right));
    bottom: calc(12px + var(--safe-bottom));
    gap: 5px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: calc(100% - 344px);
  }
  .skill-slot { min-width: 58px; padding: 5px 7px; }
  .onboarding-tip {
    bottom: calc(154px + var(--safe-bottom));
    max-width: min(460px, calc(100% - 40px));
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  .modal-card { width: min(736px, 96%); }
  .architect-column { max-width: 460px; margin: 0 auto; }
  .affinity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-slider-wrap input[type="range"] { width: 130px; }
}

/* Mobile Web Portrait Orientation */
@media (max-width: 600px) and (orientation: portrait) {
  :root {
    --modal-backdrop-pad: 10px;
    --modal-card-pad: 14px;
    --modal-grid-cols: minmax(0, 1fr);
    --shop-grid-cols: minmax(0, 1fr);
  }
  .rotate-overlay:not(.is-dismissed) {
    display: flex;
  }
  html[data-device="ipad"] .game-shell,
  html[data-device="iphone"] .game-shell {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .hud-top {
    flex-wrap: wrap;
    gap: 6px;
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
  }
  .hades-banner { display: none; }
  .hud-right-top,
  html[data-device="iphone"] .hud-right-top { gap: 5px; }
  .hades-currencies,
  html[data-device="iphone"] .hades-currencies { gap: 8px; padding: 5px 10px; }
  .hub-quick-btns,
  html[data-device="iphone"] .hub-quick-btns { gap: 4px; max-width: 100%; }
  .hud-top .btn-hades,
  html[data-device="iphone"] .hud-top .btn-hades { padding: 4px 9px; font-size: 10px; }
  .audio-captions,
  html[data-device="iphone"] .audio-captions {
    top: calc(134px + var(--safe-top));
    font-size: 11px;
    padding: 4px 12px;
    max-width: calc(100% - 20px);
  }
  html[data-qa-enabled="true"]:not([data-capacitor-native="true"]):not([data-windows-app="true"]):not([data-device="iphone"]) .audio-captions {
    top: calc(var(--qa-h, 36px) + 130px + var(--safe-top));
  }
  .affinity-grid { grid-template-columns: minmax(0, 1fr); }
  .settings-row { flex-wrap: wrap; gap: 10px; }
  .settings-slider-wrap input[type="range"] { width: 120px; }
  .desktop-skillbar {
    left: calc(8px + var(--safe-left));
    right: calc(8px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
  }
  .skill-slot { min-width: 54px; padding: 5px 6px; }
  .hades-player-hud,
  html[data-device="iphone"] .hades-player-hud {
    left: calc(8px + var(--safe-left));
    right: auto;
    bottom: calc(206px + var(--safe-bottom));
    min-width: 220px;
    max-width: calc(100% - 16px);
  }
  .touch-joy-ring,
  html[data-device="iphone"] .touch-joy-ring {
    bottom: calc(92px + var(--safe-bottom));
    left: 68px;
  }
  .touch-buttons {
    right: calc(10px + var(--safe-right));
    bottom: calc(10px + var(--safe-bottom));
    grid-template-columns: repeat(3, 50px);
    gap: 6px;
  }
  .tbtn { width: 50px; height: 50px; font-size: 9px; }
  .tbtn-fire { width: 58px; height: 58px; }
  .onboarding-tip,
  html[data-device="iphone"] .onboarding-tip {
    bottom: calc(306px + var(--safe-bottom));
    max-width: calc(100% - 20px);
    padding: 6px 12px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
}
