:root {
    --ink: #172018;
    --muted: #66736a;
    --paper: #f7f6ef;
    --surface: rgba(255, 255, 255, 0.9);
    --line: rgba(23, 32, 24, 0.14);
    --moss: #35a66f;
    --acid: #d7f252;
    --berry: #e0528d;
    --ember: #f29b4b;
    --night: #21303f;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    touch-action: auto;
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 20%, rgba(215, 242, 82, 0.34), transparent 26%),
        radial-gradient(circle at 80% 12%, rgba(224, 82, 141, 0.22), transparent 26%),
        linear-gradient(135deg, #ecf4df 0%, #f8efe9 44%, #e9f2f5 100%);
}

body.is-playing {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html:fullscreen {
    width: 100%;
    height: 100%;
}

html:fullscreen body.is-playing,
html:fullscreen body.is-playing #app,
html:fullscreen body.is-playing .match-screen {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.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;
}

.lobby-brand {
    text-align: center;
}

.lobby-brand .tagline {
    margin-inline: auto;
}

.brawl-lobby {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(240px, 320px);
    gap: 16px;
    width: min(1040px, 100%);
    margin: 0 auto;
    align-items: stretch;
}

.selected-character-card,
.selection-panel,
.map-info-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(26, 36, 30, 0.12);
    backdrop-filter: blur(18px);
}

.selected-character-card {
    display: grid;
    gap: 12px;
    align-content: start;
    justify-items: center;
    padding: 16px;
    min-height: 360px;
}

.character-bundle-button {
    width: 100%;
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #d7f252, #7ee65b);
}

.bundle-icons {
    display: flex;
    gap: 4px;
}

.bundle-icons i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #35a66f;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.lobby-character-preview {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    position: relative;
    width: min(170px, 55vw);
    aspect-ratio: 1;
    border-radius: 42% 42% 46% 46%;
    background: radial-gradient(circle at 35% 30%, #fff 0 7%, transparent 8%), var(--character-color);
    box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.12), 0 24px 30px rgba(23, 32, 24, 0.16);
}

.lobby-character-preview::before,
.lobby-character-preview::after {
    content: '';
    position: absolute;
    top: 42%;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--character-accent);
}

.lobby-character-preview::before { left: 25%; }
.lobby-character-preview::after { right: 25%; }

.lobby-character-preview.is-slime {
    border-radius: 48% 48% 38% 38%;
    transform: scaleY(0.88);
}

.selected-character-name {
    margin: 0;
    font-weight: 900;
}

.lobby-play-panel {
    border-radius: 18px;
    gap: 14px;
}

.selected-map-card {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 2px solid rgba(53, 166, 111, 0.35);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.76);
    cursor: pointer;
}

.selected-map-card canvas,
.map-choice-card canvas,
.map-info-card canvas {
    width: 100%;
    border-radius: 12px;
    background: #dff2c4;
    box-shadow: inset 0 0 0 1px rgba(23, 32, 24, 0.12);
}

.selected-map-card h2 {
    font-size: clamp(20px, 4vw, 30px);
}

.selected-map-card p:not(.eyebrow) {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

.map-card-actions {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 8px;
}

#mapInfoButton {
    border-radius: 999px;
    font-size: 20px;
}

.map-select-screen,
.character-select-screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.selection-panel {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.map-grid,
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.map-choice-card,
.character-choice-card,
.custom-map-choice {
    display: grid;
    gap: 8px;
    justify-items: start;
    min-height: 0;
    height: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.8);
    box-shadow: none;
    text-align: left;
}

.map-choice-card.is-selected,
.character-choice-card.is-selected {
    border-color: rgba(53, 166, 111, 0.8);
    background: rgba(215, 242, 82, 0.3);
}

.map-choice-card small,
.character-choice-card small {
    color: var(--muted);
    line-height: 1.35;
}

.custom-map-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.character-choice-avatar {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    width: 80px;
    aspect-ratio: 1;
    border-radius: 44%;
    background: var(--character-color);
    box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12);
}

.character-choice-card {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    justify-items: center;
    text-align: center;
}

.character-choice-card .character-choice-avatar {
    background: radial-gradient(circle at 33% 35%, var(--character-accent) 0 8%, transparent 9%), radial-gradient(circle at 66% 35%, var(--character-accent) 0 8%, transparent 9%), var(--character-color);
}

.map-info-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 12, 10, 0.48);
}

.map-info-modal[hidden] {
    display: none;
}

.map-info-card {
    position: relative;
    width: min(520px, 100%);
    padding: 18px;
}

