.header { padding: 0 clamp(12px, 2.2vw, 36px); }
.header-right { gap: clamp(5px, 1vw, 12px); }
.game-logo { margin: clamp(8px, 2vw, 28px); }
.game-logo img { width: clamp(96px, 12vw, 188px); filter: drop-shadow(0 4px 5px #21140880); }

#lobby-bg-video {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center bottom;
    z-index: -1;
    pointer-events: none;
}

.player-sprite:not(.has-gel-avatar)::before {
    content: '';
    position: absolute;
    left: 50%;
    /* Os pés modulares terminam 46px abaixo da caixa do avatar. */
    bottom: -43px;
    width: 122px;
    height: 31px;
    transform: translate(-50%, 50%);
    z-index: -2;
    pointer-events: none;
    background:
        radial-gradient(ellipse 39px 5px at 50% 47%,
            rgba(61, 31, 19, .57), rgba(72, 37, 22, .30) 56%, transparent),
        radial-gradient(ellipse 61px 15px at 50% 52%,
            rgba(87, 48, 28, .37), rgba(103, 59, 33, .17) 57%, transparent);
}

.player-sprite.has-rigged-avatar::before {
    /* O rig pinta o chão 4px acima do fim do canvas, que se estende 46px. */
    bottom: -41px;
}

.currency {
    flex-direction: row;
    align-items: center;
    gap: 7px;
    width: auto;
    min-width: 76px;
    padding: 4px 9px;
    background: var(--ui-ink);
    border: 2px solid var(--ui-outline);
    border-radius: 8px;
    box-shadow: 0 3px var(--ui-outline), inset 0 1px #8ccad05c;
    font: 800 14px var(--ui-display);
    font-variant-numeric: tabular-nums;
}
.currency img { width: 28px; height: 28px; flex: none; }
.currency.coins { color: var(--ui-amber); transform: none; }
.currency.gems { color: #dfb9ff; transform: none; }
.header-right .settings-btn { width: 42px; padding: 0; transform: none; }
.news-btn.arcade-control {
    position: fixed;
    top: 78px;
    right: clamp(12px, 2.2vw, 36px);
    z-index: 100;
}

.lobby-customize {
    position: fixed;
    left: 50%;
    bottom: clamp(16px, 3.2vh, 36px);
    translate: -50%;
    z-index: 100;
}
.lobby-customize.arcade-control:hover { translate: -50% -2px; }
.lobby-customize.arcade-control:active { translate: -50% 2px; }

.lobby-modes {
    position: fixed;
    right: clamp(14px, 2.3vw, 38px);
    bottom: clamp(16px, 3.2vh, 36px);
    width: clamp(244px, 21vw, 330px);
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.lobby-mode { flex-direction: column; gap: 4px; min-height: 68px; }
.lobby-mode { font-size: 16px; }
.lobby-mode small { font-size: 11px; color: var(--ui-muted); }
.lobby-private, .lobby-battle { grid-column: 1 / -1; }
.lobby-battle {
    min-height: 69px;
    justify-content: flex-start;
    padding-inline: 19px;
    gap: 13px;
    text-align: left;
    font-size: clamp(19px, 1.75vw, 28px);
    letter-spacing: -.025em;
}
.lobby-battle small { display: block; font-size: 11px; margin-top: 2px; letter-spacing: normal; }

#scenarioPickerModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 3vw, 28px);
    background: #11232bd1;
    backdrop-filter: blur(6px);
}
#scenarioPickerModal.open { display: flex; }
.scenario-picker-box, .settings-dialog, .room-dialog, .waiting-room-content {
    color: var(--ui-paper);
    font-family: var(--ui-display);
    background: var(--ui-ink);
    border: 3px solid var(--ui-outline);
    border-radius: 14px 20px 14px 20px;
    box-shadow: 0 6px var(--ui-outline), 0 24px 60px #120d06ad;
}
.scenario-picker-box {
    width: min(100%, 960px);
    max-height: calc(100dvh - clamp(16px, 6vw, 56px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sp-header, .sp-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 15px clamp(12px, 2.5vw, 25px);
    background: #193642;
}
.sp-header, .settings-header, .room-dialog-header, .waiting-room-header {
    border-bottom: 2px solid var(--ui-outline);
    box-shadow: inset 0 3px var(--ui-flame);
    background: linear-gradient(150deg, #326172, #193642 65%);
}
.sp-header h2, .settings-header h2, .room-dialog-header h2, .waiting-room-header h2 {
    color: var(--ui-amber);
    font-size: clamp(23px, 3vw, 34px);
    font-weight: 900;
    line-height: 1.05;
    text-shadow: 1px 2px var(--ui-outline);
}
.sp-header p { color: var(--ui-muted); font-size: 13px; margin-top: 5px; }
.sp-mode-badge {
    border: 2px solid var(--ui-outline);
    background: #142e37;
    color: var(--ui-sky);
    padding: 6px 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 800;
}
.sp-body {
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.55fr);
    align-items: start;
    gap: 18px;
    padding: 18px clamp(12px, 2.5vw, 25px);
}
.sp-featured-panel, .scenario-card {
    min-width: 0;
    overflow: hidden;
    border: 2px solid var(--ui-outline);
    border-radius: 8px 12px 8px 12px;
    background: var(--ui-panel);
    color: var(--ui-paper);
    box-shadow: 0 3px var(--ui-outline);
}
.sp-featured-thumb, .sc-thumb-wrap {
    display: block;
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #172a30;
}
.sp-featured-thumb img, .sc-thumb-wrap img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.sp-featured-info { padding: 15px; }
.sp-featured-tag {
    color: var(--ui-sky);
    font-size: 11px;
    letter-spacing: .08em;
    font-weight: 800;
    text-transform: uppercase;
}
.sp-featured-name { font-size: clamp(18px, 2vw, 25px); font-weight: 800; margin: 4px 0; }
.sp-featured-desc { color: var(--ui-muted); font-size: 13px; line-height: 1.4; }
.scenario-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.scenario-card {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0;
    font: 800 13px/1.2 var(--ui-display);
    text-align: left;
    cursor: pointer;
}
.sc-thumb-wrap { width: 100%; flex: none; }
.scenario-card:hover { border-color: var(--ui-sky); }
.scenario-card.selected { border-color: var(--ui-amber); box-shadow: 0 3px var(--ui-outline); }
.sc-info {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    min-height: 37px;
    overflow-wrap: anywhere;
}
.sc-check {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    place-items: center;
    background: var(--ui-amber);
    color: var(--ui-ink);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    box-shadow: 0 2px 5px #171d37bb;
}
.scenario-card.selected .sc-check { display: grid; }
.sp-footer { justify-content: flex-end; border-top: 2px solid var(--ui-outline); padding-bottom: 18px; }

.settings-dialog, .room-dialog {
    --settings-gutter: clamp(14px, 5vw, 24px);
    width: min(472px, calc(100% - 24px));
    max-height: calc(100dvh - 28px);
    margin: auto;
    padding: 0;
    overflow: auto;
    color-scheme: dark;
}
.settings-dialog::backdrop { background: #11232bd1; backdrop-filter: blur(6px); }
.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px var(--settings-gutter);
}
.settings-header h2 { font-size: clamp(23px, 5vw, 31px); }
.settings-close.arcade-control { width: 44px; padding: 0; flex: none; }

.settings-body {
    display: grid;
    gap: 21px;
    padding: 19px var(--settings-gutter) 22px;
}
.settings-body label { font-size: 14px; font-weight: 800; }
.settings-profile { display: grid; gap: 7px; }
.settings-profile input, .room-field input {
    width: 100%;
    min-height: 44px;
    padding: 8px 12px;
    border: 2px solid #0c1d23;
    border-radius: 8px 11px 8px 11px;
    background: #10242c;
    box-shadow: inset 0 1px #07181e, 0 1px #70bad14a;
    color: var(--ui-paper);
    font: 700 16px var(--ui-display);
}
.settings-dialog :is(input, .settings-logout):focus-visible, .room-field input:focus-visible {
    outline: 2px solid var(--ui-sky);
    outline-offset: 3px;
}
.settings-profile input[aria-invalid="true"] { border-color: #ffad9b; }
.settings-audio {
    min-width: 0;
    display: grid;
    gap: 13px;
    padding: 9px 13px 13px;
    border: 1px solid #3c5d65;
    border-radius: 9px 13px 9px 13px;
    background: #193642;
}
.settings-audio legend {
    padding: 0 6px;
    color: var(--ui-sky);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.settings-volume {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2px 8px;
}
.settings-volume output {
    min-width: 47px;
    padding: 3px 5px;
    border: 1px solid #436570;
    border-radius: 5px;
    background: #122835;
    color: var(--ui-sky);
    font-size: 12px;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.settings-volume input {
    --level: 50%;
    --track: linear-gradient(to right, #71d2ef 0 var(--level), #10232c var(--level) 100%);
    grid-column: 1 / -1;
    appearance: none;
    width: 100%;
    height: 30px;
    background: transparent;
    cursor: pointer;
}
.settings-volume input::-webkit-slider-runnable-track {
    height: 9px;
    border: 1px solid #0d2027;
    border-radius: 5px;
    background: var(--track);
}
.settings-volume input::-moz-range-track {
    height: 7px;
    border: 1px solid #0d2027;
    border-radius: 5px;
    background: var(--track);
}
.settings-volume input::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 19px;
    margin-top: -6px;
    border: 2px solid var(--ui-outline);
    border-radius: 5px;
    background: linear-gradient(#fff5d5, var(--ui-amber));
}
.settings-volume input::-moz-range-thumb {
    width: 14px;
    height: 15px;
    border: 2px solid var(--ui-outline);
    border-radius: 5px;
    background: linear-gradient(#fff5d5, var(--ui-amber));
}
.settings-error, .room-form-error { color: #ffb8a8; font-size: 13px; }
.settings-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px var(--settings-gutter) 17px;
    border-top: 2px solid var(--ui-outline);
    background: #193642;
}
.settings-actions { display: flex; gap: 8px; margin-inline-start: auto; }
.settings-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    border: 0;
    border-radius: 5px;
    background: transparent;
    color: #ffc2b1;
    font: 800 13px var(--ui-display);
    cursor: pointer;
}
.settings-logout:hover { color: #fff1e5; text-decoration: underline; }
.settings-logout svg { width: 16px; height: 16px; }

.room-dialog { width: min(500px, calc(100% - 24px)); }
#privateRoomModal, #joinRoomModal { width: min(408px, calc(100% - 24px)); }
.room-dialog-header, .waiting-room-header { padding: 15px var(--settings-gutter); }
.room-dialog-header h2, .waiting-room-header h2 { font-size: clamp(23px, 4vw, 29px); }
.room-dialog-body {
    display: grid;
    gap: 16px;
    padding: 18px var(--settings-gutter) 22px;
}
.room-entry-actions .arcade-control { justify-content: flex-start; min-height: 50px; }
.room-dialog-footer, .waiting-room-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
    padding: 13px var(--settings-gutter) 17px;
    border-top: 2px solid var(--ui-outline);
    background: #193642;
}
.room-field { display: grid; gap: 7px; }
.room-field label, .room-mode-field legend { font-size: 14px; font-weight: 800; }
.room-field label span { color: var(--ui-muted); font-weight: 400; }
#roomCode { text-transform: uppercase; letter-spacing: .15em; }
.room-mode-field { border: 0; min-width: 0; }
.mode-tiles-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.mode-tile.arcade-control {
    flex-direction: column;
    gap: 4px;
    min-height: 86px;
    padding: 8px 4px;
    text-align: center;
}

.waiting-room {
    position: fixed;
    inset: 0;
    z-index: 1100;
    padding: clamp(10px, 3vw, 32px);
    overflow: auto;
}
.waiting-room-content {
    --settings-gutter: clamp(12px, 3vw, 22px);
    width: min(100%, 880px);
    flex: none;
    margin: auto;
    overflow: hidden;
}
.waiting-room-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 9px 14px;
}
.room-count-pill {
    border: 1px solid #4a7585;
    border-radius: 7px;
    background: #142e37;
    color: var(--ui-sky);
    padding: 5px 9px;
    font-size: 13px;
    font-weight: 800;
}
.waiting-room-body { padding: 16px var(--settings-gutter); }
.waiting-room-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(172px, 222px);
    gap: 14px;
    align-items: start;
}
.waiting-slots-area, .room-info-sidebar {
    padding: clamp(9px, 2vw, 15px);
    border: 1px solid #3c5d65;
    border-radius: 9px 13px 9px 13px;
    background: #193642;
}
.players-cards-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    width: min(100%, 320px);
    margin-inline: auto;
}
.players-cards-container[data-slots="6"] {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(100%, 464px);
}
.player-card {
    display: grid;
    justify-items: center;
    gap: 5px;
    min-width: 0;
    padding: 8px 5px;
    border: 2px solid var(--ui-outline);
    border-radius: 8px 11px 8px 11px;
    background: #102831;
    text-align: center;
}
.player-card.connected { border-color: #63988d; background: #1c3e45; }
.player-card.loading { border-style: dashed; border-color: #5d7f89; }
.slot-badge { color: var(--ui-muted); font-size: 10px; font-weight: 900; }
.slot-badge.ready { color: #a8f2cc; }
.player-avatar {
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    width: min(100%, 104px);
    height: clamp(66px, 17vh, 108px);
    overflow: hidden;
    color: #73a3b3;
    background: radial-gradient(ellipse at 50% 85%, #61aabb38, transparent 66%);
}
.player-avatar svg { width: 27px; height: 27px; }
.player-skin-preview { display: block; width: 100%; height: 100%; object-fit: contain; }
#waitingRoom .player-name {
    display: block;
    margin: 0;
    color: var(--ui-paper);
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
    max-width: 100%;
}
.room-info-sidebar { display: grid; gap: 12px; }
.sidebar-label { color: var(--ui-muted); font-size: 12px; font-weight: 700; }
.sidebar-value { color: var(--ui-paper); font-size: 15px; font-weight: 900; }
.sidebar-invite-box { padding-top: 10px; border-top: 1px solid #3c5d65; }
.sidebar-invite-code {
    margin-block: 4px 9px;
    color: var(--ui-amber);
    font: 900 clamp(20px, 4vw, 25px) var(--ui-display);
    letter-spacing: .13em;
}
.copy-code-btn.arcade-control { width: 100%; }
.waiting-countdown { font-size: 14px; color: var(--ui-sky); }
.loading-dots { display: flex; gap: 5px; }
.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #71b9ce;
}
.loading-dots span:nth-child(2) { opacity: .65; }
.loading-dots span:nth-child(3) { opacity: .38; }
.waiting-room.is-private #playWithBotsBtn { display: none; }

.message {
    position: fixed;
    top: 84px;
    right: clamp(10px, 2vw, 24px);
    z-index: 1200;
    max-width: min(340px, calc(100vw - 20px));
    padding: 10px 15px;
    border: 2px solid var(--ui-outline);
    border-left: 4px solid var(--ui-sky);
    border-radius: 8px 11px 8px 11px;
    background: var(--ui-ink);
    box-shadow: var(--ui-shadow);
    color: var(--ui-paper);
    font: 800 14px/1.35 var(--ui-display);
    opacity: 0;
    pointer-events: none;
    translate: 12px 0;
    transition: opacity .16s ease, translate .16s ease;
}
.message.show { opacity: 1; translate: 0; }
.message.error { border-left-color: #ff9b85; }
.message.warning { border-left-color: var(--ui-amber); }
@media (prefers-reduced-motion: reduce) { .message { transition: none; } }

@media (max-width: 600px) {
    .waiting-room-stage { grid-template-columns: 1fr; gap: 10px; }
    .waiting-room.is-private .room-info-sidebar { grid-row: 1; }
    .player-avatar { height: clamp(57px, 14vh, 87px); }
}

@media (max-width: 390px) {
    .settings-footer { gap: 7px; }
    .settings-actions .arcade-control { padding-inline: 10px; }
}

@media (max-width: 720px) {
    .scenario-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .game-logo { margin: 6px; }
    .game-logo img { width: 92px; }
    .currency { min-width: 56px; padding: 4px 5px; gap: 3px; font-size: 12px; }
    .currency img { width: 22px; height: 22px; }
    .lobby-customize { padding-inline: 8px; font-size: 12px; }
    .lobby-customize { left: auto; right: 14px; bottom: 12px; translate: none; }
    .lobby-customize.arcade-control:hover { translate: 0 -2px; }
    .lobby-customize.arcade-control:active { translate: 0 2px; }
    .lobby-modes {
        left: 14px;
        right: 14px;
        bottom: 71px;
        width: auto;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }
    .lobby-private { grid-column: auto; padding-inline: 5px; }
    .lobby-battle { min-height: 50px; }
    .lobby-mode { min-height: 49px; padding: 5px; font-size: 13px; }
    .sp-body { display: flex; flex-direction: column; align-items: stretch; gap: 13px; }
    .sp-body > * { flex: none; }
    .sp-featured-panel { display: grid; grid-template-columns: 37% 1fr; }
    .sp-featured-thumb { aspect-ratio: auto; }
    .sp-featured-thumb img { position: absolute; inset: 0; }
    .sp-featured-info { padding: 10px; }
}
@media (max-width: 360px) {
    .lobby-customize {
        gap: 5px;
        padding-inline: 6px;
        font-size: 11px;
    }
}
