:root {
    --snake-game-width: 1616px;
}

body {
    height: 100vh;
    padding: 14px 12px 28px;
    overflow: hidden;
}

.shell {
    width: min(1560px, 100%);
    height: calc(100vh - 42px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 18px;
    margin: 0 auto;
}

.topbar,
.game-layout {
    width: min(var(--snake-game-width), 100%);
    justify-self: center;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 18px;
    align-items: start;
    min-height: 0;
}

.panel-head,
.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.panel-head {
    padding: 10px 14px;
}

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

.muted {
    color: var(--ui-muted);
    font-size: 14px;
    line-height: 1.6;
}

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

.head-actions .badge,
.head-actions button {
    min-height: 34px;
    border-radius: 4px;
}

.arena-panel {
    border-radius: 0;
    overflow: hidden;
    min-height: 0;
    min-width: 0;
}

.arena-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: min(900px, calc(100vh - 214px));
    min-height: 620px;
    overflow: hidden;
    border-top: 1px solid var(--ui-line);
    background:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        radial-gradient(circle at 20% 10%, rgba(139, 246, 194, 0.12), transparent 28%),
        #07111e;
    background-size: 20px 20px, 20px 20px, auto, auto;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
}

.minimap {
    position: absolute;
    right: 18px;
    bottom: 18px;
    z-index: 4;
    width: 170px;
    height: 116px;
    border: 1px solid rgba(139, 246, 194, 0.42);
    background: rgba(3, 10, 18, 0.72);
    pointer-events: none;
}

.minimap-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dot-color, #8bf6c2);
    box-shadow: 0 0 8px rgba(246, 251, 255, 0.55);
    transform: translate(-50%, -50%);
}

.minimap-dot.is-me {
    width: 10px;
    height: 10px;
    border: 2px solid #f6fbff;
    animation: minimapPulse 900ms ease-in-out infinite;
}

.server-toast-list {
    position: absolute;
    top: 14px;
    right: 16px;
    z-index: 5;
    display: grid;
    justify-items: end;
    gap: 6px;
    width: min(320px, calc(100% - 32px));
    pointer-events: none;
}

.server-toast {
    max-width: 100%;
    padding: 5px 8px;
    border: 1px solid rgba(139, 246, 194, 0.26);
    border-radius: 4px;
    background: rgba(3, 10, 18, 0.58);
    color: rgba(246, 251, 255, 0.86);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.35;
    text-align: right;
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
    animation: serverToastFade 4.2s ease-out forwards;
}

@keyframes serverToastFade {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }

    12%,
    68% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes minimapPulse {
    0%,
    100% {
        box-shadow: 0 0 6px rgba(139, 246, 194, 0.5), 0 0 0 0 rgba(139, 246, 194, 0.55);
    }

    50% {
        box-shadow: 0 0 14px rgba(139, 246, 194, 0.95), 0 0 0 7px rgba(139, 246, 194, 0);
    }
}

.start-layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(2, 7, 14, 0.66);
}

.start-layer[hidden] {
    display: none;
}

.start-card {
    width: min(520px, 100%);
}

.side-column {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 18px;
    height: calc(64px + min(900px, calc(100vh - 214px)));
    min-height: 0;
}

.section {
    display: grid;
    min-height: 0;
    gap: 14px;
    padding: 18px;
}

.players-section,
.logs-section {
    overflow: hidden;
    align-content: start;
    grid-template-rows: auto minmax(0, 1fr);
}

.player-list,
.log-list {
    display: block;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    align-self: stretch;
    justify-self: stretch;
    padding-right: 2px;
    scrollbar-color: rgba(139, 246, 194, 0.42) rgba(255, 255, 255, 0.05);
    scrollbar-width: thin;
}

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

.inline-stats {
    grid-template-columns: repeat(3, minmax(72px, auto));
}

.inline-stats div,
.stats-grid div {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.inline-stats div {
    min-height: 34px;
    padding: 5px 10px;
}

.inline-stats div:nth-child(1) {
    border-color: rgba(255, 209, 102, 0.36);
    background: rgba(255, 209, 102, 0.14);
}

.inline-stats div:nth-child(2) {
    border-color: rgba(139, 246, 194, 0.34);
    background: rgba(139, 246, 194, 0.13);
}

.inline-stats div:nth-child(3) {
    border-color: rgba(102, 229, 255, 0.34);
    background: rgba(102, 229, 255, 0.13);
}

.inline-stats span,
.stats-grid span,
.player-meta,
.log-time {
    color: var(--ui-muted);
    font-size: 12px;
    font-weight: 700;
}

.inline-stats strong,
.stats-grid strong {
    font-size: 20px;
}

.inline-stats strong {
    font-size: 14px;
}

.player-list,
.log-list,
.control-list {
    align-content: start;
    gap: 10px;
}

.player-list > *,
.log-list > * {
    margin-bottom: 10px;
}

.player-list > *:last-child,
.log-list > *:last-child {
    margin-bottom: 0;
}

.control-list {
    display: grid;
}

.player-item {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
}

.player-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.player-name {
    overflow: hidden;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-score {
    color: var(--ui-accent-2);
    font-weight: 900;
}

.rank-position {
    color: var(--ui-accent);
    font-size: 13px;
    font-weight: 900;
}

.log-item {
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border: 1px solid var(--ui-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.control-list p {
    margin: 0;
    color: var(--ui-muted);
    line-height: 1.7;
}

.key {
    display: inline-flex;
    min-width: 28px;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    border: 1px solid var(--ui-line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ui-text);
    font-size: 12px;
    font-weight: 900;
}

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

    .arena-wrap {
        height: 620px;
        min-height: 620px;
    }

    .side-column {
        height: auto;
        grid-template-rows: auto;
    }
}

@media (max-width: 620px) {
    body {
        height: auto;
        overflow: auto;
        padding: 16px 12px 30px;
    }

    .shell {
        height: auto;
    }

    .panel-head,
    .section-head {
        align-items: stretch;
        flex-direction: column;
    }

    .head-actions {
        justify-content: flex-start;
    }

    .inline-stats,
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
