/* New controls stay absent on desktop. Enhanced layout is coarse-phone only. */
.dkc-phone-only {display: none;}
.dkc-phone-safe-area {position: fixed; visibility: hidden; pointer-events: none; width: 0; height: 0; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);}
@media (max-width: 650px) and (pointer: coarse), (max-width: 1100px) and (max-height: 650px) and (pointer: coarse) {
  body.dkc-phone {position: fixed; inset: 0; overflow: hidden; font-family: system-ui, sans-serif; --phone-pad: clamp(44px, 12.5vw, 54px); --phone-action: clamp(52px, 15vw, 64px);}
  body.dkc-phone #portrait {display: none !important;}
  body.dkc-phone .dkc-phone-only {display: block;}
  body.dkc-phone button, body.dkc-phone select {min-width: 44px; min-height: 44px; touch-action: manipulation;}
  body.dkc-phone button:focus-visible {outline: 3px solid #ffe09b; outline-offset: 2px;}
  body.dkc-phone #hud,
  body.dkc-phone #hud[hidden] {
    position: fixed; display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: start; gap: 5px 8px;
    left: calc(var(--dkc-phone-left, 0px) + env(safe-area-inset-left) + 6px);
    right: auto; top: calc(var(--dkc-phone-top, 0px) + env(safe-area-inset-top) + 6px);
    width: calc(var(--dkc-phone-width, 100vw) - env(safe-area-inset-left) - env(safe-area-inset-right) - 12px);
    z-index: 3; pointer-events: none;
  }
  body.dkc-phone #hud[hidden] {visibility: hidden;}
  body.dkc-phone #status {font: 600 12px/1.35 system-ui; padding: 6px 8px; min-height: 44px; border-radius: 8px; background: #052024; overflow-wrap: anywhere;}
  body.dkc-phone #pauseButton {height: 44px; width: 44px; padding: 5px; font: 700 22px system-ui; pointer-events: auto;}
  body.dkc-phone #phoneZoomBar {grid-column: 1 / -1;}
  body.dkc-phone .phone-zoom-controls {display: flex; align-items: center; gap: 8px; pointer-events: auto;}
  body.dkc-phone .phone-zoom-controls button {height: 44px; padding: 7px 12px; font: 600 13px/1.2 system-ui; flex: 0 0 auto; background: #143a38;}
  body.dkc-phone .phone-zoom-controls output {flex: 1; min-width: 48px; color: #ffe09b; font: 700 14px/1 system-ui; font-variant-numeric: tabular-nums; text-align: center;}
  body.dkc-phone #phoneBossHud {grid-column: 1 / -1; min-width: 0; padding: 4px 8px; background: #052024; border: 1px solid #c9a456; border-radius: 7px; font: 600 12px/1.25 system-ui; text-align: center; color: #ffe09b;}
  body.dkc-phone #phoneBossHud[hidden] {display: none;}
  body.dkc-phone #touch {
    position: fixed; display: flex; align-items: center; justify-content: space-between; gap: 10px;
    left: calc(var(--dkc-phone-left, 0px) + env(safe-area-inset-left) + 8px); right: auto;
    top: calc(var(--dkc-phone-top, 0px) + var(--dkc-phone-height, 100dvh) - env(safe-area-inset-bottom) - 6px); bottom: auto;
    width: calc(var(--dkc-phone-width, 100vw) - env(safe-area-inset-left) - env(safe-area-inset-right) - 16px);
    height: calc(var(--phone-pad) * 2 + 4px);
    transform: translateY(-100%);
    z-index: 3; visibility: hidden;
  }
  body.dkc-phone.playing #touch {display: flex; visibility: visible;}
  body.dkc-phone #touch .dpad {display: grid; grid-template-columns: repeat(3, var(--phone-pad)); gap: 4px; align-items: center;}
  body.dkc-phone #touch .dpad > div {display: flex; flex-direction: column; gap: 4px;}
  body.dkc-phone #touch button {width: var(--phone-pad); height: var(--phone-pad); min-width: 44px; min-height: 44px; padding: 2px; font: 700 12px/1.15 system-ui; border-radius: 10px; background: #143a38; border-color: #a9bd9c; box-shadow: none; touch-action: none;}
  body.dkc-phone #touch .actions {display: grid; grid-template-columns: repeat(2, var(--phone-action)); gap: 4px; align-items: center;}
  body.dkc-phone #touch .actions button {width: var(--phone-action);}
  body.dkc-phone #touch .actions button:last-child {height: var(--phone-pad); width: var(--phone-action); border-radius: 10px; background: #a88434; color: #fff7dc;}
  body.dkc-phone #touch button.held {background: #e9c169; color: #082927; border-color: #ffe5ad;}
  body.dkc-phone #toast {z-index: 4; top: calc(var(--dkc-phone-top, 0px) + 27%); max-width: calc(var(--dkc-phone-width, 100vw) - 28px); padding: 8px 12px; font: 13px/1.35 system-ui;}
  body.dkc-phone .panel {
    position: fixed; inset: auto;
    left: calc(var(--dkc-phone-left, 0px) + env(safe-area-inset-left));
    top: calc(var(--dkc-phone-top, 0px) + env(safe-area-inset-top));
    width: calc(var(--dkc-phone-width, 100vw) - env(safe-area-inset-left) - env(safe-area-inset-right));
    height: calc(var(--dkc-phone-height, 100dvh) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    min-height: 0; padding: 8px; overflow: hidden; z-index: 5; touch-action: pan-y;
  }
  body.dkc-phone .sheet {width: 100%; max-height: 100%; min-height: 0; padding: 17px; border-radius: 12px; overflow-y: auto; overflow-x: hidden; touch-action: pan-y; overscroll-behavior: contain; scroll-padding: 12px;}
  body.dkc-phone .sheet button {font-family: system-ui;}
  body.dkc-phone .hero h1 {font-size: clamp(32px, 8vw, 48px); line-height: 1;}
  body.dkc-phone h2 {font-size: 27px;}
  body.dkc-phone p {font: 15px/1.45 system-ui;}
  body.dkc-phone .eyebrow {font-size: 11px; letter-spacing: .15em;}
  body.dkc-phone .slots {grid-template-columns: 1fr; gap: 8px; margin: 14px 0;}
  body.dkc-phone .slot {min-height: 62px; padding: 9px 12px;}
  body.dkc-phone .slot strong, body.dkc-phone .slot small {margin: 3px 0;}
  body.dkc-phone .row {gap: 8px; margin: 12px 0;}
  body.dkc-phone .row button {font-size: 14px; padding: 9px 12px;}
  body.dkc-phone .worlds {grid-template-columns: 1fr; gap: 12px;}
  body.dkc-phone .world button {min-height: 44px; font-size: 14px; padding: 8px;}
  body.dkc-phone .settings {grid-template-columns: 1fr; gap: 10px;}
  body.dkc-phone .settings label {font: 14px/1.35 system-ui; min-height: 44px;}
  body.dkc-phone .settings input[type=range] {min-width: 95px; width: 45%; height: 44px; touch-action: pan-x;}
  body.dkc-phone .settings input[type=checkbox] {width: 22px; height: 22px; flex-shrink: 0;}
  body.dkc-phone .settings select {max-width: 45%; padding: 7px;}
  body.dkc-phone .controls {font-size: 14px; line-height: 1.5;}
  body.dkc-phone .remap {gap: 7px;}
  body.dkc-phone .remap button {font-size: 13px; padding: 8px 10px;}
  body.dkc-phone .phone-view-settings {grid-column: 1 / -1; border: 1px solid #9eb38b77; border-radius: 10px; padding: 12px; margin: 14px 0; background: #082828;}
  body.dkc-phone .phone-view-settings h3 {font-size: 18px; color: #ffe09b;}
  body.dkc-phone .phone-view-settings p {font-size: 13px; margin: 6px 0 10px;}
}
@media (max-width: 1100px) and (max-height: 650px) and (orientation: landscape) and (pointer: coarse) {
  body.dkc-phone {--phone-pad: 44px; --phone-action: 56px;}
  body.dkc-phone #hud, body.dkc-phone #hud[hidden] {grid-template-columns: minmax(0, 1fr) 254px 44px; gap: 5px 8px;}
  body.dkc-phone #status {grid-column: 1; grid-row: 1; font-size: 12px;}
  body.dkc-phone #pauseButton {grid-column: 3; grid-row: 1;}
  body.dkc-phone #phoneZoomBar {grid-column: 2; grid-row: 1;}
  body.dkc-phone .phone-zoom-controls {gap: 6px;}
  body.dkc-phone #phoneBossHud {grid-row: 2;}
  body.dkc-phone #touch .actions {grid-template-columns: repeat(4, var(--phone-action)); gap: 6px;}
  body.dkc-phone #touch .actions button:last-child {height: 56px;}
  body.dkc-phone .slots, body.dkc-phone .worlds {grid-template-columns: repeat(3, minmax(0, 1fr));}
  body.dkc-phone .settings {grid-template-columns: 1fr 1fr;}
  body.dkc-phone .sheet {padding: 14px 18px;}
}