.map-info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 42px;
    min-height: 42px;
    border-radius: 999px;
    font-size: 22px;
}

.map-info-card p {
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 820px) {
    .brawl-lobby {
        grid-template-columns: 1fr;
    }

    .selected-character-card {
        min-height: 0;
    }

    .selected-map-card {
        grid-template-columns: 1fr;
    }
}

.match-screen {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

#app,
.screen {
    width: 100%;
}

#app {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: visible;
}

body:not(.is-playing) #app {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: visible;
    touch-action: pan-y;
}

body.is-playing #app {
    height: 100%;
    overflow: hidden;
}

.screen[hidden] {
    display: none;
}

.lobby-screen {
    display: flex;
    flex-direction: column;
    gap: 22px;
    justify-content: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: visible;
    touch-action: auto;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.brand-lockup {
    width: min(860px, 100%);
    margin: 0 auto;
}

.eyebrow {
    margin: 0 0 6px;
    color: #34705b;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(46px, 12vw, 92px);
    line-height: 0.9;
}

.tagline {
    max-width: 560px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}

.lobby-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    gap: 16px;
    width: min(860px, 100%);
    margin: 0 auto;
}

.join-panel,
.leaderboard-panel,
.result-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(26, 36, 30, 0.12);
    backdrop-filter: blur(18px);
}

.join-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
}

.join-panel label,
.hud-label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.mode-picker,
.character-picker {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0;
    border: 0;
    padding: 0;
}

.mode-picker legend,
.character-picker legend {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.mode-option,
.character-option {
    display: flex;
    align-items: stretch;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 253, 248, 0.7);
    cursor: pointer;
    overflow: hidden;
}

.mode-option input,
.character-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mode-option span,
.character-option span {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 11px 12px;
}

.mode-option strong,
.character-option strong {
    color: var(--ink);
    font-size: 14px;
}

.mode-option small,
.character-option small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.25;
}

.mode-option:has(input:checked),
.character-option:has(input:checked) {
    border-color: rgba(53, 166, 111, 0.7);
    background: rgba(215, 242, 82, 0.28);
    box-shadow: inset 0 0 0 2px rgba(53, 166, 111, 0.16);
}

.character-option:has(input[value="slime"]:checked) {
    border-color: rgba(42, 180, 80, 0.8);
    background: rgba(111, 232, 92, 0.28);
}

.mode-option:has(input:focus-visible),
.character-option:has(input:focus-visible) {
    outline: 3px solid rgba(53, 166, 111, 0.18);
    outline-offset: 2px;
}

.mode-picker:has(input:disabled),
.character-picker:has(input:disabled) {
    opacity: 0.64;
}

.join-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.bot-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    text-transform: none;
}

.bot-toggle input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--moss);
}

input {
    min-width: 0;
    height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 13px;
    color: var(--ink);
    background: #fffdf8;
    outline: 0;
}

input:focus {
    border-color: var(--moss);
    box-shadow: 0 0 0 3px rgba(53, 166, 111, 0.18);
}

button {
    min-height: 44px;
    border-radius: 8px;
    padding: 0 16px;
    color: #07140c;
    background: var(--acid);
    font-weight: 900;
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

button:active {
    transform: translateY(1px);
}

.ghost-button {
    border: 1px solid var(--line);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.54);
    box-shadow: none;
}

.status-line,
.queue-copy {
    min-height: 20px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.queue-meter {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(33, 48, 63, 0.12);
}

.queue-meter span {
    display: block;
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--moss), var(--acid), var(--berry));
    transition: width 180ms ease;
}

.leaderboard-panel {
    padding: 16px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.panel-head h2 {
    font-size: 18px;
}

.panel-head button {
    min-height: 34px;
    padding: 0 10px;
    font-size: 12px;
}

.leaderboard-list,
.result-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.leaderboard-list li,
.result-list li {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 42px;
    border: 1px solid rgba(23, 32, 24, 0.08);
    border-radius: 8px;
    padding: 8px;
    background: rgba(255, 253, 248, 0.72);
    font-size: 13px;
}

.leaderboard-list strong,
.result-list strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-pill {
    color: #fff;
    border-radius: 999px;
    padding: 4px 7px;
    background: var(--night);
    font-size: 11px;
    font-weight: 800;
}


.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;
}

.lobby-brand {
    text-align: center;
}

.lobby-brand .tagline {
    margin-inline: auto;
}

.brawl-lobby {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(240px, 320px);
    gap: 16px;
    width: min(1040px, 100%);
    margin: 0 auto;
    align-items: stretch;
}

