:root { color-scheme: dark; font-family: system-ui, sans-serif; background: #062c41; color: #fff0cd; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; overflow: hidden; width: 100%; height: 100%; }
button, a, input { font: inherit; }
button, .menu-actions a { min-height: 48px; border: 1.5px solid #ffc947; border-radius: 10px; color: #fff0cd; background: rgb(3 25 39 / 50%); font-weight: 750; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #fff4e4; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }
button:active, button.pressed { background: rgb(172 90 18 / 68%); }
button, #touch, #tools { touch-action: none; user-select: none; -webkit-user-select: none; }
a { color: #ffe2a1; }
#player { position: fixed; inset: 0; height: 100vh; height: 100dvh; width: 100%; background: #073e54; overflow: hidden; }
#stage { position: absolute; inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); overflow: hidden; }
#player[data-playing="true"] #stage { touch-action: none; }
#screen { position: absolute; display: block; left: var(--game-x, 0px); top: var(--game-y, 0px); width: var(--game-width, 0px); height: var(--game-height, 0px); image-rendering: pixelated; background: #05131a; }
.wing { position: absolute; top: 0; bottom: 0; overflow: hidden; width: var(--side, 0px); background: #074459; }
.wing-left { left: 0; border-right: 2px solid #ffc947; }
.wing-right { right: 0; border-left: 2px solid #ffc947; }
.wing::before { position: absolute; inset: 0; content: ''; background-image: url(panels.webp); background-repeat: no-repeat; background-position: var(--panel-offset) center; background-size: var(--panel-width) var(--panel-height); }
.wing-left::before { --panel-offset: var(--panel-left); }
.wing-right::before { --panel-offset: var(--panel-right); }
#touch, #tools { position: absolute; inset: 0; pointer-events: none; }
.pad, .game-button { position: absolute; pointer-events: auto; touch-action: none; }
.game-button, .pad button { background: rgb(3 25 39 / var(--control-opacity, .5)); }
.game-button.pressed, .pad button.pressed { background: rgb(172 90 18 / 80%); }
.pad button { position: absolute; width: calc((100% - 12px) / 3); min-height: 0; height: calc((100% - 12px) / 3); padding: 0; line-height: 1; }
.pad .up { top: 0; left: 50%; transform: translateX(-50%); }
.pad .down { bottom: 0; left: 50%; transform: translateX(-50%); }
.pad .left { left: 0; top: 50%; transform: translateY(-50%); }
.pad .right { right: 0; top: 50%; transform: translateY(-50%); }
.game-button.action { border-radius: 50%; font-size: clamp(18px, 4.5vh, 25px); }
.game-button.service { display: grid; place-items: center; padding: 0 8px; white-space: nowrap; line-height: 1; font-size: 12px; letter-spacing: .025em; }
.game-button.tool { font-size: 21px; }
.game-button.is-fallback { border-color: #ffc94777; background: #03192755; }
.overlay { position: absolute; inset: 0; overflow-y: auto; background: linear-gradient(90deg, #052635 12%, #052635ea 46%, #05263544), url(panels.webp) center/cover, #073e54; }
#player { --menu-gutter: max(16px, calc((100% - 1200px) / 2)); }
.player-header { position: sticky; top: 0; z-index: 1; min-height: 60px; padding: max(10px, env(safe-area-inset-top)) max(var(--menu-gutter), env(safe-area-inset-right)) 10px max(var(--menu-gutter), env(safe-area-inset-left)); display: flex; justify-content: space-between; align-items: center; background: #073448; border-bottom: 1px solid #ffc9476b; }
.player-header a { text-decoration: none; font-weight: 800; min-height: 40px; display: grid; place-items: center; }
.overlay-inner { display: grid; align-content: center; justify-items: start; min-height: calc(100% - 62px); padding: clamp(18px, 5vh, 60px) var(--menu-gutter); }
.overlay-inner > *, #menu .menu-dialog > * { max-width: 740px; }
h1 { font-size: clamp(2.65rem, 7.8vw, 6rem); line-height: .97; letter-spacing: -.045em; margin: 0; color: #ffce57; }
#subtitle { margin: 8px 0 22px; font-size: clamp(1rem, 4vw, 1.55rem); font-weight: 700; }
.menu-actions { display: flex; align-items: stretch; flex-wrap: wrap; gap: 8px; }
.menu-actions button, .menu-actions a { display: inline-flex; align-items: center; padding: 9px 16px; text-decoration: none; }
#solo, #resume, #start { background: #ffca4a; color: #052c42; }
#status:empty { display: none; }
#status, .hint { margin: 12px 0 0; }
.hint, .catalog { font-size: .9rem; }
.catalog { display: inline-flex; align-items: center; min-height: 44px; }
.install-help { width: min(100%, 430px); margin-top: 14px; border: 1px solid #ffc94766; border-radius: 9px; background: #052635e8; }
.install-help summary { min-height: 44px; padding: 11px 13px; color: #ffe2a1; font-size: .9rem; font-weight: 700; cursor: pointer; }
.install-help ol { margin: 0; padding: 0 14px 12px 34px; font-size: .9rem; }
.install-help li + li { margin-top: 5px; }
@media (display-mode: standalone) { .install-help { display: none; } }
dialog { width: min(calc(100% - 32px), 410px); border: 1px solid #ffc947; border-radius: 14px; background: #092f42; color: inherit; }
dialog::backdrop { background: #032130aa; }
.menu-dialog { display: grid; gap: 14px; padding: 8px; }
.menu-dialog h2 { margin: 0; }

#menu { padding: 0; }
#menu .player-header { min-height: 50px; padding-top: 4px; padding-bottom: 4px; }
#menu .menu-dialog { padding: 18px; }
#pause-hint { margin: 0; }
@media (min-width: 960px) and (min-height: 420px) {
  #menu { width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; background: linear-gradient(90deg, #052635 12%, #052635e8 48%, #05263544), url(panels.webp) center/cover, #073e54; }
  #menu .player-header { min-height: 60px; padding-top: 10px; padding-bottom: 10px; }
  #menu .menu-dialog { place-content: center start; min-height: calc(100% - 60px); padding: 24px var(--menu-gutter); }
  #pause-title { color: #ffce57; font-size: clamp(42px, 7vw, 88px); line-height: 1; }
}
#controls-settings { width: min(calc(100% - 24px), 620px); max-height: calc(100% - 24px); padding: 0; overscroll-behavior: contain; scrollbar-gutter: stable; }
.settings-heading { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(12px, 4vw, 22px); gap: 12px; background: #092f42; }
.settings-heading h2 { margin: 0; }
#close-controls { min-width: 48px; font-size: 24px; }
.control-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; margin: 0 clamp(12px, 4vw, 22px) 10px; }
.control-tabs button { padding: 4px; font-size: clamp(.72rem, 2.9vw, .94rem); overflow-wrap: anywhere; }
.control-tabs button[aria-pressed="true"] { color: #052635; background: #ffca4a; }
#controls-settings [data-page], #controls-status, .controls-footer { padding: 10px clamp(12px, 4vw, 22px) 16px; }
#controls-settings p { margin: 0 0 10px; font-size: .9rem; }
#controls-settings section > button, .touch-options > button, .control-actions button { padding: 5px 10px; }
.control-row { display: flex; min-height: 44px; align-items: center; flex-wrap: wrap; gap: 8px; }
.control-row select { max-width: 100%; min-height: 44px; padding: 4px; border: 1px solid #ffc94788; border-radius: 7px; color: inherit; background: #073448; font: inherit; }
.control-row input { accent-color: #ffca4a; }
.control-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.control-bindings { display: grid; gap: 7px; margin: 0 0 12px; }
.binding-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(2, minmax(62px, 26%)); align-items: center; gap: 7px; }
.binding-row span { overflow-wrap: anywhere; }
#pad-bindings .binding-row { grid-template-columns: minmax(0, 1fr) minmax(105px, 52%); }
.binding-row button { padding: 5px; overflow-wrap: anywhere; font-size: .85rem; }
#layout-preview { position: relative; margin: 10px auto; width: min(100%, 480px); max-height: 280px; background: #07516b; border: 1px solid #ffc94766; border-radius: 9px; overflow: hidden; touch-action: none; }
#layout-preview::before { content: ''; position: absolute; left: var(--frame-x); top: var(--frame-y); width: var(--frame-w); height: var(--frame-h); background: #0a263a; outline: 1px solid #ffc94755; }
#layout-preview button { position: absolute; padding: 0; min-height: 0; min-width: 0; border-width: 1px; border-radius: 4px; line-height: 1; background: #073448; overflow: hidden; font-size: clamp(6px, 1.15vw, 10px); }
#layout-preview button[aria-pressed="true"] { color: #052635; background: #ffca4a; }
#layout-preview button.is-hidden:not([aria-pressed="true"]) { opacity: .35; }
#layout-preview button[data-control="a"], #layout-preview button[data-control="b"] { border-radius: 50%; }
.control-sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin-bottom: 10px; }
.control-range { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: 2px; font-size: .85rem; }
.control-range span { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 5px; }
.control-range input { width: 100%; height: 32px; accent-color: #ffca4a; margin: 0; }
#controls-status { color: #ffd374; }
.controls-footer { border-top: 1px solid #ffc94744; }
@media (min-width: 630px) and (max-height: 540px) {
  #controls-settings [data-page="touch"] { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; }
  #layout-preview { max-height: 172px; }
}

#open-rooms { max-width: 36rem; margin: 1.2rem 0; }
#rooms-heading { font-size: 1.15rem; margin: 0 0 .45rem; }
#available-rooms { display: grid; gap: .5rem; color: #ffeabb; }
#available-rooms a { display: block; padding: .7rem 1rem; border: 1px solid #ffc947; border-radius: .5rem; color: #fff2d0; background: #08354b; text-decoration: none; overflow-wrap: anywhere; }
#available-rooms a:focus-visible { outline: 3px solid white; }
