/* ============================================================================
   YASD 3D — Handheld Console Architecture (Zero Desktop Impact)
   ============================================================================
   Every layout and control rule in this stylesheet is strictly gated under
   `html.yasd-handheld` so Desktop, fine-hover laptops, and resized desktop
   windows experience 0.00% style or layout changes.
   ============================================================================ */

/* Desktop & non-handheld: keep handheld-only structural surfaces hidden */
#handheld-deck-plate,
#handheld-autonav-stop,
#quick-slot-bar,
#quick-slot-popover {
    display: none;
}

html.yasd-handheld {
    --hh-bg-deck: #12151c;
    --hh-bg-surface: #181d27;
    --hh-bg-button: #202736;
    --hh-bg-button-press: #2a3346;
    --hh-border: rgba(212, 175, 55, 0.36);
    --hh-border-strong: rgba(223, 184, 88, 0.72);
    --hh-ink: #e2ded3;
    --hh-ink-muted: #b6bfd0;
    --hh-gold: #dfb858;
    --hh-safe-top: env(safe-area-inset-top, 0px);
    --hh-safe-bottom: env(safe-area-inset-bottom, 0px);
    --hh-safe-left: env(safe-area-inset-left, 0px);
    --hh-safe-right: env(safe-area-inset-right, 0px);
}

/* ----------------------------------------------------------------------------
   1. Shared Handheld Visual System, 44px Touch Targets & Scotopic Palette
   ---------------------------------------------------------------------------- */
html.yasd-handheld body {
    touch-action: manipulation;
    overscroll-behavior: none;
}

/* Never leak 3D console plates/quick-slots over Splash, Main Menu, Terminal, or Death */
html.yasd-handheld body.terminal-active #app-container #handheld-deck-plate,
html.yasd-handheld body.terminal-mode-active #app-container #handheld-deck-plate,
html.yasd-handheld #app-container:has(#splash-overlay:not(.hidden)) #handheld-deck-plate,
html.yasd-handheld #app-container:has(#main-menu-overlay:not(.hidden)) #handheld-deck-plate,
html.yasd-handheld #app-container:has(#terminal-container:not(.hidden)) #handheld-deck-plate,
html.yasd-handheld #app-container:has(#death-modal:not(.hidden)) #handheld-deck-plate,
html.yasd-handheld body.terminal-active #app-container #quick-slot-bar,
html.yasd-handheld body.terminal-mode-active #app-container #quick-slot-bar,
html.yasd-handheld #app-container:has(#splash-overlay:not(.hidden)) #quick-slot-bar,
html.yasd-handheld #app-container:has(#main-menu-overlay:not(.hidden)) #quick-slot-bar,
html.yasd-handheld #app-container:has(#terminal-container:not(.hidden)) #quick-slot-bar,
html.yasd-handheld #app-container:has(#death-modal:not(.hidden)) #quick-slot-bar,
html.yasd-handheld #app-container:has(#terminal-container:not(.hidden)) #handheld-autonav-stop {
    display: none !important;
}

/* Never render keyboard hints or cluster dividers inside handheld deck buttons */
html.yasd-handheld #app-container #action-bar .action-btn kbd,
html.yasd-handheld #app-container #action-bar .act-btn kbd,
html.yasd-handheld #app-container #action-bar .action-cluster-sep,
html.yasd-handheld #app-container #action-bar #action-bar-drag-handle,
html.yasd-handheld #app-container #hud-footer,
html.yasd-handheld #app-container #hud-footer.hud-status-bar,
html.yasd-handheld #app-container .viewport-edge-turn,
html.yasd-handheld #app-container .streetview-nav-rosette {
    display: none !important;
}

html.yasd-handheld #app-container #top-right-bar #btn-hud-realm,
html.yasd-handheld #app-container #top-right-bar #btn-toggle-chronicle,
html.yasd-handheld #app-container #top-right-bar #btn-toggle-msg-feed,
html.yasd-handheld #app-container #top-right-bar #btn-toggle-minimap,
html.yasd-handheld #app-container #top-right-bar #btn-toggle-hero,
html.yasd-handheld #app-container #top-right-bar #btn-toggle-actions,
html.yasd-handheld #app-container #top-right-bar #sound-control-group #btn-top-music,
html.yasd-handheld #app-container #top-right-bar #sound-control-group .volume-slider-wrap,
html.yasd-handheld #app-container #top-right-bar #sound-control-group #btn-sound-config {
    display: none !important;
}

