@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@500;700&display=swap');

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

body {
    background: #06070a;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Rajdhani', sans-serif;
    color: #e2e8f0;
    overflow: hidden;
    background-image: 
        radial-gradient(at 0% 0%, rgba(33, 150, 243, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(244, 67, 54, 0.05) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(15, 23, 42, 0.95) 0px, transparent 70%);
}

#game-container {
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 15px;
}

#game-container:fullscreen,
#game-container:-webkit-full-screen,
#game-container.is-fullscreen {
    max-width: 100% !important;
    width: 100% !important;
    height: 100% !important;
    padding: 10px !important;
    background: #06070a;
}

#fullscreenBtn {
    padding: 6px 14px;
    font-size: 11px;
    letter-spacing: 1px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.4);
    color: #38bdf8;
    border-radius: 6px;
    cursor: pointer;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#fullscreenBtn:hover {
    background: rgba(33, 150, 243, 0.35);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
    transform: translateY(-1px);
}

#fullscreenBtn.active {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    color: #fbbf24;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* Glassmorphism Header */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(15, 20, 30, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hub-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(33, 150, 243, 0.15);
    border: 1px solid rgba(33, 150, 243, 0.5);
    border-radius: 6px;
    color: #64b5f6;
    text-decoration: none;
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    transition: all 0.2s ease;
}

.hub-btn:hover {
    background: rgba(33, 150, 243, 0.4);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(33, 150, 243, 0.5);
    transform: translateY(-1px);
}

#title {
    font-family: 'Orbitron', monospace;
    font-size: 26px;
    font-weight: 900;
    letter-spacing: 5px;
    background: linear-gradient(90deg, #2196F3, #64B5F6, #00E5FF);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(33, 150, 243, 0.3);
}

#title small { font-size: 10px; color: #f59e0b; -webkit-text-fill-color: #f59e0b; letter-spacing: 2px; vertical-align: top; }

