* {
    box-sizing: border-box;
}

:root {
    color-scheme: dark;
    --bg: #111;
    --panel: #1b1b1b;
    --panel-2: #252525;
    --border: #444;
    --text: #eee;
    --muted: #aaa;
    --accent: #55dd88;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
    border: 1px solid #666;
    border-radius: 7px;
    background: #333;
    color: #fff;
    padding: 9px 14px;
}

button:hover:not(:disabled) {
    background: #444;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

input {
    border: 1px solid #555;
    border-radius: 7px;
    background: #202020;
    color: #fff;
    padding: 10px 12px;
}

#utilityBar {
    position: fixed;
    z-index: 70;
    top: 0;
    left: 0;
    right: 0;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 7px 14px;
    border-bottom: 1px solid #303030;
    background: rgba(20, 20, 20, 0.97);
    backdrop-filter: blur(8px);
}

#connectionStatus {
    color: var(--muted);
    font-size: 13px;
}

#languageSwitcher {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid #555;
    border-radius: 8px;
    background: #1d1d1d;
}

#languageSwitcher button {
    min-width: 46px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 5px 8px;
    color: #aaa;
    font-size: 12px;
    font-weight: 700;
}

#languageSwitcher button + button {
    border-left: 1px solid #555;
}

#languageSwitcher button.language-active {
    background: var(--accent);
    color: #07140c;
}

.view-panel {
    width: min(560px, calc(100% - 32px));
    margin: 64px auto 0;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--panel);
}

.view-panel h1,
.view-panel h2 {
    margin-top: 0;
}

.view-description,
.room-hint {
    color: var(--muted);
}

.lobby-form {
    display: grid;
    gap: 10px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 8px;
}

.secondary-button {
    margin-left: auto;
}

.solo-button {
    border-color: #5f8f68;
    background: linear-gradient(180deg, #31553a, #24452e);
}

.solo-button:hover {
    background: linear-gradient(180deg, #3a6545, #2b5035);
}

.solo-launch-row {
    display: flex;
    align-items: end;
    gap: 10px;
    margin-top: 2px;
    padding: 10px;
    border: 1px solid #36503c;
    border-radius: 10px;
    background: rgba(49, 85, 58, 0.16);
}

.solo-difficulty {
    display: grid;
    gap: 6px;
    min-width: 160px;
}

.solo-difficulty label {
    color: #d7dfd9;
    font-size: 13px;
    font-weight: 700;
}

.solo-launch-row .solo-button {
    flex: 1;
    min-height: 42px;
}

@media (max-width: 520px) {
    .solo-launch-row {
        align-items: stretch;
        flex-direction: column;
    }

    .solo-difficulty {
        min-width: 0;
    }
}

#playersList div {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0;
    padding: 6px;
    border-radius: 6px;
    background: #333;
}

.player-ready-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: auto;
    color: #ddd;
    font-size: 14px;
}

#gameView {
    overflow: hidden;
    padding-top: 50px;
}

#gameTopBar {
    display: flex;
    align-items: center;
    gap: 18px;
    min-height: 45px;
    padding: 8px 12px;
    background: #181818;
    border-bottom: 1px solid #333;
}

#turnInfo {
    font-size: 18px;
    font-weight: 700;
}

#selectionInfo {
    min-width: 160px;
    color: #bbb;
}

.small-button {
    margin-left: auto;
    padding: 6px 10px;
}

#zoomControls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

#zoomControls .small-button {
    margin-left: 0;
    min-width: 34px;
}

#zoomControls .zoom-reset-button {
    min-width: 58px;
    font-variant-numeric: tabular-nums;
}

#zoomLevel {
    display: inline-block;
    min-width: 38px;
}

#gameCanvas {
    display: block;
    border-top: 1px solid #444;
    background: #222;
}

#barCanvas {
    display: block;
    width: 100%;
    max-width: 100%;
    background: #222;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

/* Chat */
#chatPanel {
    position: fixed;
    z-index: 50;
    right: 14px;
    bottom: 14px;
    width: min(340px, calc(100vw - 28px));
    height: 390px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #555;
    border-radius: 12px;
    background: rgba(24, 24, 24, 0.97);
}

#chatPanel[hidden] {
    display: none;
}