.selected-character-card,
.selection-panel,
.map-info-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(26, 36, 30, 0.12);
    backdrop-filter: blur(18px);
}

.selected-character-card {
    display: grid;
    gap: 12px;
    align-content: start;
    justify-items: center;
    padding: 16px;
    min-height: 360px;
}

.character-bundle-button {
    width: 100%;
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #d7f252, #7ee65b);
}

.bundle-icons {
    display: flex;
    gap: 4px;
}

.bundle-icons i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #35a66f;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.lobby-character-preview {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    position: relative;
    width: min(170px, 55vw);
    aspect-ratio: 1;
    border-radius: 42% 42% 46% 46%;
    background: radial-gradient(circle at 35% 30%, #fff 0 7%, transparent 8%), var(--character-color);
    box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.12), 0 24px 30px rgba(23, 32, 24, 0.16);
}

.lobby-character-preview::before,
.lobby-character-preview::after {
    content: '';
    position: absolute;
    top: 42%;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--character-accent);
}

.lobby-character-preview::before { left: 25%; }
.lobby-character-preview::after { right: 25%; }

.lobby-character-preview.is-slime {
    border-radius: 48% 48% 38% 38%;
    transform: scaleY(0.88);
}

.selected-character-name {
    margin: 0;
    font-weight: 900;
}

.lobby-play-panel {
    border-radius: 18px;
    gap: 14px;
}

.selected-map-card {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 2px solid rgba(53, 166, 111, 0.35);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.76);
    cursor: pointer;
}

.selected-map-card canvas,
.map-choice-card canvas,
.map-info-card canvas {
    width: 100%;
    border-radius: 12px;
    background: #dff2c4;
    box-shadow: inset 0 0 0 1px rgba(23, 32, 24, 0.12);
}

.selected-map-card h2 {
    font-size: clamp(20px, 4vw, 30px);
}

.selected-map-card p:not(.eyebrow) {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

.map-card-actions {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 8px;
}

#mapInfoButton {
    border-radius: 999px;
    font-size: 20px;
}

.map-select-screen,
.character-select-screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.selection-panel {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.map-grid,
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.map-choice-card,
.character-choice-card,
.custom-map-choice {
    display: grid;
    gap: 8px;
    justify-items: start;
    min-height: 0;
    height: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.8);
    box-shadow: none;
    text-align: left;
}

.map-choice-card.is-selected,
.character-choice-card.is-selected {
    border-color: rgba(53, 166, 111, 0.8);
    background: rgba(215, 242, 82, 0.3);
}

.map-choice-card small,
.character-choice-card small {
    color: var(--muted);
    line-height: 1.35;
}

.custom-map-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.character-choice-avatar {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    width: 80px;
    aspect-ratio: 1;
    border-radius: 44%;
    background: var(--character-color);
    box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12);
}

.character-choice-card {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    justify-items: center;
    text-align: center;
}

.character-choice-card .character-choice-avatar {
    background: radial-gradient(circle at 33% 35%, var(--character-accent) 0 8%, transparent 9%), radial-gradient(circle at 66% 35%, var(--character-accent) 0 8%, transparent 9%), var(--character-color);
}

.map-info-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 12, 10, 0.48);
}

.map-info-modal[hidden] {
    display: none;
}

.map-info-card {
    position: relative;
    width: min(520px, 100%);
    padding: 18px;
}

.map-info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 42px;
    min-height: 42px;
    border-radius: 999px;
    font-size: 22px;
}

.map-info-card p {
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 820px) {
    .brawl-lobby {
        grid-template-columns: 1fr;
    }

    .selected-character-card {
        min-height: 0;
    }

    .selected-map-card {
        grid-template-columns: 1fr;
    }
}

.match-screen {
    position: relative;
    height: 100dvh;
    overflow: hidden;
    background: #172018;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body.is-playing.is-game-fullscreen .match-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.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;
}

.lobby-brand {
    text-align: center;
}

.lobby-brand .tagline {
    margin-inline: auto;
}

.brawl-lobby {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(240px, 320px);
    gap: 16px;
    width: min(1040px, 100%);
    margin: 0 auto;
    align-items: stretch;
}

.selected-character-card,
.selection-panel,
.map-info-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(26, 36, 30, 0.12);
    backdrop-filter: blur(18px);
}

.selected-character-card {
    display: grid;
    gap: 12px;
    align-content: start;
    justify-items: center;
    padding: 16px;
    min-height: 360px;
}

