:root { --app-height: 100dvh; --app-width: 100vw; --viewport-top: 0px; --viewport-left: 0px; }
/* Establish the cabinet height immediately after login, including first paint. */
html:has(body[data-portal="play"] .lobby) { overflow: hidden; overscroll-behavior: none; }
body[data-portal="play"]:has(.lobby) {
  height: var(--app-height); min-height: 0; max-height: var(--app-height);
  overflow: hidden; overscroll-behavior: none;
}
body[data-portal="play"]:has(.lobby) #app { min-height: 0; }
body[data-portal="play"]:has(.player-entry),
body[data-portal="play"]:has(.player-entry) #app,
body[data-portal="play"] .player-entry.vault-scene {
  height: var(--app-height); min-height: 0; overflow: hidden;
}
body[data-portal="play"] .player-entry .keypad-panel { max-height: calc(var(--app-height) - 16px); }

/* PIN entry is a separate blue security panel with its own masked keypad. */
#modal:has(#pin-form) {
  width: min(400px, calc(100vw - 16px)); max-height: calc(var(--app-height) - 16px);
  padding: 0; overflow: auto;
}
#modal:has(#pin-form)::before { border-image-source: url('/assets/skill-panel-blue.png'); border-width: 38px; }
#modal:has(#pin-form) .modal-content { position: relative; padding: 56px 28px 22px; }
#modal:has(#pin-form) .eyebrow { display: none; }
#modal:has(#pin-form) h2 { margin: 0; font-size: 25px; color: #d5f5ff; }
.pin-security-label { color: #88dfff; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .2em; margin-top: 4px; }
.pin-instruction { text-align: center; font-size: 13px; margin: 7px 0 10px; color: #c4d9ef; }
#pin-form { gap: 8px; }
#modal:has(#pin-form) .pin-display {
  text-align: center; letter-spacing: .5em; padding: 0 0 0 .5em; height: 48px;
  font-size: 28px; background: #061b39; border-color: #59bdda; color: #e1f9ff; cursor: default;
}
.pin-keys { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }
body #modal:has(#pin-form) .pin-keys button {
  min-height: 44px; height: clamp(44px,7svh,58px); padding: 0; border: 0; border-radius: 0;
  background: url('/assets/skill-signin-key.png') center/100% 100% no-repeat;
  box-shadow: none; font-size: 24px; font-weight: 800; color: #eefaff;
}
body #modal:has(#pin-form) .pin-keys :is([data-erase],[type="submit"]) { font-size: 13px; }
body #modal:has(#pin-form) .pin-keys [type="submit"] { color: #ffe3a1; }
.pin-secondary-actions {
  position: absolute; inset: 8px 16px auto;
  display: flex; justify-content: space-between; align-items: center;
}
body #modal:has(#pin-form) .pin-secondary-actions button {
  min-height: 44px; padding: 0 8px; border: 0;
  background: transparent; box-shadow: none; color: #d5f5ff;
  font-size: 13px; line-height: 1;
}
body #modal:has(#pin-form) #cancel-pin { width: 44px; padding: 0; font-size: 26px; }
#pin-form .error:empty { display: none; }
#pin-form .error { margin: 0; font-size: 12px; }
@media (max-height: 480px) and (orientation: landscape) {
  #modal:has(#pin-form) { width: min(600px,calc(100vw - 16px)); }
  #modal:has(#pin-form) .modal-content { padding: 52px 26px 18px; }
  #pin-form { grid-template-columns: 1fr 1.4fr; align-items: center; column-gap: 20px; }
  #pin-form .pin-keys { grid-column: 2; grid-row: 1 / span 2; gap: 3px; }
  body #modal:has(#pin-form) .pin-keys button { height: 44px; }
  .pin-instruction { margin: 2px 0 5px; }
}
