/* OctoBahn — dark theme to match Starflame Games. */

* { box-sizing: border-box; }

html {
    height: 100%;
}
body {
    margin: 0;
    min-height: 100%;
    background: #0b0b12;
    color: #e9e9f2;
    font-family: system-ui, "Segoe UI", sans-serif;
    /* Page scrolls normally so mobile browser chrome (URL bar, pull-to-refresh)
       stays reachable. The canvas preventDefaults its own touch drags, so
       gameplay isn't affected. */
    -webkit-tap-highlight-color: transparent;
}

.oct-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
#octIntro {
    position: fixed;
    inset: 0;
    z-index: 250;
    overflow: hidden;
    background: #080910;
    opacity: 1;
    transition: opacity 240ms ease;
    touch-action: none;
}
#octIntro.oct-intro-done {
    opacity: 0;
    pointer-events: none;
}
#octIntroCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

#octStage {
    height: 100vh;
    height: 100dvh;            /* avoid mobile URL-bar overflow */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
#octStage[hidden] { display: none; }

#octCanvas {
    background:
        radial-gradient(circle at 50% 45%, rgba(60, 80, 140, 0.18), transparent 60%),
        #0e0e18;
    border-radius: 14px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
    touch-action: none;
    cursor: crosshair;
}

#octArcadePauseActions {
    position: fixed;
    z-index: 38;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    width: min(230px, calc(100vw - 72px));
    padding: 12px;
    border: 1px solid rgba(105, 106, 137, 0.9);
    border-radius: 13px;
    background: rgba(10, 10, 20, 0.9);
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
    transform: translate(-50%, -50%);
}
#octArcadePauseActions[hidden] { display: none; }
#octArcadePauseActions button {
    min-height: 35px;
    padding: 7px 12px;
    border: 1px solid #55566f;
    border-radius: 9px;
    background: rgba(35, 35, 53, 0.96);
    color: #f2f2fa;
    font: 750 13px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
}
#octArcadePauseActions button:hover,
#octArcadePauseActions button:focus-visible {
    border-color: #65e8ed;
    outline: none;
    filter: brightness(1.12);
}
#octArcadePauseActions #octContinueArcade {
    border-color: #2ca65d;
    background: #20894b;
    color: #fff;
}
.oct-score-log-list {
    max-height: min(52vh, 390px);
    overflow-y: auto;
    margin-top: 12px;
    padding: 0 8px 0 0;
    text-align: left;
}
.oct-score-log-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid rgba(115, 116, 145, 0.32);
    color: #d5d5e2;
}
.oct-score-log-row:last-child { border-bottom: 0; }
.oct-score-log-row span {
    min-width: 0;
    overflow-wrap: anywhere;
}
.oct-score-log-row strong {
    align-self: start;
    color: #7ff;
    text-align: right;
    white-space: nowrap;
}

#octBootSlowBtn {
    position: fixed;
    z-index: 35;
    left: 50%;
    top: calc(50% + 72px);
    transform: translateX(-50%);
    width: min(340px, calc(100vw - 32px));
    padding: 11px 15px;
    border: 1px solid #ff9a55;
    border-radius: 10px;
    background: #7a2f20;
    color: #fff;
    font: 800 14px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}
#octBootSlowBtn:hover { filter: brightness(1.15); }
#octBootSlowBtn[hidden] { display: none; }
#octBootSlowBtn.oct-boot-pauser {
    top: auto;
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 66px));
}

#octPublicInvite {
    position: fixed;
    z-index: 45;
    left: 50%;
    bottom: max(6px, calc(env(safe-area-inset-bottom) + 6px));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: max-content;
    max-width: calc(100vw - 24px);
    padding: 5px 7px;
    border: 1px solid #4f506c;
    border-radius: 9px;
    background: rgba(20, 20, 31, 0.97);
    color: #ededf7;
    font-size: 11px;
    font-weight: 700;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.58);
}
#octPublicInvite span { white-space: nowrap; }
#octPublicInvite button {
    min-height: 24px;
    padding: 2px 7px;
    border: 1px solid #565773;
    border-radius: 7px;
    background: #292a3d;
    color: #f5f5fb;
    font: 800 10px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
}
#octPublicInvite button[data-public-invite-yes] {
    border-color: #2a9b5b;
    background: #1c7f48;
}
#octPublicInvite button:hover { filter: brightness(1.13); }
@media (max-width: 360px) {
    #octPublicInvite { gap: 4px; padding: 4px 6px; font-size: 10px; }
    #octPublicInvite button { min-height: 22px; padding-inline: 6px; font-size: 9px; }
}

