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

body {
    overflow: hidden;
    background: #000;
    font-family: 'Rajdhani', 'Share Tech Mono', monospace;
    color: #00e5ff;
    cursor: crosshair;
}

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    touch-action: none;
    -ms-touch-action: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

.overlay > * {
    pointer-events: auto;
}

/* ========== MAIN MENU ========== */
#menu {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 5, 15, 0.85);
    pointer-events: auto;
    z-index: 100;
}

.menu-container {
    text-align: center;
    padding: 50px;
    border: 1px solid rgba(0, 229, 255, 0.3);
    background: rgba(0, 20, 30, 0.6);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.1), inset 0 0 40px rgba(0, 229, 255, 0.05);
}

.menu-columns {
    display: flex;
    gap: 50px;
    align-items: flex-start;
}

.menu-left {
    flex: 0 0 auto;
    text-align: center;
}

.menu-right {
    flex: 0 0 auto;
    text-align: left;
    border-left: 1px solid rgba(0, 229, 255, 0.1);
    padding-left: 50px;
}

.controls-section {
    margin-bottom: 15px;
}

.controls-heading {
    font-size: 10px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.3);
    margin-bottom: 6px;
}

@media (max-width: 800px) {
    .menu-columns { flex-direction: column; gap: 25px; }
    .menu-right { border-left: none; padding-left: 0; border-top: 1px solid rgba(0, 229, 255, 0.1); padding-top: 25px; }
}

.title {
    font-family: 'Rajdhani', sans-serif;
    font-size: 72px;
    font-weight: 700;
    letter-spacing: 20px;
    color: #00e5ff;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.5), 0 0 40px rgba(0, 229, 255, 0.3);
    margin-bottom: 5px;
}

.subtitle {
    font-size: 18px;
    letter-spacing: 15px;
    color: rgba(0, 229, 255, 0.5);
    margin-bottom: 50px;
}

.menu-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.menu-form label {
    font-size: 14px;
    letter-spacing: 5px;
    color: rgba(0, 229, 255, 0.6);
}

.menu-form input {
    width: 300px;
    padding: 12px 20px;
    background: rgba(0, 20, 30, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #00e5ff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 18px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

.menu-form input:focus {
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.menu-form input::placeholder {
    color: rgba(0, 229, 255, 0.3);
}

.btn-primary {
    width: 300px;
    padding: 15px;
    background: transparent;
    border: 1px solid #00e5ff;
    color: #00e5ff;
    font-family: 'Rajdhani', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-primary:hover {
    background: rgba(0, 229, 255, 0.15);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.btn-primary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.status {
    margin-top: 20px;
    font-size: 12px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.4);
}

.status.connected {
    color: #00ff88;
}

.status.error {
    color: #ff3366;
}

/* ========== HUD ========== */
/* Center reticle — shows ship forward direction */
#center-reticle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.reticle-circle {
    width: 12px;
    height: 12px;
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 50%;
}

/* Crosshair — follows mouse, where you aim/shoot */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    pointer-events: none;
}

/* Damage direction indicators */
#damage-indicators {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

.dmg-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 80px;
    height: 4px;
    transform-origin: center;
    pointer-events: none;
}

.dmg-indicator-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #ff2233, transparent);
    opacity: 0.8;
    animation: dmgFade 1s ease-out forwards;
}

@keyframes dmgFade {
    0% { opacity: 0.9; }
    100% { opacity: 0; }
}

.cross-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #00e5ff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 6px #00e5ff;
}

.cross-h, .cross-v {
    position: absolute;
    background: rgba(0, 229, 255, 0.8);
}

.cross-h {
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    transform: translateY(-50%);
}

.cross-v {
    left: 50%;
    top: 0;
    width: 1px;
    height: 100%;
    transform: translateX(-50%);
}

