:root {
    --bg-deep: #0c141d;
    --bg-mid: #12263a;
    --accent: #ff6a3d;
    --accent-2: #2ec4ff;
    --text: #edf3f9;
    --muted: #9db0c2;
    --panel: rgba(8, 14, 24, 0.82);
    --panel-strong: rgba(9, 17, 30, 0.94);
    --good: #6ce17f;
    --warn: #ffd65b;
    --danger: #ff4d5f;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    font-family: 'Rajdhani', 'Segoe UI', Tahoma, sans-serif;
    background-color: #000;
    color: var(--text);
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

canvas {
    display: block;
}

/* HUD */
#hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: none;
}

#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 14px rgba(46, 196, 255, 0.35);
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background-color: rgba(255, 255, 255, 0.9);
}

#crosshair::before {
    width: 2px;
    height: 20px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#crosshair::after {
    width: 20px;
    height: 2px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

#health-container {
    position: absolute;
    bottom: 24px;
    left: 24px;
    min-width: 260px;
    padding: 12px 14px;
    background: linear-gradient(140deg, rgba(10, 20, 33, 0.9), rgba(11, 18, 31, 0.7));
    border: 1px solid rgba(160, 196, 223, 0.3);
    border-radius: 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
    font-size: 18px;
    letter-spacing: 0.05em;
}

#health-bar {
    width: 100%;
    height: 16px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 6px;
}

#health-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--danger), #ff8e66);
    transition: width 0.25s ease;
}

#health-text {
    margin-top: 5px;
    font-weight: 700;
    color: #f9fcff;
}

#cash-display {
    position: absolute;
    top: 22px;
    right: 24px;
    color: var(--good);
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0 0 10px rgba(108, 225, 127, 0.28), 0 4px 12px rgba(0, 0, 0, 0.45);
}

#cash-display::before {
    content: '$';
    color: #aef3b8;
    margin-right: 3px;
}

#weapon-info {
    position: absolute;
    bottom: 24px;
    right: 24px;
    min-width: 180px;
    text-align: right;
    padding: 10px 14px;
    background: linear-gradient(140deg, rgba(9, 16, 26, 0.88), rgba(12, 22, 35, 0.66));
    border: 1px solid rgba(114, 146, 174, 0.28);
    border-radius: 10px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

#top-announcement {
    position: absolute;
    top: 28px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    max-width: min(92vw, 700px);
    padding: 10px 18px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #f4fbff;
    background: rgba(11, 20, 33, 0.88);
    border: 1px solid rgba(151, 190, 219, 0.42);
    border-radius: 10px;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.2s ease;
}

#top-announcement.visible {
    opacity: 1;
}

#scoreboard-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(88vw, 520px);
    background: rgba(8, 16, 27, 0.94);
    border: 1px solid rgba(127, 169, 201, 0.46);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    display: none;
    padding: 14px 14px 10px;
}

#scoreboard-overlay.visible {
    display: block;
}

#scoreboard-title {
    font-family: 'Teko', sans-serif;
    font-size: 34px;
    letter-spacing: 0.08em;
    text-align: center;
    color: #f3faff;
    margin-bottom: 8px;
}

#scoreboard-rows {
    display: grid;
    gap: 6px;
}

.scoreboard-row {
    display: grid;
    grid-template-columns: 1fr 70px 80px;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    font-size: 18px;
    color: #eaf6ff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(141, 182, 213, 0.2);
    border-radius: 8px;
}

.scoreboard-row.you {
    border-color: rgba(255, 106, 61, 0.65);
}

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

.score-kills,
.score-deaths {
    text-align: center;
    font-weight: 700;
}

#weapon-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-2);
    letter-spacing: 0.07em;
}

#ammo-count {
    font-size: 34px;
    color: var(--warn);
    font-weight: 700;
    margin-top: 2px;
}

/* Shop */
#shop-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(8, 14, 24, 0.97), rgba(10, 20, 35, 0.95));
    border: 1px solid rgba(104, 173, 220, 0.42);
    border-radius: 14px;
    padding: 24px;
    display: none;
    z-index: 70;
    width: min(92vw, 520px);
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

#shop-menu h2 {
    color: #f4fbff;
    font-family: 'Teko', sans-serif;
    font-size: 48px;
    letter-spacing: 0.08em;
    text-align: center;
    margin-bottom: 8px;
    grid-column: 1 / -1;
}

