html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none;
  background: #03090c; color: #e5eff0; font: 14px system-ui, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
#game-shell { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh;
  overflow: hidden; background: #03090c; }
#game-stage { position: absolute; left: 50%; top: 50%; width: 100%; height: 100%;
  transform: translate(-50%, -50%); }
#game-stage.rotated { transform: translate(-50%, -50%) rotate(90deg); }
#game-area { position: absolute; inset: max(0px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right))
  max(0px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left)); }
#game-frame { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(100vw, 133.333vh); height: min(100vh, 75vw); overflow: hidden; background: #000; }
#game-image, #canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
#game-image { pointer-events: none; }
#canvas { outline: none; touch-action: none; background: transparent; }
button { min-height: 44px; padding: 8px 12px; border: 1px solid #3c646d; border-radius: 10px;
  background: #10282fee; color: #e5eff0; font: 600 12px system-ui, sans-serif;
  touch-action: manipulation; cursor: pointer; }
button:active { background: #28535b; }
button:focus-visible, input:focus-visible { outline: 2px solid #92e0e7; outline-offset: 2px; }
button:disabled { opacity: .45; cursor: wait; }
#display-controls { position: absolute; top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 5; }
#rotate, #play-controls { display: none; }
.touch #rotate, .rotated #rotate { display: block; }
.touch #play-controls { display: flex; position: absolute; right: max(8px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom)); gap: 8px; z-index: 5; }
.touch:not(.portrait) #game-area { right: max(108px, calc(env(safe-area-inset-right) + 100px)); }
.touch:not(.portrait) #display-controls, .touch:not(.portrait) #play-controls {
  width: 88px; flex-direction: column; }
.touch.portrait #game-area { top: max(60px, calc(env(safe-area-inset-top) + 52px));
  bottom: max(68px, calc(env(safe-area-inset-bottom) + 60px)); }
.touch.portrait #play-controls { left: max(8px, env(safe-area-inset-left)); justify-content: center; }
#launch { background: #174952; border-color: #58a0aa; min-width: 82px; }
#keyboard { min-height: 36px; font-size: 11px; }
#status { position: absolute; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; white-space: pre-line; pointer-events: none; background: #03090cda; }
#status a { pointer-events: auto; color: #9de3ef; }
#stream { position: absolute; bottom: 4px; left: 4px; z-index: 4; font-size: 10px;
  max-width: calc(100% - 110px); padding: 2px 6px; background: #071418c0; pointer-events: none; }
#display-hint { position: absolute; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 9;
  width: min(85%, 390px); padding: 12px; border-radius: 10px; background: #17383ef5; text-align: center; }
#name-entry { position: absolute; z-index: 12; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(90%, 320px); padding: 18px; border: 1px solid #3c646d; border-radius: 12px;
  background: #0a1c23; display: flex; gap: 8px; flex-wrap: wrap; }
#name-entry label, #name-entry input { width: 100%; }
#name-entry input { min-height: 44px; font-size: 16px; padding: 8px; }
.guest-modal-open #play-controls { display: none; }
  #guest-dialog-layer { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
    justify-content: center; background: rgba(0,0,0,.15); color: #000; }
  .guest-dialog { padding: 3px; background: #c0c0c0; font: 11px "MS Sans Serif", Arial, sans-serif;
    box-shadow: inset -1px -1px #000, inset 1px 1px #dfdfdf, inset -2px -2px #808080, inset 2px 2px #fff;
    transform-origin: center; flex: none; }
  .guest-titlebar { height: 18px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 2px 0 3px; color: #fff; font-weight: bold; background: #000080; }
  .guest-titlebar button { padding: 0; width: 16px; height: 14px; font: bold 14px Arial; line-height: 10px; }
  .guest-dialog-client { position: relative; margin: 2px 1px; }
  .guest-control { position: absolute; box-sizing: border-box; padding: 0; margin: 0; font: inherit; color: #000; }
  .guest-dialog button { border: 0; border-radius: 0; background: #c0c0c0; color: #000;
    box-shadow: inset -1px -1px #000, inset 1px 1px #fff, inset -2px -2px #808080, inset 2px 2px #dfdfdf; }
  .guest-dialog button:active { box-shadow: inset 1px 1px #000, inset -1px -1px #fff, inset 2px 2px #808080; }
  .guest-dialog button:focus { outline: 1px dotted #000; outline-offset: -5px; }
  .guest-dialog button.guest-default { border: 1px solid #000; }
  .guest-dialog input:not([type=checkbox]):not([type=radio]), .guest-dialog textarea, .guest-dialog select {
    border: 0; border-radius: 0; background: #fff; padding: 2px 3px;
    box-shadow: inset 1px 1px #808080, inset -1px -1px #fff, inset 2px 2px #000; }
  .guest-dialog textarea { resize: none; }
  .guest-dialog input[readonly], .guest-dialog textarea[readonly] { background: #c0c0c0; }
  .guest-choice { display: flex; align-items: center; gap: 4px; white-space: pre-wrap; }
  .guest-choice input { margin: 0; padding: 0; accent-color: #000080; width: 13px; height: 13px; }
  .guest-static { white-space: pre-wrap; overflow: hidden; }
  .guest-dialog fieldset { border: 2px groove #fff; padding: 0 6px; }
  .guest-dialog legend { padding: 0 2px; }
  .guest-dialog canvas { image-rendering: pixelated; }
  .guest-dialog :disabled { color: #808080; }