.cross-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 1px solid rgba(0, 229, 255, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Stat bars — centered around the radar */
.stat-bar {
    position: absolute;
    bottom: 40px;
    width: 160px;
}

.stat-bar.left {
    left: calc(50% - 130px);
    transform: translateX(-100%);
    text-align: right;
}

.stat-bar.right {
    left: calc(50% + 130px);
}

.bar-label {
    font-size: 10px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.4);
    margin-bottom: 4px;
}

.bar-track {
    width: 100%;
    height: 3px;
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.15);
    position: relative;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    transition: width 0.15s ease;
}

.bar-fill.shield {
    background: linear-gradient(90deg, rgba(0,229,255,0.2), #00e5ff);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
    width: 100%;
    float: right; /* fills from right for shield */
}

.bar-fill.hull {
    background: linear-gradient(90deg, #ff3366, rgba(255,51,102,0.2));
    box-shadow: 0 0 8px rgba(255, 51, 102, 0.5);
    width: 100%;
}

.bar-value {
    font-size: 13px;
    margin-top: 3px;
    font-family: 'Share Tech Mono', monospace;
}

/* Speed */
#speed-indicator {
    position: absolute;
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
}

.speed-label {
    font-size: 10px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.4);
}

.speed-value {
    font-size: 24px;
    font-family: 'Share Tech Mono', monospace;
}

/* Top bar */
#top-bar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
}

#round-timer {
    font-size: 28px;
    font-family: 'Share Tech Mono', monospace;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

#score-display {
    font-size: 16px;
    color: rgba(0, 229, 255, 0.6);
    margin-top: 5px;
}

/* Kill feed */
#kill-feed {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 300px;
    text-align: right;
}

.kill-entry {
    font-size: 13px;
    padding: 4px 8px;
    margin-bottom: 3px;
    background: rgba(0, 20, 30, 0.6);
    border-right: 2px solid #ff3366;
    animation: fadeIn 0.3s ease;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.kill-entry .killer {
    color: #00e5ff;
}

.kill-entry .victim {
    color: #ff3366;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Scoreboard */
#scoreboard {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 10, 20, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.3);
    padding: 30px;
    min-width: 400px;
}

.scoreboard-title {
    font-size: 20px;
    letter-spacing: 5px;
    text-align: center;
    margin-bottom: 20px;
    color: #00e5ff;
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.scoreboard-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: 14px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.1);
}

.scoreboard-row.header {
    color: rgba(0, 229, 255, 0.5);
    font-size: 11px;
    letter-spacing: 2px;
}

.scoreboard-row.self {
    background: rgba(0, 229, 255, 0.1);
}

/* Death screen */
#death-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.death-text {
    font-size: 48px;
    font-weight: 700;
    color: #ff3366;
    text-shadow: 0 0 30px rgba(255, 51, 102, 0.5);
    letter-spacing: 10px;
}

.respawn-timer {
    font-size: 16px;
    color: rgba(255, 51, 102, 0.7);
    margin-top: 15px;
}

/* Weapon bar — sci-fi tech style */
#weapon-bar {
    position: absolute;
    bottom: 30px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.weapon-slot {
    padding: 5px 12px;
    background: rgba(0, 12, 20, 0.7);
    border-left: 2px solid rgba(0, 229, 255, 0.15);
    border-top: none; border-right: none; border-bottom: none;
    text-align: left;
    font-size: 11px;
    letter-spacing: 1px;
    opacity: 0.4;
    transition: all 0.2s;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
}

.weapon-slot::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 0%;
    background: rgba(0, 229, 255, 0.05);
    transition: width 0.3s;
}

.weapon-slot.active {
    opacity: 1;
    border-left-color: #00e5ff;
    background: rgba(0, 20, 35, 0.8);
}

.weapon-slot.active::before {
    width: 100%;
}

.weapon-key {
    font-size: 10px;
    color: rgba(0, 229, 255, 0.3);
    font-family: 'Share Tech Mono', monospace;
    width: 14px;
}

