body{font-family:system-ui,sans-serif;background:#111;color:#eee;text-align:center;margin:0;padding:16px}
canvas{background:#1b1b1b;border:1px solid #333;border-radius:8px;max-width:100%}

#game-container {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

#game {
    display: block;
    box-sizing: border-box;
}

#zone-warning {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(180, 20, 20, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    pointer-events: none;
}

#death-screen {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#death-screen h2 {
    color: #ef4444;
    font-size: 42px;
    margin: 0;
}

#respawn-btn {
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 30px;
    font-size: 18px;
    cursor: pointer;
}

#respawn-btn:hover {
    background: #16a34a;
}

#controls {
    color: #999;
    font-size: 14px;
}

[hidden] {
    display: none !important;
}

#leaderboard {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 190px;
    padding: 14px;
    background: rgba(15, 15, 15, 0.85);
    border: 1px solid #444;
    border-radius: 10px;
    color: white;
    text-align: left;
    pointer-events: none;
}

#leaderboard h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.leaderboard-header,
.leaderboard-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    padding: 6px 0;
}

.leaderboard-header {
    color: #999;
    border-bottom: 1px solid #444;
}

.leaderboard-row {
    border-bottom: 1px solid #292929;
}

.leaderboard-row span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-row.current-player {
    color: #4ade80;
    font-weight: bold;
}

#player-stats {
    position: absolute;
    bottom: 15px;
    left: 15px;
    background: rgba(15, 15, 15, 0.85);
    border: 1px solid #444;
    border-radius: 10px;
    padding: 12px 16px;
    color: #ccc;
    font-size: 13px;
    text-align: left;
    line-height: 1.8;
    pointer-events: none;
}

#player-stats strong {
    color: white;
}

/* Zone countdown: timer, a bar that empties over the round, and a status line */
.zone-stat {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(85, 255, 193, 0.2);
}

.zone-bar {
    width: 150px;
    height: 6px;
    margin: 4px 0 2px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

#zone-bar-fill {
    height: 100%;
    width: 100%;
    background: #55ffc1;
    transition: width 0.5s linear;
}

#zone-bar-fill.late {
    background: #f87171;
}

.zone-status {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
}

.zone-status.late {
    color: #f87171;
    font-weight: bold;
}

#death-screen {
    z-index: 10;
}

#zone-warning {
    z-index: 5;
}

/* Neon arcade theme */

body {
    background: radial-gradient(
        ellipse at top, #17263b, #080e19 75%
    );
    color: #e2e8f0;
    font-family: "Trebuchet MS", Arial, sans-serif;
    min-height: 100vh;
}

h1 {
    color: #55ffc1;
    text-transform: uppercase;
    letter-spacing: 5px;
    font-size: 36px;
    text-shadow: 0 0 22px rgba(85, 255, 193, 0.35);
}

#status {
    color: #55ffc1;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#game {
    background: #0b1422;
    border: 1px solid #30445b;
    border-radius: 14px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.4);
    max-width: 100%;
    height: auto;
    cursor: crosshair;
}

#leaderboard,
#player-stats {
    background: rgba(12, 23, 38, 0.92);
    border: 1px solid #30445b;
    border-radius: 12px;
    backdrop-filter: blur(8px);
}

#leaderboard h3 {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 13px;
    color: #cbd5e1;
}

.leaderboard-row {
    border-bottom-color: #243247;
}

.leaderboard-row.current-player {
    color: #55ffc1;
}

#player-score {
    color: #55ffc1 !important;
    font-size: 20px;
}

#controls {
    color: #94a3b8;
    letter-spacing: 1px;
}

#death-screen {
    background: rgba(5, 10, 20, 0.88);
    backdrop-filter: blur(5px);
}

#death-screen h2 {
    text-transform: uppercase;
    letter-spacing: 5px;
    text-shadow: 0 0 25px rgba(239, 68, 68, 0.5);
}

#respawn-btn {
    background: #55ffc1;
    color: #08121a;
    font-weight: bold;
    box-shadow: 0 0 20px rgba(85, 255, 193, 0.3);
}