.oct-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5, 6, 13, 0.78);
    backdrop-filter: blur(5px);
}
.oct-confirm-card {
    width: min(460px, 100%);
    padding: 28px;
    border: 1px solid #4a4a65;
    border-radius: 18px;
    background: #151522;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
    text-align: center;
}
.oct-confirm-card h2 {
    margin: 0 0 12px;
    color: #f4f4fb;
    font-size: clamp(25px, 5vw, 34px);
}
.oct-confirm-card p {
    margin: 0;
    color: #c8c8d8;
    font-size: 17px;
    line-height: 1.5;
}
.oct-dialog-field { display: grid; gap: 8px; text-align: left; color: #c8c8d8; font-weight: 750; }
.oct-dialog-field input,
.oct-dialog-field select {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid #50506d;
    border-radius: 11px;
    background: #0d0d17;
    color: #f4f4fb;
    font: 700 18px system-ui, "Segoe UI", sans-serif;
}
.oct-dialog-field select {
    padding-right: 42px;
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, #f4f4fb 50%) calc(100% - 22px) 21px / 7px 7px no-repeat,
        linear-gradient(135deg, #f4f4fb 50%, transparent 50%) calc(100% - 15px) 21px / 7px 7px no-repeat,
        #0d0d17;
    cursor: pointer;
}
.oct-dialog-field input:focus,
.oct-dialog-field select:focus {
    border-color: #65e8ed;
    outline: 2px solid rgba(101, 232, 237, 0.2);
}
.oct-dialog-error { min-height: 22px; margin: 8px 0 0 !important; color: #ff9a8f !important; font-size: 14px !important; }
.oct-score-account-actions {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}
.oct-score-account-actions button,
.oct-score-change-user {
    min-height: 44px;
    border: 1px solid #565773;
    border-radius: 12px;
    background: #25263a;
    color: #f4f4fb;
    font: 850 15px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
}
.oct-score-account-actions button:first-child,
.oct-score-account-actions button:nth-child(2) {
    border-color: #1c884e;
    background: #1b7f49;
}
.oct-score-account-actions button:hover,
.oct-score-change-user:hover { filter: brightness(1.12); }
.oct-score-change-user {
    width: 100%;
    min-height: 38px;
    margin-top: -8px;
}
.oct-score-anon-note {
    margin: -6px 0 0;
    color: #aaaabd;
    font-size: 13px;
    text-align: center;
}
.oct-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 24px;
}
.oct-confirm-actions.is-single { grid-template-columns: minmax(140px, 220px); justify-content: center; }
.oct-confirm-actions button {
    min-height: 48px;
    padding: 11px 16px;
    border: 1px solid #50506d;
    border-radius: 12px;
    background: #232335;
    color: #f2f2fa;
    font: 750 16px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
}
.oct-confirm-actions button:hover,
.oct-confirm-actions button:focus-visible {
    border-color: #65e8ed;
    outline: none;
    filter: brightness(1.12);
}
.oct-confirm-actions .oct-confirm-danger {
    border-color: #b95b55;
    background: #8f3732;
}
@media (max-width: 430px) {
    .oct-confirm-card { padding: 23px 18px; }
    .oct-confirm-actions { grid-template-columns: 1fr; }
    .oct-preset-dialog .oct-confirm-actions { grid-template-columns: 1fr 1fr; }
}

#octHint {
    font-size: 13px;
    color: #8b8ba0;
    user-select: none;
}

/* Per-client paddle-speed slider (shown during play, below the hint). */
#octSpeedCtl {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #9a9ab0;
    user-select: none;
}
#octSpeedCtl[hidden] { display: none; }
#octSpeedCtl input[type="range"] { width: 150px; accent-color: #39d0ff; cursor: pointer; }
body.oct-touch-device #octSpeedCtl { visibility: hidden; }
body.oct-touch-device #octSpeedCtl.oct-keyboard-active { visibility: visible; }
#octSpeedVal { min-width: 38px; text-align: right; color: #cdd6e6; }

/* Fixed page header (centered between the corner buttons) + copyright footer. */
#octHeader {
    position: fixed;
    top: max(6px, env(safe-area-inset-top));
    left: 0;
    right: 0;
    z-index: 30;
    text-align: center;
    pointer-events: none;        /* let taps fall through except the home link */
    line-height: 1.12;
}
#octHeader .oct-hdr-home {
    pointer-events: auto;
    color: #7ff;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none;
}
#octHeader .oct-hdr-home:hover { text-decoration: underline; }
#octHeader .oct-hdr-title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #39d0ff, #c08bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
#octHeader .oct-hdr-page {
    margin-top: 2px;
    color: #b8b8ca;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.25px;
}
#octHeader .oct-season-countdown {
    display: block;
    width: min(90vw, 400px);
    margin: 5px auto 0;
    color: #ffdf7e;
    font-size: clamp(11px, 2.7vw, 14px);
    font-weight: 800;
    line-height: 1.25;
    text-align: center;
    text-shadow: 0 0 10px rgba(255, 210, 110, 0.32);
}
#octHeader .oct-season-countdown[hidden] { display: none; }
#octCopyright {
    position: fixed;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(12px, env(safe-area-inset-left));
    right: auto;
    z-index: 30;
    text-align: left;
    pointer-events: none;
    font-size: 11px;
    color: #5c5c70;
}