.weapon-name {
    font-weight: 600;
    color: #00e5ff;
    font-size: 12px;
    flex: 1;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.weapon-ammo {
    font-family: 'Share Tech Mono', monospace;
    font-size: 14px;
    color: rgba(0, 229, 255, 0.6);
    min-width: 24px;
    text-align: right;
}

.weapon-slot[data-weapon="1"] .weapon-name { color: #ff7744; }
.weapon-slot[data-weapon="1"].active { border-left-color: #ff6633; }
.weapon-slot[data-weapon="1"].active::before { background: rgba(255, 102, 51, 0.05); }
.weapon-slot[data-weapon="2"] .weapon-name { color: #9999ff; }
.weapon-slot[data-weapon="2"].active { border-left-color: #8888ff; }
.weapon-slot[data-weapon="2"].active::before { background: rgba(136, 136, 255, 0.05); }

/* Rotate device prompt */
#rotate-prompt {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 5, 15, 0.95);
    z-index: 200;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rotate-icon {
    font-size: 72px;
    color: #00e5ff;
    animation: rotateHint 2s ease-in-out infinite;
    margin-bottom: 20px;
}

@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(90deg); }
}

.rotate-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 18px;
    letter-spacing: 5px;
    color: rgba(0, 229, 255, 0.7);
}

@media (max-width: 1024px) and (orientation: portrait) and (pointer: coarse) {
    #rotate-prompt { display: flex; }
}

@media (pointer: coarse) {
    .controls-help { display: none !important; }
    .menu-columns { flex-direction: column; gap: 15px; }
    .menu-right { display: none !important; }
    .title { font-size: 42px; letter-spacing: 10px; }
    .subtitle { font-size: 14px; letter-spacing: 8px; }
    .menu-container { padding: 30px; }
    .menu-form input, .btn-primary, .btn-secondary { width: 250px; }
    .menu-form label { margin-bottom: 0; }
    .menu-form { gap: 8px; }
    .title { margin-bottom: 0; }
    .subtitle { margin-bottom: 20px; }
    #btn-fullscreen { display: block !important; margin: 5px auto 0; }
    #menu { overflow-y: auto; }
}

/* Controls help on menu */
.controls-help {
    margin-top: 30px;
    text-align: left;
}

.controls-title {
    font-size: 12px;
    letter-spacing: 4px;
    color: rgba(0, 229, 255, 0.4);
    margin-bottom: 10px;
    text-align: center;
}

.controls-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 15px;
    font-size: 12px;
}

.controls-grid span:nth-child(odd) {
    color: #00e5ff;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    text-align: right;
}

.controls-grid span:nth-child(even) {
    color: rgba(200, 210, 220, 0.5);
}

/* Quality selector */
.quality-selector {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.quality-label {
    font-size: 11px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.4);
    margin-right: 5px;
}

.quality-btn {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.2);
    color: rgba(0, 229, 255, 0.5);
    font-family: 'Rajdhani', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.quality-btn:hover { border-color: rgba(0, 229, 255, 0.5); }
.quality-btn.active {
    border-color: #00e5ff;
    color: #00e5ff;
    background: rgba(0, 229, 255, 0.1);
}

/* Fullscreen button */
.btn-secondary {
    width: 300px;
    padding: 10px;
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: rgba(0, 229, 255, 0.6);
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 5px;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
}

.btn-secondary:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.5);
}

/* Chat */
#chat {
    position: absolute;
    bottom: 140px;
    left: 20px;
    width: 350px;
}

#chat-messages {
    max-height: 150px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.chat-msg {
    font-size: 12px;
    padding: 2px 0;
    opacity: 1;
    transition: opacity 0.5s;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.8);
}

.chat-msg .chat-name {
    color: #00e5ff;
    font-weight: 600;
}

.chat-msg .chat-text {
    color: rgba(220, 230, 240, 0.9);
}

#chat-input {
    width: 100%;
    padding: 6px 10px;
    background: rgba(0, 10, 20, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #dde6f0;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    outline: none;
    margin-top: 4px;
}

#chat-input:focus {
    border-color: #00e5ff;
}

/* Enemy targeting brackets */
.tgt-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.tgt-brackets {
    width: 100%;
    height: 100%;
}