#respawn-btn:hover {
    background: #a7f3d0;
}

/* Kill feed (bottom-right; newest at the bottom) */
#kill-feed {
    position: absolute;
    bottom: 15px;
    right: 15px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-align: right;
    font-size: 13px;
    pointer-events: none;
}

.feed-entry {
    background: rgba(12, 23, 38, 0.88);
    border: 1px solid #30445b;
    border-right: 3px solid #fb7185;
    border-radius: 8px;
    padding: 5px 10px;
    color: #dbe7f5;
}

.feed-entry.bounty {
    border-right-color: #facc15;
    color: #fde68a;
}

.feed-entry.zone {
    border-right-color: #ef4444;
}

.feed-entry.me {
    font-weight: bold;
    color: #55ffc1;
}

/* ===== Full-screen layout (overrides the centered 800x600 box above) ===== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#game-container {
    position: fixed;
    inset: 0;
    width: auto;
    max-width: none;
    margin: 0;
}

#game {
    width: 100%;
    height: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Small wordmark + connection status, top-center */
#brand {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
}

#brand h1 {
    font-size: 20px;
    margin: 0;
}

#brand #status {
    margin: 2px 0 0;
    font-size: 11px;
}

#zone-warning {
    top: 72px;
}

/* Logged-in bar (added by the server after <body>) */
#auth-bar {
    position: fixed;
    top: 14px;
    left: 66px;
    z-index: 20;
    background: rgba(12, 23, 38, 0.92);
    border: 1px solid #30445b;
    border-radius: 999px;
    padding: 6px 8px 6px 16px;
    font-size: 13px;
    color: #cbd5e1;
    backdrop-filter: blur(8px);
}

#auth-bar strong {
    color: #55ffc1;
}

#auth-bar a {
    color: #55ffc1;
}

#auth-bar button {
    margin-left: 8px;
    background: transparent;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
    border-radius: 999px;
    padding: 3px 10px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

#auth-bar button:hover {
    background: #7f1d1d;
    color: white;
}

#settings-btn {
    position: absolute;
    top: 12px;
    left: 14px;
    z-index: 20;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #30445b;
    background: rgba(12, 23, 38, 0.92);
    color: #cbd5e1;
    font-size: 20px;
    cursor: pointer;
}

#settings-btn:hover {
    color: #55ffc1;
    border-color: #55ffc1;
}

#leaderboard {
    top: 12px;
    right: 14px;
}

#player-stats {
    bottom: 14px;
    left: 14px;
}

#kill-feed {
    bottom: 14px;
    right: 14px;
}

/* Controls hint fades out after a few seconds */
#controls {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    font-size: 13px;
    pointer-events: none;
    animation: hint-fade 1s ease 8s forwards;
}

@keyframes hint-fade {
    to { opacity: 0; }
}

/* Settings menu and login prompt */
.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(5, 10, 20, 0.72);
    backdrop-filter: blur(4px);
}

.panel {
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-sizing: border-box;
    padding: 24px 28px;
    text-align: left;
    background: #0e1a2b;
    border: 1px solid #30445b;
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(85, 255, 193, 0.08);
}

.panel h2 {
    margin: 0 0 6px;
    color: #55ffc1;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-size: 22px;
}

.panel h3 {
    margin: 18px 0 8px;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 13px;
}

.panel .note {
    margin: 0 0 14px;
    color: #94a3b8;
    font-size: 13px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    color: #e2e8f0;
    font-size: 14px;
    cursor: pointer;
}

.toggle input {
    width: 18px;
    height: 18px;
    accent-color: #55ffc1;
}

.toggle small {
    color: #94a3b8;
}

.legend {
    margin: 0;
    padding-left: 18px;
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.6;
}

.legend b {
    color: #f1f5f9;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 10px;
    background: #55ffc1;
    color: #08121a;
    font: inherit;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    background: #a7f3d0;
}