#shop-cash {
    color: var(--good);
    font-size: 28px;
    text-align: center;
    margin-bottom: 18px;
    font-weight: 700;
    grid-column: 1 / -1;
}

#shop-cash::before {
    content: 'Cash: $';
    color: #d5e5f3;
}

.shop-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "main price"
        "main buy";
    gap: 10px;
    align-items: start;
    padding: 12px 14px;
    margin: 9px 0;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(155, 192, 223, 0.18);
    border-radius: 10px;
    pointer-events: auto;
    margin: 0;
    min-height: 84px;
}

.shop-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.shop-item-name {
    color: #eaf5ff;
    font-size: 14px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.shop-item-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    grid-area: main;
}

.shop-item-weapon-preview {
    width: 78px;
    height: 44px;
    border-radius: 8px;
    background: linear-gradient(140deg, rgba(12, 22, 34, 0.95), rgba(17, 30, 45, 0.88));
    border: 1px solid rgba(139, 175, 202, 0.34);
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
    overflow: hidden;
}

.shop-item-weapon-preview canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.shop-item-price {
    color: #ffe67d;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    grid-area: price;
    justify-self: end;
    align-self: start;
}

.shop-item-price::before {
    content: '$';
}

.shop-buy-btn {
    padding: 6px 12px;
    background: linear-gradient(135deg, #ff7950, #ff5d5d);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.18s ease, filter 0.18s ease;
    grid-area: buy;
    justify-self: end;
}

.shop-buy-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
}

.shop-buy-btn:disabled {
    background: #5d6672;
    color: #c8d2dc;
    cursor: not-allowed;
    transform: none;
}

#shop-close {
    margin-top: 16px;
    width: 100%;
    padding: 12px;
    background: #364658;
    color: #f2f8ff;
    border: 1px solid rgba(132, 165, 194, 0.45);
    border-radius: 8px;
    cursor: pointer;
    font-size: 17px;
    pointer-events: auto;
    grid-column: 1 / -1;
}

#shop-close:hover {
    background: #415669;
}

/* Start Screen + Menu */
#start-screen {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 82% 18%, rgba(46, 196, 255, 0.18), transparent 32%),
        radial-gradient(circle at 14% 74%, rgba(255, 106, 61, 0.2), transparent 34%),
        linear-gradient(135deg, var(--bg-deep), var(--bg-mid));
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 100;
    padding: 16px;
    overflow-y: auto;
}

.menu-panel {
    width: min(92vw, 720px);
    background: var(--panel);
    border: 1px solid rgba(133, 172, 204, 0.34);
    border-radius: 16px;
    padding: 18px 20px;
    text-align: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.menu-logo {
    width: min(56%, 280px);
    height: auto;
    display: block;
    margin: 0 auto 10px;
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(138, 179, 210, 0.32);
}

#start-screen h1 {
    font-family: 'Teko', sans-serif;
    font-size: clamp(54px, 10vw, 90px);
    color: #f4fbff;
    text-shadow: 0 0 20px rgba(46, 196, 255, 0.25);
    letter-spacing: 0.08em;
    margin-bottom: 0;
    line-height: 0.9;
}

#start-screen p {
    color: #d2dfeb;
    font-size: 20px;
    margin-bottom: 12px;
}

#main-menu,
#host-lobby,
#join-lobby {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.auth-panel {
    width: min(100%, 420px);
    margin: 12px auto 14px;
    display: grid;
    gap: 10px;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.auth-tab,
.mini-button {
    min-height: 38px;
    padding: 8px 12px;
    color: #dceeff;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(139, 182, 214, 0.32);
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    font-weight: 700;
    pointer-events: auto;
}

.auth-tab.active {
    color: #07111a;
    background: #2ec4ff;
    border-color: #2ec4ff;
}

#auth-title {
    margin: 0;
    color: #f4fbff;
    font-family: 'Teko', sans-serif;
    font-size: 34px;
    letter-spacing: 0.06em;
}

.auth-form {
    display: grid;
    gap: 9px;
}

.auth-form input {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    color: #edf3f9;
    background: rgba(5, 12, 22, 0.72);
    border: 1px solid rgba(139, 182, 214, 0.34);
    border-radius: 8px;
    font: inherit;
    pointer-events: auto;
}

