:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #111419;
  color: #f3f5f2;
  --panel: #20262c;
  --outline: #414b50;
  --green: #b7efb6;
  --muted: #b7c4c0;
}
* { box-sizing: border-box; }
body { margin: 0; }
main { width: min(100%, 55rem); margin: 0 auto; padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left)); }
header, footer, .actions, .shoulders, .main-controls, .middle { display: flex; align-items: center; }
header, footer, .shoulders, .main-controls { justify-content: space-between; }
header { gap: .6rem; padding-bottom: .9rem; }
h1 { margin: 0 0 .2rem; font-size: clamp(1.4rem, 5vw, 2rem); }
p { margin: 0; line-height: 1.5; }
#player, #game-status, #lobby-status, details { color: var(--muted); }
#partner { border: 1px solid var(--outline); padding: .4rem .65rem; border-radius: 2rem; font-size: .9rem; white-space: nowrap; }
#partner[data-online="true"] { color: var(--green); border-color: #5c8961; }
#lobby, #signin { background: var(--panel); padding: clamp(1.1rem, 4vw, 2rem); border: 1px solid var(--outline); border-radius: 1rem; }
#signin form:not([hidden]) { display: grid; gap: .75rem; max-width: 26rem; justify-items: start; }
#signin input { width: 100%; min-height: 44px; padding: .55rem .8rem; font: inherit; color: inherit; background: #111419; border: 1px solid var(--outline); border-radius: .55rem; }
#signin-status:not(:empty) { margin-top: .85rem; }
#lobby-status { margin: .85rem 0; }
details { margin-top: 1.25rem; }
details p { margin-top: .5rem; }
button { font: inherit; color: inherit; background: #272f35; border: 1px solid var(--outline); padding: .55rem .8rem; min-height: 44px; border-radius: .55rem; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, summary:focus-visible { outline: 2px solid var(--green); outline-offset: 3px; }
button.primary, .controls button[data-pressed="true"] { background: var(--green); color: #13291b; border-color: var(--green); font-weight: 700; }
.actions { gap: .45rem; flex-wrap: wrap; }
.screen { border: 1px solid var(--outline); padding: .45rem; border-radius: .8rem; background: #090b0c; }
canvas { display: block; width: 100%; height: auto; max-height: 56svh; object-fit: contain; image-rendering: pixelated; }
.controls { width: min(100%, 28rem); margin: .65rem auto; user-select: none; -webkit-user-select: none; touch-action: none; }
.controls button { touch-action: none; min-width: 46px; font-weight: 700; }
.shoulders button { min-width: 3.6rem; }
.dpad { display: grid; gap: 2px; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 44px); }
.dpad [data-key="64"] { grid-area: 1 / 2; }
.dpad [data-key="32"] { grid-area: 2 / 1; }
.dpad [data-key="16"] { grid-area: 2 / 3; }
.dpad [data-key="128"] { grid-area: 3 / 2; }
.face { display: flex; align-items: center; gap: .35rem; }
.face button { width: 3.5rem; height: 3.5rem; border-radius: 50%; }
.face button:last-child { margin-bottom: 1.5rem; }
.middle { justify-content: center; gap: .5rem; }
footer { gap: .45rem; flex-wrap: wrap; border-top: 1px solid var(--outline); padding-top: .65rem; }
@media (orientation: landscape) and (max-height: 580px) {
  header { padding-bottom: .4rem; }
  #game:not([hidden]) { display: grid; grid-template-columns: minmax(0, 3fr) minmax(14rem, 2fr); align-items: center; gap: .5rem; }
  canvas { max-height: 72svh; }
  footer { grid-column: 1 / -1; }
}