html.yasd-handheld #app-container #top-right-bar {
    position: fixed !important;
    top: calc(2px + var(--hh-safe-top)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    left: auto !important;
    bottom: auto !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    z-index: 1000 !important;
}

html.yasd-handheld #app-container #top-right-bar #sound-control-group {
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

html.yasd-handheld #app-container #top-right-bar .icon-btn {
    min-width: 34px !important;
    width: auto !important;
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 7px !important;
    background: var(--hh-bg-button) !important;
    background-image: none !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 6px !important;
    color: var(--hh-ink) !important;
    font-size: 12px !important;
    gap: 3px !important;
}

html.yasd-handheld #app-container #top-right-bar .sound-label,
html.yasd-handheld #app-container #top-right-bar .menu-label {
    display: none !important;
}

html.yasd-handheld #app-container #top-message-banner {
    position: fixed !important;
    top: calc(2px + var(--hh-safe-top)) !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: calc(118px + var(--hh-safe-right)) !important;
    width: auto !important;
    max-width: none !important;
    height: 30px !important;
    min-height: 30px !important;
    margin: 0 !important;
    padding: 0 10px !important;
    display: flex !important;
    align-items: center !important;
    background: var(--hh-bg-surface) !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 6px !important;
    color: var(--hh-ink) !important;
    font-size: 12px !important;
    z-index: 28 !important;
}

html.yasd-handheld #app-container #top-message-banner #message-text {
    color: var(--hh-ink) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
}

/* Primary Console Panels (Higher Specificity than hud-skin & dungeon.css) */
html.yasd-handheld #app-container #action-bar,
html.yasd-handheld #app-container #touch-controls,
html.yasd-handheld #app-container #char-panel,
html.yasd-handheld #app-container #minimap-container {
    background-color: var(--hh-bg-surface) !important;
    background-image: none !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    transform: none !important;
    pointer-events: auto !important;
}

/* Force Closed Action Bar to Exact 7 Consistent Buttons Across Portrait & Landscape */
html.yasd-handheld #app-container #action-bar:not(.drawer-open) .action-btn {
    display: none !important;
}

html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-hero-action,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-inventory,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-equipment,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-quaff,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-explore,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-rest,
html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-action-more {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 4px 5px !important;
    background: var(--hh-bg-button) !important;
    background-image: none !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 8px !important;
    color: var(--hh-ink) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    line-height: 1.1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
    touch-action: manipulation !important;
}

html.yasd-handheld #app-container #action-bar:not(.drawer-open) #btn-hero-action {
    grid-column: 1 / -1 !important;
    background: linear-gradient(180deg, #362912 0%, #231a0b 100%) !important;
    border-color: var(--hh-border-strong) !important;
    color: #f3e6c2 !important;
    font-size: 13px !important;
}

html.yasd-handheld #app-container #action-bar .action-btn.smart-low-hp {
    background: linear-gradient(180deg, #691b22 0%, #441016 100%) !important;
    border-color: #f2848e !important;
    color: #f7e6e6 !important;
}

html.yasd-handheld #app-container #action-bar #btn-action-more {
    background: #232b3d !important;
    border-color: rgba(223, 184, 88, 0.56) !important;
    color: var(--hh-gold) !important;
}

/* 4-Slot Smart Quick Belt */
html.yasd-handheld #app-container #quick-slot-bar {
    display: grid !important;
    gap: 5px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: auto !important;
    z-index: 35 !important;
}

html.yasd-handheld #app-container #quick-slot-bar .quick-slot-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 100% !important;
    height: 100% !important;
    min-width: 44px !important;
    min-height: 42px !important;
    padding: 2px 6px !important;
    background: var(--hh-bg-button) !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 8px !important;
    color: var(--hh-ink) !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    overflow: hidden !important;
    touch-action: manipulation !important;
}

html.yasd-handheld #app-container #quick-slot-bar .quick-slot-btn.is-depleted {
    opacity: 0.72 !important;
    color: #aeb8cc !important;
}

html.yasd-handheld #app-container #quick-slot-bar .qs-hotkey {
    display: none !important;
}

html.yasd-handheld #app-container #quick-slot-bar .qs-label {
    max-width: 58px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* D-Pad Visuals & Always-Visible Turn Wings */