.auth-message {
    min-height: 22px;
    margin: 0;
    color: #ffd65b;
    font-size: 16px;
}

.auth-message.error {
    color: #ff8b98;
}

.auth-message.success {
    color: #6ce17f;
}

.user-panel {
    width: min(100%, 420px);
    margin: 6px auto 14px;
    padding: 9px 10px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #dceeff;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(139, 182, 214, 0.26);
    border-radius: 10px;
    font-size: 16px;
}

.user-panel strong {
    color: #ffffff;
}

#map-select-modal {
    width: min(100%, 560px);
    margin: 10px auto 0;
    padding: 14px 12px;
    border: 1px solid rgba(125, 166, 197, 0.36);
    border-radius: 12px;
    background: rgba(9, 18, 30, 0.82);
}

#map-select-modal h3 {
    font-family: 'Teko', sans-serif;
    font-size: 34px;
    letter-spacing: 0.07em;
    color: #f2f8ff;
    text-align: center;
    margin-bottom: 10px;
}

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

.map-select-btn {
    border: 1px solid rgba(129, 172, 205, 0.4);
    border-radius: 10px;
    background: linear-gradient(140deg, rgba(35, 56, 79, 0.9), rgba(20, 33, 50, 0.92));
    color: #ecf5ff;
    padding: 10px 8px;
    min-height: 94px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    text-align: left;
    transition: transform 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}

.map-select-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.07);
    border-color: rgba(166, 209, 240, 0.7);
}

.map-name {
    font-weight: 700;
    font-size: 17px;
    line-height: 1.1;
}

.map-desc {
    margin-top: 4px;
    font-size: 13px;
    color: #c9d8e8;
    line-height: 1.2;
}

#map-select-cancel {
    margin-top: 10px;
    width: 100%;
}

#host-lobby,
#join-lobby {
    width: min(92%, 500px);
    align-items: center;
    text-align: center;
    margin: 0 auto;
    padding: 12px 14px;
    border: 1px solid rgba(120, 160, 190, 0.3);
    border-radius: 12px;
    background: rgba(11, 20, 32, 0.62);
}

#host-lobby > p,
#join-lobby > p {
    width: 100%;
    margin-bottom: 4px;
}

#player-list,
#lobby-status,
#join-input-container {
    width: 100%;
}

#main-menu .lobby-button,
#host-lobby .lobby-button,
#join-lobby .lobby-button {
    width: 100%;
    max-width: 320px;
    min-width: 0;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#controls-info {
    margin-top: 12px;
    color: var(--muted);
    font-size: 15px;
    width: min(92vw, 720px);
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 8px 16px;
    text-align: left;
}

#controls-info span {
    color: #dff2ff;
    font-weight: 700;
}

#controls-info p {
    margin: 0;
}

/* Pause Menu */
#pause-menu {
    position: absolute;
    inset: 0;
    background-color: rgba(4, 10, 18, 0.72);
    backdrop-filter: blur(6px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

#pause-menu h2 {
    color: #f0f7ff;
    font-family: 'Teko', sans-serif;
    font-size: 64px;
    letter-spacing: 0.08em;
    margin-bottom: 26px;
}

.pause-logo {
    width: min(56vw, 320px);
    height: auto;
    display: block;
    margin-bottom: 14px;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(138, 179, 210, 0.28);
}

.pause-button {
    padding: 12px 34px;
    min-width: 250px;
    font-size: 20px;
    background-color: var(--panel-strong);
    color: #f0f5fb;
    border: 1px solid rgba(141, 180, 211, 0.45);
    border-radius: 10px;
    cursor: pointer;
    margin: 7px;
    transition: transform 0.18s ease, background-color 0.18s ease;
    pointer-events: auto;
}

.pause-button:hover {
    background-color: #1a3247;
    transform: translateY(-1px);
}

/* Death Screen */
#death-screen {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(120, 16, 24, 0.86), rgba(64, 7, 13, 0.9));
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 80;
}

#death-screen h2 {
    color: #ffd8dc;
    font-family: 'Teko', sans-serif;
    font-size: 84px;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

#death-timer {
    color: #ffffff;
    font-size: 30px;
    font-weight: 700;
}

/* Console */
#console-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 52%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    z-index: 60;
}