#chatPanel.chat-collapsed {
    width: min(220px, calc(100vw - 28px));
    height: 44px;
    min-height: 44px;
}

#chatPanel.chat-collapsed #chatMessages,
#chatPanel.chat-collapsed #chatComposer {
    display: none;
}

#chatHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 42px;
    padding: 8px 10px;
    border-bottom: 1px solid #444;
    background: #202020;
    cursor: pointer;
    user-select: none;
}


.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#chatUnread {
    min-width: 22px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #c33;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

#btnChatToggle {
    width: 34px;
    height: 30px;
    padding: 0;
    touch-action: manipulation;
    font-size: 20px;
    line-height: 1;
}

#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-message {
    margin-bottom: 9px;
    overflow-wrap: anywhere;
}

.chat-message-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
    font-size: 12px;
    color: #aaa;
}

.chat-message-nick {
    font-weight: 700;
}

.chat-message-text {
    white-space: pre-wrap;
}

.chat-system-message {
    margin: 7px 0;
    padding: 6px 8px;
    border-left: 3px solid #777;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: #bbb;
    font-size: 13px;
    font-style: italic;
}

.chat-system-message.chat-turn-skipped {
    border-left-color: #e4b84a;
    color: #e8cf8c;
}

.chat-system-message.chat-game-over,
.chat-system-message.chat-game-over-draw {
    border-left-color: var(--accent);
    color: #d8ffe6;
    font-weight: 700;
}

.chat-system-message.chat-player-eliminated {
    border-left-color: #e05a5a;
    color: #ffb3b3;
    font-weight: 700;
}

#chatComposer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 7px;
    padding: 9px;
    border-top: 1px solid #444;
}

#chatInput {
    min-width: 0;
}

/* Modal zasad */
.modal-backdrop {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.72);
}

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

.modal-window {
    width: min(760px, 100%);
    max-height: min(820px, calc(100vh - 36px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #666;
    border-radius: 14px;
    background: #1b1b1b;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #444;
}

.modal-header h2 {
    margin: 0;
}

#btnRulesClose {
    width: 38px;
    height: 34px;
    padding: 0;
    font-size: 24px;
}

.modal-content {
    overflow-y: auto;
    padding: 18px 24px 28px;
    line-height: 1.55;
}

.modal-content h3 {
    margin-bottom: 5px;
    color: var(--accent);
}

.modal-content ul {
    padding-left: 22px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@media (max-width: 620px) {
    #utilityBar {
        min-height: 46px;
        padding: 5px 8px;
        justify-content: space-between;
    }

    .secondary-button {
        margin-left: 0;
    }

    #gameView {
        padding-top: 46px;
    }

    #gameTopBar {
        flex-wrap: wrap;
        gap: 5px 10px;
        min-height: 40px;
        padding: 5px 8px;
    }

    #turnInfo {
        font-size: 15px;
    }

    .small-button {
        padding: 5px 7px;
        font-size: 11px;
    }

    #zoomControls {
        order: 3;
        margin-left: 0;
    }

    #zoomControls .zoom-reset-button {
        min-width: 52px;
    }

    #btnLeaveFinishedGameTop {
        margin-left: 0;
    }

    #selectionInfo {
        min-width: 0;
    }

    #chatPanel {
        right: 8px;
        bottom: 8px;
        width: calc(100vw - 16px);
        height: 46vh;
    }

    #chatPanel.chat-collapsed {
        width: min(220px, calc(100vw - 16px));
        height: 44px;
        min-height: 44px;
    }
}


/* Ekran końcowy */
.end-game-overlay {
    position: fixed;
    z-index: 80;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(
            circle at center,
            rgba(255, 255, 255, 0.08),
            rgba(0, 0, 0, 0.88) 62%
        );
    backdrop-filter: blur(4px);
}

.end-game-overlay[hidden] {
    display: none;
}

.end-game-card {
    --winner-color: #55dd88;

    width: min(520px, 100%);
    padding: 34px 28px;
    border: 3px solid var(--winner-color);
    border-radius: 18px;
    background: #151515;
    text-align: center;
    box-shadow:
        0 0 32px color-mix(
            in srgb,
            var(--winner-color) 55%,
            transparent
        );
}

#endGamePlayerLabel {
    margin: 0;
    color: var(--winner-color);
    font-size: clamp(22px, 5vw, 38px);
    font-weight: 800;
    overflow-wrap: anywhere;
}