/* ---------- Setup / menu screen (a normal page section, not a modal) ---------- */
#octSetup {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: #0b0b12;
    padding: 92px 16px 52px;
    box-sizing: border-box;
}

#octSetupCard {
    margin: 0 auto;             /* horizontal center; page scrolls if it's tall */
    width: min(560px, 94vw);
    height: calc(100vh - 144px); /* reserve shared header/footer chrome */
    height: calc(100dvh - 144px);
    max-height: 700px;
    display: flex;
    flex-direction: column;
    background: #14141f;
    border: 1px solid #33334a;
    border-radius: 14px;
    padding: 18px 18px 16px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6);
}

/* The global support control owns the bottom-right position on every screen. */
.oct-setup-foot .oct-support { display: none; }

/* Pinned header/footer bits; only #octTabContent scrolls. */
#octSetupCard h1, .oct-fixed, #octStart, .oct-back, .oct-setup-foot { flex: 0 0 auto; }

.oct-tabs { display: flex; gap: 6px; margin: 8px 0 0; }
.oct-tab {
    flex: 1;
    padding: 9px 6px;
    border: 1px solid #33334a;
    border-bottom: none;
    border-radius: 9px 9px 0 0;
    background: #0e0e16;
    color: #9a9ab0;
    font: 700 13px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
    white-space: normal;       /* allow long tab labels to wrap rather than overflow */
    line-height: 1.15;
    text-align: center;
}
.oct-tab.is-active { background: #20202e; color: #fff; }

#octTabContent {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #33334a;
    border-radius: 0 0 10px 10px;
    padding: 14px 12px;
    margin-bottom: 14px;
}
.oct-tabpane[hidden] { display: none; }
.oct-compact-settings, .oct-mobile-edit-actions { display: none; }

#octSetupCard h1 {
    margin: 0 0 2px;
    font-size: 30px;
    letter-spacing: 0.5px;
    background: linear-gradient(90deg, #39d0ff, #c08bff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.oct-sub { margin: 0 0 16px; color: #9a9ab0; font-size: 13px; line-height: 1.4; }

/* Flex column so the control can bottom-align — keeps selects level across a row
   even when one label wraps to two lines. */
.oct-field { display: flex; flex-direction: column; margin-bottom: 14px; }
.oct-field span { display: block; font-weight: 700; margin-bottom: 6px; font-size: 13px; }
#octName, #octJoinName {
    width: 100%;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid #44445e;
    background: #0c0c14;
    color: #fff;
    font-size: 16px;
}

.oct-row2 { display: flex; gap: 10px; align-items: stretch; }
.oct-half { flex: 1; }
.oct-field select {
    width: 100%;
    margin-top: auto;            /* pin to the bottom so row selects line up */
    padding: 8px;
    border-radius: 8px;
    border: 1px solid #44445e;
    background: #0c0c14;
    color: #fff;
    font-size: 14px;
}
.oct-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #c9c9da;
    margin: 2px 0 14px;
    cursor: pointer;
}
.oct-check input { width: 16px; height: 16px; flex: 0 0 auto; }

.oct-quick { font-size: 12px; color: #9a9ab0; margin-bottom: 10px; }
.oct-quickbtn {
    margin-left: 4px;
    padding: 4px 9px;
    border-radius: 7px;
    border: 1px solid #44445e;
    background: #20202e;
    color: #dcdcec;
    font-size: 12px;
    cursor: pointer;
}
.oct-quickbtn:hover { background: #2c2c40; }

#octSlots {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 18px;
}
.oct-slot { display: flex; flex-direction: column; gap: 4px; }
.oct-slot-label { font-size: 11px; color: #8b8ba0; }
.oct-fill {
    padding: 7px 8px;
    border-radius: 8px;
    border: 1px solid #44445e;
    background: #0c0c14;
    color: #fff;
    font-size: 13px;
}

#octStart {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #2a8a52;
    background: #1a7a44;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    cursor: pointer;
}
.oct-start-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 10px;
}
.oct-start-actions.oct-start-single { grid-template-columns: 1fr; }
.oct-start-actions #octStart { width: 100%; }
#octLoadArcadePreset {
    padding: 12px 10px;
    border: 1px solid #50506d;
    border-radius: 10px;
    background: #232335;
    color: #f2f2fa;
    font-weight: 800;
    cursor: pointer;
}
#octLoadArcadePreset:hover { border-color: #65e8ed; filter: brightness(1.08); }
#octStart:hover { filter: brightness(1.08); }
#octStart.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
}

.oct-back {
    display: block;
    margin-top: 12px;
    text-align: center;
    color: #7ff;
    text-decoration: none;
    font-size: 13px;
}
.oct-back:hover { text-decoration: underline; }

/* "Multiplayer (beta)" button under Start Game. */
.oct-multi {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    border-radius: 10px;
    border: 1px solid #3a6ad0;
    background: #1c2740;
    color: #cfe0ff;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
}
.oct-multi:hover { filter: brightness(1.12); }
.oct-beta, .lobby-beta {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #0b0b12;
    background: #ffcf4d;
    border-radius: 5px;
    padding: 1px 5px;
    vertical-align: middle;
}

