:root {
    --green: #7df7b9;
    --warn: #ffd166;
    --game-width: 1316px;
    --portal-width: 1160px;
}

body {
    padding: 18px 12px 38px;
}

body.is-game-view {
    min-height: 100vh;
    display: grid;
    align-items: center;
}

.shell {
    width: min(1560px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

body.is-game-view .shell {
    width: min(1560px, 100%);
}

.topbar,
.rooms-view,
.match-history-view,
.lobby-view,
.game-view {
    width: min(var(--game-width), 100%);
    justify-self: center;
}

.rooms-page .topbar,
.rooms-page .rooms-layout {
    width: min(var(--portal-width), 100%);
}

.rooms-layout {
    justify-self: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    gap: 16px;
    align-items: start;
}

.panel,
.room-card,
.slot,
.info-card {
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-md);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02)), var(--ui-panel);
    box-shadow: var(--ui-shadow);
}

.topbar {
    padding: 28px;
}

.topbar[hidden] {
    display: none;
}

.panel {
    padding: 18px;
}

.panel-head,
.stats-row,
.info-row,
.room-meta,
.slot-head,
.buttons {
    display: flex;
}

.panel-head {
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.panel h2,
.panel h3,
p {
    margin: 0;
}

.muted,
.room-card p,
.slot p,
.section p,
.section li {
    color: var(--ui-muted);
    line-height: 1.6;
}

.top-actions,
.head-actions,
.buttons {
    flex-wrap: wrap;
    gap: 10px;
}

.head-actions {
    display: flex;
    align-items: center;
}

.sound-toggle {
    min-height: 34px;
    padding: 0 12px;
    font-size: 12px;
}

.buttons.left {
    justify-content: flex-start;
}

.rooms-view,
.lobby-view,
.rooms-record-panel {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.rooms-record-panel {
    position: sticky;
    top: 18px;
}

.room-list,
.match-history-list,
.slot-list {
    display: grid;
    gap: 12px;
}

.room-card,
.match-history-card,
.slot,
.info-card {
    padding: 16px;
}

.match-history-view {
    display: grid;
    gap: 12px;
}

.match-history-card {
    display: grid;
    gap: 12px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-md);
    background:
        linear-gradient(135deg, rgba(102, 229, 255, 0.08), rgba(255, 255, 255, 0.025)),
        rgba(8, 20, 38, 0.78);
}

.match-history-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.match-history-head h3 {
    margin: 4px 0 0;
    font-size: 20px;
    letter-spacing: -0.02em;
}

.match-history-players {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 8px;
}

.match-history-player {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.045);
}

.match-history-player.winner {
    border-color: rgba(125, 247, 185, 0.4);
    background: rgba(125, 247, 185, 0.09);
}

.match-history-player strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.match-history-player span {
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 800;
}

.rooms-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.recent-results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 4px;
}

.recent-results-head h3 {
    margin: 0;
    font-size: 17px;
}

.recent-result-list {
    display: grid;
    gap: 8px;
}

.recent-result-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.recent-result-badge {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(181, 220, 255, 0.1);
    color: var(--ui-muted);
    font-size: 17px;
    font-weight: 1000;
}

.recent-result-item.win .recent-result-badge {
    background: rgba(125, 247, 185, 0.14);
    color: var(--green);
}

.recent-result-item.loss .recent-result-badge {
    background: rgba(255, 122, 122, 0.13);
    color: #ff9b9b;
}

.recent-result-item.draw .recent-result-badge {
    background: rgba(255, 209, 102, 0.13);
    color: var(--warn);
}

.recent-result-item strong {
    display: block;
    font-size: 14px;
}

.recent-result-item p {
    margin-top: 3px;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 800;
}

.room-card {
    display: grid;
    gap: 10px;
}

.room-card h3 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -0.02em;
}

.room-meta,
.stats-row {
    gap: 12px;
    flex-wrap: wrap;
}