#endGameTitle {
    margin: 12px 0;
    color: #fff;
    font-size: clamp(42px, 9vw, 78px);
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

#endGameReason {
    min-height: 24px;
    margin: 16px 0 24px;
    color: #bbb;
}

.end-game-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}


.room-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.room-actions button {
    min-width: 150px;
}

@media (max-width: 560px) {
    .room-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        width: 100%;
    }

    .room-actions button {
        min-width: 0;
        width: 100%;
    }
}

.leave-room-button {
    border-color: #b94b4b;
    background: #6f2929;
}

.leave-room-button:hover:not(:disabled) {
    background: #893535;
}

#btnLeaveFinishedGameTop {
    margin-left: 0;
}

#btnLeaveFinishedGameTop[hidden] {
    display: none;
}

#btnShowFinalBoard {
    border-color: var(--winner-color);
}


/* AdSense-ready layout */
#desktopAdRails[hidden],
.desktop-ad-rail[hidden],
.mobile-inline-ad[hidden] {
    display: none !important;
}

.desktop-ad-rail {
    position: fixed;
    z-index: 12;
    top: 86px;
    width: 160px;
    min-height: 600px;
    overflow: hidden;
}

.desktop-ad-rail-left {
    left: 10px;
}

.desktop-ad-rail-right {
    right: 10px;
}

body.ads-desktop-active #gameView {
    margin-inline: 180px;
}

.mobile-inline-ad {
    width: min(100%, 420px);
    min-height: 50px;
    margin: 8px auto;
    overflow: hidden;
    text-align: center;
}

@media (max-width: 1359px) {
    .desktop-ad-rail,
    #desktopAdRails {
        display: none !important;
    }

    body.ads-desktop-active #gameView {
        margin-inline: 0;
    }
}

@media (max-width: 620px) {
    #connectionStatus {
        max-width: 155px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-align: right;
        font-size: 11px;
    }

    #languageSwitcher button {
        min-width: 42px;
        padding: 5px 7px;
    }
}

/* Room creation options and public room browser */
select {
    border: 1px solid #555;
    border-radius: 7px;
    background: #202020;
    color: #fff;
    padding: 10px 12px;
    font: inherit;
}

.lobby-options-grid {
    display: grid;
    grid-template-columns: minmax(110px, 0.75fr) minmax(180px, 1.25fr);
    gap: 12px;
}

.lobby-option {
    display: grid;
    gap: 7px;
}

#roomCapacityDisplay {
    margin-left: 8px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 500;
}

.room-browser-window {
    width: min(780px, calc(100vw - 28px));
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-header-actions .small-button {
    margin-left: 0;
}

.room-browser-content {
    padding-top: 12px;
}

.room-browser-hint,
.room-browser-empty {
    color: var(--muted);
}

.room-browser-columns,
.room-browser-row {
    display: grid;
    grid-template-columns: minmax(130px, 1fr) 90px 120px 94px;
    align-items: center;
    gap: 10px;
}

.room-browser-columns {
    padding: 0 12px 7px;
    color: #999;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

#roomBrowserList {
    display: grid;
    gap: 7px;
}

.room-browser-row {
    min-height: 55px;
    padding: 8px 10px;
    border: 1px solid #484848;
    border-radius: 9px;
    background: #242424;
    cursor: pointer;
    user-select: none;
}

.room-browser-row:hover,
.room-browser-row:focus-visible {
    border-color: #777;
    background: #2d2d2d;
    outline: none;
}

.room-browser-row.room-unavailable {
    cursor: default;
    opacity: 0.64;
}

.room-browser-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.room-browser-key {
    margin-right: 7px;
    font-size: 16px;
}

.room-browser-count {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}

.room-browser-status {
    color: #bdbdbd;
    font-size: 13px;
}

.room-browser-join {
    width: 100%;
    padding: 7px 10px;
}

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

    .room-browser-columns {
        display: none;
    }

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

    .room-browser-name {
        grid-column: 1;
        grid-row: 1;
    }

    .room-browser-count {
        grid-column: 2;
        grid-row: 1;
    }

    .room-browser-status {
        grid-column: 1;
        grid-row: 2;
    }

    .room-browser-join {
        grid-column: 2;
        grid-row: 2;
        min-width: 84px;
    }
}