.character-bundle-button {
    width: 100%;
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 14px;
    border-radius: 16px;
    background: linear-gradient(135deg, #d7f252, #7ee65b);
}

.bundle-icons {
    display: flex;
    gap: 4px;
}

.bundle-icons i {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #35a66f;
    box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.14);
}

.lobby-character-preview {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    position: relative;
    width: min(170px, 55vw);
    aspect-ratio: 1;
    border-radius: 42% 42% 46% 46%;
    background: radial-gradient(circle at 35% 30%, #fff 0 7%, transparent 8%), var(--character-color);
    box-shadow: inset 0 -18px 0 rgba(0, 0, 0, 0.12), 0 24px 30px rgba(23, 32, 24, 0.16);
}

.lobby-character-preview::before,
.lobby-character-preview::after {
    content: '';
    position: absolute;
    top: 42%;
    width: 18%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--character-accent);
}

.lobby-character-preview::before { left: 25%; }
.lobby-character-preview::after { right: 25%; }

.lobby-character-preview.is-slime {
    border-radius: 48% 48% 38% 38%;
    transform: scaleY(0.88);
}

.selected-character-name {
    margin: 0;
    font-weight: 900;
}

.lobby-play-panel {
    border-radius: 18px;
    gap: 14px;
}

.selected-map-card {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 2px solid rgba(53, 166, 111, 0.35);
    border-radius: 18px;
    background: rgba(255, 253, 248, 0.76);
    cursor: pointer;
}

.selected-map-card canvas,
.map-choice-card canvas,
.map-info-card canvas {
    width: 100%;
    border-radius: 12px;
    background: #dff2c4;
    box-shadow: inset 0 0 0 1px rgba(23, 32, 24, 0.12);
}

.selected-map-card h2 {
    font-size: clamp(20px, 4vw, 30px);
}

.selected-map-card p:not(.eyebrow) {
    margin: 6px 0 0;
    color: var(--muted);
    line-height: 1.35;
}

.map-card-actions {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 8px;
}

#mapInfoButton {
    border-radius: 999px;
    font-size: 20px;
}

.map-select-screen,
.character-select-screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.selection-panel {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 18px;
}

.map-grid,
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.map-choice-card,
.character-choice-card,
.custom-map-choice {
    display: grid;
    gap: 8px;
    justify-items: start;
    min-height: 0;
    height: auto;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 253, 248, 0.8);
    box-shadow: none;
    text-align: left;
}

.map-choice-card.is-selected,
.character-choice-card.is-selected {
    border-color: rgba(53, 166, 111, 0.8);
    background: rgba(215, 242, 82, 0.3);
}

.map-choice-card small,
.character-choice-card small {
    color: var(--muted);
    line-height: 1.35;
}

.custom-map-list {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.character-choice-avatar {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    width: 80px;
    aspect-ratio: 1;
    border-radius: 44%;
    background: var(--character-color);
    box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12);
}

.character-choice-card {
    --character-color: #6ee7b7;
    --character-accent: #064e3b;
    justify-items: center;
    text-align: center;
}

.character-choice-card .character-choice-avatar {
    background: radial-gradient(circle at 33% 35%, var(--character-accent) 0 8%, transparent 9%), radial-gradient(circle at 66% 35%, var(--character-accent) 0 8%, transparent 9%), var(--character-color);
}

.map-info-modal {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(8, 12, 10, 0.48);
}

.map-info-modal[hidden] {
    display: none;
}

.map-info-card {
    position: relative;
    width: min(520px, 100%);
    padding: 18px;
}

.map-info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 42px;
    min-height: 42px;
    border-radius: 999px;
    font-size: 22px;
}

.map-info-card p {
    color: var(--muted);
    line-height: 1.55;
}

@media (max-width: 820px) {
    .brawl-lobby {
        grid-template-columns: 1fr;
    }

    .selected-character-card {
        min-height: 0;
    }

    .selected-map-card {
        grid-template-columns: 1fr;
    }
}

.match-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    width: 100vw;
    height: 100dvh;
}

#gameCanvas {
    display: block;
    width: 100vw;
    height: 100dvh;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html:fullscreen body.is-playing #gameCanvas {
    height: 100vh;
}

.hud {
    position: absolute;
    z-index: 20;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    color: #f8fff4;
    background: rgba(10, 18, 12, 0.72);
    backdrop-filter: blur(14px);
}

.top-hud {
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    display: flex;
    gap: 8px;
    padding: 8px;
    transform: translateX(-50%);
}

.top-hud div {
    min-width: 64px;
    text-align: center;
}