html.yasd-handheld #app-container #touch-controls .dpad-header-bar {
    display: none !important;
}

html.yasd-handheld #app-container #touch-controls {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    padding: 5px !important;
    margin: 0 !important;
    overflow: hidden !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-turn-wings {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(40px, 1fr)) !important;
    gap: 4px !important;
    width: 100% !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-grid,
html.yasd-handheld #app-container #touch-controls.dpad-collapsed .dpad-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(40px, 1fr)) !important;
    grid-template-rows: repeat(3, minmax(40px, 1fr)) !important;
    gap: 4px !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-btn {
    width: 100% !important;
    height: 100% !important;
    min-width: 40px !important;
    min-height: 40px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--hh-bg-button) !important;
    background-image: none !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 8px !important;
    color: var(--hh-ink) !important;
    font-family: "Segoe UI Symbol", "Apple Symbols", system-ui, sans-serif !important;
    font-variant-emoji: text !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    line-height: 1 !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
    touch-action: none !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-turn-btn,
html.yasd-handheld #app-container #touch-controls .dpad-run-toggle {
    min-height: 44px !important;
    font-size: 11px !important;
    gap: 1px !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-turn-symbol {
    font-size: 15px !important;
    color: var(--hh-gold) !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-turn-text,
html.yasd-handheld #app-container #touch-controls .dpad-run-text {
    font-size: 9.5px !important;
    color: var(--hh-ink-muted) !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-btn.is-slide-active {
    background: #2f3b52 !important;
    border-color: var(--hh-gold) !important;
    color: var(--hh-gold) !important;
}

html.yasd-handheld #app-container #touch-controls .dpad-btn .diag-num,
html.yasd-handheld #app-container #touch-controls .dpad-btn .dpad-sub-lbl {
    display: none !important;
}

/* Compact Character Capsule (Tap to Expand Full Sheet) */
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 3px !important;
    padding: 4px 8px !important;
    overflow: hidden !important;
    cursor: pointer !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .char-panel-header {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 15px !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-realm-crest,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-sub-meta,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .char-window-actions,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .gauge-exp,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #stats-strip,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-resist-strip,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-status-effects,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-extended-drawer,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-resize-handle {
    display: none !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #char-title {
    font-size: 11px !important;
    line-height: 1.1 !important;
    color: var(--hh-gold) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .vitals-vials-row {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 5px !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .gauge-hp,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .gauge-sp {
    position: relative !important;
    height: 16px !important;
    min-height: 16px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .gauge-header {
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 0 3px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    font-size: 10px !important;
    font-weight: 800 !important;
    color: var(--hh-ink) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9) !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #hp-label,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #sp-label {
    display: none !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #hp-text,
html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #sp-text {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    font-size: 10px !important;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #hp-text::before {
    content: '♥ ';
    color: #f4a4a8;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) #sp-text::before {
    content: '✦ ';
    color: #93c5fd;
}

html.yasd-handheld #app-container #char-panel:not(.handheld-char-expanded) .gauge-track {
    position: absolute !important;
    inset: 0 !important;
    height: 100% !important;
    z-index: 1 !important;
}

html.yasd-handheld #app-container #char-panel.handheld-char-expanded {
    position: fixed !important;
    top: calc(36px + var(--hh-safe-top)) !important;
    left: calc(8px + var(--hh-safe-left)) !important;
    right: calc(8px + var(--hh-safe-right)) !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    max-height: 76dvh !important;
    overflow-y: auto !important;
    z-index: 75 !important;
    padding: 10px 12px !important;
}

html.yasd-handheld #app-container #char-panel.handheld-char-expanded #stats-strip,
html.yasd-handheld #app-container #char-panel.handheld-char-expanded #char-resist-strip {
    display: flex !important;
}

/* Corner Radar & 1-Tap Expanded Tactical Map Modal */
html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) {
    padding: 2px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    cursor: pointer !important;
}

html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) .minimap-header,
html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) #minimap-controls-bar,
html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) #camera-tilt-bar,
html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) #mobile-map-zoom-group,
html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) #map-resize-handle {
    display: none !important;
}

html.yasd-handheld #app-container #minimap-container:not(.handheld-map-expanded) #minimap-canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
}