/* ---------- Multiplayer lobby overlay ---------- */
#octLobby {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: flex;
    background: rgba(6, 6, 12, 0.9);
    padding: 16px;
    overflow: auto;
}
#octLobbyCard {
    margin: auto;
    width: min(460px, 94vw);
    background: #14141f;
    border: 1px solid #33334a;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6);
}
.lobby-h { margin: 0 0 14px; font-size: 24px; }
.lobby-btn {
    width: 100%;
    margin-top: 10px;
    padding: 11px;
    border-radius: 10px;
    border: 1px solid #44445e;
    background: #20202e;
    color: #e9e9f2;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}
.lobby-btn:hover:not(:disabled) { filter: brightness(1.12); }
.lobby-btn:disabled { opacity: 0.5; cursor: default; }
.lobby-primary { border-color: #2a8a52; background: #1a7a44; color: #fff; }
.lobby-or { text-align: center; color: #8b8ba0; font-size: 12px; margin: 16px 0 8px; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; color: #9a9ab0; font-size: 13px; min-height: 28px; }
.oct-public-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 150px;
    text-align: center;
}
.oct-public-empty p { margin: 0; }
.oct-public-empty .lobby-btn { width: min(280px, 100%); }
.lobby-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid #33334a;
    background: #0e0e16;
    color: #e9e9f2;
    cursor: pointer;
    text-align: left;
}
.lobby-row:hover { background: #1a1a28; }
.lobby-row-col { flex-direction: column; align-items: stretch; gap: 4px; }
.lobby-row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.lobby-row-cfg { font-size: 11px; color: #8b8ba0; text-align: left; }

/* Game-settings summary line in lobbies. */
.oct-cfg-summary { text-align: center; font-size: 12px; color: #8b8ba0; margin-bottom: 12px; }
.oct-cfg-summary:empty { display: none; }
.lobby-row-code { font-weight: 800; letter-spacing: 1px; color: #7ff; }
.lobby-row-host { color: #c9c9da; }
.lobby-code {
    flex: 1;
    padding: 10px 12px;
    border-radius: 9px;
    border: 1px solid #44445e;
    background: #0c0c14;
    color: #fff;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
}
.lobby-codebox { text-align: center; font-size: 15px; color: #c9c9da; margin-bottom: 14px; }
.lobby-codebox b { font-size: 24px; letter-spacing: 3px; color: #7ff; display: block; margin-top: 2px; }
.lobby-roster { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.lobby-pl {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    background: #0e0e16;
    border: 1px solid #2a2a3c;
}
.lobby-dot { width: 9px; height: 9px; border-radius: 50%; background: #3ad07a; box-shadow: 0 0 8px #3ad07a; flex: 0 0 auto; }
.lobby-pl-name { flex: 1; }
.lobby-tag { font-size: 10px; color: #ffcf4d; border: 1px solid #6a5a1a; border-radius: 5px; padding: 0 5px; }
.lobby-rtt { font-size: 12px; color: #8b8ba0; }
.lobby-wait { text-align: center; color: #9a9ab0; font-size: 13px; padding: 10px 0; }
.lobby-err { color: #ff8a8a; font-size: 14px; }
.oct-wait-note { color: #9a9ab0; font-size: 13px; align-self: center; }

/* ---------- Main-menu card + host lobby bits ---------- */
.oct-menu-card .lobby-btn { margin-top: 12px; }
.oct-menu-card .oct-sub { text-align: center; }

/* Host join-code box under the name field. */
.oct-codebox {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 8px 12px;
    border-radius: 9px;
    background: #0e0e16;
    border: 1px solid #33334a;
    font-size: 13px;
    color: #c9c9da;
}
.oct-codebox b { font-size: 20px; letter-spacing: 3px; color: #7ff; }
.oct-copy {
    padding: 4px 10px;
    border-radius: 7px;
    border: 1px solid #44445e;
    background: #20202e;
    color: #dcdcec;
    font-size: 12px;
    cursor: pointer;
}
.oct-copy:hover { background: #2c2c40; }
/* Joined-player seat rows on the AI/players tab. */
.oct-slot-player .oct-player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #2a2a3c;
    background: #0e0e16;
    margin-top: auto;
}
.oct-player-name { flex: 1; color: #e9e9f2; font-size: 14px; }
.oct-kick {
    border: none;
    background: none;
    color: #ff8a8a;
    font: 600 12px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
    padding: 2px 4px;
}
.oct-kick:hover { text-decoration: underline; }

/* Reorder arrows on each seat (host). */
.oct-fill-row { display: flex; align-items: center; gap: 6px; margin-top: auto; }
.oct-fill-row .oct-fill { margin-top: 0; flex: 1; }
.oct-arrows { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.oct-arrows button {
    width: 26px; height: 30px;
    border-radius: 7px;
    border: 1px solid #44445e;
    background: #20202e;
    color: #cdd6e6;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}
.oct-arrows button:hover:not(:disabled) { background: #2c2c40; }
.oct-arrows button:disabled { opacity: 0.35; cursor: default; }

/* "X joined / left" toast above the Start button. */
.oct-join-toast {
    min-height: 18px;
    text-align: center;
    font-size: 12px;
    color: #3ad07a;
    opacity: 0;
    transition: opacity 0.25s;
    margin-bottom: 6px;
}
.oct-join-toast.show { opacity: 1; }

/* Main menu: two buttons per row (one per row on phones). */
.oct-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}
.oct-menu-grid .lobby-btn { margin-top: 0; }
.oct-arcade-grid { margin-bottom: 20px; }
@media (max-width: 480px) { .oct-menu-grid { grid-template-columns: 1fr; } }

/* Arcade score HUD, centered above the board while a level is active. */
#octArcadeHud {
    position: relative;
    z-index: 20;
    margin-top: 70px;
    min-width: 210px;
    padding: 7px 14px;
    border: 1px solid rgba(57, 208, 255, 0.45);
    border-radius: 12px;
    background: rgba(12, 12, 20, 0.88);
    text-align: center;
    pointer-events: none;
}
#octArcadeHud[hidden] { display: none; }
#octArcadeLevel { color: #9a9ab0; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
#octArcadeTotal { display: block; color: #fff; font-size: 25px; line-height: 1.05; }
#octArcadeAward { display: block; min-height: 16px; color: #7ff; font-size: 12px; }
#octArcadeCheat { display: block; color: #ff5d5d; font-size: 10px; font-style: normal; font-weight: 800; }
#octArcadeCheat[hidden] { display: none; }

.oct-score-final { text-align: center; color: #7ff; font-size: 34px; font-weight: 900; margin: 8px 0 18px; }
.oct-score-card { width: min(780px, 96vw) !important; }
.oct-score-browser-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 32px);
    overflow: hidden;
}
.oct-score-list-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    margin-bottom: 8px;
}
#octScoreTabs,
#octScoreFooter {
    flex: 0 0 auto;
}
.oct-pull-refresh {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: -4px auto 8px;
    padding: 4px 8px;
    width: fit-content;
    border-radius: 999px;
    background: rgba(12, 12, 20, 0.88);
    color: #7ff;
    font-size: 12px;
    font-weight: 800;
    pointer-events: none;
}
.oct-pull-refresh.is-ready,
.oct-pull-refresh.is-loading {
    box-shadow: 0 0 12px rgba(122, 255, 255, 0.35);
}
.oct-score-list-scroll + .lobby-btn {
    flex: 0 0 auto;
    margin-top: 0;
}
#octWinnerCard.oct-score-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 144px);
    overflow: hidden;
}
#octWinnerCard.oct-score-card .oct-standings-wrap {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
#octWinnerCard.oct-score-card .oct-gameover-actions {
    flex: 0 0 auto;
}
.oct-score-entry-card {
    width: min(620px, 94vw) !important;
    overflow-y: auto;
}
.oct-score-entry-card h1 {
    margin: 0 0 14px;
    text-align: center;
    font-size: 26px;
}
.oct-score-entry-card .oct-field input[type="text"] {
    width: 100%;
    padding: 11px 12px;
    border-radius: 9px;
    border: 1px solid #44445e;
    background: #0c0c14;
    color: #fff;
    font-size: 16px;
}
.oct-score-entry-card .oct-field input[type="text"]:focus {
    outline: 2px solid rgba(57, 208, 255, 0.65);
    outline-offset: 1px;
    border-color: #39d0ff;
}
.oct-score-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
.oct-location-group { position: relative; }
.oct-location-group .oct-field { margin-bottom: 0; }
.oct-location-suggestions {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 180px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid #44445e;
    border-radius: 9px;
    background: #0c0c14;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.oct-location-suggestions[hidden] { display: none; }
.oct-location-suggestions button {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #e9e9f2;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.oct-location-suggestions button:hover,
.oct-location-suggestions button:focus { background: #20202e; outline: none; }
.oct-location-credit {
    display: block;
    margin-top: 4px;
    color: #77778c;
    font-size: 9px;
    text-align: right;
}
.oct-location-credit a { color: inherit; }
.oct-score-status { min-height: 20px; margin: 2px 0 8px; text-align: center; color: #ffb0b0; font-size: 13px; }
.oct-score-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.oct-score-actions .lobby-btn { margin-top: 0; }
.oct-score-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 4px 0 0;
    padding: 4px;
    border: 1px solid #44445e;
    border-radius: 11px;
    background: #0c0c14;
}
.oct-score-tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #aaaabd;
    font: inherit;
    font-weight: 800;
    font-size: clamp(11px, 2.5vw, 15px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.oct-score-tab:hover { color: #fff; background: #20202e; }
.oct-score-tab.active { color: #081019; background: #7ff; }
.oct-weekly-reset {
    min-height: 16px;
    margin: 6px 0 8px;
    color: #aaaabd;
    font-size: 11px;
    text-align: center;
}
.oct-high-scores { width: 100%; border-collapse: collapse; color: #e9e9f2; font-size: 13px; }
.oct-score-caption {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
    padding-top: 8px;
    color: #aaaabd;
    font-size: 11px;
    text-align: left;
}
.oct-score-caption span {
    flex: 1 1 auto;
    min-width: 0;
    white-space: normal;
}
.oct-score-refresh-link {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #7ff;
    font: inherit;
    font-weight: 400;
    text-decoration: underline;
    cursor: pointer;
    white-space: nowrap;
}
.oct-score-refresh-link:hover { color: #fff; }
.oct-score-refresh-link:disabled {
    color: #aaaabd;
    cursor: default;
    text-decoration: none;
}
.oct-season-save-note {
    margin: 4px 0 2px;
    color: #ffd48a;
    font-size: 12px;
    line-height: 1.25;
}
.oct-high-scores th, .oct-high-scores td { padding: 8px 7px; border-bottom: 1px solid #33334a; text-align: left; }
.oct-high-scores th:last-child, .oct-high-scores td:last-child { text-align: right; font-weight: 800; }
.oct-high-scores a,
.oct-high-scores a[x-apple-data-detectors],
.oct-high-scores a[x-apple-data-detectors]:hover,
.oct-high-scores a[x-apple-data-detectors]:active,
.oct-high-scores a[x-apple-data-detectors]:visited {
    color: inherit !important;
    cursor: default !important;
    text-decoration: none !important;
    pointer-events: none !important;
}
.oct-high-scores .oct-player-score-row {
    color: #fff;
    background: rgba(57, 208, 255, 0.22);
    outline: 2px solid #39d0ff;
    outline-offset: -2px;
}
.oct-unverified-score {
    display: inline-block;
    width: 0.75em;
    margin-right: 2px;
    color: #ffcc66;
    font-weight: 900;
    cursor: help;
}
.oct-season-trophy {
    display: inline-block;
    margin-right: 5px;
    font-size: 0.92em;
    filter: drop-shadow(0 0 2px rgba(255, 214, 94, 0.45));
    transform-origin: center;
    animation: octTrophyGlow 2.8s ease-in-out infinite;
}
.oct-season-winner {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    max-width: 100%;
    cursor: help;
    border-radius: 6px;
}
.oct-season-winner:focus {
    outline: 2px solid rgba(104, 255, 255, 0.85);
    outline-offset: 2px;
}
.oct-season-winner::after {
    content: attr(data-oct-tooltip);
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    z-index: 20;
    min-width: max-content;
    max-width: min(260px, 75vw);
    padding: 7px 10px;
    border: 1px solid rgba(104, 255, 255, 0.55);
    border-radius: 10px;
    background: rgba(16, 16, 27, 0.96);
    color: #f5f5ff;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
    font-size: 0.72em;
    font-weight: 800;
    line-height: 1.25;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 120ms ease, transform 120ms ease;
}
.oct-season-winner:hover::after,
.oct-season-winner:focus::after,
.oct-season-winner.oct-tooltip-open::after {
    opacity: 1;
    transform: translateY(0);
}
@keyframes octTrophyGlow {
    0%, 100% {
        filter: drop-shadow(0 0 1px rgba(255, 214, 94, 0.35));
        transform: scale(1);
    }
    45% {
        filter: drop-shadow(0 0 6px rgba(255, 230, 140, 0.75));
        transform: scale(1.05);
    }
}
.oct-player-score-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0;
    padding: 12px 14px;
    border: 1px solid #44445e;
    border-radius: 10px;
    background: #151520;
}

@media (prefers-reduced-motion: reduce) {
    .oct-season-trophy {
        animation: none;
    }
}
.oct-player-score-bottom strong { color: #7ff; font-size: 22px; }
.oct-gameover-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}
.oct-gameover-actions .lobby-btn {
    width: 100%;
    margin-top: 0;
    padding: 9px 10px;
    font-size: 14px;
}
.oct-gameover-actions .lobby-btn:only-child { grid-column: 1 / -1; }
#octWinnerCard.oct-score-card > .oct-setup-foot { flex: 0 0 auto; }
@media (max-width: 600px) {
    #octArcadeHud { min-width: 180px; }
    #octWinnerCard.oct-score-card { padding: 14px 12px 10px; }
    #octWinnerCard.oct-score-card h2 { margin-bottom: 8px; font-size: 25px; }
    #octWinnerCard.oct-score-card .oct-score-tabs {
        gap: 3px;
        margin-top: 0;
        padding: 3px;
    }
    #octWinnerCard.oct-score-card .oct-score-tab {
        padding: 6px 4px;
        font-size: 11px;
    }
    #octWinnerCard.oct-score-card .oct-weekly-reset { margin: 3px 0 4px; }
    #octWinnerCard.oct-score-card .oct-standings-wrap { margin-bottom: 6px; }
    #octWinnerCard.oct-score-card .oct-back { margin-top: 7px; }
    .oct-high-scores { font-size: 11px; }
    .oct-high-scores th, .oct-high-scores td { padding: 6px 3px; }
    .oct-score-entry-card h1 { margin-bottom: 10px; font-size: 21px; }
    .oct-score-entry-card .oct-score-fields {
        grid-template-columns: 1fr;
        gap: 2px;
    }
    .oct-score-entry-card .oct-field { margin-bottom: 5px; }
    .oct-score-entry-card .oct-score-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .oct-score-entry-card .oct-score-actions .lobby-btn {
        padding: 9px 8px;
        font-size: 14px;
    }
}

/* Name picker grid (public games). */
.oct-name-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 4px;
}
.oct-name-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}
.oct-name-picker-card > .oct-setup-foot {
    flex: 0 0 auto;
    background: #14141f;
}

/* On short screens, scroll the main-menu choices rather than the whole card. */
.oct-main-menu-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 4px;
}
.oct-name-btn {
    padding: 11px;
    border-radius: 10px;
    border: 1px solid #44445e;
    background: #20202e;
    color: #e9e9f2;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}
.oct-name-btn:hover { filter: brightness(1.15); border-color: #5a5a72; }

/* Persistent "X joined (N/8)" line above the host's Start Game button. */
.oct-host-status {
    text-align: center;
    font-size: 13px;
    color: #c9c9da;
    margin-bottom: 8px;
}
.oct-host-start-error {
    min-height: 18px;
    margin-bottom: 3px;
    color: #ff9b9b;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}
.oct-host-start-error[hidden] { display: none; }

/* Footer row: Back link left-aligned, Support link to its right. */
.oct-setup-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.oct-setup-foot .oct-back { margin-top: 12px; text-align: left; }
.oct-setup-foot .oct-support { color: #d8ffd8; }

/* ---------- Winner overlay ---------- */
.oct-celebration,
#octCelebration {
    position: fixed;
    inset: 0;
    z-index: 27;
    opacity: 0.5;
    pointer-events: none;
}
#octWinner {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: #0b0b12;
    padding: 92px 16px 52px;
    box-sizing: border-box;
}
#octWinnerCard {
    position: relative;
    z-index: 26;
    text-align: center;
    background: #14141f;
    border: 1px solid #33334a;
    border-radius: 14px;
    padding: 24px 26px;
    max-width: min(460px, 94vw);
    max-height: calc(100dvh - 144px);
    overflow: auto;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6);
}
#octWinnerCard h2 { margin: 0 0 18px; font-size: 30px; }
#octAgain {
    padding: 11px 22px;
    border-radius: 10px;
    border: 1px solid #3a6ad0;
    background: #2a55b8;
    color: #fff;
    font-weight: 800;
    font-size: 15px;
    cursor: pointer;
}
#octAgain:hover { filter: brightness(1.08); }

.oct-winner-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}
.oct-textbtn {
    background: none;
    border: none;
    padding: 4px;
    color: #7ff;
    font: 600 13px system-ui, "Segoe UI", sans-serif;
    text-decoration: none;
    cursor: pointer;
}
.oct-textbtn:hover { text-decoration: underline; }

/* ---------- Standings table (end / between-round screen) ---------- */
.oct-standings-wrap {
    max-height: 46vh;
    overflow: auto;
    margin: 4px 0 16px;
    -webkit-overflow-scrolling: touch;
}
.oct-standings {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 13px;
    color: #e9e9f2;
}
.oct-standings th, .oct-standings td {
    padding: 5px 9px;
    text-align: center;
    white-space: nowrap;
}
.oct-standings th {
    color: #9a9ab0;
    font-size: 11px;
    font-weight: 700;
    border-bottom: 1px solid #33334a;
}
.oct-standings td:nth-child(2) { text-align: left; }
.oct-standings tr.oct-lead td { color: #fff; font-weight: 700; }
.oct-standings tr.oct-lead { background: rgba(122, 220, 255, 0.10); }
.oct-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 7px;
    vertical-align: middle;
}
.oct-you { color: #7ff; font-size: 11px; }

/* ---------- Floating Ko-fi support pill (bottom-right) ---------- */
#supportFloat {
    position: fixed;
    bottom: max(10px, env(safe-area-inset-bottom));
    right: max(12px, env(safe-area-inset-right));
    z-index: 40;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(0, 255, 0, 0.45);
    background: rgba(15, 15, 22, 0.92);
    color: #d8ffd8;
    font: 700 13px system-ui, "Segoe UI", sans-serif;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    user-select: none;
}
#supportFloat:visited { color: #d8ffd8; }
#supportFloat:hover { background: rgba(28, 28, 40, 0.96); border-color: rgba(0, 255, 0, 0.75); }

/* ---------- Menu button (top-left on every screen) ---------- */
#octMenuBtn {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 45;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid #44445e;
    background: rgba(15, 15, 22, 0.92);
    color: #cdd6e6;
    font: 700 13px system-ui, "Segoe UI", sans-serif;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    user-select: none;
}
#octMenuBtn:hover { background: rgba(28, 28, 40, 0.96); border-color: #5a5a72; }

/* ---------- Sound/account controls (top-right) ---------- */
#octTopRight {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 12px;
}

#octSoundBtn {
    width: 38px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #44445e;
    background: rgba(15, 15, 22, 0.92);
    color: #cdd6e6;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    user-select: none;
}
#octSoundBtn:hover { background: rgba(28, 28, 40, 0.96); border-color: #5a5a72; }

#octPlayerAccount {
    min-width: 0;
}
#octPlayerAccount .sfg-account-profile {
    max-width: 190px;
}
#octPlayerAccount .sfg-account-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Small screens / phones ---------- */
@media (max-width: 480px) {
    #octSetupCard { padding: 16px; width: 96vw; }
    #octSetupCard h1 { font-size: 24px; }
    .oct-sub { font-size: 12px; }
    /* >=16px keeps iOS from zooming the page when a field is focused */
    #octName, #octJoinName, .oct-field select { font-size: 16px; }
    #octHint { font-size: 11px; padding: 0 10px; text-align: center; }
    #octMenuBtn { padding: 6px 10px; font-size: 12px; }
    /* Stack paired controls one-per-line so nothing gets squeezed. */
    .oct-row2 { flex-direction: column; gap: 0; }
    /* AI / player slots stack to a single column too. */
    #octSlots { grid-template-columns: 1fr; }
}

/* On short phones, show useful summaries and open the full controls in a
   focused editor instead of squeezing them into a tiny scrolling area. */
@media (max-width: 600px) and (max-height: 760px) {
    body.oct-settings-edit-open #octHeader,
    body.oct-settings-edit-open #octMenuBtn,
    body.oct-settings-edit-open #octTopRight,
    body.oct-settings-edit-open #octSoundBtn,
    body.oct-settings-edit-open #octPlayerAccount,
    body.oct-settings-edit-open #octCopyright,
    body.oct-settings-edit-open #supportFloat,
    body.oct-settings-edit-open .oct-start-actions,
    body.oct-settings-edit-open #octPublicInvite,
    body.oct-settings-edit-open .oct-setup-foot .oct-support {
        display: none !important;
    }
    #octSetupCard.oct-host-setup {
        height: calc(100vh - 144px);
        height: calc(100dvh - 144px);
    }
    .oct-settings-setup #octTabContent { margin-bottom: 7px; }
    .oct-host-setup .oct-host-status { margin-top: -4px; margin-bottom: 6px; }
    .oct-settings-setup .oct-compact-settings {
        display: block;
        padding: 3px 2px;
    }
    .oct-settings-setup .oct-settings-summary {
        margin: 0;
        color: #d7d7e5;
        font-size: 14px;
        line-height: 1.5;
    }
    .oct-settings-setup .oct-edit-settings {
        display: inline;
        padding: 0;
        border: 0;
        background: transparent;
        color: #7ff;
        font: 700 14px system-ui, "Segoe UI", sans-serif;
        text-decoration: underline;
        cursor: pointer;
    }
    .oct-settings-setup .oct-tabpane > .oct-pane-fields { display: none; }
    .oct-settings-setup .oct-tabpane > .oct-pane-fields.is-editing {
        position: fixed;
        z-index: 100;
        inset: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
        border: 1px solid #4b4b66;
        border-radius: 14px;
        background: #14141f;
        box-shadow: 0 0 0 100vmax rgba(5, 5, 10, 0.82), 0 18px 70px #000;
    }
    .oct-settings-setup .oct-edit-scroll {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 18px 16px 10px;
    }
    .oct-settings-setup .oct-mobile-edit-actions {
        display: flex;
        flex: 0 0 auto;
        gap: 10px;
        padding: 10px 16px 16px;
        border-top: 1px solid #33334a;
        background: #14141f;
    }
    .oct-settings-setup .oct-mobile-edit-actions button {
        flex: 1;
        padding: 11px;
        border: 1px solid #4b4b66;
        border-radius: 9px;
        background: #242436;
        color: #fff;
        font-weight: 800;
        font-size: 15px;
    }
    .oct-settings-setup .oct-mobile-edit-actions button[data-edit-ok] {
        border-color: #2a8a52;
        background: #1a7a44;
    }
}

/* Cup-only support action on phones, mobile landscape, and touch devices. */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    #supportFloat,
    .oct-setup-foot .oct-support {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 34px;
        padding: 0;
        overflow: hidden;
        white-space: nowrap;
        font-size: 0;
    }
    #supportFloat {
        position: fixed;
        bottom: max(8px, env(safe-area-inset-bottom));
        border: 0;
        background: transparent;
        box-shadow: none;
    }
    .oct-setup-foot .oct-support { position: relative; }
    #supportFloat::before,
    .oct-setup-foot .oct-support::before {
        content: "☕";
        position: absolute;
        inset: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding-left: 2px;
        font-size: 18px;
        line-height: 1;
    }
    #supportFloat::before {
        align-items: flex-end;
    }
    #supportFloat:hover {
        border: 0;
        background: transparent;
    }
}
