:root {
  --neon-cyan: #0ff;
  --neon-pink: #f0f;
  --bg-dark: #000a17;
  --glass-dark: rgba(0,15,40,0.9);
  --glass-light: rgba(138,211,171,0.2);
  --font-main: 'Orbitron', sans-serif;
  --hud-height: 2.5rem;
  --control-size: 3rem;
}

/* ======== BASE & UTILITIES ======== */
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--neon-cyan);
  font-family: var(--font-main);
  font-size: 16px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* Safe area insets */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
/* Loader styles */
        .loader-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
            background: rgba(0, 0, 0, 0.5);
            z-index: 10009;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .loader-overlay.hidden {
            display: none;
        }
.loader-overlay lottie-player {
  width: 100vw;
  height: 100vh;
  max-width: 550px;
  max-height: 550px;
 pointer-events: none;
}
@media (max-width: 600px) {
  .loader-overlay lottie-player {
    width: 150px;
    height: 150px;
  }
}
.toggle-cmd-btn {
    position:fixed;
    bottom: 80px;
    right: 24px;
    width: 44px;
    height: 44px;
    font-size: 20px;
    background: #000;
    color: #0ff;
    border-radius: 50%;
    border: 2px solid #0ff;
    z-index: 1001;
    cursor: pointer;
  }

  .command-bar {
    position: fixed;
    bottom: 25px; /* space above toggle */
    right: 23px;
    display: flex;
    align-items: center;
    border-radius: 30px;
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 12px;
    box-shadow: 0 0 8px #0ff;
    z-index: 1000;
    transition: opacity 0.3s ease;
  }

  .command-bar.hidden {
    display: none;
  }

  .command-bar input {
    border: none;
    outline: none;
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 30px;
    background: #111;
    color: #0ff;
    width: 180px;
  }

  .icon-btn {
    background: transparent;
    border: none;
    color: #0ff;
    font-size: 18px;
    padding: 6px;
    margin-left: 6px;
    cursor: pointer;
  }
/* ======== TOP BAR ======== */
#topBar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  z-index: 300;
  background: var(--glass-dark);
  backdrop-filter: blur(4px);
  border-bottom: 1px solid var(--neon-cyan);
}

.btn-icon {
  background: rgba(54, 104, 189, 0.7);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-family: var(--font-main);
  box-shadow: 0 0 8px var(--neon-cyan);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon:active {
  transform: scale(0.95);
  box-shadow: 0 0 12px var(--neon-cyan);
}


/* ======== GAME CANVAS ======== */
.game-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ✅ Canvas Mobile Touch Enhancements */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  touch-action: manipulation;
  pointer-events: auto;
  -webkit-tap-highlight-color: rgba(0,0,0,0); /* No tap flash */
}

/* ✅ Visual feedback ripple */
@keyframes tapPulse {
  0% {
    transform: scale(0.5);
    opacity: 0.7;
  }
  100% {
    transform: scale(2);
    opacity: 0;
  }
}

/* ✅ Prevent accidental text selection */
body {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}


/* ======== HUD ======== */
#hud {
  position: fixed;
  top: var(--hud-height);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1rem;
  background: var(--glass-dark);
  padding: 0.5rem 1rem;
  border: 1px solid var(--neon-cyan);
  border-radius: 0.5rem;
  box-shadow: 0 0 8px var(--neon-cyan);
  z-index: 400;
  backdrop-filter: blur(2px);
}

#hud span {
  font-size: 0.9rem;
  white-space: nowrap;
}

#btnNextMission {
  background: none;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

#btnNextMission:active {
  background: rgba(0,255,255,0.2);
}

/* ======== SLIDE OVERLAY ======== */
.canvas-slide-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 150;
}

.slide-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  max-height: 45vh;
  padding: 1rem;
  background: var(--glass-dark);
  border: 1px solid var(--neon-cyan);
  border-radius: 0.5rem;
  box-shadow: 0 0 20px var(--neon-cyan);
  overflow-y: auto;
  pointer-events: auto;
  backdrop-filter: blur(4px);
}

.slide-text {
  color: white;
  font-size: 0.95rem;
  line-height: 1.4;
}