/* Estetyczne okno hasła do pokoju */
.password-modal-backdrop {
    z-index: 130;
    backdrop-filter: blur(5px);
    background: rgba(0, 0, 0, 0.78);
}

.password-modal-window {
    width: min(430px, calc(100vw - 28px));
    padding: 26px;
    border: 1px solid rgba(232, 190, 86, 0.55);
    border-radius: 18px;
    background:
        radial-gradient(circle at top, rgba(232, 190, 86, 0.13), transparent 42%),
        linear-gradient(180deg, #242424, #171717);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
    text-align: center;
}

.password-modal-icon {
    display: grid;
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    place-items: center;
    border: 1px solid rgba(232, 190, 86, 0.7);
    border-radius: 50%;
    background: rgba(232, 190, 86, 0.12);
    font-size: 27px;
    box-shadow: 0 0 24px rgba(232, 190, 86, 0.16);
}

.password-modal-window h2 {
    margin: 0 0 8px;
    color: #f4d47b;
    font-size: clamp(22px, 5vw, 28px);
}

.password-modal-description {
    margin: 0 0 20px;
    color: #c9c9c9;
    line-height: 1.45;
}

#roomPasswordForm {
    display: grid;
    gap: 9px;
    text-align: left;
}

#roomPasswordForm > label {
    color: #f1f1f1;
    font-size: 13px;
    font-weight: 800;
}

.password-input-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    overflow: hidden;
    border: 1px solid #5d5d5d;
    border-radius: 10px;
    background: #101010;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.password-input-shell:focus-within {
    border-color: #e8be56;
    box-shadow: 0 0 0 3px rgba(232, 190, 86, 0.14);
}

#roomBrowserPasswordInput {
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 13px 14px;
    color: #fff;
    font-size: 16px;
    outline: none;
}

.password-toggle {
    min-width: 76px;
    margin: 0;
    border: 0;
    border-left: 1px solid #444;
    border-radius: 0;
    background: #2b2b2b;
    color: #f2d783;
    font-size: 13px;
    font-weight: 800;
}

.password-modal-error {
    margin: 1px 0 0;
    padding: 9px 11px;
    border: 1px solid rgba(255, 104, 104, 0.45);
    border-radius: 8px;
    background: rgba(145, 26, 26, 0.2);
    color: #ffaaaa;
    font-size: 13px;
    font-weight: 700;
}

.password-modal-error[hidden] {
    display: none;
}

.password-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 12px;
}

.password-modal-actions button {
    width: 100%;
    min-height: 44px;
}

.password-modal-actions .secondary-button {
    border: 1px solid #555;
    background: #292929;
    color: #ddd;
}

@media (max-width: 420px) {
    .password-modal-window {
        padding: 22px 17px 18px;
    }
}

/* Walidacja formularza wejściowego bez przeglądarkowych alertów. */
.lobby-field-error,
.lobby-general-error {
    margin: -3px 2px 2px;
    color: #ff9a9a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.25;
}

.lobby-field-error[hidden],
.lobby-general-error[hidden] {
    display: none;
}

.lobby-general-error {
    margin: 2px 0 0;
    padding: 8px 10px;
    border: 1px solid rgba(255, 105, 105, 0.55);
    border-radius: 7px;
    background: rgba(130, 25, 25, 0.24);
}

.lobby-input-invalid {
    border-color: #ff6969 !important;
    box-shadow:
        0 0 0 2px rgba(255, 105, 105, 0.16),
        0 0 12px rgba(255, 70, 70, 0.18);
}

@keyframes lobby-input-shake {
    0%, 100% { transform: translateX(0); }
    18% { transform: translateX(-7px); }
    36% { transform: translateX(6px); }
    54% { transform: translateX(-5px); }
    72% { transform: translateX(3px); }
    88% { transform: translateX(-1px); }
}

.lobby-input-shake {
    animation: lobby-input-shake 380ms ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
    .lobby-input-shake {
        animation: none;
    }
}

/* Discord and persistent lobby counters */
#utilityActions {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

#discordLink {
    width: 38px;
    height: 32px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #7380f2;
    border-radius: 8px;
    background: #5865f2;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: transform 120ms ease, background 120ms ease;
}