html.yasd-handheld #app-container #minimap-container.handheld-map-expanded {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    width: min(320px, calc(100vw - 24px)) !important;
    height: auto !important;
    padding: 8px !important;
    flex-direction: column !important;
    gap: 6px !important;
    z-index: 78 !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.95) !important;
}

html.yasd-handheld #app-container #minimap-container.handheld-map-expanded #minimap-canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 48dvh !important;
}

html.yasd-handheld #app-container #minimap-container.handheld-map-expanded #mobile-map-zoom-group {
    display: flex !important;
    position: static !important;
    transform: none !important;
    gap: 8px !important;
    justify-content: center !important;
}

html.yasd-handheld #app-container #minimap-container.handheld-map-expanded .mobile-map-btn,
html.yasd-handheld #app-container #minimap-container.handheld-map-expanded #btn-minimap-close {
    min-width: 44px !important;
    min-height: 44px !important;
    width: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
}

/* ----------------------------------------------------------------------------
   2. PORTRAIT CONSOLE (Split-Stage Horizon: Top Unobstructed 3D, Bottom Deck)
   ---------------------------------------------------------------------------- */
html.yasd-handheld.is-portrait #app-container #viewport-canvas,
html.yasd-handheld.is-portrait #app-container #dungeon-vignette {
    position: fixed !important;
    top: calc(98px + var(--hh-safe-top)) !important;
    left: 0 !important;
    right: auto !important;
    bottom: auto !important;
    width: 100vw !important;
    height: calc(100dvh - 436px - var(--hh-safe-top) - var(--hh-safe-bottom)) !important;
}

html.yasd-handheld.is-portrait #app-container #diegetic-reticle {
    top: calc(98px + var(--hh-safe-top) + (100dvh - 436px - var(--hh-safe-top) - var(--hh-safe-bottom)) * 0.5) !important;
}

html.yasd-handheld.is-portrait #app-container #handheld-deck-plate {
    display: block !important;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: calc(338px + var(--hh-safe-bottom)) !important;
    background: var(--hh-bg-deck) !important;
    border-top: 1px solid var(--hh-border-strong) !important;
    z-index: 8 !important;
    pointer-events: none !important;
}

html.yasd-handheld.is-portrait #app-container #char-panel:not(.handheld-char-expanded) {
    position: fixed !important;
    top: calc(36px + var(--hh-safe-top)) !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: calc(70px + var(--hh-safe-right)) !important;
    bottom: auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 58px !important;
    z-index: 30 !important;
}

html.yasd-handheld.is-portrait #app-container #minimap-container:not(.handheld-map-expanded) {
    position: fixed !important;
    top: calc(36px + var(--hh-safe-top)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    left: auto !important;
    bottom: auto !important;
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    z-index: 30 !important;
}

html.yasd-handheld.is-portrait #app-container #quick-slot-bar {
    position: fixed !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    top: auto !important;
    bottom: calc(286px + var(--hh-safe-bottom)) !important;
    height: 46px !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    z-index: 35 !important;
}

html.yasd-handheld.is-portrait #app-container #touch-controls,
html.yasd-handheld.is-portrait #app-container #touch-controls.dpad-collapsed {
    position: fixed !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: auto !important;
    top: auto !important;
    bottom: calc(6px + var(--hh-safe-bottom)) !important;
    width: 174px !important;
    height: 274px !important;
    max-width: 46vw !important;
    z-index: 32 !important;
}

html.yasd-handheld.is-portrait #app-container #action-bar:not(.drawer-open) {
    position: fixed !important;
    left: calc(186px + var(--hh-safe-left)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    top: auto !important;
    bottom: calc(6px + var(--hh-safe-bottom)) !important;
    width: auto !important;
    max-width: none !important;
    height: 274px !important;
    padding: 5px !important;
    margin: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: 52px repeat(3, minmax(46px, 1fr)) !important;
    gap: 5px !important;
    z-index: 35 !important;
}

/* ----------------------------------------------------------------------------
   3. LANDSCAPE CONSOLE (Steam Deck / Switch Side-Grip Split, 92% Stage Height)
   ---------------------------------------------------------------------------- */
html.yasd-handheld.is-landscape #app-container #viewport-canvas,
html.yasd-handheld.is-landscape #app-container #dungeon-vignette {
    position: fixed !important;
    top: calc(32px + var(--hh-safe-top)) !important;
    left: calc(174px + var(--hh-safe-left)) !important;
    right: auto !important;
    bottom: auto !important;
    width: calc(100vw - 362px - var(--hh-safe-left) - var(--hh-safe-right)) !important;
    height: calc(100dvh - 32px - var(--hh-safe-top) - var(--hh-safe-bottom)) !important;
}