.top-hud strong {
    display: block;
    font-size: 18px;
}

.connection-hud {
    top: max(14px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
}

.fullscreen-exit {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 35;
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 999px;
    color: #f8fff4;
    background: rgba(10, 18, 12, 0.76);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
}

.stick-zone {
    position: absolute;
    z-index: 30;
    width: min(32vw, 138px);
    aspect-ratio: 1;
    bottom: max(20px, env(safe-area-inset-bottom));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 36px rgba(255, 255, 255, 0.06);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.left-stick {
    left: max(20px, env(safe-area-inset-left));
}

.right-stick {
    right: max(20px, env(safe-area-inset-right));
}

.ultimate-button {
    position: absolute;
    z-index: 31;
    right: max(168px, calc(env(safe-area-inset-right) + 168px));
    bottom: max(42px, calc(env(safe-area-inset-bottom) + 42px));
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    gap: 0;
    border: 2px solid rgba(255, 255, 255, 0.22);
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.58);
    background: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.24), rgba(76, 60, 116, 0.72));
    box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.08), 0 14px 28px rgba(0, 0, 0, 0.24);
    touch-action: none;
}

.ultimate-button:disabled {
    opacity: 0.72;
}

.ultimate-button.is-ready {
    color: #fffdf8;
    border-color: rgba(125, 211, 252, 0.82);
    background: radial-gradient(circle at 30% 24%, #fffdf8, #7dd3fc 38%, #8b5cf6 100%);
    box-shadow: 0 0 28px rgba(125, 211, 252, 0.7), 0 14px 28px rgba(0, 0, 0, 0.28);
    opacity: 1;
}

.ultimate-label {
    display: block;
    font-size: 26px;
    font-weight: 1000;
    line-height: 1;
}

.ultimate-count {
    display: block;
    margin-top: -8px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: -0.02em;
}


.stick-zone.is-floating-stick {
    transform: translate(-50%, -50%);
    opacity: 0.96;
}

.left-stick-floating {
    border-color: rgba(215, 242, 82, 0.34);
}

.right-stick-floating {
    border-color: rgba(224, 82, 141, 0.38);
}

.stick-thumb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff8df, #d7f252);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.result-screen {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 18px;
    background: rgba(8, 13, 10, 0.54);
    backdrop-filter: blur(10px);
}

.result-panel {
    width: min(460px, 100%);
    padding: 18px;
}

.result-panel h2 {
    margin-bottom: 14px;
    font-size: 32px;
}

.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.result-actions button {
    flex: 1;
}

@media (max-width: 720px) {
    .lobby-screen {
        justify-content: flex-start;
    }

    .lobby-layout {
        grid-template-columns: 1fr;
    }

    .join-row {
        grid-template-columns: 1fr;
    }

    .mode-picker {
        grid-template-columns: 1fr;
    }

    .leaderboard-panel {
        padding: 14px;
    }

    .top-hud {
        left: max(10px, env(safe-area-inset-left));
        transform: none;
    }

    .top-hud div {
        min-width: 52px;
    }

    .connection-hud {
        max-width: 112px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

@media (max-height: 520px) {
    .stick-zone {
        width: min(24vw, 112px);
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .top-hud {
        padding: 6px;
    }
}


.map-select-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.map-select-row select {
    min-width: 0;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    color: var(--ink);
    background: #fffdf8;
    font-weight: 800;
}

.map-editor-screen {
    min-height: 100vh;
    min-height: 100dvh;
    padding: max(22px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.map-editor-panel {
    display: grid;
    gap: 12px;
    width: min(980px, 100%);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    background: var(--surface);
    box-shadow: 0 18px 50px rgba(26, 36, 30, 0.12);
}

.map-editor-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) repeat(2, minmax(88px, 120px)) auto auto;
    gap: 8px;
    align-items: end;
}

.map-editor-controls label {
    display: grid;
    gap: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

#mapEditorCanvas {
    width: 100%;
    max-height: 66vh;
    border: 1px solid rgba(23, 32, 24, 0.18);
    border-radius: 8px;
    background: #172018;
    touch-action: none;
}

.map-toolbox {
    position: sticky;
    bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 253, 248, 0.88);
    backdrop-filter: blur(12px);
}

.map-tool.is-selected {
    color: #f8fff4;
    background: var(--moss);
}

.map-editor-status {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

@media (max-width: 720px) {
    .map-editor-controls {
        grid-template-columns: 1fr 1fr;
    }

    .map-editor-controls label:first-child {
        grid-column: 1 / -1;
    }
}