.slide-controls {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.slide-controls button {
  background: none;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
}

.btn-slide-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--neon-cyan);
  font-size: 1.25rem;
  cursor: pointer;
}
.blinking-cursor {
    animation: blink 1s step-start 0s infinite;
  }
  @keyframes blink {
    50% { opacity: 0; }
  }
/* ======== MOBILE CONTROLS ======== */
.mobile-controls {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 250;
}
.control-pad,
.action-pad {
  pointer-events: auto;
}
.control-pad {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  width: 100px;
  height: 100px;
  background: rgba(0,10,23,0.6);
  border: 2px solid #0ff;
  border-radius: 50%;
  display: grid;
  grid-template-areas:
    ". up ."
    "left center right"
    ". down .";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  justify-items: center;
  align-items: center;
  touch-action: none;
  z-index: 250;
}
#padUp { grid-area: up; }
#padLeft { grid-area: left; }
#padRight { grid-area: right; }
#padDown { grid-area: down; }
#btnJump {
  grid-area: center;
  background: rgba(0,0,0,0.6);
  border: 1px solid #0ff;
  color: #0ff;
  font-size: 1rem;
  padding: 0.5rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
}
#btnJump:active {
  background: rgba(0,255,255,0.2);
  transform: scale(0.95);
}
.action-pad {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 250;
}
.action-pad button {
  background: rgba(0,0,0,0.6);
  border: 1px solid #0ff;
  color: #0ff;
  font-size: 1.2rem;
  padding: 0.5rem;
  border-radius: 50%;
}
.action-pad button:active {
 transform: scale(0.8);
  background: rgba(0, 255, 255, 0.3) !important;
  transition: all 0.1s;
}
.control-pad button.pressed,
.action-pad button.pressed {
  background: rgba(0,255,255,0.3) !important;
  box-shadow: 0 0 8px #0ff !important;
  transform: scale(0.95) !important;
}

/* ======== CHAT PANEL ======== */
 #chatPanel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 5rem;
  width: 100%;
  max-width: 100vw;
  background: var(--glass-dark);
  border-top: 1px solid var(--neon-cyan);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  z-index: 350;
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 0 1rem;
}

#chatPanel.expanded {
  transform: translateY(0);
}
#panelMessages {
  display: none !important;
}

#panelMessages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  max-height: 30vh;
  background: rgba(0, 0, 0, 0.3);
}

/* Two-row input layout */
#panelInputWrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 0;
  justify-content: space-between;
  box-sizing: border-box;
}

/* Top row â€” Input field full width */
#chatInputPanel {
  width: 100%;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--neon-cyan);
  color: white;
  border-radius: 0.25rem;
  font-size: 1rem;
  box-sizing: border-box;
}

/* Second row â€” Buttons and dropdown */
#panelInputWrapper select,
#micBtnPanel,
#sendBtnPanel {
  flex: 1;
  min-width: 30%;
  padding: 0.5rem;
  box-sizing: border-box;
  border-radius: 0.25rem;
  font-weight: bold;
}

/* Dropdown and Mic button style */
#panelInputWrapper select,
#micBtnPanel {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
}

/* Send button style */
#sendBtnPanel {
  background: var(--neon-cyan);
  color: black;
  border: none;
  cursor: pointer;
}

/* Hide Inbox Drawerâ€™s input (for compatibility) */
#inputDrawer {
  display: none !important;
}

.sub-header {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
   background: var(--glass-dark);
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid var(--neon-cyan);
  padding: 0.5rem 1rem;
  font-family: 'Orbitron', sans-serif;
  color: var(--neon-cyan);
  z-index: 250;
  position: relative;
  top: 3.2rem; 
  left: 0;
  right: 0;
}
.hud-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  flex: 1;
   width: 100%;
}

.hud-group span {
  margin-right: 1rem;
}

.hud-group button {
  background: var(--neon-cyan);
  color: black;
  border: none;
  border-radius: 0.25rem;
  padding: 0.4rem 0.8rem;
  font-weight: bold;
  cursor: pointer;
}

