#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    pointer-events: none;
    padding: 16px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

#hud-top-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
    cursor: pointer;
}

:root {
    --timer-primary: #FFCA22;
}

#hud-top-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    top: 10px;
    pointer-events: none;
}

#timer {
    position: relative;
    background: #140A05;
    border: none;
    padding: 4px 12px;
    padding-left: 32px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--timer-primary);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    pointer-events: auto;
    cursor: pointer;
    transition: background 0.15s ease;
}

#timer:hover {
    background: #2a1a10;
}

#timer-text {
    display: inline-block;
    width: 3.5em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

#timer-progress {
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: conic-gradient(var(--timer-primary) 0deg, #140A05 0deg);
    z-index: 0;
    transition: all 0.15s ease;
}

#timer-icon {
    position: absolute;
    left: -15px;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    flex-shrink: 0;
    object-fit: contain;
    z-index: 1;
    transition: transform 0.12s ease;
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;
}

#timer:hover #timer-icon {
    transform: translateY(-50%) scale(0.85);
}

#timer:hover #timer-progress {
    transform: translateY(-50%) scale(0.85);
}

#hud-top-left span {
    background: var(--hud-bg, rgba(10, 10, 26, 0.85));
    border: 1px solid var(--border, rgba(0, 255, 242, 0.15));
        padding: 3px 12px;
    border-radius: 4px;
    font-size: 12px;
    color: #FFCA2A;
    top:-3px
   
}

#bolt-count {
    position: relative;
    background: #140A05 !important;
    border: none !important;
    color: #FFCA2A;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding-left: 40px !important;
    transition: background 0.15s ease;
}

#hud-top-left:hover #bolt-count {
    background: #2a1a10 !important;
}

#shop-icon {
    position: absolute;
    left: -10px;
    top: 40%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    flex-shrink: 0;
    object-fit: contain;
    z-index: 1;
    transition: transform 0.12s ease;
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: auto;
    cursor: pointer;
}

#hud-top-left:hover #shop-icon {
    transform: translateY(-50%) scale(0.85);
}

#fullscreen-btn {
    background: #140A05;
    border: none;
    color: #FFCA2A;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.15s ease, transform 0.12s ease;
    padding: 0;
    -webkit-user-select: none;
    user-select: none;
}

#fullscreen-btn:hover {
    background: #2a1a10;
    transform: scale(0.9);
}

#fullscreen-btn svg {
    display: block;
}

#hud-top-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#player-list {
    background: none;
    border: none;
    min-width: 200px;
        margin-top: -3px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.player-row.dead {
    opacity: 0.35;
}

.player-row.disconnected {
    opacity: 0.5;
    filter: grayscale(1);
}

.player-indicator {
    position: relative;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.player-avatar-mini {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    object-fit: cover;
    display: block;
}

.player-avatar-toggle {
    cursor: pointer;
    pointer-events: auto;
}

.player-indicator .player-crown {
    position: absolute;
    top: -6px;
    right: -6px;
}
.player-row-self .player-indicator .player-crown {
    top: 4px;
    right: 5px;
 }

.player-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}

.player-position {
    display: none;
}