#discordLink:hover,
#discordLink:focus-visible {
    background: #6d78f5;
    transform: translateY(-1px);
    outline: none;
}

#discordLink img {
    width: 22px;
    height: 18px;
    display: block;
}

.lobby-stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin-top: 22px;
    padding-top: 15px;
    border-top: 1px solid #343434;
    color: #d8d8d8;
}

.lobby-stat {
    min-width: 92px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 7px 11px;
    border: 1px solid #414141;
    border-radius: 999px;
    background: rgba(255,255,255,0.035);
}

.lobby-stat img {
    width: 22px;
    height: 22px;
    display: block;
}

.lobby-stat strong {
    min-width: 2ch;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 620px) {
    #utilityActions {
        gap: 6px;
    }

    #discordLink {
        width: 34px;
        height: 30px;
    }

    #discordLink img {
        width: 20px;
        height: 17px;
    }

    .lobby-stats {
        gap: 10px;
        margin-top: 18px;
    }

    .lobby-stat {
        min-width: 0;
        flex: 1 1 0;
        max-width: 150px;
        padding-inline: 8px;
    }
}


.utility-icon-link,
#homeLink {
    min-width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid #555;
    border-radius: 8px;
    background: #1d1d1d;
    color: #eee;
    font-size: 22px;
    line-height: 1;
    text-decoration: none;
}
.utility-icon-link:hover,
#homeLink:hover { background: #333; color: #fff; }


/* RULES35: kolejka samouczka AI */
.ai-queue-notice {
  margin: 10px auto 2px;
  max-width: 720px;
  padding: 10px 14px;
  border: 1px solid rgba(214, 200, 79, 0.55);
  border-radius: 10px;
  background: rgba(214, 200, 79, 0.10);
  color: #f3e8a6;
  font-weight: 700;
  text-align: center;
}

.ai-queue-notice[hidden] {
  display: none !important;
}


/* Replay browser */
.replay-page {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 64px 14px 28px;
}

.replay-heading {
    width: auto;
    max-width: none;
    margin-bottom: 14px;
}

.replay-layout {
    display: grid;
    grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.replay-list-panel,
.replay-player-panel {
    border: 1px solid #444;
    border-radius: 12px;
    background: #1b1b1b;
    overflow: hidden;
}

.replay-list-panel {
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.replay-list-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid #3d3d3d;
    background: #1b1b1b;
}

.replay-list-header h2 {
    margin: 0;
    font-size: 18px;
}

.replay-list-header .small-button {
    margin-left: auto;
}

#replayListStatus {
    padding: 12px;
}

.replay-list {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.replay-list-item {
    display: grid;
    gap: 4px;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    border: 1px solid #444;
    border-radius: 9px;
    background: #252525;
}

.replay-list-item:hover,
.replay-list-item:focus-visible {
    border-color: #777;
    background: #303030;
}

.replay-list-item span {
    color: #bbb;
    font-size: 12px;
}

.replay-empty-player {
    min-height: 360px;
    display: grid;
    place-items: center;
    padding: 24px;
    color: #aaa;
}

.replay-empty-player[hidden],
#replayPlayer[hidden] {
    display: none !important;
}

.replay-meta-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid #444;
}

.replay-meta-line span {
    color: #bbb;
    font-size: 13px;
}

#replayCanvas {
    display: block;
    width: 100%;
    background: #222;
}

.replay-controls {
    display: grid;
    grid-template-columns: auto auto auto minmax(120px, 1fr);
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}

#replayRange {
    width: 100%;
}

.replay-event-panel {
    display: grid;
    gap: 5px;
    padding: 10px 12px 14px;
}

#replayFrameLabel {
    color: #aaa;
    font-size: 12px;
}

#replayEventText {
    min-height: 24px;
    font-weight: 700;
}

@media (max-width: 820px) {
    .replay-page {
        padding-top: 56px;
    }

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

    .replay-list-panel {
        max-height: 300px;
    }

    .replay-controls {
        grid-template-columns: repeat(3, 1fr);
    }

    #replayRange {
        grid-column: 1 / -1;
    }
}

.build-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: -4px 0 12px;
    padding: 5px 9px;
    border: 1px solid #5f8f68;
    border-radius: 999px;
    background: rgba(49, 85, 58, 0.24);
    color: #d9f2df;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
}