html.yasd-handheld.is-landscape #app-container #diegetic-reticle {
    left: calc(174px + var(--hh-safe-left) + (100vw - 362px - var(--hh-safe-left) - var(--hh-safe-right)) * 0.5) !important;
    top: calc(32px + var(--hh-safe-top) + (100dvh - 32px - var(--hh-safe-top) - var(--hh-safe-bottom)) * 0.5) !important;
}

html.yasd-handheld.is-landscape #app-container #handheld-deck-plate {
    display: none !important;
}

html.yasd-handheld.is-landscape #app-container #char-panel:not(.handheld-char-expanded) {
    position: fixed !important;
    top: calc(34px + var(--hh-safe-top)) !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: auto !important;
    bottom: auto !important;
    width: 164px !important;
    min-width: 164px !important;
    max-width: 164px !important;
    height: 50px !important;
    z-index: 30 !important;
}

html.yasd-handheld.is-landscape #app-container #touch-controls,
html.yasd-handheld.is-landscape #app-container #touch-controls.dpad-collapsed {
    position: fixed !important;
    top: calc(88px + var(--hh-safe-top)) !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: auto !important;
    bottom: calc(6px + var(--hh-safe-bottom)) !important;
    width: 164px !important;
    height: auto !important;
    z-index: 32 !important;
}

html.yasd-handheld.is-landscape #app-container #minimap-container:not(.handheld-map-expanded) {
    position: fixed !important;
    top: calc(34px + var(--hh-safe-top)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    left: auto !important;
    bottom: auto !important;
    width: 176px !important;
    min-width: 176px !important;
    max-width: 176px !important;
    height: 50px !important;
    min-height: 50px !important;
    padding: 2px 8px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    z-index: 30 !important;
}

html.yasd-handheld.is-landscape #app-container #minimap-container:not(.handheld-map-expanded) #minimap-canvas {
    width: 44px !important;
    height: 44px !important;
    flex: 0 0 44px !important;
}

html.yasd-handheld.is-landscape #app-container #minimap-container:not(.handheld-map-expanded)::after {
    content: 'RADAR ⛶';
    font-size: 10.5px;
    font-weight: 700;
    color: var(--hh-ink-muted);
    letter-spacing: 0.5px;
}

html.yasd-handheld.is-landscape #app-container #action-bar:not(.drawer-open) {
    position: fixed !important;
    top: calc(88px + var(--hh-safe-top)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    left: auto !important;
    bottom: calc(100px + var(--hh-safe-bottom)) !important;
    width: 176px !important;
    max-width: 176px !important;
    height: auto !important;
    padding: 4px !important;
    margin: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(4, minmax(40px, 1fr)) !important;
    gap: 4px !important;
    z-index: 35 !important;
}

html.yasd-handheld.is-landscape #app-container #quick-slot-bar {
    position: fixed !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    left: auto !important;
    bottom: calc(6px + var(--hh-safe-bottom)) !important;
    width: 176px !important;
    height: 90px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-template-rows: repeat(2, minmax(40px, 1fr)) !important;
    gap: 4px !important;
    z-index: 35 !important;
}

html.yasd-handheld.is-landscape #app-container #quick-slot-bar .quick-slot-btn {
    padding: 2px 4px !important;
    font-size: 10.5px !important;
}

/* ----------------------------------------------------------------------------
   4. Expanded Action Sheet (.drawer-open), Prompt Mirror & Bottom Sheets
   ---------------------------------------------------------------------------- */
html.yasd-handheld #app-container #action-bar.drawer-open {
    position: fixed !important;
    left: calc(8px + var(--hh-safe-left)) !important;
    right: calc(8px + var(--hh-safe-right)) !important;
    bottom: calc(8px + var(--hh-safe-bottom)) !important;
    top: auto !important;
    width: auto !important;
    max-width: 640px !important;
    height: auto !important;
    max-height: 68dvh !important;
    overflow-y: auto !important;
    margin: 0 auto !important;
    padding: 10px !important;
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)) !important;
    gap: 6px !important;
    background: var(--hh-bg-deck) !important;
    border: 1.5px solid var(--hh-border-strong) !important;
    border-radius: 12px !important;
    z-index: 60 !important;
}