.chip,
.badge {
    color: var(--ui-muted);
}

.chip.ok {
    color: var(--green);
}

.chip.warn {
    color: var(--warn);
}

.empty-message {
    margin: 0;
    color: var(--ui-muted);
}

.room-list {
    overflow: visible;
}

.lobby-grid {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(420px, 1fr);
    gap: 16px;
    align-items: start;
    overflow: visible;
}

.lobby-players {
    display: grid;
    gap: 12px;
    align-content: start;
    min-height: 0;
}

.slot-list {
    grid-template-columns: 1fr;
    align-content: start;
    gap: 10px;
}

.lobby-side {
    display: grid;
    gap: 12px;
    align-content: stretch;
    min-height: 0;
    overflow: hidden;
}

.slot {
    position: relative;
    overflow: hidden;
    display: grid;
    gap: 9px;
    min-height: 92px;
    padding: 14px;
    border-color: rgba(102, 229, 255, 0.28);
    background:
        radial-gradient(circle at 12% 20%, rgba(102, 229, 255, 0.2), transparent 34%),
        linear-gradient(135deg, rgba(102, 229, 255, 0.12), rgba(125, 247, 185, 0.045)),
        rgba(8, 20, 38, 0.9);
    transition: border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

.slot::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 8px;
    background: linear-gradient(180deg, var(--ui-accent), var(--green));
}

.slot::after {
    content: none;
}

.slot.ready {
    border-color: rgba(125, 247, 185, 0.82);
    background:
        radial-gradient(circle at 12% 20%, rgba(125, 247, 185, 0.28), transparent 34%),
        linear-gradient(135deg, rgba(125, 247, 185, 0.22), rgba(102, 229, 255, 0.08)),
        rgba(8, 20, 38, 0.94);
}

.slot.host {
    border-color: rgba(255, 209, 102, 0.68);
}

.slot.mine {
    box-shadow: inset 0 0 0 1px rgba(102, 229, 255, 0.24);
}

.slot.empty {
    opacity: 1;
    border-style: dashed;
    border-color: rgba(181, 220, 255, 0.1);
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.028) 0 8px, transparent 8px 16px),
        linear-gradient(135deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01)),
        rgba(3, 9, 20, 0.54);
}

.slot.empty::before {
    background: rgba(181, 220, 255, 0.16);
}

.slot.empty .slot-seat,
.slot.empty .slot-name,
.slot.empty .slot-meta span {
    color: rgba(181, 220, 255, 0.42);
}

.slot-head {
    align-items: center;
    justify-content: space-between;
}

.slot-seat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ui-accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.slot-seat em {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 7px;
    border: 1px solid rgba(255, 209, 102, 0.38);
    border-radius: 999px;
    background: rgba(255, 209, 102, 0.11);
    color: var(--warn);
    font-size: 10px;
    font-style: normal;
    letter-spacing: 0.02em;
}

.slot.empty .slot-seat em {
    border-color: rgba(181, 220, 255, 0.16);
    background: rgba(181, 220, 255, 0.045);
    color: rgba(181, 220, 255, 0.5);
}

