.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg-tint, rgba(55, 4, 106, 0.2));
    gap: 20px;
}

/* --- Loading Overlay --- */

#loading-overlay {
    background: rgb(30, 5, 60);
    overflow: hidden;
    z-index: 101;
}

#loading-overlay::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: url('../bg.jpg') center/cover no-repeat;
    filter: blur(2px);
}

#loading-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(55, 4, 106, 0.5);
}

#loading-overlay > * {
    position: relative;
    z-index: 1;
}

#loading-logo {
    max-width: clamp(200px, 50vw, 450px);
    height: auto;
}

#loading-bar {
    width: clamp(200px, 50vw, 340px);
    height: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    border: 1px solid rgba(160, 120, 0, 0.4);
    overflow: hidden;
}

#loading-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(180deg, #f5d442 0%, #e8b800 50%, #c89e00 100%);
    border-radius: 5px;
    transition: width 0.25s ease-out;
    box-shadow: 0 0 8px rgba(232, 184, 0, 0.4);
}

#loading-status {
    font-size: clamp(9px, 1.4vw, 12px);
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.6);
}

#loading-overlay.fade-out {
    opacity: 0;
    transition: opacity 0.4s ease-out;
    pointer-events: none;
}

/* --- Start Overlay --- */

#start-overlay {
    background: none;
    overflow: hidden;
}

#start-overlay::before {
    content: '';
    position: absolute;
    inset: -4px;
    background: url('../bg.jpg') center/cover no-repeat;
    filter: blur(2px);
}

#start-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(55, 4, 106, 0.5);
}

#start-overlay > * {
    position: relative;
    z-index: 1;
}

#death-overlay {
    background: rgba(55, 4, 106, 0.5);
}

#start-logo {
    max-width: clamp(200px, 50vw, 450px);
    height: auto;
}

