: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%); }
#player, .overlay, dialog, a, button { touch-action: manipulation; }
button, #touch, #tools { user-select: none; -webkit-user-select: none; }
a { color: #ffe2a1; }
#player { position: fixed; inset: 0; height: 100vh; height: 100dvh; width: 100%; background: #091520; 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; width: var(--side, 0px); background: repeating-linear-gradient(#193e32 0 40px, #1d4838 40px 80px); }
.wing-left { left: 0; }
.wing-right { right: 0; }
#touch, #tools { position: absolute; inset: 0; pointer-events: none; }
.pad, .game-button { position: absolute; pointer-events: auto; touch-action: none; }
.game-button, .pad::before { background: rgb(3 25 39 / var(--control-opacity, .5)); }
.game-button.pressed, .pad button.pressed { background: rgb(172 90 18 / 80%); }
.pad { border-radius: 12%; overflow: hidden; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); }
.pad::before {
    position: absolute;
    inset: 0;
    content: '';
    pointer-events: none;
    clip-path: polygon(33.333% 0, 66.667% 0, 66.667% 33.333%, 100% 33.333%,
        100% 66.667%, 66.667% 66.667%, 66.667% 100%, 33.333% 100%,
        33.333% 66.667%, 0 66.667%, 0 33.333%, 33.333% 33.333%);
}
.pad button {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    padding: 0;
    border: 1px solid #ffc947;
    border-radius: 0;
    background: transparent;
    line-height: 1;
    touch-action: none;
}
.pad .up { grid-area: 1 / 2; border-bottom: 0; border-radius: 9px 9px 0 0; }
.pad .left { grid-area: 2 / 1; border-right: 0; border-radius: 9px 0 0 9px; }
.pad .right { grid-area: 2 / 3; border-left: 0; border-radius: 0 9px 9px 0; }
.pad .down { grid-area: 3 / 2; border-top: 0; border-radius: 0 0 9px 9px; }
.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; }
#player {
    --menu-gutter: max(16px, calc((100% - 1200px) / 2));
    --pitch-art: url(pitch-pc-20261123.webp);
    --pitch-shade: linear-gradient(90deg, #102c25f2 6%, #102c25b8 44%, #102c2524 75%);
    --pitch-position: center;
}
.overlay { position: absolute; inset: 0; overflow-y: auto; background: var(--pitch-shade), var(--pitch-art) var(--pitch-position)/cover, #102c25; }
.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: #102c25; 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: #f2b044; }
#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: var(--pitch-shade), var(--pitch-art) var(--pitch-position)/cover, #102c25; }
  #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: #f2b044; 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; }

#room-heading { margin: 0; }
#room-roster { margin-top: 14px; }
#seats { margin: 8px 0 0; padding-inline-start: 22px; }
#seats li { margin: 5px 0; overflow-wrap: anywhere; }
@media (min-width: 621px) and (max-width: 1080px) and (max-aspect-ratio: 4/3) {
    #player { --pitch-art: url(pitch-tablet-20261123.webp); }
    #gate .hint { max-width: 50ch; }
}
@media (max-width: 620px) and (orientation: portrait) {
    #player {
        --pitch-art: url(pitch-phone-20261123.webp);
        --pitch-shade: linear-gradient(180deg, transparent 12%, #102c2555 38%, #102c25e8 57%);
        --pitch-position: center top;
    }
}

.player-links { display: flex; flex-wrap: wrap; column-gap: 20px; }

/* Keep room controls separate from solo, and make the next action easy to find. */
#gate[data-room] .overlay-inner {
    min-height: calc(100% - 60px);
    align-content: start;
    padding-block: clamp(20px, 5vh, 52px);
}
#gate[data-room] #title { font-size: clamp(2.3rem, 6vw, 4.4rem); }
#gate[data-room] #subtitle { margin-bottom: 20px; }
#gate[data-room] .overlay-inner > .menu-actions { order: 2; margin-top: 14px; }
#gate[data-room] .player-links { order: 3; }
#lobby {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    width: min(100%, 880px);
    max-width: none;
    gap: 12px;
}
.lobby-main, .lobby-invite {
    min-width: 0;
    padding: clamp(16px, 2.5vw, 24px);
    border: 1px solid #e1b54b66;
    border-radius: 16px;
    background: #081b23f5;
}
#room-heading { margin: 0 0 14px; font-size: clamp(1.2rem, 3vw, 1.7rem); overflow-wrap: anywhere; }
#seats { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#seats li {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 10px 12px;
    border-radius: 9px;
    background: #112931;
}
#seats strong { display: block; overflow-wrap: anywhere; }
.seat-role { display: block; margin-bottom: 3px; color: #d3c7ab; font-size: .82rem; }
.seat-badge { color: #ffe2a1; background: #66502455; border-radius: 999px; padding: 5px 9px; font-size: .78rem; }
#seats li[data-ready="true"] .seat-badge { color: #dfffd4; background: #2a613c; }
#lobby-next { margin: 16px 0 12px; line-height: 1.42; }
.lobby-actions .lobby-primary, #lobby-copy { background: #ffca4a; color: #071922; }
.lobby-invite h3 { margin: 0 0 8px; }
#invite-help { margin: 0 0 12px; line-height: 1.4; }
#lobby-qr img { display: block; width: min(100%, 160px); height: auto; margin-top: 12px; image-rendering: pixelated; }
#lobby-copy-status:empty { display: none; }
#lobby-copy-status { margin: 8px 0 0; line-height: 1.35; }
#lobby-invite-url { width: 100%; margin-top: 10px; min-height: 36px; }
#peer-wait { display: none; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
    width: max-content; max-width: 65%; padding: 6px 10px; border-radius: 8px;
    color: #fff0cd; background: #081b23ed; text-align: center; pointer-events: none; }
#player[data-playing="true"][data-peer-paused="true"]:not(:has(#menu[open])) #peer-wait { display: block; }
@media (max-width: 660px) {
    #lobby { grid-template-columns: minmax(0, 1fr); }
    .lobby-actions button { width: 100%; justify-content: center; }
    #gate[data-room] .overlay-inner { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