.slot-name {
    overflow: hidden;
    font-size: 20px;
    line-height: 1.05;
    letter-spacing: -0.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.slot-meta span {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 800;
}

.slot-record {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
}

.slot-record span {
    min-width: 0;
    padding: 7px 5px;
    border: 1px solid rgba(255, 255, 255, 0.075);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    text-align: center;
}

.slot-record strong {
    color: var(--ui-text);
    font-size: 12px;
}

.info-card {
    display: grid;
    gap: 8px;
}

.info-row {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.compact-guide p {
    font-size: 13px;
    line-height: 1.6;
}

.lobby-action-card {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid rgba(102, 229, 255, 0.24);
    border-radius: var(--ui-radius-md);
    background:
        radial-gradient(circle at 18% 18%, rgba(102, 229, 255, 0.14), transparent 32%),
        linear-gradient(135deg, rgba(102, 229, 255, 0.12), rgba(125, 247, 185, 0.06)),
        rgba(8, 20, 38, 0.86);
}

.lobby-action-card button {
    width: 100%;
    min-height: 56px;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.lobby-action-card button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.lobby-match-summary {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(181, 220, 255, 0.14);
    border-radius: var(--ui-radius-md);
    background:
        linear-gradient(135deg, rgba(102, 229, 255, 0.1), rgba(125, 247, 185, 0.05)),
        rgba(3, 9, 20, 0.42);
}

.lobby-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.lobby-history-head h3 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.match-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.match-summary-item {
    display: grid;
    gap: 3px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.045);
}

.match-summary-item span {
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 900;
}

.match-summary-item strong {
    color: var(--ui-text);
    font-size: 18px;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.lobby-chat {
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.chat-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.chat-head h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.chat-messages {
    height: 100%;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--ui-line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.035);
}

.chat-message {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
}

.chat-message.mine {
    background: rgba(102, 229, 255, 0.1);
}

.chat-message.system {
    padding: 8px 10px;
    border: 1px dashed var(--ui-line);
    color: var(--ui-muted);
    font-size: 16px;
    text-align: center;
}

.chat-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 800;
}

.chat-name {
    color: var(--ui-accent);
}

.chat-text {
    color: var(--ui-text);
    font-size: 18px;
    line-height: 1.55;
    word-break: break-word;
}

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

.chat-form input {
    min-width: 0;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--ui-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ui-text);
    font: inherit;
    font-size: 16px;
}

.chat-form input:focus {
    outline: 2px solid rgba(102, 229, 255, 0.18);
    border-color: var(--ui-line-strong);
}

.game-view {
    display: grid;
    grid-template-columns: minmax(430px, 560px) minmax(320px, 1fr);
    gap: 18px;
    align-items: start;
    align-self: center;
}

.game-view > .board-panel {
    grid-column: 1;
    grid-row: 1 / span 2;
}

.center-panel,
.opponents-panel {
    grid-column: 2;
}

.center-panel {
    grid-row: 1;
}

.opponents-panel {
    grid-row: 2;
}

.game-guide-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 8px;
}

.lobby-view[hidden],
.game-view[hidden] {
    display: none;
}

.board-panel,
.center-panel,
.opponents-panel,
.guide-block {
    display: grid;
    gap: 14px;
}

.opponent-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.opponent-card {
    display: grid;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    background: rgba(255, 255, 255, 0.045);
}

.opponent-card.empty {
    min-height: 190px;
    place-items: center;
    border-style: dashed;
    color: var(--ui-muted);
    text-align: center;
}

.opponent-card.dead {
    opacity: 0.66;
    border-color: rgba(255, 107, 127, 0.28);
}

.opponent-name {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    font-weight: 900;
}

.opponent-name strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opponent-card canvas {
    aspect-ratio: 1 / 2;
}

.opponent-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.opponent-stats span {
    display: grid;
    gap: 2px;
    padding: 7px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.055);
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 800;
}

.opponent-stats strong {
    color: var(--ui-text);
    font-size: 13px;
}

.section {
    display: grid;
    gap: 10px;
    padding: 16px;
    background: rgba(255,255,255,0.04);
}

.section p {
    line-height: 1.65;
}

.section h3 {
    margin-bottom: 2px;
}

.guide-block {
    align-content: start;
    gap: 6px;
    padding: 10px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    background: rgba(255,255,255,0.04);
}

.guide-block h3 {
    font-size: 13px;
}

.guide-block p {
    color: var(--ui-muted);
    font-size: 11px;
    line-height: 1.45;
}

.panel-head.slim {
    margin-bottom: 4px;
}

.mini-stat {
    flex: 1 1 0;
    padding: 12px 14px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-sm);
    background: rgba(255,255,255,0.06);
}