.overlay h1 {
    font-size: clamp(28px, 6vw, 56px);
    color: #fff;
    letter-spacing: 6px;
    text-shadow: 0 0 20px var(--primary, #00fff2);
}

.overlay h2 {
    font-size: clamp(24px, 5vw, 44px);
    letter-spacing: 4px;
    color: var(--primary, #00fff2);
    text-shadow: 0 0 20px var(--primary, #00fff2);
}

.overlay h2.victory {
    color: var(--primary, #00fff2);
    text-shadow: 0 0 20px var(--primary, #00fff2);
}

.overlay h2.defeat {
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

.overlay p {
    font-size: clamp(11px, 2vw, 16px);
    color: #fafafa;
    text-align: center;
    letter-spacing: 2px;
    line-height: 1.8;
}

.overlay .stats {
    color: var(--text, #e0e0ff);
    font-size: clamp(10px, 1.5vw, 14px);
}

#nickname-frame {
    position: relative;
    width: 360px;
    max-width: 85vw;
    margin-top:-40px;
    z-index:1;
    aspect-ratio: 350 / 90;;
    background: url('../img/input.png') center / 100% 100% no-repeat;
}

#nickname-frame:focus-within {
    filter: brightness(1.2);
}

#nickname-input {
    position: absolute;
    top: 16%;
    left: 8%;
    width: 84%;
    height: 68%;
    background: transparent;
    border: none;
    color: var(--text-dim, #8888aa);
    font-family: inherit;
    font-size: clamp(12.6px, 2.25vw, 19.8px);
    font-weight: 700;
    letter-spacing: 3.6px;
    text-align: center;
    text-transform: uppercase;
    padding: 0;
    outline: none;
}

#nickname-input::placeholder {
    color: var(--text-dim, #8888aa);
    letter-spacing: 3px;
    font-weight: 400;
    text-transform: uppercase;
}

#nickname-input.shake,
#avatar-display.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

#theme-selector {
    display: flex;
    gap: 12px;
    margin: 10px 0;
}

.theme-btn {
    background: var(--btn-bg, rgba(0, 255, 242, 0.15));
    color: var(--btn-text, #00fff2);
    border: 1px solid var(--border, rgba(0, 255, 242, 0.15));
    padding: 10px 22px;
    font-family: inherit;
    font-size: clamp(10px, 1.5vw, 13px);
    letter-spacing: 2px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.theme-btn:hover {
    background: var(--btn-hover, rgba(0, 255, 242, 0.3));
}

.theme-btn.active {
    background: var(--primary, #00fff2);
    color: var(--bg, #0a0a1a);
    font-weight: 700;
}

/* --- Avatar Carousel --- */

#avatar-carousel {
    display: flex;
    align-items: center;
    gap: 16px;
     z-index:5;
}

#avatar-display {
    width: 150px;
    height: 150px;
    border-radius: 12px;
    overflow: hidden;
    transition: filter 0.3s, opacity 0.3s;
   
}

#avatar-display.taken {
    filter: grayscale(100%) brightness(0.4);
    opacity: 0.5;
}

#avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    pointer-events: none;
}

.avatar-arrow {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    transition: transform 0.25s ease-out, filter 0.25s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-arrow img {
    width: 48px;
    height: 48px;
    display: block;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.avatar-arrow.arrow-left:hover {
    transform: translateX(-6px);
}

.avatar-arrow.arrow-right:hover {
    transform: translateX(6px);
}

.avatar-arrow.arrow-left:active,
.avatar-arrow.arrow-left.pressed {
    transform: translateX(-2px) scale(0.88);
    filter: brightness(0.7);
    transition: transform 0.06s ease-out, filter 0.06s ease-out;
}

.avatar-arrow.arrow-right:active,
.avatar-arrow.arrow-right.pressed {
    transform: translateX(2px) scale(0.88);
    filter: brightness(0.7);
    transition: transform 0.06s ease-out, filter 0.06s ease-out;
}

#start-btn, #respawn-btn, #error-retry-btn {
    position: relative;
    background: linear-gradient(180deg, #f5d442 0%, #e8b800 40%, #c89e00 60%, #e8b800 100%);
    color: #4a3600;
    border: 2px solid #a07800;
    border-top-color: #f5e06a;
    padding: 16px 56px;
    font-family: inherit;
    font-size: clamp(12px, 2vw, 18px);
    font-weight: 700;
    letter-spacing: 4px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    border-bottom: 4px solid #674e03;
    border-radius: 25px;
    transition: all 0.2s;
    margin-top: 10px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,200,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.15);
    text-shadow: 0 1px 0 rgba(255,235,140,0.6);
}

/* Bolt pseudo-elements */
#start-btn::before, #start-btn::after,
#respawn-btn::before, #respawn-btn::after,
#error-retry-btn::before, #error-retry-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    transform: translateY(-50%);
    background: url('../img/bolt.png') center / contain no-repeat;
}

#start-btn::before, #respawn-btn::before, #error-retry-btn::before {
    left: 12px;
}

#start-btn::after, #respawn-btn::after, #error-retry-btn::after {
    right: 12px;
}

#start-btn:hover, #respawn-btn:hover, #error-retry-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(180deg, #ffe04a 0%, #f0c800 40%, #d4a800 60%, #f0c800 100%);
    box-shadow:
        0 4px 12px rgba(200,160,0,0.5),
        inset 0 1px 0 rgba(255,255,200,0.5),
        inset 0 -1px 0 rgba(0,0,0,0.15);
}

#death-overlay h2 {
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

#death-overlay .killer-name {
    color: #ff6666;
    font-weight: bold;
    text-transform: uppercase;
}

#connecting-overlay h2 {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#error-overlay h2 {
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

#restart-overlay {
    background: var(--restart-bg, rgba(5, 5, 16, 0.5));
    pointer-events: none;
    animation: fadeInOut 3s ease-in-out forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; }
    10% { opacity: 1; }
    70% { opacity: 1; }
    100% { opacity: 0; }
}

/* --- Vote Overlay --- */

