.chess-spectator-view {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    background: #06051a;
}

.chess-spectator-toolbar {
    position: absolute;
    z-index: 7;
    top: 24px;
    right: 8px;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
    padding: 0;
}

.chess-spectator-toolbar button {
    --fullscreen-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 3H3v5m13-5h5v5M3 16v5h5m13-5v5h-5' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E");
    min-height: 44px;
    padding: 8px 16px;
    border: 1px solid #9988ff;
    border-radius: 8px;
    background: #30285b;
    color: #fff;
    font: 600 15px/1.4 Arial, sans-serif;
    cursor: pointer;
}

.chess-spectator-toolbar button:hover { background: #453777; }
.chess-spectator-toolbar button[aria-pressed="true"] {
    --fullscreen-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 8h5V3m13 5h-5V3M3 16h5v5m13-5h-5v5' fill='none' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E");
}
.chess-spectator-toolbar button:focus-visible { outline: 3px solid #77e6df; outline-offset: 2px; }
.chess-spectator-toolbar [hidden] { display: none; }

.chess-spectator-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1455 / 824;
    overflow: hidden;
}

.chess-spectator-view .chess-spectator-stage iframe {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1455px !important;
    max-width: none;
    height: 824px;
    min-height: 0;
    margin: -412px 0 0 -727.5px;
    transform: scale(var(--spectator-scale, 1)) !important;
    transform-origin: center;
    border: 0;
}

.chess-spectator-view:fullscreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #06051a;
    padding: 0;
    border: 0;
    border-radius: 0;
}

.chess-spectator-view:fullscreen .chess-spectator-stage { flex: 1 1 0; min-height: 0; aspect-ratio: auto; }

@media (max-width: 600px) {
    [data-chess-spectator]:not(:fullscreen) { display: flex; flex-direction: column; }
    [data-chess-spectator]:not(:fullscreen) > .chess-spectator-toolbar {
        position: static;
        order: 2;
        padding: 8px 8px 0;
    }
}

@media (min-width: 601px) and (max-width: 1100px), (max-height: 600px) {
    .chess-spectator-toolbar { top: 4px; }
    .chess-spectator-view .chess-spectator-toolbar button[data-spectator-fullscreen] {
        width: 36px;
        height: 36px;
        min-height: 36px;
        padding: 0;
        font-size: 0;
        background-image: var(--fullscreen-icon);
        background-repeat: no-repeat;
        background-position: center;
        background-size: 20px;
    }
}

.wrap_iframe .middle-info .new-container.chess-spectator-container,
.wrap_iframe .middle-info .new-container.chess-fitted-container {
    display: block !important;
    max-width: 1455px !important;
    padding: 0;
}

.chess-spectator-container .room_area2_window,
.chess-spectator-container #gameview {
    width: 100%;
    min-width: 0;
}

.sc-replay {
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    width: min(1455px, 100vw);
    max-width: 1455px;
    margin-inline: 0;
    padding-inline: 0;
}

.sc-replay-card.chess-spectator-view {
    padding: 0;
    border: 0;
    border-radius: 0;
}