.mini-stat span {
    display: block;
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.mini-stat strong {
    display: block;
    margin-top: 6px;
    font-size: 24px;
    letter-spacing: -0.03em;
}

canvas {
    display: block;
    width: 100%;
    border-radius: var(--ui-radius-sm);
    background: #060b16;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}

#board {
    aspect-ratio: 1 / 2;
}

#next {
    width: 156px;
    height: 156px;
}

.overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(3, 8, 18, 0.78);
    backdrop-filter: blur(8px);
}

.overlay[hidden] {
    display: none;
}

.overlay-card {
    width: min(720px, 100%);
    display: grid;
    gap: 14px;
    padding: 26px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-md);
    background: rgba(8, 20, 38, 0.96);
    text-align: left;
}

.form-card {
    width: min(440px, 100%);
    text-align: left;
}

.room-form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 8px;
}

.field span {
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 700;
}

.field input {
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1px solid var(--ui-line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ui-text);
    font: inherit;
}

.field input:focus {
    outline: 2px solid rgba(102, 229, 255, 0.18);
    border-color: var(--ui-line-strong);
}

.form-error {
    color: #ff98a7;
    font-size: 13px;
    font-weight: 700;
}

.overlay-title {
    font-size: 22px;
    font-weight: 900;
}

.overlay-kicker {
    color: var(--ui-accent);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.overlay-text {
    color: var(--ui-muted);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-line;
}

.winner-hero {
    display: grid;
    gap: 8px;
    padding: 22px 20px;
    border: 1px solid rgba(102, 229, 255, 0.22);
    border-radius: 22px;
    background:
        radial-gradient(circle at 18% 18%, rgba(102, 229, 255, 0.18), transparent 32%),
        rgba(255, 255, 255, 0.05);
    text-align: center;
}

.winner-hero span {
    color: var(--ui-muted);
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.winner-hero strong {
    color: var(--ui-text);
    font-size: clamp(42px, 9vw, 72px);
    line-height: 0.95;
    letter-spacing: -0.06em;
}

.winner-hero.win strong {
    color: var(--green);
}

.winner-hero.lose strong {
    color: #ff98a7;
}

.winner-hero.draw strong {
    color: var(--warn);
}

.result-card {
    background:
        linear-gradient(145deg, rgba(102, 229, 255, 0.12), rgba(255, 255, 255, 0.03) 28%, rgba(8, 20, 38, 0.98) 76%),
        rgba(8, 20, 38, 0.96);
}

.result-countdown {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(102, 229, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
}

.result-countdown span {
    color: var(--ui-muted);
    font-size: 14px;
    font-weight: 700;
}

.result-countdown strong {
    min-width: 44px;
    text-align: center;
    color: var(--ui-accent);
    font-size: 24px;
    line-height: 1;
}

.result-stats {
    display: grid;
    gap: 10px;
}

.result-summary-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.result-summary-strip span {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--ui-line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 800;
}

.result-summary-strip strong {
    color: var(--ui-text);
    font-size: 16px;
}

.result-rank-list {
    display: grid;
    gap: 8px;
}

.result-rank-card {
    display: grid;
    grid-template-columns: 38px minmax(120px, 1fr) repeat(4, minmax(58px, auto));
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--ui-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.result-rank-card.mine {
    border-color: rgba(102, 229, 255, 0.44);
    background: rgba(102, 229, 255, 0.08);
}

.result-rank-card.winner {
    border-color: rgba(125, 247, 185, 0.56);
}

.rank-no {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ui-accent);
    font-weight: 900;
}

.rank-player {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.rank-player strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
}

.rank-player span,
.rank-metric span {
    color: var(--ui-muted);
    font-size: 11px;
    font-weight: 800;
}

.rank-metric {
    display: grid;
    gap: 3px;
    text-align: right;
}

.rank-metric strong {
    font-size: 14px;
}

.result-stat {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--ui-line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.result-stat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.result-stat-label {
    font-size: 13px;
    font-weight: 800;
}

.result-stat-badge {
    padding: 5px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ui-muted);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.result-stat-badge.win {
    background: rgba(125, 247, 185, 0.16);
    color: var(--green);
}

.result-stat-badge.lose {
    background: rgba(255, 107, 127, 0.14);
    color: #ff98a7;
}

.result-stat-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.result-stat-value {
    display: grid;
    gap: 4px;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

.result-stat-value span {
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 700;
}

.result-stat-value strong {
    font-size: 18px;
    letter-spacing: -0.03em;
}

.result-stat-bar {
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
}

.result-bar {
    position: relative;
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
}

.result-bar::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: calc(var(--fill, 0) * 1%);
    border-radius: inherit;
    background: linear-gradient(90deg, rgba(102, 229, 255, 0.96), rgba(125, 247, 185, 0.96));
}

.result-bar.enemy::after {
    background: linear-gradient(90deg, rgba(255, 209, 102, 0.96), rgba(255, 107, 127, 0.96));
}

.countdown-screen {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 18px;
    background:
        radial-gradient(circle at 50% 30%, rgba(102, 229, 255, 0.14), transparent 28%),
        rgba(3, 8, 18, 0.84);
    backdrop-filter: blur(10px);
}

.countdown-screen[hidden] {
    display: none;
}

.countdown-card {
    width: min(380px, 100%);
    display: grid;
    gap: 14px;
    place-items: center;
    padding: 30px 24px;
    border: 1px solid rgba(102, 229, 255, 0.22);
    border-radius: 24px;
    background:
        linear-gradient(145deg, rgba(102, 229, 255, 0.1), rgba(255, 255, 255, 0.03) 30%, rgba(5, 16, 30, 0.96) 76%),
        rgba(5, 16, 30, 0.94);
    text-align: center;
}

.countdown-value {
    min-width: 140px;
    font-size: clamp(72px, 14vw, 128px);
    line-height: 0.9;
    font-weight: 900;
    letter-spacing: -0.06em;
    color: var(--ui-text);
}

.countdown-text {
    color: var(--ui-muted);
    line-height: 1.7;
}

.key {
    display: inline-flex;
    min-width: 26px;
    min-height: 22px;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    padding: 0 6px;
    border: 1px solid var(--ui-line);
    border-radius: 7px;
    background: rgba(255,255,255,0.08);
    color: var(--ui-text);
    font-size: 11px;
    font-weight: 800;
}

ul {
    margin: 0;
    padding-left: 18px;
}

@media (max-width: 1120px) {
    .game-view {
        grid-template-columns: 1fr;
    }

    .game-view > .board-panel,
    .center-panel,
    .opponents-panel {
        grid-column: auto;
        grid-row: auto;
    }

    .game-guide-panel {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .rooms-layout {
        grid-template-columns: 1fr;
    }

    .rooms-record-panel {
        position: static;
    }

    .lobby-grid {
        grid-template-columns: 1fr;
        max-height: none;
    }

    .lobby-side {
        height: auto;
        max-height: none;
    }

    .chat-messages {
        max-height: 420px;
    }

    .slot-list {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 861px) {
    .lobby-side {
        height: var(--lobby-chat-height, 560px);
        max-height: var(--lobby-chat-height, 560px);
    }
}

@media (max-width: 640px) {
    body {
        padding: 10px;
    }

    body.is-game-view {
        align-items: start;
    }

    .panel-head {
        align-items: start;
        flex-direction: column;
    }

    .result-stat-values {
        grid-template-columns: 1fr;
    }

    .result-stats,
    .result-summary-strip {
        grid-template-columns: 1fr;
    }

    .result-rank-card {
        grid-template-columns: 32px minmax(0, 1fr) repeat(2, minmax(54px, auto));
    }

    .rank-metric.optional {
        display: none;
    }

    .opponent-list {
        grid-template-columns: 1fr;
    }
}