html.yasd-handheld #app-container #action-bar.drawer-open .action-btn:not([data-realm-hidden="1"]):not([data-context-hidden="1"]):not([style*="display: none"]):not([style*="display:none"]),
html.yasd-handheld #app-container #action-bar.drawer-open #btn-cast:not([data-realm-hidden="1"]):not([style*="display: none"]):not([style*="display:none"]),
html.yasd-handheld #app-container #action-bar.drawer-open #btn-command-palette,
html.yasd-handheld #app-container #action-bar.drawer-open #btn-action-more {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 5px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    height: 44px !important;
    font-size: 11.5px !important;
    background: var(--hh-bg-button) !important;
    background-image: none !important;
    color: var(--hh-ink) !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 8px !important;
}

html.yasd-handheld #app-container #action-bar.drawer-open #btn-stair:not(.stair-active),
html.yasd-handheld #app-container #action-bar.drawer-open .context-tile-btn.hidden {
    display: none !important;
}

html.yasd-handheld #app-container #action-bar.drawer-open #btn-action-more {
    grid-column: 1 / -1 !important;
    background: #3a1a20 !important;
    border-color: #d9777f !important;
    color: #f3e0e0 !important;
}

/* Thumb-Docked Prompt Mirror (zero mid-screen obstruction) */
html.yasd-handheld #app-container #prompt-mirror:not([hidden]):not(.hidden) {
    position: fixed !important;
    top: auto !important;
    transform: none !important;
    margin: 0 !important;
    max-width: none !important;
    max-height: 42dvh !important;
    overflow-y: auto !important;
    background: var(--hh-bg-deck) !important;
    border: 1.5px solid var(--hh-border-strong) !important;
    border-radius: 10px !important;
    color: var(--hh-ink) !important;
    z-index: 44 !important;
}

html.yasd-handheld.is-portrait #app-container #prompt-mirror:not([hidden]):not(.hidden) {
    left: calc(6px + var(--hh-safe-left)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    bottom: calc(340px + var(--hh-safe-bottom)) !important;
    width: auto !important;
}

html.yasd-handheld.is-landscape #app-container #prompt-mirror:not([hidden]):not(.hidden) {
    left: calc(176px + var(--hh-safe-left)) !important;
    right: calc(188px + var(--hh-safe-right)) !important;
    bottom: calc(8px + var(--hh-safe-bottom)) !important;
    width: auto !important;
}

html.yasd-handheld #app-container #prompt-mirror button {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 13px !important;
}

/* Touch Bottom-Sheet Styling for ItemSheet & Quick-Slot Binder */
html.yasd-handheld #item-sheet[open] {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    max-height: 82dvh !important;
    border-radius: 14px 14px 0 0 !important;
    background: var(--hh-bg-deck) !important;
    background-image: none !important;
    padding: 12px 12px max(16px, var(--hh-safe-bottom)) !important;
    z-index: 88 !important;
}

html.yasd-handheld .item-sheet-tab,
html.yasd-handheld .item-sheet-close,
html.yasd-handheld .item-verb-btn,
html.yasd-handheld .item-sheet-crt-btn {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 6px 12px !important;
    font-size: 12.5px !important;
}

html.yasd-handheld .item-sheet-crt-btn {
    background: var(--hh-bg-button) !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 6px !important;
    color: var(--hh-gold) !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    margin-left: auto !important;
    margin-right: 6px !important;
}

html.yasd-handheld #app-container #quick-slot-popover.is-open {
    position: fixed !important;
    top: auto !important;
    bottom: calc(12px + var(--hh-safe-bottom)) !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100vw - 16px) !important;
    max-width: 520px !important;
    max-height: 76dvh !important;
    overflow-y: auto !important;
    background: var(--hh-bg-deck) !important;
    z-index: 90 !important;
}

html.yasd-handheld #app-container #quick-slot-popover .qs-candidate-item,
html.yasd-handheld #app-container #quick-slot-popover .qs-slot-tab {
    min-height: 44px !important;
    font-size: 12.5px !important;
}

/* Concentric Radial Marking Menu Styling */
html.yasd-handheld .radial-menu-overlay {
    z-index: 92 !important;
    background: rgba(8, 10, 15, 0.72) !important;
}