.sub-tools {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 0;
  width: 100%;
}
.hud-group span,
.sub-tools label {
  white-space: nowrap;
  font-size: 0.9rem;
}
.sub-tools button,
.sub-tools label {
  color: var(--neon-cyan);
  font-size: 0.9rem;
}
@media screen and (max-width: 768px) {
  .hud-group {
    flex-direction: row;
    align-items: center;
  }

  .sub-tools {
    flex-direction: row;
    justify-content: flex-start;
  }

  .change-role-btn {
    margin-top: 0;
  }
}
.change-role-btn {
   position: static;
   right: auto;
   top: auto;
    margin-left: auto;
  background: transparent;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 0.4rem 0.8rem;
  border-radius: 0.25rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}
/* ðŸ”§ Toggle button (shown only on small screens) */
.top-hud-btn {
  display: none;
  font-size: 1.2rem;
  background: var(--glass-dark);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 0.4rem 0.6rem;
  border-radius: 0.4rem;
  margin-left: auto;
  margin-right: 0.5rem;
}

@media (max-width: 800px) {
  .top-hud-btn {
    display: inline-block;
  }

  .sub-header {
    display: none;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.7);
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .sub-header.active {
    display: flex;
  }

  .sub-header .hud-group,
  .sub-header .sub-tools {
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
  }

  #chooseRoleBtn {
    align-self: stretch;
    text-align: center;
  }
}

/* ======== CHAT DRAWER ======== */
#chatDrawer {
  position: fixed;
  top: 0;
  left: -100%;
  width: 85%;
  height: 100%;
  background: var(--glass-dark);
  border-right: 1px solid var(--neon-cyan);
  transition: left 0.3s ease;
  z-index: 400;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

#chatDrawer.open {
  left: 0;
}

.drawer-header {
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--neon-cyan);
}

.drawer-header h2 {
  color: var(--neon-cyan);
  margin: 0;
  font-size: 1.2rem;
}

.drawer-header button {
  background: none;
  border: none;
  color: var(--neon-cyan);
  font-size: 1.5rem;
  cursor: pointer;
}

#drawerMessages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background: rgba(0,0,0,0.3);
}

.drawer-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--neon-cyan);
  background: rgba(0,0,0,0.3);
}

#drawerInput {
  flex: 1;
  padding: 0.5rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--neon-cyan);
  color: white;
  border-radius: 0.25rem;
}

.drawer-input select,
#btnMicDrawer {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  padding: 0.5rem;
  border-radius: 0.25rem;
}

#btnSendDrawer {
  background: var(--neon-cyan);
  color: black;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.25rem;
  font-weight: bold;
  cursor: pointer;
}

/* ======== ROLE MODAL ======== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--glass-dark);
  padding: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--neon-cyan);
  max-width: 90%;
  text-align: center;
}

.modal-content h2 {
  color: var(--neon-cyan);
  margin-top: 0;
}

.role-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}
.change-role-btn {
  position: relative;
  top: 12px;
  right: 120px;
  padding: 6px 12px;
  font-size: 14px;
  border: none;
  border-radius: 6px;
  background: #2063a25d;
  color: #fff;
  z-index: 9998;
}

.role-options button {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--neon-cyan);
  color: white;
  padding: 0.75rem;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.role-options button:active {
  background: rgba(0,255,255,0.2);
}

/* ======== RESPONSIVE ADJUSTMENTS ======== */
@media (orientation: landscape) {
  #hud {
    top: 0.5rem;
    left: 0.5rem;
    right: auto;
    transform: none;
    flex-direction: column;
    align-items: flex-start;
  }

  .mobile-controls {
    bottom: 0.5rem;
  }

  .control-pad {
    width: calc(var(--control-size) * 2);
    height: calc(var(--control-size) * 2);
  }

  #btnAction {
    width: calc(var(--control-size) * 0.9);
    height: calc(var(--control-size) * 0.9);
  }

  #chatPanel.expanded {
    width: 40%;
    left: auto;
    right: 0;
  }

  #chatDrawer {
    width: 40%;
  }
}

@media (max-width: 480px) {
  :root {
    --control-size: 2.5rem;
    --hud-height: 2.2rem;
  }

  .btn-icon {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }

  #hud {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .slide-overlay {
    max-height: 40vh;
  }
}