.touch-controls { display: none; }

@media (pointer: coarse) {
  .workstation {
    --shell: #c8c5cb;
    --shell-edge: #8f8a9b;
    --plastic: linear-gradient(100deg, #e0dde3, var(--shell) 66%, #beb9c5);
    --ink: #302449;
    --screen-gutter: clamp(3px, 1vw, 7px);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
    justify-items: stretch;
    align-content: stretch;
    overscroll-behavior: none;
    background: var(--plastic);
  }

  .workstation .room, .workstation .power, .workstation .sticky-note,
  .workstation .desk-keys, .workstation .desk-tools { display: none; }

  .workstation .desk {
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    width: 100%;
    height: 100%;
    min-height: 0;
    max-width: none;
    aspect-ratio: auto;
    margin: 0;
    padding: max(var(--screen-gutter), env(safe-area-inset-top))
      max(var(--screen-gutter), env(safe-area-inset-right))
      0 max(var(--screen-gutter), env(safe-area-inset-left));
  }

  .workstation .monitor {
    position: relative;
    inset: auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
    border: 2px solid #25272a;
    border-radius: 6px;
    background: #161d12;
    box-shadow: 0 0 0 1px #626272, inset 0 0 12px #040703;
  }

  .workstation .glass { inset: 0; }

  .workstation .game-menu { padding-inline: 6cqw; }

  .touch-controls {
    --pad: #2b2931;
    --pad-edge: #18161d;
    --switch-return: 95ms cubic-bezier(.18, .71, .4, 1);
    --switch-light: #ffe190;
    --arm: clamp(34px, 10.7vmin, 46px);
    position: relative;
    isolation: isolate;
    z-index: 6;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(122px, 1fr);
    grid-template-areas:
      "brand utilities"
      "move action";
    justify-items: center;
    align-items: center;
    width: 100%;
    padding: 3px max(11px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom)) max(11px, env(safe-area-inset-left));
    row-gap: 6px;
    border-top: 1px solid #f3eff5;
    box-shadow: inset 0 -3px 0 var(--shell-edge), inset 0 -5px 7px #7c728534;
    color: var(--ink);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }

  .touch-controls button {
    color: inherit;
    touch-action: manipulation;
    -webkit-touch-callout: none;
  }

  .touch-controls button:focus-visible {
    z-index: 1;
    outline-color: #442e6d;
    outline-offset: 2px;
  }

  .handheld-brand {
    grid-area: brand;
    place-self: stretch;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding-inline: 3px;
    letter-spacing: 0.06em;
    font: 900 italic clamp(0.59rem, 2.25vw, 0.78rem)/1 Arial, sans-serif;
    white-space: nowrap;
  }
  .handheld-brand-actions { display: flex; align-items: center; gap: 4px; }
  .handheld-brand .handheld-dash {
    padding: 3px 5px;
    min-height: 29px;
    border: 1px solid #83724e;
    border-radius: 5px;
    background: linear-gradient(#ffda77, #e6ab2d);
    box-shadow: inset 0 1px #ffefb2, 0 3px #89744f, 0 4px 3px #40354c50;
    font: 800 0.7rem/1 "Courier New", monospace;
    text-transform: uppercase;
    touch-action: none;
    transition: transform var(--switch-return), box-shadow var(--switch-return);
  }
  .handheld-dash:is(:active, .is-pressed) {
    transform: translateY(3px);
    background: #d69e2c;
    box-shadow: inset 0 2px 4px #7d5c27, 0 1px #8c754e;
    transition-duration: 0ms;
  }

  .handheld-power {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    font: 800 0.63rem/1 "Courier New", monospace;
    text-transform: uppercase;
  }

  .handheld-power span {
    width: 9px;
    height: 9px;
    border: 1px solid #872341;
    border-radius: 50%;
    background: #d45068;
    box-shadow: inset 0 0 2px #ffd9c7, 0 0 4px #f2436d82;
  }

  .handheld-power:is(:active, .is-pressed) span {
    transform: scale(.88);
    background: #fa6785;
    box-shadow: inset 0 1px 2px #783152, 0 0 7px #c83160;
  }

  .handheld-pad {
    grid-area: move;
    position: relative;
    display: grid;
    grid-template-columns: repeat(3, var(--arm));
    grid-template-rows: repeat(3, var(--arm));
    grid-template-areas:
      ". up ."
      "left middle right"
      ". down .";
    isolation: isolate;
    filter: drop-shadow(0 1px 0 #e0d9e8);
  }

  .handheld-pad::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -4px;
    background: #756c82;
    clip-path: polygon(32% 0, 68% 0, 68% 32%, 100% 32%, 100% 68%, 68% 68%, 68% 100%, 32% 100%, 32% 68%, 0 68%, 0 32%, 32% 32%);
    box-shadow: inset 0 3px 7px #2118279e;
    pointer-events: none;
  }

  .handheld-pad button, .pad-center {
    display: grid;
    place-items: center;
    padding: 0;
    min-width: 0;
    min-height: 0;
    background: var(--pad);
    border: 0;
  }

  .handheld-pad button {
    position: relative;
    isolation: isolate;
    background: transparent;
    touch-action: none;
  }

  .handheld-pad button::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(#3d3946, var(--pad) 56%, #282430);
    box-shadow: var(--cap-edge), 0 2px var(--pad-edge);
    pointer-events: none;
    transition: transform var(--switch-return), box-shadow var(--switch-return);
  }

  .handheld-pad button span {
    width: 12px;
    height: 9px;
    background: #a29bae;
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    transform: translate(var(--icon-x, 0px), var(--icon-y, 0px)) rotate(var(--rotation, 0deg));
    pointer-events: none;
  }

  .handheld-pad .pad-up {
    --cap-edge: inset 2px 2px #615b6b, inset -2px 0 var(--pad-edge);
    --travel-y: 4px;
    grid-area: up;
    border-radius: 6px 6px 0 0;
  }

  .handheld-pad .pad-left {
    --cap-edge: inset 2px 2px #615b6b, inset 0 -2px var(--pad-edge);
    --rotation: -90deg;
    --travel-x: 2px;
    grid-area: left;
    border-radius: 6px 0 0 6px;
  }

  .handheld-pad .pad-right {
    --cap-edge: inset 0 2px #615b6b, inset -2px -2px var(--pad-edge);
    --rotation: 90deg;
    --travel-x: -2px;
    grid-area: right;
    border-radius: 0 6px 6px 0;
  }

  .handheld-pad .pad-down {
    --cap-edge: inset 2px 0 #615b6b, inset -2px -2px var(--pad-edge);
    --rotation: 180deg;
    --travel-y: 2px;
    grid-area: down;
    border-radius: 0 0 6px 6px;
  }

  .pad-center {
    grid-area: middle;
    box-shadow: inset 0 -2px #211e27;
    pointer-events: none;
  }

  .pad-center::after {
    content: "";
    width: 16px;
    aspect-ratio: 1;
    background: radial-gradient(circle at 45% 44%, #24222a, #16151a);
    border: 1px solid #3d3946;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px #0b0a10, 0 1px #484552;
    transition: transform var(--switch-return);
  }

  .handheld-pad button:is(:active, .is-pressed) {
    --icon-x: var(--travel-x, 0px);
    --icon-y: var(--travel-y, 3px);
  }

  .handheld-pad button:is(:active, .is-pressed)::before {
    transform: translate(var(--icon-x), var(--icon-y)) scale(.95);
    background: linear-gradient(#2a2632, #34303d);
    box-shadow: inset 0 3px 6px #100b16b3, inset 0 -1px #5a5366, 0 0 0 1px #1c1724;
    transition-duration: 0ms;
  }

  .handheld-pad button:is(:active, .is-pressed) span { background: var(--switch-light); }
  .handheld-pad:has(.pad-up:is(:active, .is-pressed)) { --pivot-y: -1px; }
  .handheld-pad:has(.pad-down:is(:active, .is-pressed)) { --pivot-y: 2px; }
  .handheld-pad:has(.pad-left:is(:active, .is-pressed)) { --pivot-x: -2px; }
  .handheld-pad:has(.pad-right:is(:active, .is-pressed)) { --pivot-x: 2px; }

  .handheld-pad:has(button:is(:active, .is-pressed)) .pad-center::after {
    transform: translate(var(--pivot-x, 0px), var(--pivot-y, 0px)) scale(.9);
    transition-duration: 0ms;
  }

  .handheld-actions {
    --button-size: clamp(49px, 14.5vmin, 70px);
    grid-area: action;
    position: relative;
    display: flex;
    isolation: isolate;
    align-items: flex-start;
    gap: clamp(5px, 2.2vmin, 12px);
    padding: 3px 3px 0;
  }

  .handheld-actions::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: 1px -7px 27px -7px;
    border-radius: 99px;
    border-top: 1px solid #a39ba9;
    background: linear-gradient(170deg, #aaa4b0, #c6c2cc 78%);
    box-shadow: 0 1px 0 #ede9f1;
    transform: rotate(-18deg);
  }

  .handheld-actions .handheld-round {
    display: grid;
    place-items: center;
    width: var(--button-size);
    min-height: var(--button-size);
    gap: 5px;
    padding: 0;
    border: 0;
    background: transparent;
    font-weight: 900;
  }

  .handheld-actions .handheld-use {
    --button-face: #a13365;
    --button-shade: #71193f;
    --button-ink: #f9e1e9;
    margin-top: 18px;
  }

  .handheld-actions .handheld-spray {
    --button-face: #eab940;
    --button-shade: #a47418;
    --button-ink: #362400;
    touch-action: none;
  }

  .handheld-round span {
    display: grid;
    place-items: center;
    width: var(--button-size);
    aspect-ratio: 1;
    border: 1px solid var(--button-shade);
    border-bottom-width: 5px;
    border-radius: 50%;
    background: radial-gradient(circle at 33% 23%, #ffffff36, transparent 48%), var(--button-face);
    box-shadow: 0 2px 0 2px #63546775, 0 4px 5px #3422377a, inset 1px 2px #ffffff52, inset -3px -5px #00000014;
    color: var(--button-ink);
    font: 900 1.02rem/1 Arial, sans-serif;
    pointer-events: none;
    transition: transform var(--switch-return), box-shadow var(--switch-return);
  }

  .handheld-round small {
    color: var(--ink);
    font: 900 0.77rem/1 Arial, sans-serif;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    pointer-events: none;
  }

  .handheld-round:is(:active, .is-pressed) span {
    transform: translateY(5px) scale(.95);
    border-bottom-width: 2px;
    box-shadow: 0 -2px 0 2px #4e3b518a, inset 0 3px 7px #43273593, inset 0 -1px #fff3;
    transition-duration: 0ms;
  }

  .handheld-utilities {
    grid-area: utilities;
    justify-self: end;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }

  .handheld-utilities button {
    display: grid;
    grid-template-rows: 11px auto;
    place-items: center;
    gap: 4px;
    min-width: 39px;
    min-height: 34px;
    padding: 2px 4px;
    border: 0;
    background: transparent;
    font: 900 0.67rem/1 "Courier New", monospace;
    text-transform: uppercase;
  }

  .handheld-utilities button::before {
    content: "";
    display: block;
    width: 29px;
    height: 8px;
    background: linear-gradient(#827b90, #696176);
    border: 1px solid #585064;
    border-radius: 9px;
    transform: rotate(-15deg);
    box-shadow: 0 2px 0 #53495d, 0 3px 2px #51455c70, inset 0 1px #b6aebf;
    transition: transform var(--switch-return), box-shadow var(--switch-return);
  }

  .handheld-utilities button:is(:active, .is-pressed)::before {
    background: #544b63;
    transform: translateY(2px) rotate(-15deg) scale(.93);
    box-shadow: 0 -1px 0 #403648, inset 0 2px 3px #2f293b;
    transition-duration: 0ms;
  }

  .handheld-speaker {
    position: absolute;
    left: 50%;
    bottom: max(11px, env(safe-area-inset-bottom));
    display: flex;
    gap: 4px;
    transform: translateX(-50%) rotate(-24deg);
    pointer-events: none;
  }

  .handheld-speaker i {
    width: 3px;
    height: 16px;
    background: #81778a;
    border-radius: 9px;
    box-shadow: inset 0 1px 2px #585061, 1px 1px #e7e1eb;
  }
}

@media (pointer: coarse) and (orientation: portrait) and (max-width: 360px) {
  .handheld-brand > span, .handheld-speaker { display: none; }
}

@media (pointer: coarse) and (prefers-reduced-motion: reduce) {
  .handheld-brand .handheld-dash, .handheld-pad button::before, .pad-center::after,
  .handheld-round span, .handheld-utilities button::before { transition: none; }
}

@media (pointer: coarse) and (orientation: landscape) {
  .workstation {
    --wing-width: clamp(112px, 17dvh, 174px);
    --west-wing: calc(var(--wing-width) + env(safe-area-inset-left));
    --east-wing: calc(var(--wing-width) + env(safe-area-inset-right));
    grid-template-rows: minmax(0, 1fr);
  }

  .workstation .desk {
    grid-area: 1 / 1;
    padding: max(var(--screen-gutter), env(safe-area-inset-top)) var(--east-wing)
      max(var(--screen-gutter), env(safe-area-inset-bottom)) var(--west-wing);
    box-shadow: inset 0 -3px 0 var(--shell-edge), inset 0 -5px 7px #7c728534;
  }

  .touch-controls {
    --arm: clamp(32px, calc((var(--wing-width) - 14px) / 3), 46px);
    grid-area: 1 / 1;
    align-self: stretch;
    align-content: center;
    grid-template-columns: var(--west-wing) minmax(0, 1fr) var(--east-wing);
    grid-template-areas:
      "brand . utilities"
      "move . action";
    padding: max(var(--screen-gutter), env(safe-area-inset-top)) 0
      max(var(--screen-gutter), env(safe-area-inset-bottom));
    gap: 10px 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    pointer-events: none;
  }

  .handheld-brand, .handheld-pad, .handheld-actions, .handheld-utilities { pointer-events: auto; }

  .handheld-brand, .handheld-pad, .handheld-actions, .handheld-utilities { place-self: center; }
  .handheld-brand, .handheld-pad { margin-left: env(safe-area-inset-left); }
  .handheld-actions, .handheld-utilities { margin-right: env(safe-area-inset-right); }

  .handheld-actions {
    --button-size: clamp(45px, calc((var(--wing-width) - 13px) / 2), 60px);
    padding: 0;
    gap: 3px;
  }

  .handheld-brand {
    justify-content: center;
  }

  .handheld-brand > span, .handheld-speaker { display: none; }
  .handheld-power { min-height: 36px; }

  .handheld-utilities { gap: 0; }
  .handheld-utilities button { min-width: 34px; padding: 2px 1px; }
}