.player-name {
    flex: 1;
    color: var(--text, #e0e0ff);
    font-weight: 700;
    
}

/* Local player row overrides */
.player-row-self {
    position: relative;
    background: #140A05;
    border-radius: 4px;
    padding: 4px 12px 4px 28px;
    transition: background 0.15s ease;
    pointer-events: auto;
    margin-bottom: 10px;
}

.player-row-self:hover {
    background: #2a1a10;
}

.player-row-self .player-indicator {
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 45px;
    height: 45px;
    z-index: 1;
    transition: transform 0.12s ease;
    -webkit-user-drag: none;
    user-select: none;
}

.player-row-self:hover .player-indicator {
    transform: translateY(-50%) scale(0.85);
}

.player-row-self .player-avatar-mini {
    width: 36px;
    height: 36px;
    border-radius: 4px;
   margin-top: 3px;
       margin-left: -2px;
}

.player-row-self .player-position {
    display: inline;
    color: var(--text-dim, #8888aa);
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.player-row-self .player-name {
    padding: 0;
}

.player-crown {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-crown::before {
    content: '\265B';
    color: #ffd700;
    font-size: 15px;
    line-height: 1;
    position: relative;
    top: -3px;
}

.player-bolts {
    display: none;
}

.player-kills {
    color: var(--text, #e0e0ff);
    font-weight: 700;
    min-width: 45px;
    text-align: right;
}

.player-territory {
    color: var(--text-dim, #8888aa);
    font-size: 10px;
    min-width: 40px;
    text-align: right;
}

/* Emoji wheel trigger button — floating middle-right */
.emoji-trigger {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: #140A05;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    padding: 0;
    transition: background 0.15s ease, transform 0.12s ease;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.276);
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.emoji-trigger:hover {
    background: #2a1a10;
    transform: scale(1.08);
}

.emoji-trigger-floating {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;
}

.emoji-trigger-floating:hover {
    transform: translateY(-50%) scale(1.08);
}

.emoji-trigger::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    height: var(--emoji-cd, 0%);
    top: auto;
    bottom: 0;
    pointer-events: none;
    transition: height 0.08s linear;
}

.emoji-trigger-cooldown {
    cursor: not-allowed;
    opacity: 0.7;
}

/* Radial wheel popup */
.emoji-wheel {
    position: fixed;
    z-index: 200;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(20, 10, 5, 0.95) 0%, rgba(20, 10, 5, 0.85) 70%, rgba(20, 10, 5, 0) 100%);
    pointer-events: auto;
    animation: emoji-wheel-pop 0.18s ease-out;
}

@keyframes emoji-wheel-pop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.emoji-wheel-center {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.emoji-wheel-slice {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    font-size: 26px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: background 0.12s ease, transform 0.12s ease;
    padding: 0;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.emoji-wheel-slice:hover {
    background: rgba(255, 202, 42, 0.35);
    transform: translate(-50%, -50%) scale(1.18);
}

@media (max-width: 600px) {
    .emoji-trigger {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
}

#minimap-container {
    --minimap-border-size: 2px;
    --minimap-corner-radius: 6px;
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
    z-index: 10;
    width: 150px;
    height: 150px;
    box-sizing: border-box;
    padding: var(--minimap-border-size);
    background: #fff;
    /* Outer hex frame */
    clip-path: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%);
    border-radius: var(--minimap-corner-radius);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.276));
}

.minimap-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    /* Inner hex inset to reveal border frame */
    clip-path: polygon(50% 0%, 93.3% 25%, 93.3% 75%, 50% 100%, 6.7% 75%, 6.7% 25%);
    border-radius: var(--minimap-corner-radius);
}

#stamina-bar {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border, rgba(0, 255, 242, 0.15));
    border-radius: 3px;
    z-index: 10;
    overflow: hidden;
}

#stamina-fill {
    height: 100%;
    width: 100%;
    background: var(--primary, #00fff2);
    border-radius: 2px;
    transition: width 0.1s linear;
}

#stamina-fill.boosting {
    background: var(--accent, #ff00ff);
}

@keyframes stamina-flash {
    0%   { background: #ff2222; box-shadow: 0 0 8px #ff2222; }
    100% { background: var(--primary, #00fff2); box-shadow: none; }
}

#stamina-fill.flash {
    animation: stamina-flash 0.4s ease-out;
}

@media (max-width: 600px) {
    #hud {
        padding: 4px;
    }

    #hud-top-left {
        gap: 3px;
    }

    #hud-top-left span {
        font-size: 7px;
        padding: 3px 7px;
        letter-spacing: 0.5px;
    }

    #player-list {
        min-width: 100px;
        padding: 3px 5px;
    }

    .player-row {
        font-size: 6px;
        gap: 4px;
        padding: 2px 0;
    }

    .player-indicator {
        width: 14px;
        height: 14px;
    }

    .player-avatar-mini {
        width: 14px;
        height: 14px;
    }

    .player-row-self {
        padding: 2px 8px 2px 28px;
    }

    .player-row-self .player-indicator {
        width: 30px;
        height: 30px;
    }

    .player-row-self .player-avatar-mini {
        width: 30px;
        height: 30px;
    }

    .player-row-self .player-position {
        font-size: 6px;
        min-width: 12px;
    }

    .player-color {
        width: 6px;
        height: 6px;
    }

    .player-crown {
        width: 6px;
        height: 6px;
    }

    .player-crown::before {
        font-size: 6px;
    }

    .player-bolts,
    .player-kills,
    .player-territory {
        font-size: 6px;
        min-width: 20px;
    }

    #fullscreen-btn {
        width: 22px;
        height: 22px;
    }

    #fullscreen-btn svg {
        width: 14px;
        height: 14px;
    }

    #stamina-bar {
        width: 120px;
        height: 4px;
    }

    #minimap-container {
        width: 100px;
        height: 100px;
        bottom: 100px;
    }
}

/* Mobile touch: smaller minimap, bottom center */
@media (pointer: coarse), (hover: none) {
    #minimap-container {
        width: 90px;
        height: 90px;
        opacity: 0.75;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    #stamina-bar {
        bottom: 20px;
    }
}

/* Small viewport height: hide player list, minimap to bottom-right at 3/4 size */
@media (pointer: coarse) and (max-height: 500px) {
    #hud-top-right {
        display: none;
    }

    #minimap-container {
        top: 10px;
        bottom: auto;
        left: auto;
        right: 10px;
        transform: none;
    }
}

/* Network debug overlay (F9 or ?net=1) */
#net-debug {
    position: fixed;
    left: 8px;
    bottom: 8px;
    margin: 0;
    padding: 6px 8px;
    z-index: 30;
    pointer-events: none;
    font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #e8f0ff;
    background: rgba(10, 14, 24, 0.72);
    border-radius: 6px;
    white-space: pre;
}

#team-scores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; padding: 7px; margin-bottom: 5px; border-radius: 6px; background: rgba(5, 5, 30, .8); font-size: 11px; }