.tgt-brackets line {
    stroke: #ff3344;
    stroke-width: 2.5;
    stroke-dasharray: 6 3;
    stroke-linecap: square;
}

.tgt-name {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Rajdhani', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #ff3344;
    white-space: nowrap;
    text-shadow: 0 0 4px rgba(255, 51, 68, 0.5);
    letter-spacing: 1px;
}

.tgt-dist {
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Share Tech Mono', monospace;
    font-size: 10px;
    color: #ff3344;
    white-space: nowrap;
    text-shadow: 0 0 4px rgba(255, 51, 68, 0.5);
}

/* Leaderboard — persistent top 3 */
#leaderboard {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 180px;
}

.lb-title {
    font-size: 10px;
    letter-spacing: 3px;
    color: rgba(0, 229, 255, 0.4);
    margin-bottom: 8px;
}

.lb-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    margin-bottom: 3px;
    background: rgba(0, 20, 30, 0.5);
    border-left: 2px solid rgba(0, 229, 255, 0.3);
    font-size: 12px;
}

.lb-entry.gold { border-left-color: #ffcc00; }
.lb-entry.silver { border-left-color: #aabbcc; }
.lb-entry.bronze { border-left-color: #cc7733; }
.lb-entry.self { background: rgba(0, 229, 255, 0.08); }

.lb-rank {
    color: rgba(0, 229, 255, 0.4);
    font-size: 10px;
    width: 16px;
}

.lb-name {
    flex: 1;
    margin: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-kills {
    font-family: 'Share Tech Mono', monospace;
    color: #00e5ff;
}

/* Round end screen */
#round-end {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    background: rgba(0, 5, 15, 0.9);
    border: 1px solid rgba(0, 229, 255, 0.3);
    padding: 40px 60px;
    min-width: 450px;
}

.round-end-title {
    font-size: 36px;
    font-weight: 700;
    letter-spacing: 8px;
    color: #00e5ff;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
    margin-bottom: 5px;
}

.round-end-subtitle {
    font-size: 14px;
    letter-spacing: 5px;
    color: rgba(0, 229, 255, 0.4);
    margin-bottom: 25px;
}

.round-end-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 15px;
    margin-bottom: 3px;
    font-size: 15px;
    border-left: 3px solid transparent;
}

.round-end-row.rank-1 { border-left-color: #ffcc00; background: rgba(255, 204, 0, 0.05); }
.round-end-row.rank-2 { border-left-color: #aabbcc; background: rgba(170, 187, 204, 0.03); }
.round-end-row.rank-3 { border-left-color: #cc7733; background: rgba(204, 119, 51, 0.03); }
.round-end-row.self { background: rgba(0, 229, 255, 0.08); }

.round-end-row .rank { color: rgba(0, 229, 255, 0.4); width: 30px; }
.round-end-row .name { flex: 1; text-align: left; margin: 0 15px; color: #dde6f0; }
.round-end-row .kd { font-family: 'Share Tech Mono', monospace; color: #00e5ff; }

.round-end-timer {
    margin-top: 25px;
    font-size: 16px;
    color: rgba(0, 229, 255, 0.6);
    letter-spacing: 2px;
}

/* Debug info — hidden by default, shown with backtick */
#debug-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 11px;
    font-family: 'Share Tech Mono', monospace;
    color: rgba(0, 229, 255, 0.3);
    text-align: right;
    line-height: 1.6;
    display: none;
}

/* Hit direction indicators */
.hit-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60px;
    height: 4px;
    background: rgba(255, 51, 102, 0.8);
    transform-origin: center;
    pointer-events: none;
    animation: hitFade 0.5s ease forwards;
}

@keyframes hitFade {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Screen shake class */
.screen-shake {
    animation: shake 0.2s ease;
}

@keyframes shake {
    0%, 100% { transform: translate(0); }
    25% { transform: translate(-3px, 2px); }
    50% { transform: translate(3px, -2px); }
    75% { transform: translate(-2px, -3px); }
}