html.yasd-handheld .radial-menu-disc {
    position: relative !important;
    width: 280px !important;
    height: 280px !important;
    border-radius: 50% !important;
    background: radial-gradient(circle, rgba(24, 29, 39, 0.96) 0%, rgba(16, 20, 28, 0.98) 100%) !important;
    border: 2px solid var(--hh-border-strong) !important;
    box-shadow: 0 20px 52px rgba(0, 0, 0, 0.9) !important;
}

html.yasd-handheld .radial-wedge {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    width: 78px !important;
    height: 54px !important;
    transform: translate(-50%, -50%) rotate(var(--wedge-angle, 0deg)) translateY(-96px) rotate(calc(-1 * var(--wedge-angle, 0deg))) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2px !important;
    background: var(--hh-bg-button) !important;
    border: 1px solid var(--hh-border) !important;
    border-radius: 10px !important;
    color: var(--hh-ink) !important;
    font-size: 10.5px !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: 3px !important;
}

html.yasd-handheld .radial-wedge.wedge-selected {
    background: #362912 !important;
    border-color: var(--hh-gold) !important;
    color: #f3e6c2 !important;
    box-shadow: 0 0 14px rgba(223, 184, 88, 0.55) !important;
}

html.yasd-handheld .radial-wedge.wedge-disabled {
    opacity: 0.35 !important;
}

html.yasd-handheld .radial-wedge .radial-key {
    display: none !important;
}

/* Auto-Walk Floating Stop Pill */
html.yasd-handheld #app-container #handheld-autonav-stop {
    display: none;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(344px + var(--hh-safe-bottom));
    min-height: 44px;
    padding: 8px 18px;
    border-radius: 999px;
    background: #7c2229;
    border: 1.5px solid #f2848e;
    color: #f4ecec;
    font-weight: 700;
    font-size: 13px;
    z-index: 48;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.75);
}

html.yasd-handheld.is-landscape #app-container #handheld-autonav-stop {
    bottom: calc(14px + var(--hh-safe-bottom));
}

html.yasd-handheld #app-container #handheld-autonav-stop.is-active {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Message Feed Expanded Drawer */
html.yasd-handheld #app-container #message-feed-window:not(.mobile-expanded) {
    display: none !important;
}

html.yasd-handheld #app-container #message-feed-window.mobile-expanded {
    display: flex !important;
    position: fixed !important;
    top: calc(36px + var(--hh-safe-top)) !important;
    left: calc(6px + var(--hh-safe-left)) !important;
    right: calc(6px + var(--hh-safe-right)) !important;
    bottom: auto !important;
    width: auto !important;
    max-width: none !important;
    height: 60dvh !important;
    z-index: 80 !important;
}

/* Handheld First-Run Coachmark Strip (Clean Horizontal Stage Header, Zero Overlap) */
html.yasd-handheld .ftue-coachmark-pill {
    border-radius: 10px !important;
    padding: 6px 10px !important;
    font-size: 11.5px !important;
    line-height: 1.25 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    z-index: 65 !important;
    background: var(--hh-bg-deck) !important;
    border: 1px solid var(--hh-border-strong) !important;
    color: var(--hh-ink) !important;
}

html.yasd-handheld.is-portrait .ftue-coachmark-pill {
    top: calc(104px + var(--hh-safe-top)) !important;
    left: calc(8px + var(--hh-safe-left)) !important;
    right: calc(8px + var(--hh-safe-right)) !important;
}

html.yasd-handheld.is-landscape .ftue-coachmark-pill {
    top: calc(36px + var(--hh-safe-top)) !important;
    left: calc(180px + var(--hh-safe-left)) !important;
    right: calc(188px + var(--hh-safe-right)) !important;
}

html.yasd-handheld .ftue-coachmark-btn,
html.yasd-handheld .ftue-coachmark-dismiss {
    min-width: 40px !important;
    min-height: 38px !important;
    flex-shrink: 0 !important;
}

/* Coarse Tablet Touch Target Guarantee (device-tablet only; 0 Desktop Impact) */
html.device-tablet #app-container #action-bar .action-btn,
html.device-tablet #app-container #action-bar .act-btn,
html.device-tablet #app-container #touch-controls .dpad-btn {
    min-width: 40px !important;
    min-height: 40px !important;
    height: 40px !important;
}

html.device-tablet #app-container #action-bar {
    margin-bottom: 4px !important;
}