.sc-replay-native-wrap.chess-spectator-stage { margin: 0; border-radius: 0; }
.sc-replay-card .chess-spectator-toolbar button { min-height: 44px; }
.sc-replay-card.chess-spectator-view:fullscreen .chess-spectator-stage { margin: 0; }
.sc-replay-deck { padding: 8px 12px; background: #06051aeF; }
.sc-replay-deck .sc-replay-recording-picker { margin-bottom: 6px; }
.sc-replay-deck .sc-replay-controls { margin-bottom: 6px; }
.sc-replay-deck .sc-replay-seek { margin-bottom: 0; }
.chess-spectator-view:fullscreen .sc-replay-deck {
    position: absolute;
    z-index: 5;
    inset: auto 0 0;
    margin-inline: auto;
    max-width: 760px;
}

.chess-room-content .ribbon_area2 table.room_players_t tbody > tr {
    grid-template-columns: minmax(0, 1fr) 60px minmax(0, 1fr);
    height: auto;
}

.chess-room-content .ribbon_area2 .room_players_t .chess-room-score-row > td {
    grid-column: 1 / -1;
    justify-self: stretch;
    text-align: center;
}

.chess-room-content .ribbon_area2 table.room_players_t tbody > tr:nth-child(3) > td {
    grid-column: auto;
    width: auto;
    min-width: 0;
}

.chess-room-content .ribbon_area2 .room_players_t td.room_players_t_a2 > div,
.chess-room-content .ribbon_area2 .room_players_t td.room_players_t_c2 > div {
    max-width: 100%;
}

.chess-room-content .ribbon_area2 .room_players_t td[colspan="3"] {
    grid-column: 1 / -1;
    min-width: 0;
}

.chess-spectator-view.chess-expanded {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-width: none;
    background: #06051a;
    border: 0;
    border-radius: 0;
}
.chess-spectator-view.chess-expanded .chess-spectator-stage {
    flex: 1 1 0;
    min-height: 0;
    aspect-ratio: auto;
}
body.chess-room-expanded { overflow: hidden; }

@media (max-width: 768px) {
    .chess-spectator-view[data-chess-viewport]:not(:fullscreen):not(.chess-expanded) {
        display: flex;
        flex-direction: column;
    }
    .chess-spectator-view[data-chess-viewport]:not(:fullscreen):not(.chess-expanded) > .chess-spectator-toolbar {
        position: static;
        order: 2;
        padding: 8px;
    }
    .chess-room-content .ribbon_area2 table.room_players_t tbody > tr {
        grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
    }
    .chess-room-content .ribbon_area2 table.room_players_t { margin-bottom: 12px; }
    .chess-room-content .ribbon_area2 table.room_players_t td.room_players_t_a2,
    .chess-room-content .ribbon_area2 table.room_players_t td.room_players_t_c2 {
        box-sizing: border-box;
        padding: 10px 8px;
        border: 1px solid #9186ff;
        border-radius: 8px;
        margin-bottom: 10px;
        align-items: center;
    }
    .chess-room-content .room_players_t_a2 > div,
    .chess-room-content .room_players_t_c2 > div {
        width: 100%;
        min-width: 0;
        flex-direction: column !important;
        text-align: center;
    }
    .chess-room-content .room_players_t_a2 > div > div,
    .chess-room-content .room_players_t_c2 > div > div {
        width: 100% !important;
        min-width: 0;
        padding: 0 !important;
        float: none !important;
        text-align: center;
    }
    .chess-room-content .room_players_t_a2 a,
    .chess-room-content .room_players_t_c2 a,
    .chess-room-content .nick_badge {
        max-width: 100%;
        overflow-wrap: anywhere;
        white-space: normal;
    }
    .chess-room-content #report, .chess-room-content #report_sent {
        display: inline-block;
        padding: 10px 16px;
        font: 600 16px/1.4 Arial, sans-serif;
    }
    .chess-room-content .room_report_text,
    .chess-room-content .room_report_submit {
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }
}

.chess-spectator-view.chess-expanded > .chess-spectator-toolbar { position: absolute; top: 8px; right: 8px; order: 0; padding: 0; }

@media (max-width: 768px) {
    .chess-spectator-view[data-chess-viewport] .chess-spectator-stage {
        aspect-ratio: auto;
        height: calc(100vw + 160px);
    }
    .chess-spectator-view[data-chess-viewport] .chess-spectator-stage iframe {
        top: 0;
        left: 0;
        width: 100% !important;
        max-width: 100%;
        height: 100%;
        margin: 0;
        transform: none !important;
    }
}

@media (max-width: 768px) { .chess-room-content .room_players_t_a2 > div { flex-direction: column-reverse !important; } }

@media (max-width: 768px), (max-height: 600px) and (pointer: coarse) {
    .chess-spectator-view[data-chess-viewport]:not(:fullscreen):not(.chess-expanded),
    .chess-spectator-view[data-chess-spectator]:not(:fullscreen):not(.chess-expanded) {
        display: flex;
        flex-direction: column;
    }
    .chess-spectator-view[data-chess-viewport]:not(:fullscreen):not(.chess-expanded) > .chess-spectator-toolbar,
    .chess-spectator-view[data-chess-spectator]:not(:fullscreen):not(.chess-expanded) > .chess-spectator-toolbar {
        position: sticky;
        top: 0;
        right: auto;
        order: 0;
        z-index: 20;
        display: flex;
        flex: 0 0 auto;
        justify-content: flex-end;
        padding: 6px 8px;
        background: #06051a;
    }
    .chess-spectator-view .chess-spectator-toolbar button[data-spectator-fullscreen] {
        width: auto;
        height: auto;
        min-height: 44px;
        padding: 8px 14px;
        font-size: 15px;
        background-image: none;
    }
    .chess-room-content .room_players_t .chess-room-teams-row,
    .chess-room-content .room_players_t .chess-room-score-row,
    .chess-room-content .room_players_t .chess-room-members-row {
        display: none;
    }
    .room_area2.chess-room-content {
        min-height: 0;
        padding-bottom: 8px;
        margin-bottom: 8px;
    }
    .chess-spectator-view[data-chess-viewport] .chess-spectator-stage iframe {
        top: 0;
        left: 0;
        width: 100% !important;
        max-width: 100%;
        height: 100%;
        margin: 0;
        transform: none !important;
    }
}

@media (max-width: 768px), (max-height: 600px) and (pointer: coarse) {
    .chess-spectator-view:not(:fullscreen):not(.chess-expanded) > .chess-spectator-toolbar {
        display: none !important;
    }
}