#vote-overlay {
    background: rgba(5, 5, 30, 0.85);
    z-index: 150;
}

#vote-overlay h2 {
    font-size: 2rem;
    margin: 0;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

#vote-countdown {
    font-size: 3rem;
    font-weight: bold;
    color: #ffcc00;
    margin: 0;
}

#vote-tiles {
    display: flex;
    gap: 24px;
    margin-top: 10px;
}

.vote-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    cursor: pointer;
    transition: transform 0.2s, filter 0.2s;
    color: #fff;
    font-family: inherit;
    font-size: 1.4rem;
}

.vote-tile:hover {
    transform: scale(1.05);
}

.vote-tile:hover .vote-tile-border {
    opacity: 0.5;
}

.vote-tile.selected .vote-tile-border {
    opacity: 1;
}

.vote-tile.winning .vote-tile-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid #4cff4c;
    border-radius: 6px;
    pointer-events: none;
}

.vote-tile-card {
    position: relative;
    width: 180px;
    overflow: hidden;
}

.vote-tile-img {
    display: block;
    width: 100%;
    height: auto;
    pointer-events: none;
}

.vote-tile-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.vote-tile-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 34%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.4rem;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    pointer-events: none;
}

.vote-tile-count {
    font-size: 1.3rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* --- Round results --- */
#winner-overlay {
    background: rgba(5, 5, 30, .96);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 160;
    padding: 20px 16px;
    animation: winnerFadeIn .4s ease-out;
    touch-action: pan-y;
}
@keyframes winnerFadeIn { from { opacity: 0; } to { opacity: 1; } }
#winner-panel { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(760px, 100%); max-height: 100%; min-height: 0; }
#winner-overlay h2 { flex-shrink: 0; margin: 0; max-width: 100%; text-align: center; overflow-wrap: anywhere; font-size: clamp(20px, 3vw, 32px); color: #ffcc00; }
#winner-overlay h2.victory { color: #4dff88; text-shadow: 0 0 22px #4dff8840; }
#winner-reason { flex-shrink: 0; color: #c5ccdb; font-size: clamp(9px, 1.5vw, 12px); text-align: center; }
#winner-reason:empty { display: none; }
#winner-results { width: 100%; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: 10px; }
.winner-group { border: 1px solid #344057; border-radius: 10px; overflow: hidden; background: #141d30; }
.winner-group + .winner-group { margin-top: 14px; }
.winner-team-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin: 0; padding: 12px 16px; background: color-mix(in srgb, var(--result-team-color) 12%, #141d30); color: var(--result-team-color); border-left: 4px solid var(--result-team-color); font-size: 14px; }
.winner-team-heading > span:last-child { color: #c5ccdb; font-size: 10px; font-weight: normal; }
.winner-table { width: 100%; table-layout: fixed; border-collapse: collapse; text-align: left; font-size: 12px; color: #e5eaf5; }
.winner-table thead { background: #10182a; color: #8f9db5; font-size: 10px; }
.winner-table th, .winner-table td { padding: 10px 12px; }
.winner-table thead th { font-weight: normal; }
.winner-table th:first-child, .winner-table td:first-child { width: 60px; text-align: center; }
.winner-table th:nth-child(3), .winner-table td:nth-child(3) { width: 108px; text-align: right; }
.winner-table th:last-child, .winner-table td:last-child { width: 64px; text-align: right; }
.winner-table tbody tr + tr { border-top: 1px solid #2b354b; }
.winner-table tbody th { font-weight: normal; }
.winner-top-three { background: #f8ca4c0c; box-shadow: inset 3px 0 var(--medal-color); }
.winner-top-three[data-rank="1"] { --medal-color: #f8ca4c; }
.winner-top-three[data-rank="2"] { --medal-color: #c3cddd; }
.winner-top-three[data-rank="3"] { --medal-color: #d79b6d; }
.winner-top-three .winner-name { color: var(--medal-color); font-weight: bold; }
.winner-rank { color: #8f9db5; font-variant-numeric: tabular-nums; }
.winner-top-three .winner-rank { font-size: 22px; }
.winner-player { display: flex; align-items: center; gap: 10px; min-width: 0; }
.winner-avatar { width: 30px; height: 30px; flex-shrink: 0; border-radius: 6px; }
.winner-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.winner-you { color: #95a5bf; font-size: 8px; flex-shrink: 0; }
#winner-continue { flex-shrink: 0; padding: 12px 28px; border: 1px solid #50617c; border-radius: 8px; background: #273750; color: #fff; font: inherit; font-size: 12px; cursor: pointer; }
#winner-continue:hover { background: #354a68; }
#winner-continue:focus-visible { outline: 3px solid #f8ca4c; outline-offset: 3px; }
@media (max-width: 600px) {
    #winner-overlay { padding: 16px 10px; }
    #winner-panel { gap: 12px; }
    .winner-table { font-size: 10px; }
    .winner-table thead { font-size: 8px; }
    .winner-table th, .winner-table td { padding: 8px 6px; }
    .winner-table th:first-child, .winner-table td:first-child { width: 38px; }
    .winner-table th:nth-child(3), .winner-table td:nth-child(3) { width: 76px; }
    .winner-table th:last-child, .winner-table td:last-child { width: 38px; }
    .winner-player { gap: 6px; }
    .winner-avatar { width: 24px; height: 24px; }
    .winner-team-heading { padding: 10px; font-size: 12px; }
    .winner-team-heading > span:last-child { font-size: 9px; }
}

/* --- Fade Overlay (join/welcome transition) --- */

#fade-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
}

#fade-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.controls-hint {
    font-size: clamp(9px, 1.2vw, 11px);
    color: var(--text-dim, #8888aa);
    letter-spacing: 1px;
}

@media (max-width: 680px) and (orientation: landscape) {
    #start-overlay > * {
        transform: scale(0.66);
        margin-top: -30px;
    }
    #start-btn { margin-top:0}
    #nickname-frame {margin-top: -60px;}
     #start-overlay > p {
            display:none;
     }
    .overlay {
        gap:0px;
    }
}

@media (max-width: 600px) {

    #theme-selector {
        flex-direction: column;
        gap: 8px;
    }

    .theme-btn {
        padding: 8px 16px;
    }

    #nickname-frame {
        width: 280px;
    }

    #nickname-input {
        font-size: 16px;
    }

    #avatar-display {
        width: 110px;
        height: 110px;
    }

    .avatar-arrow img {
        width: 36px;
        height: 36px;
    }

    #avatar-carousel {
        gap: 10px;
    }
}

/* --- Shop / Tech Tree Overlay --- */

#shop-overlay {
    background: rgba(10, 15, 30, 0.90);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
}

#shop-panel {
    position: relative;
    background-image: url('../img/blueprint.png');
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    overflow: hidden;
    width: 90vw;
    max-width: 920px;
    aspect-ratio: 1.5 / 1;
}

/* Container for nodes — positioned over the blueprint */
.tech-grid {
    position: absolute;
    inset: 10%;
}

/* Tank outline image */
.tech-tank {
    position: absolute;
    left: 0%;
    top: 48%;
    transform: translate(-50%, -50%);
}

.tech-tank img {
    width: 100%;
    max-width: 100px;
    height: auto;
    filter: brightness(1.2);
}

/* Individual tech node */
.tech-node {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.15s;
    -webkit-user-select: none;
    user-select: none;
}

.tech-node img {
    width: clamp(36px, 5vw, 56px);
    height: clamp(36px, 5vw, 56px);
    object-fit: contain;
    transition: filter 0.2s;
}

.tech-node:hover:not(.locked) img {
    filter: brightness(1.3);
}

.tech-node:hover:not(.locked) {
    transform: translate(-50%, -50%) scale(1.08);
}

.tech-node.locked {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.tech-node.active img {
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

/* Node ID label (A, A1, B2, etc) */
.tech-node-id {
    color: #fff;
    font-size: clamp(10px, 1.4vw, 15px);
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Node name label */
.tech-node-name {
    color: rgba(255, 255, 255, 0.85);
    font-size: clamp(7px, 1vw, 11px);
    text-align: center;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Cost badge */
.tech-node-cost {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #FFCA2A;
    font-size: clamp(7px, 0.9vw, 10px);
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 6px;
    line-height: 1.3;
}

.tech-node.active .tech-node-cost {
    display: none;
}

/* SVG connection lines overlay */
.tech-lines {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.tech-lines path {
    stroke: #7BA0C1;
    stroke-width: 2;
    fill: none;
}

.tech-lines path.line-available {
    stroke: #fff;
    stroke-width: 2.5;
}

.tech-lines path.line-purchased {
    stroke: #F8CA4C;
    stroke-width: 2.5;
}

/* Bottom-right info box */
.tech-info-box {
   position: absolute;
    right: 6%;
    bottom: 5%;
    padding: 3px 2px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0px;
    z-index: 2;
    width:230px;
    height: 122px;
}

.tech-info-title {
    color: #fff;
    font-size: clamp(14px, 2.2vw, 18px);
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-right: 12px;
    margin-top: 13px;
}

.tech-info-bolts {
    color: rgba(255, 255, 255, 0.8);
    font-size: clamp(10px, 1.3vw, 14px);
    font-weight: 700;
    position: absolute;
        bottom: 10px;
    left: 14px;
}

.tech-info-bolts span {
    color: #FFCA2A;
}

#shop-close-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    padding: 6px 22px;
    font-family: inherit;
    font-size: clamp(10px, 1.4vw, 14px);
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
    position: absolute;
    bottom: 2px;
    right: 2px;
}

#shop-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#shop-repair-btn {
    background: rgba(248, 202, 76, 0.15);
    color: #F8CA4C;
    border: 1px solid rgba(248, 202, 76, 0.5);
    border-radius: 4px;
    padding: 6px 14px;
    font-family: inherit;
    font-size: clamp(10px, 1.4vw, 14px);
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
    position: absolute;
    bottom: 38px;
    right: 2px;
}

#shop-repair-btn:hover:not(:disabled) {
    background: rgba(248, 202, 76, 0.35);
}

#shop-repair-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

@media (min-width: 601px) and (max-width: 920px) {
    .tech-info-box {
        transform: scale(tan(atan2(90vw, 920px)));
        transform-origin: bottom right;
    }
}

/* --- Mobile --- */
@media (max-width: 600px) {
    #shop-panel {
        width: 98vw;
        aspect-ratio: auto;
        min-height: 60vh;
    }

    .tech-node img {
        width: 32px;
        height: 32px;
    }

    .tech-node-name {
        font-size: 7px;
    }

    .tech-info-box {
        padding: 0px 10px;
    width: 172px;
            height: 106px;
         BACKGROUND: rgb(16 96 155);

    }
}

/* Map/mode voting: two rows with mode cards beside the map cards. */
#vote-overlay, #team-overlay {
    overflow-y: auto;
    justify-content: flex-start;
    padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    gap: 12px;
}
#vote-overlay h2, #team-overlay h2 { font-size: clamp(20px, 4vw, 30px); }
#vote-countdown { font-size: 28px; }
#vote-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    width: min(100%, 700px);
    margin: auto;
    gap: 16px;
}
#vote-panel h2 { text-align: center; }
#vote-tiles { display: grid; gap: 20px; width: 100%; margin: 0; }
.vote-mode { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }
.vote-mode-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    aspect-ratio: 474 / 700;
    min-width: 0;
    padding: 12px;
    margin: 0;
    border: 2px solid;
    border-radius: 8px;
    text-align: center;
    color: #fff;
    box-shadow: inset 0 1px 0 #ffffff20, 0 4px 12px #00000030;
}
.vote-mode-ffa { background: linear-gradient(150deg, #555b65, #30343c); border-color: #747b86; }
.vote-mode-teams { background: linear-gradient(150deg, #ad353d, #6b1e28); border-color: #d75960; }
.vote-mode-card strong { font-size: clamp(12px, 2.5vw, 22px); letter-spacing: 1px; }
.vote-mode-card span { margin-top: 12px; font-size: clamp(9px, 1.4vw, 12px); line-height: 1.6; font-weight: normal; color: #ffffffc9; }
.vote-row { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.vote-tile { min-width: 0; gap: 3px; }
.vote-tile-card { width: 100%; }
.vote-tile-name { font-size: clamp(10px, 2.5vw, 20px); }
.vote-tile-count { font-size: 18px; }
.vote-tile:focus-visible { outline: 3px solid #ffcc00; outline-offset: 4px; }
#team-overlay {
    z-index: 150;
    background: rgba(5, 5, 30, .93);
    justify-content: center;
    gap: 22px;
}
#team-overlay h2 {
    margin: 0;
    color: #eef3ff;
    font-size: clamp(22px, 4vw, 28px);
    letter-spacing: 1px;
    text-shadow: none;
}
#team-status { max-width: 550px; text-align: center; color: #ff9f9f; font-size: 12px; margin: 0; }
#team-status:empty { display: none; }
#team-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; width: min(100%, 580px); }
.team-choice {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 162px;
    padding: 0;
    overflow: hidden;
    text-align: left;
    border: 1px solid var(--team-color);
    border-radius: 8px;
    background: #121b30;
    color: #fff;
    font-family: var(--font-family, 'Orbitron', sans-serif);
    cursor: pointer;
}
.team-header {
    display: block;
    padding: 12px 14px;
    background: color-mix(in srgb, var(--team-color) 15%, #121b30);
    border-bottom: 1px solid color-mix(in srgb, var(--team-color) 35%, transparent);
    color: var(--team-color);
    font-size: 16px;
    font-weight: 700;
}
.team-roster { display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.team-player-row { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 3px 4px; font-size: 12px; letter-spacing: .5px; }
.team-player-row .player-avatar-mini { width: 20px; height: 20px; flex-shrink: 0; }
.team-player-row .player-name { color: #eef3ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-player-self { background: rgba(255,255,255,.07); border-radius: 4px; }
.team-choice:disabled { opacity: .45; cursor: not-allowed; }
.team-choice:hover:not(:disabled), .team-choice:focus-visible { background: #1d2b45; outline: 2px solid var(--team-color); outline-offset: 3px; }
@media (max-width: 420px) {
    .vote-mode, .vote-row { gap: 8px; }
    .vote-mode-card { padding: 6px; }
    .vote-mode-card span { margin-top: 8px; }
    .team-roster { padding: 8px 4px; }
    .team-player-row { gap: 6px; font-size: 11px; }
}
@media (max-height: 650px) {
    #vote-overlay { padding-block: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-bottom)); }
    #vote-panel { gap: 8px; width: min(100%, 500px); }
    #vote-tiles { gap: 10px; }
}

#vote-overlay, #team-overlay { touch-action: pan-y; }
#vote-tiles, #team-choices { flex-shrink: 0; }

@media (max-height: 430px) {
    #team-overlay { justify-content: flex-start; gap: 12px; }
}

/* Respawn hangar */
#death-overlay {
    justify-content: flex-start;
    background: rgba(9, 15, 28, .92);
    backdrop-filter: blur(8px);
    overflow-y: auto;
    padding: 24px 16px;
    touch-action: pan-y;
}
#respawn-panel { width: min(940px, 100%); margin: auto; flex-shrink: 0; color: #f3f6fc; }
#respawn-tabs { display: flex; gap: 6px; padding: 5px; border-radius: 12px; background: #101b2d; margin-bottom: 20px; }
#respawn-tabs button { flex: 1; padding: 14px 8px; border: 0; border-radius: 8px; background: transparent; color: #94a7c2; font: inherit; font-size: 12px; cursor: pointer; }
#respawn-tabs button[aria-selected="true"] { background: #2b3d57; color: #fff; }
#tank-choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tank-choice { display: flex; flex-direction: column; text-align: left; position: relative; padding: 20px; border: 2px solid #30415b; border-radius: 14px; background: linear-gradient(150deg, #22334c, #131e30); color: #e7edf7; font: inherit; cursor: pointer; min-width: 0; }
.tank-choice:hover { background: linear-gradient(150deg, #2c4360, #18263b); }
.tank-choice.selected { border-color: #f8ca4c; box-shadow: 0 0 0 1px #f8ca4c40, inset 0 0 32px #f8ca4c0a; }
.tank-role { text-transform: uppercase; letter-spacing: 2px; color: #a1b3cc; font-size: 9px; }
.tank-name { font-size: clamp(17px, 2.6vw, 25px); margin-top: 9px; }
.tank-choice canvas { width: 100%; aspect-ratio: 11 / 7; display: block; }
.tank-stats { display: grid; gap: 12px; border-top: 1px solid #40516a; padding-top: 18px; margin-top: 12px; width: 100%; }
.tank-stat { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; font-size: 11px; color: #c5d1e2; }
.tank-stat-bar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.tank-stat-segment { height: 13px; border: 1px solid #506079; border-radius: 2px; background: #111b2b; }
.tank-stat-segment.filled { background: #f8ca4c; border-color: #ffda76; }
.tank-bonus { margin-top: 20px; font-size: 12px; color: #94a7c2; }
.tank-bonus strong { color: #f3f6fc; font-weight: 700; }
.tank-selection-mark { text-align: center; width: 100%; color: #f8ca4c; font-size: 10px; letter-spacing: 2px; margin-top: 20px; visibility: hidden; }
.selected .tank-selection-mark { visibility: visible; }
.hangar-hint { color: #91a4bf; text-align: center; font-size: 10px; line-height: 1.7; margin: 18px 0; }
.hangar-footer { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 22px; }
#deployment-summary { font-size: 12px; color: #d5dfed; }
#respawn-btn { margin: 0; font-size: 14px; padding: 16px 30px; }
#respawn-btn::before, #respawn-btn::after { display: none; }
#respawn-btn:disabled { opacity: .45; cursor: not-allowed; }
#teams-content #team-choices { width: 100%; }
.team-choice.selected { outline: 2px solid var(--team-color); outline-offset: 2px; background: #253752; }
#respawn-panel #team-status { max-width: none; margin-top: 16px; }
.tank-choice:focus-visible, #respawn-tabs button:focus-visible, #respawn-btn:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
@media (max-width: 600px) {
    #death-overlay { padding: 18px 12px; }
    #tank-choices { grid-template-columns: 1fr; gap: 12px; }
    .tank-choice { display: grid; grid-template-columns: clamp(78px, 25vw, 110px) minmax(0, 1fr); padding: 14px; column-gap: 14px; }
    .tank-role, .tank-name, .tank-stats, .tank-bonus { grid-column: 2; }
    .tank-choice canvas { grid-column: 1; grid-row: 1 / 5; align-self: center; }
    .tank-name { font-size: 20px; }
    .tank-stats { gap: 10px; padding-top: 12px; }
    .tank-stat { grid-template-columns: 48px minmax(0, 1fr); gap: 6px; font-size: 10px; }
    .tank-stat-bar { gap: 3px; }
    .tank-bonus { margin-top: 14px; font-size: 11px; }
    .tank-selection-mark { grid-column: 1 / -1; margin-top: 12px; }
    .hangar-footer { position: sticky; bottom: -18px; background: #0d1525; padding: 14px 0; margin-top: 10px; }
    #respawn-btn { padding: 14px 18px; font-size: 12px; }
    #deployment-summary { font-size: 10px; }
}