.launch-screen { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 25%, rgba(30,80,120,.38), transparent 38%), rgba(3,8,14,.96); backdrop-filter: blur(12px); }
.launch-screen[hidden], [hidden] { display: none !important; }
.launch-panel { width: min(680px, 94vw); padding: 38px; border: 1px solid rgba(56,189,248,.3); border-radius: 18px; background: linear-gradient(145deg, rgba(15,28,43,.98), rgba(6,12,20,.98)); box-shadow: 0 30px 100px #000, inset 0 1px rgba(255,255,255,.06); text-align: center; }
.launch-panel h2 { margin: 8px 0 6px; font: 900 28px/1.2 'Orbitron', monospace; letter-spacing: 3px; }
.launch-panel p { color: #94a3b8; }
.launch-panel a { color: #38bdf8; }
.launch-kicker { color: #38bdf8; font: 700 11px 'Orbitron', monospace; letter-spacing: 4px; }
.launch-top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.launch-home-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.15); border-radius: 6px; color: #94a3b8; font: 700 11px 'Orbitron', monospace; letter-spacing: 1px; text-decoration: none; transition: all .2s ease; cursor: pointer; }
.launch-home-btn:hover { background: rgba(56,189,248,.15); border-color: #38bdf8; color: #fff; box-shadow: 0 0 12px rgba(56,189,248,.25); }
.online-bottom-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.07); }
.launch-exit-btn-link { display: inline-flex; align-items: center; gap: 6px; color: #94a3b8; font: 700 12px 'Rajdhani', sans-serif; letter-spacing: 0.5px; text-decoration: none; transition: all .2s ease; cursor: pointer; }
.launch-exit-btn-link:hover { color: #38bdf8; text-decoration: underline; }
.launch-error { min-height: 22px; margin: 10px 0; color: #fca5a5; font-weight: 700; }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 22px; }
.mode-card { min-height: 150px; padding: 24px; border: 1px solid rgba(255,255,255,.12); border-radius: 12px; background: rgba(255,255,255,.035); color: #e2e8f0; cursor: pointer; transition: .2s ease; }
.mode-card:hover { transform: translateY(-3px); border-color: #38bdf8; background: rgba(56,189,248,.1); box-shadow: 0 10px 30px rgba(14,165,233,.15); }
.mode-card strong { display: block; margin-bottom: 12px; color: #fff; font: 800 16px 'Orbitron', monospace; }
.mode-card span { color: #94a3b8; font: 600 15px 'Rajdhani', sans-serif; }
.online-options { display: grid; gap: 16px; margin-top: 20px; text-align: left; }
.online-options label { display: grid; gap: 6px; color: #94a3b8; font-weight: 700; }
.online-options select, .join-row input { width: 100%; padding: 12px; border: 1px solid rgba(255,255,255,.15); border-radius: 7px; background: #0b1320; color: #fff; font: 700 14px 'Rajdhani', sans-serif; }
.online-actions, .join-row { display: flex; gap: 10px; }
.online-actions > *, .join-row input { flex: 1; }
.text-btn { justify-self: center; border: 0; background: none; color: #94a3b8; cursor: pointer; }
.room-code { margin: 12px 0; color: #fbbf24; font: 900 44px 'Orbitron', monospace; letter-spacing: 9px; }
.room-players { display: grid; gap: 8px; margin: 20px 0; }
.room-players div { display: flex; justify-content: space-between; padding: 12px 15px; border: 1px solid rgba(255,255,255,.08); border-radius: 7px; background: rgba(255,255,255,.035); }
.room-players strong { color: #10b981; font: 700 11px 'Orbitron', monospace; }
.ready-btn { width: 100%; }
.room-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.cancel-btn {
  width: 100%;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  cursor: pointer;
  padding: 12px;
  border-radius: 7px;
  font: 700 13px 'Orbitron', monospace;
  letter-spacing: 1px;
  transition: all 0.2s ease;
}
.cancel-btn:hover {
  background: rgba(239, 68, 68, 0.35);
  border-color: #ef4444;
  color: #ffffff;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
}
.user-stats-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  background: rgba(33, 150, 243, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 20px;
  font: 700 12px 'Orbitron', monospace;
  color: #38bdf8;
  letter-spacing: 0.5px;
}
.user-stats-pill strong {
  color: #34d399;
}
.player-wins-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 4px;
  color: #fbbf24;
  font: 700 11px 'Orbitron', monospace;
}
.quit-hub-btn {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #fca5a5 !important;
  cursor: pointer;
}
.quit-hub-btn:hover {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4) !important;
}
.network-banner { position: fixed; z-index: 900; top: 6px; left: 50%; transform: translateX(-50%); padding: 5px 14px; border: 1px solid rgba(16,185,129,.35); border-radius: 999px; background: rgba(2,12,18,.9); color: #6ee7b7; font: 700 9px 'Orbitron', monospace; letter-spacing: 1px; pointer-events: none; }

@media (max-width: 620px) { .mode-grid { grid-template-columns: 1fr; } .launch-panel { padding: 24px; } .online-actions { flex-direction: column; } }

#stats {
    display: flex;
    gap: 30px;
    font-size: 18px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    color: #64748b;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
}

.stat-value {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: #f8fafc;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

#level-select {
    display: flex;
    gap: 8px;
}

.level-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
    letter-spacing: 1px;
}

.level-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #f8fafc;
    transform: translateY(-1px);
}

.level-btn.active {
    background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
    border-color: #2196F3;
    color: #fff;
    box-shadow: 0 0 15px rgba(33, 150, 243, 0.4);
}

#game-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    gap: 12px;
    position: relative;
    width: 100%;
}

#canvas-container {
    flex: 1;
    min-width: 0;
    height: 100%;
    position: relative;
    background: #3f6838;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Dedicated Tactical Info Sidebar (Docked Outside Map on the Right) */
#info-panel {
    width: 250px;
    flex-shrink: 0;
    height: 100%;
    background: rgba(15, 20, 30, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.panel-header h3 {
    font-family: 'Orbitron', monospace;
    font-size: 12px;
    font-weight: 900;
    color: #38bdf8;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 0;
}

#base-info {
    display: none;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

#base-info.visible {
    display: flex;
}

.info-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-right: none;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row span:first-child {
    color: #64748b;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0;
}

.info-row span:last-child {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: #f1f5f9;
    font-size: 12px;
    text-align: right;
}

#standby-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 2px;
    color: #64748b;
    gap: 10px;
}

.scanner-icon {
    font-size: 26px;
    color: #38bdf8;
    opacity: 0.6;
    animation: scannerPulse 2.5s infinite ease-in-out;
}

@keyframes scannerPulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 0.95; text-shadow: 0 0 12px rgba(56, 189, 248, 0.6); }
}

.standby-title {
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.standby-desc {
    font-size: 12px;
    line-height: 1.5;
    color: #64748b;
    margin-bottom: 4px;
}

.tactical-tips {
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
    text-align: left;
}

.tip-title {
    font-family: 'Orbitron', monospace;
    font-size: 10px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
    text-align: center;
}

.tip-item {
    font-size: 11px;
    color: #94a3b8;
    padding: 5px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.tip-item:last-child {
    border-bottom: none;
}

.tip-item .key {
    font-family: 'Orbitron', monospace;
    font-size: 9px;
    font-weight: 700;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px solid rgba(56, 189, 248, 0.3);
    white-space: nowrap;
}

/* Glassmorphism Controls */
#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(15, 20, 30, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    margin-top: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.control-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn.primary {
    background: linear-gradient(180deg, #2196F3 0%, #1565c0 100%);
    border-color: #2196F3;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn.primary:hover {
    background: linear-gradient(180deg, #42a5f5 0%, #1e88e5 100%);
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.5);
}

.btn.danger {
    background: linear-gradient(180deg, #f44336 0%, #c62828 100%);
    border-color: #f44336;
    color: #fff;
}

.btn.danger:hover {
    background: linear-gradient(180deg, #ef5350 0%, #d32f2f 100%);
    box-shadow: 0 0 20px rgba(244, 67, 54, 0.5);
}

.btn.active {
    background: linear-gradient(180deg, #4caf50 0%, #2e7d32 100%);
    border-color: #4caf50;
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.4);
}

#mode-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.mode-btn {
    padding: 6px 14px;
    font-size: 11px;
    letter-spacing: 1.5px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94a3b8;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.mode-btn.active#modeMoveBtn {
    background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
    border-color: #38bdf8;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}

.mode-btn.active#modeFrontlineBtn {
    background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
    border-color: #f59e0b;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.45);
}

.btn-stop-fl {
    padding: 2px 8px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid #ef4444;
    color: #fca5a5;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-stop-fl:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #ffffff;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

#speed-controls {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.speed-btn {
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: #64748b;
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 4px;
}

.speed-btn:hover {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.03);
}

.speed-btn.active {
    background: #ff9800;
    color: #06070a;
    box-shadow: 0 0 10px rgba(255, 152, 0, 0.4);
}

/* Beautiful Message Overlay */
#message-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(8, 12, 20, 0.96);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 45px 70px;
    text-align: center;
    display: none;
    z-index: 100;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), inset 0 0 30px rgba(255, 255, 255, 0.02);
}

#message-overlay.visible {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#message-overlay h2 {
    font-family: 'Orbitron', monospace;
    font-size: 38px;
    font-weight: 900;
    margin-bottom: 16px;
    letter-spacing: 6px;
}

#message-overlay.victory h2 {
    color: #4CAF50;
    text-shadow: 0 0 35px rgba(76, 175, 80, 0.5);
    background: linear-gradient(180deg, #81c784 0%, #4caf50 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#message-overlay.defeat h2 {
    color: #F44336;
    text-shadow: 0 0 35px rgba(244, 67, 54, 0.5);
    background: linear-gradient(180deg, #e57373 0%, #f44336 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#message-overlay p {
    color: #94a3b8;
    margin-bottom: 30px;
    font-size: 16px;
    letter-spacing: 1px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

#legend {
    display: flex;
    gap: 20px;
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}

.legend-color.player { 
    background: #2196F3; 
    border: 1px solid #64B5F6;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
}
.legend-color.enemy { 
    background: #F44336; 
    border: 1px solid #EF5350;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.5);
}
.legend-color.neutral { 
    background: #9E9E9E; 
    border: 1px solid #BDBDBD;
    box-shadow: 0 0 8px rgba(158, 158, 158, 0.3);
}