.btn.secondary {
    background: transparent;
    color: #55ffc1;
    border: 1px solid #55ffc1;
}

.btn.secondary:hover {
    background: rgba(85, 255, 193, 0.12);
}

.btn.danger {
    background: transparent;
    color: #fca5a5;
    border: 1px solid #7f1d1d;
    margin-left: auto;
}

.btn.danger:hover {
    background: #7f1d1d;
    color: white;
}

#login-prompt .panel {
    text-align: center;
}

#login-prompt .panel-actions {
    justify-content: center;
}

/* Active perks with time left (bottom-center) */
#perk-bar {
    position: absolute;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 6;
    pointer-events: none;
}

.perk-chip {
    position: relative;
    overflow: hidden;
    min-width: 120px;
    padding: 7px 14px 10px;
    border-radius: 10px;
    background: rgba(12, 23, 38, 0.92);
    border: 1px solid var(--perk-color, #30445b);
    box-shadow: 0 0 16px color-mix(in srgb, var(--perk-color, #55ffc1) 35%, transparent);
    color: #f1f5f9;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
}

.perk-bar-fill {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--perk-color, #55ffc1);
}

/* Hitmarker when you get a kill (the camera keeps your snake centered) */
#hitmarker {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0;
    height: 0;
    z-index: 8;
    color: #ffffff;
    pointer-events: none;
    /* its own layer: the glow is drawn once and the pop animation just scales it,
       instead of redrawing the glow on top of the game every frame */
    will-change: transform, opacity;
}

#hitmarker.bounty {
    color: #facc15;
}

#hitmarker .hm-x {
    position: absolute;
    left: -32px;
    top: -32px;
    width: 64px;
    height: 64px;
    filter: drop-shadow(0 0 6px rgba(255, 80, 80, 0.9));
}

#hitmarker.bounty .hm-x {
    filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.9));
}

#hitmarker-text {
    position: absolute;
    top: 44px;
    left: 0;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(255, 80, 80, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
}

#hitmarker.bounty #hitmarker-text {
    font-size: 20px;
    text-shadow: 0 0 14px rgba(250, 204, 21, 0.8), 0 2px 4px rgba(0, 0, 0, 0.8);
}

#hitmarker.show {
    animation: hitmarker-pop 1.1s ease-out forwards;
}

@keyframes hitmarker-pop {
    0%   { opacity: 0; transform: scale(1.7); }
    12%  { opacity: 1; transform: scale(1); }
    70%  { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

/* Zone announcements (new round, zone growing) */
#announce {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 7;
    padding: 12px 26px;
    border-radius: 12px;
    background: rgba(12, 23, 38, 0.92);
    border: 1px solid #55ffc1;
    box-shadow: 0 0 24px rgba(85, 255, 193, 0.25);
    color: #55ffc1;
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 1px;
    white-space: nowrap;
    pointer-events: none;
}

#announce.show {
    animation: announce-pop 3s ease-out forwards;
}

@keyframes announce-pop {
    0%   { opacity: 0; transform: translateX(-50%) scale(1.3); }
    8%   { opacity: 1; transform: translateX(-50%) scale(1); }
    80%  { opacity: 1; }
    100% { opacity: 0; }
}

/* How-to-play screen shown before joining */
.intro-panel {
    width: min(600px, calc(100vw - 32px));
}

.intro-list {
    margin: 0;
    padding-left: 18px;
    color: #cbd5e1;
    font-size: 14px;
    line-height: 1.6;
}

.intro-list b {
    color: #f1f5f9;
}

.intro-list b.red {
    color: #fca5a5;
}

.intro-zone {
    display: flex;
    gap: 16px;
    align-items: center;
}

.zone-diagram {
    flex: 0 0 180px;
    width: 180px;
}

@media (max-width: 560px) {
    .intro-zone {
        flex-direction: column;
    }
}

.intro-actions {
    align-items: center;
    justify-content: space-between;
}

.intro-actions .btn {
    padding: 12px 36px;
    font-size: 17px;
}