#console-input {
    position: absolute;
    bottom: 16px;
    left: 16px;
    width: calc(100% - 32px);
    padding: 13px;
    font-size: 18px;
    background-color: rgba(10, 15, 19, 0.96);
    color: #99ffb4;
    border: 1px solid #4ec07d;
    border-radius: 7px;
    outline: none;
}

#console-output {
    position: absolute;
    top: 14px;
    left: 16px;
    width: calc(100% - 32px);
    height: calc(100% - 70px);
    overflow-y: auto;
    color: #93f4ad;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.console-line {
    margin: 4px 0;
}

.console-line.error {
    color: #ff7a7a;
}

.console-line.success {
    color: #7ce7ff;
}

/* Lobby */
.lobby-button {
    padding: 13px 30px;
    font-size: 20px;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, #ff7d53, #ff5f49);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.18s ease, filter 0.18s ease;
    pointer-events: auto;
    min-width: 230px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
}

.lobby-button.alt {
    background: linear-gradient(135deg, #3267a1, #2d4f7c);
}

.lobby-button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.lobby-button:disabled {
    background: #5f6b78;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

#room-code-display {
    font-size: 50px;
    color: #87f0ff;
    font-weight: 700;
    letter-spacing: 0.28em;
    margin: 10px 0 16px;
    text-shadow: 0 0 20px rgba(135, 240, 255, 0.26);
}

#join-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

#room-code-input {
    padding: 12px;
    font-size: 24px;
    width: auto;
    height: 54px;
    flex: 1;
    text-align: center;
    text-transform: uppercase;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(147, 196, 237, 0.6);
    border-radius: 8px;
    color: white;
    outline: none;
}

#room-code-input::placeholder {
    color: #97adc2;
    text-transform: none;
}

#connect-button {
    width: 140px;
}

#lobby-status {
    color: #b7c9da;
    font-size: 16px;
    margin-top: 6px;
    min-height: 24px;
    text-align: center;
}

#player-list {
    margin-top: 8px;
    width: 100%;
    color: white;
    font-size: 18px;
    text-align: center;
}

.player-item {
    padding: 8px 12px;
    margin: 5px 0;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    border: 1px solid rgba(145, 179, 209, 0.2);
}

.player-item.host {
    border-left: 4px solid var(--accent);
}

/* Name Tags */
#name-tags-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 40;
}

.player-name-tag {
    position: absolute;
    color: #f7fbff;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    padding: 5px 9px;
    background-color: rgba(10, 17, 30, 0.72);
    border: 1px solid rgba(146, 180, 208, 0.28);
    border-radius: 7px;
    white-space: nowrap;
    transform: translate(-50%, -100%);
    display: none;
}

.player-name-tag.visible {
    display: block;
}

@media (max-width: 860px) {
    #health-container,
    #weapon-info {
        transform: scale(0.9);
        transform-origin: bottom;
    }

    #cash-display {
        font-size: 28px;
    }

    .lobby-button {
        min-width: 210px;
    }

    #shop-menu {
        width: min(95vw, 520px);
        padding: 20px;
    }
}

@media (max-width: 620px) {
    .map-select-grid {
        grid-template-columns: 1fr;
    }

    #shop-menu {
        grid-template-columns: 1fr;
    }

    .menu-panel {
        padding: 16px 14px;
    }

    .menu-logo {
        width: min(62%, 220px);
    }

    #start-screen p {
        font-size: 17px;
    }

    .auth-tabs,
    .user-panel {
        grid-template-columns: 1fr;
    }

    .user-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .mini-button {
        width: 100%;
    }

    #controls-info {
        font-size: 13px;
        grid-template-columns: repeat(2, minmax(130px, 1fr));
        gap: 8px 12px;
        text-align: left;
    }

    .shop-item {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "main price"
            "buy buy";
    }

    .shop-buy-btn {
        grid-column: 1 / span 2;
        width: 100%;
        justify-self: stretch;
    }

    #join-input-container {
        flex-direction: column;
        width: 100%;
    }

    #room-code-input {
        width: 100%;
        max-width: 220px;
    }

    #connect-button {
        width: 100%;
        max-width: 220px;
    }

    .scoreboard-row {
        grid-template-columns: 1fr 56px 64px;
        font-size: 16px;
    }
}
