/* Reusable icon styles */
@import "./icons.css";

body {
  margin: 0;
}

:root {
  /* HUD font customization moved from JS */
  --hud-font-sector: 16px Arial;
  --hud-font-flashfuel: 15px Arial;
  --hud-font-mouse-title: 15px Arial;
  --hud-font-mouse-help: 12px Arial;
  --hud-font-heatbar: 13px Arial;
  --hud-line-spacing: 22;
  --xp-floater-fill: #daa520;
  --xp-floater-stroke: rgba(0, 0, 0, 0.75);
  --panel-bg: rgba(20, 20, 20, 0.94);
  --panel-bg-collapsed: rgba(20, 20, 20, 0.9);
  --panel-border: #3a3a3a;
  --panel-radius: 10px;
  --panel-shadow: 0 4px 14px #000a;
  --panel-header-height: 34px; /* increased from 28px for easier drag target */
  --panel-font: 12px/1.4 system-ui, "Segoe UI", Arial, sans-serif;
  --panel-divider: #2d2d2d;
  --panel-scrollbar-thumb: #4b4b4b;
  --panel-text: #e3e3e3;
  --panel-text-muted: #b3b3b3;
  --panel-text-faint: #8a8a8a;
  --panel-accent: #4da3ff;
  --color-hp: #ff4040;
  --color-shields: #2aa3ff;
  --color-armor: #c28f2c;
  --color-power: #ffa500;
  --tooltip-bg: rgba(20, 20, 30, 0.95);
  --tooltip-border: #888;
  --tooltip-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  --death-overlay-bg: rgba(0, 0, 0, 0.55);

  /* Mobile Safe Area Variables - Define the zones where game content can safely render */
  --mobile-safe-top: 0px; /* Top inset from mobile top bar */
  --mobile-safe-bottom: 0px; /* Bottom inset from mobile drawer */
  --mobile-safe-left: 0px; /* Left inset (future use) */
  --mobile-safe-right: 0px; /* Right inset (future use) */

  /* Computed safe area dimensions */
  --mobile-safe-height: 100vh; /* Available height after top/bottom insets */
  --mobile-safe-width: 100vw; /* Available width after left/right insets */
}

/* Moved from inline JS styling */
#minimapTooltip {
  position: fixed;
  pointer-events: none;
  background: var(--tooltip-bg);
  color: #fff;
  padding: 6px 10px;
  font:
    12px Arial,
    sans-serif;
  border: 1px solid var(--tooltip-border);
  border-radius: 4px;
  z-index: 99999;
  max-width: 240px;
  white-space: nowrap;
  box-shadow: var(--tooltip-shadow);
  user-select: none;
  /* start hidden via visibility/opacity only so transitions can run (avoid display:none) */
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease;
  left: 0;
  top: 0; /* position from origin */
  transform: translate(var(--tip-x, 0), var(--tip-y, 0));
}
#minimapTooltip.visible {
  visibility: visible;
  opacity: 1;
}

#deathOverlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none; /* toggled in JS */
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 32px;
  background: var(--death-overlay-bg);
  z-index: 30;
  flex-direction: column;
  text-align: center;
  padding: 24px 40px;
  border-radius: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}
#deathOverlay.shown {
  display: flex;
  opacity: 1;
}
#deathOverlay::before {
  content: attr(data-msg);
  display: block;
}

/* Generic panel base */
.gh-panel {
  position: absolute;
  display: flex;
  flex-direction: column;
  font: var(--panel-font);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  background: var(--panel-bg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(3px) saturate(1.1);
  overflow: hidden;
  z-index: 1150;
  transition:
    background-color 0.16s ease,
    height 0.18s ease,
    left 0.14s ease,
    top 0.14s ease,
    width 0.24s cubic-bezier(0.4, 0.12, 0.2, 1);
  color: var(--panel-text);
}

/* NEW: Fallback mode indicator - subtle top border when panel is constrained */
.gh-panel[data-fallback="1"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #ff9800 0%, #ff5722 100%);
  opacity: 0.7;
  z-index: 1;
  pointer-events: none;
}

/* NEW: Mobile viewport mode indicators */
.gh-panel[data-viewport-mode="mobile"],
.gh-panel[data-viewport-mode="mobile-small"] {
  border-color: rgba(255, 152, 0, 0.6) !important;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.65),
    0 0 8px rgba(255, 152, 0, 0.25) !important;
}

/* NEW: Mobile strategy specific styles */
.gh-panel[data-mobile-strategy="modal-fullscreen"] {
  /* Fullscreen modal on mobile */
  border-radius: 0 !important;
}

.gh-panel[data-mobile-strategy="hidden"] {
  display: none !important;
}

/* NEW: Fallback reason tooltip (visible on hover in desktop mode) */
.gh-panel[data-fallback="1"][data-fallback-reason]::after {
  content: attr(data-fallback-reason);
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 40, 40, 0.95);
  color: #ff9800;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 10001;
  border: 1px solid rgba(255, 152, 0, 0.5);
}

.gh-panel[data-fallback="1"]:hover::after {
  opacity: 1;
}

.gh-panel.auto-width {
  transition:
    width 0.26s cubic-bezier(0.4, 0.12, 0.2, 1),
    background-color 0.16s ease;
}
.gh-panel.auto-width::after {
  content: "AUTO";
  position: absolute;
  bottom: 2px;
  right: 6px;
  font-size: 9px;
  letter-spacing: 0.8px;
  color: #5cb4ff;
  opacity: 0.55;
  pointer-events: none;
}
.gh-panel.collapsed {
  height: var(--panel-header-height) !important;
  background: var(--panel-bg-collapsed);
}
.gh-panel.dragging {
  cursor: grabbing;
}
.gh-panel.snapped::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid #73d673;
  border-radius: var(--panel-radius);
  pointer-events: none;
  animation: snapFlash 0.6s ease;
}
@keyframes snapFlash {
  0% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
  }
}

.gh-panel-header {
  height: var(--panel-header-height);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #161616;
  padding: 0 10px;
  border-bottom: 1px solid var(--panel-divider);
  user-select: none;
  cursor: grab;
}
.gh-panel.dragging .gh-panel-header {
  cursor: grabbing;
}
.gh-panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.55px;
  color: var(--panel-text);
  text-shadow: 0 1px 1px #000;
}
.gh-panel-collapse {
  margin-left: auto;
  background: #242424;
  color: var(--panel-text);
  border: 1px solid #3d3d3d;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 0 8px;
  width: 26px;
  height: 24px;
  line-height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gh-panel-collapse:hover {
  background: #2f2f2f;
  color: #fff;
  border-color: #4b4b4b;
}

.gh-panel-body {
  flex: 1;
  overflow: auto;
  padding: 10px 14px 12px;
}
.gh-panel-body::-webkit-scrollbar {
  width: 8px;
}
.gh-panel-body::-webkit-scrollbar-thumb {
  background: var(--panel-scrollbar-thumb);
  border-radius: 4px;
}

/* Re: Zero in */
#rezeroPanel {
  --bg: rgba(0, 0, 0, 0.85);
  --border: rgba(255, 255, 255, 0.2);
  --header-height: 50px;
}

#rezeroPanel .gh-panel-body {
  padding: 0;
}

#rezeroPanel .panel-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#rezeroPanel .section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

#rezeroPanel .section:last-child {
  border-bottom: none;
}

#rezeroPanel h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: #fff;
}

#rezeroPanel p {
  margin: 0 0 12px 0;
  color: #e0e0e0;
}

/* Resizer moved back to bottom-right */
.gh-panel-resizer {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, #4d4d4d, #1d1d1d);
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  opacity: 0.75;
  box-shadow: 0 1px 2px #0008 inset;
}
.gh-panel-resizer::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.35) 0 2px,
    rgba(255, 255, 255, 0) 2px 4px
  );
  border-radius: 2px;
  mix-blend-mode: overlay;
  pointer-events: none;
}
.gh-panel.collapsed .gh-panel-resizer {
  display: none;
}
.gh-panel-resizer:hover {
  opacity: 0.95;
}

/* Adjust collapse button vertical alignment slightly for taller header */

/* Tabs */
.gh-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.gh-tabs button {
  background: #232323;
  border: 1px solid #363636;
  color: var(--panel-text-faint);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 0.4px;
}
.gh-tabs button.active {
  background: #2f2f2f;
  color: var(--panel-text);
  border-color: #4a4a4a;
}
.gh-tab-panel {
  display: none;
}
.gh-tab-panel.active {
  display: block;
}

/* Player panel fragments */
.pp-section {
  margin-bottom: 12px;
}
.pp-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  padding: 2px 0;
}
.pp-label {
  color: var(--panel-text-faint);
  margin-right: 8px;
}
.pp-val {
  color: var(--panel-text);
  font-weight: 500;
}
.pp-subtitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.45px;
  color: var(--panel-text-muted);
  margin: 6px 0 4px;
  text-transform: uppercase;
}

.ship-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 4px 10px;
  font-size: 11px;
}
.ship-stats > div {
  display: flex;
  flex-direction: column;
  background: #1e1e1e;
  border: 1px solid #303030;
  padding: 4px 6px;
  border-radius: 6px;
}
.ship-stats label {
  font-size: 10px;
  color: var(--panel-text-faint);
}
.ship-stats span {
  font-size: 11px;
  color: var(--panel-text);
}

/* Meters */
.gh-meter {
  position: relative;
  height: 16px;
  background: #1f1f1f;
  border: 1px solid #3b3b3b;
  border-radius: 5px;
  margin: 6px 0 10px;
  overflow: hidden;
}
.gh-meter-bar {
  position: absolute;
  inset: 0;
  width: calc(var(--pct, 0) * 100%);
  background: var(--meter-color, #666);
  transition: width 0.18s ease;
}
.gh-meter-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.gh-meter--hp {
  --meter-color: var(--color-hp);
}
.gh-meter--shields {
  --meter-color: var(--color-shields);
}
.gh-meter--armor {
  --meter-color: var(--color-armor);
}
.gh-meter--power {
  --meter-color: var(--color-power);
}

/* Chat panel scrollbar */
#chatPanel .log::-webkit-scrollbar {
  width: 8px;
}
#chatPanel .log::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

#gameContainer {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  height: 100vh;
  justify-content: center;
}

.canvasWrapper {
  padding: 32px 0 32px 32px;
  display: flex;
  align-items: flex-start;
  position: relative; /* Add positioning context for forms */
}

/* Canvas wrapper constrained to safe area */
.canvasWrapper {
  padding: 0 !important;
  width: var(
    --mobile-safe-width
  ); /* match safe-area width to avoid horizontal offset */
  height: var(--mobile-safe-height) !important; /* Use CSS safe area */
  margin-top: var(--mobile-safe-top);
  display: flex !important;
  align-items: flex-start !important; /* top-align canvas in safe area */
  justify-content: center !important; /* keep horizontal centering */
  background: #000 !important; /* Black letterbox bars */
  overflow: hidden !important;
  position: relative;
}

#gameCanvas {
  border: 1px solid black;
  display: block;
}

#infoPanel {
  width: 260px;
  background: #222;
  color: #fff;
  padding: 32px 12px 32px 12px;
  box-sizing: border-box;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 600px;
}

#userInfo,
#worldInfo,
#shipInfo,
#equippedInfo {
  border-bottom: 1px solid #444;
  padding-bottom: 8px;
}

h3 {
  margin: 0 0 8px 0;
}

form {
  position: absolute;
  /* Position relative to canvasWrapper */
  /* leftPanel is ~260px, canvas is 800px, so center of canvas is 260px + 400px = 660px from left */
  /* But since we're using left:50% and transform, we need to offset for the leftPanel */
  left: calc(
    50% + 130px
  ); /* 50% of wrapper + half of leftPanel width (260/2) to center on canvas */
  top: 50%; /* Middle vertically */
  transform: translate(-50%, -50%); /* Center the form itself */
  z-index: 10000;
  background: #222;
  padding: 20px;
  border-radius: 8px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  min-width: 280px;
}

/* Registration modal styles */
#registerModal {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #222;
  padding: 24px 18px;
  border-radius: 10px;
  z-index: 20;
  color: #fff;
  min-width: 300px;
}

#registerModal h3 {
  margin-top: 0;
}

#registerModal input,
#registerModal select {
  width: 100%;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #333;
  color: #fff;
}

#registerModal button {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

#registerModal button[type="submit"] {
  background: #4285f4;
  color: #fff;
}

#registerModal button#closeRegisterBtn {
  background: #444;
  color: #fff;
  margin-top: 8px;
}

/* Google login button styles */
#googleLoginBtn {
  background: #4285f4;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#googleLoginBtn:hover {
  background: #357ae8;
}

#logoutBtn {
  background: #c00;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 16px;
}

#logoutBtn:hover {
  background: #a00;
}

/* Popout styles for Equipped Modules */
#equippedInfoPopout {
  display: none;
  position: fixed;
  top: 80px;
  right: 40px;
  width: 300px;
  background: #222;
  color: #fff;
  padding: 24px 18px;
  border-radius: 10px;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#equippedInfoPopout h3 {
  margin: 0 0 16px 0;
}

#equippedInfoPopout button {
  background: #444;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 8px;
}

#equippedInfoPopout button:hover {
  background: #666;
}

/* Shared button styles moved from inline */
.gh-btn {
  padding: 4px 6px;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  background: #333;
  color: #eee;
  border: 1px solid #555;
  border-radius: 4px;
  min-width: 105px;
  max-width: 105px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}
.gh-btn:hover {
  background: #3d3d3d;
}
.gh-btn.gm-on {
  background: #d40000; /* bright red when godmode active */
  color: #fff;
  border-color: #ff5a5a;
}
/* Disabled state */
.gh-btn:disabled,
.gh-btn.disabled {
  opacity: 0.45;
  background: #2a2a2a;
  border-color: #444;
  cursor: not-allowed;
}

/* Click animations */
.gh-btn.btn-click {
  transform: scale(0.94);
  filter: brightness(1.18);
}
.gh-btn.btn-active {
  transform: scale(0.97);
}
/* Mouse Control button active state */
#mouseControlBtn.active {
  background: #4285f4 !important;
  border-color: #357ae8 !important;
  color: #fff !important;
  box-shadow: 0 0 8px rgba(66, 133, 244, 0.3);
}

#mouseControlBtn.active:hover {
  background: #357ae8 !important;
}

/* Left panel buttons (two-column grid layout matching World Information panel exactly) */
#leftActionButtons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, auto); /* Auto-sizing rows to fit content */
  gap: 8px; /* Match horizontal gap to vertical gap */
  margin-bottom: 12px; /* Match World Information panel bottom margin exactly */
  padding: 18px 14px 12px 14px; /* Reduce bottom padding to match visual spacing */
  background: #222; /* Match World Information panel background exactly */
  color: #fff; /* Match World Information panel text color */
  border-radius: 10px; /* Match World Information panel border radius exactly */
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18); /* Match World Information panel shadow exactly */
  min-width: 220px; /* Match World Information panel min-width exactly */
  max-width: 260px; /* Match World Information panel max-width exactly */
  width: 100%; /* Take full available width like World Information panel */
  box-sizing: border-box; /* Include padding in width calculation */
  align-items: start;
  /* Remove any fixed height constraints to let container fit contents */
  height: auto; /* Let container auto-size to content */
  /* Temporary border to visualize the exact boundaries - keeping as requested */
  border: 1px solid rgba(255, 0, 0, 0.3);
}

#leftActionButtons .gh-btn {
  min-width: 110px; /* Make buttons wider to better fill the space */
  max-width: 110px; /* Make buttons wider to better fill the space */
  font-size: 11px;
  padding: 8px 4px; /* Keep button padding compact */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  transition: all 0.15s ease;
  /* Keep the green borders as requested */
  border: 1px solid rgba(0, 255, 0, 0.2) !important;
  /* Ensure buttons auto-size to their content */
  height: auto;
}

#leftActionButtons .gh-btn:hover {
  background: #3d3d3d;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Override hover for active mouse control button */
#leftActionButtons #mouseControlBtn.active:hover {
  background: #357ae8 !important;
}

/* NEW BUTTON ORDER: Mouse Control first, then Godmode buttons */
#mouseControlBtn {
  grid-column: 1;
  grid-row: 1; /* Mouse Control now first */
}

#godmodeBtn {
  grid-column: 1;
  grid-row: 2; /* Godmode second */
}

#jumpHomeBtn {
  grid-column: 1;
  grid-row: 3; /* Jump Home third */
  display: none;
}

#jumpMiddleBtn {
  grid-column: 1;
  grid-row: 4; /* Jump Middle fourth */
  display: none;
}

/* Right column buttons - ALWAYS at top */
#openStoreBtn {
  grid-column: 2;
  grid-row: 1; /* Always row 1 - top of right column */
}

#sectorMapBtn {
  grid-column: 2;
  grid-row: 2; /* Always row 2 - second from top in right column */
}

/* Admin buttons styling when present */
#leftActionButtons #openAdminBtn {
  grid-column: span 2; /* Span both columns */
  grid-row: 5; /* Place below other buttons */
  max-width: 100%;
  margin-top: 8px;
}

/* Ship Information panel buttons - make them match the left panel styling */
#shipInfo .gh-btn,
#openEquipBtn,
#openStorageBtn {
  min-width: 110px !important;
  max-width: 110px !important;
  font-size: 11px !important;
  padding: 8px 4px !important;
  margin: 0 4px 0 0 !important; /* Small right margin between buttons */
  border: 1px solid rgba(0, 255, 0, 0.2) !important; /* Match the green border style */
  transition: all 0.15s ease !important;
}

#shipInfo .gh-btn:hover,
#openEquipBtn:hover,
#openStorageBtn:hover {
  background: #3d3d3d !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

/* Hide the old leftButtons container to prevent conflicts */
#leftButtons {
  display: none !important;
}

/* Equipment & Storage panel styles (migrated to panelBase) */
.equip-header-row,
.storage-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.equip-title,
.storage-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #ddd;
}
.equip-body-wrap {
  overflow: auto;
  max-height: calc(100% - 110px);
  padding-right: 4px;
}
.equip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.equip-table th {
  text-align: left;
  padding: 6px 8px;
  background: #222;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #bbb;
}
.equip-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #2d2d2d;
}
.equip-table tr:nth-child(even) {
  background: #262626;
}
.equip-table tr:hover {
  background: #303030;
}
.equip-empty {
  color: #777;
}
.equip-actions {
  text-align: right;
}
.equip-unequip-btn {
  background: #2e2e2e;
  border: 1px solid #444;
  border-radius: 6px;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.equip-unequip-btn:hover svg {
  stroke: #fff;
}
.equip-footer-hint {
  margin-top: 10px;
  font-size: 11px;
  color: #bbb;
  line-height: 1.4;
}

.storage-meta {
  font-size: 12px;
  margin: 0 0 8px;
  color: #bbb;
}
.storage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  overflow: auto;
  max-height: calc(100% - 120px);
}
.storage-cell {
  position: relative;
  border: 1px solid #555;
  padding: 8px 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #2a2a2a;
  min-width: 170px;
  min-height: 46px;
  font-size: 12px;
}
.storage-cell.empty {
  background: #2a2a2a55;
  color: #777;
  justify-content: center;
}
.storage-badge {
  position: absolute;
  top: 4px;
  right: 6px;
  background: #0009;
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
}
.cell-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cell-actions {
  display: flex;
  gap: 4px;
}

/* Icon button reset (for storage/equipment action icons) reuse existing theming */
button[data-act="jettison"],
button[data-act="equip"],
.equip-unequip-btn {
  line-height: 0;
}

.gh-panel-close {
  background: #242424;
  color: var(--panel-text);
  border: 1px solid #3d3d3d;
  border-radius: 6px;
  width: 26px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: 6px;
  padding: 0;
}
.gh-panel-close:hover {
  background: #2f2f2f;
  color: #fff;
  border-color: #4b4b4b;
}
.gh-panel-close-ic {
  pointer-events: none;
  display: block;
}

/* Auth panel styles */
#authPanel .auth-input {
  width: 100%;
  box-sizing: border-box;
  display: block;
  padding: 10px 9px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1f1f1f;
  color: #eee;
  font-size: 13px;
  outline: none;
}

/* Reset global absolute form positioning inside auth panel */
#authPanel form#authForm {
  position: static;
  left: auto;
  top: auto;
  transform: none;
  background: transparent; /* panel background already present */
  padding: 0;
  box-shadow: none;
  min-width: 0;
  border-radius: 0;
}

#authPanel .auth-input:focus {
  border-color: #5a8dff;
}

#authPanel h2 {
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
}

#authPanel .auth-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
}

#authPanel .auth-form-wrap {
  flex: 1;
  overflow: visible;
  display: flex;
  flex-direction: column;
  align-items: center; /* Center horizontally */
  justify-content: center; /* Center vertically */
  gap: 14px;
}

#authPanel .auth-form-wrap form {
  width: 340px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0; /* ensure no unintended margins */
}

#authPanel .auth-footer-msg {
  min-height: 18px;
  font-size: 12px;
  color: #faa;
  text-align: center;
  flex-shrink: 0; /* Prevent shrinking */
}

#authPanel .auth-actions-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  flex-shrink: 0; /* Prevent shrinking */
}

#authPanel .auth-top-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#authPanel .gh-btn.switch {
  min-width: 90px;
}

#authPanel .auth-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

#authPanel .auth-panel-body-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#authPanel .gh-btn.google-small {
  background: #2e2e2e;
  border: 1px solid #444;
  color: #ddd;
}

#authPanel .gh-btn.google-small:hover {
  background: #383838;
}

#authPanel .gh-btn.google-small svg {
  display: block;
}

#authPanel .gh-btn.google-small:active {
  transform: scale(0.95);
}

#authPanel .inline-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#authPanel .inline-icon svg {
  width: 16px;
  height: 16px;
}

/* NEW: Tablet mode adjustments (768px - 1199px) */
@media (min-width: 768px) and (max-width: 1199px) {
  .gh-panel[data-anchor="right-top"],
  .gh-panel[data-anchor="left-top"] {
    max-width: 240px !important;
  }

  .gh-panel-header {
    font-size: 13px;
    padding: 0 8px;
  }

  .gh-panel-title {
    font-size: 10px;
  }

  .gh-btn {
    font-size: 10px;
    padding: 6px 8px;
    min-width: 90px;
    max-width: 90px;
  }
}

/* NEW: Mobile mode adjustments (480px - 767px) */
@media (max-width: 767px) {
  /* Hide desktop-only panels */
  .desktop-only,
  #leftActionButtons,
  #infoPanel {
    display: none !important;
  }

  /* Canvas wrapper constrained to safe area */
  .canvasWrapper {
    padding: 0 !important;
    width: var(--mobile-safe-width);
    height: var(--mobile-safe-height) !important;
    margin-top: var(--mobile-safe-top);
    display: flex !important;
    align-items: flex-start !important;
    justify-content: center !important;
    background: #000 !important;
    overflow: hidden !important;
    position: relative;
  }

  #gameContainer {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  #gameCanvas {
    max-height: var(--mobile-safe-height);
    max-width: 100%;
    display: block;
    margin: 0 auto;
  }

  /* Fullscreen modals on mobile */
  .gh-panel[data-mobile-strategy="modal-fullscreen"],
  .gh-panel[data-mobile-strategy="auto-modal"] {
    position: fixed !important;
    top: var(--mobile-safe-top) !important;
    left: 0 !important;
    width: 100vw !important;
    height: var(--mobile-safe-height) !important;
    max-width: 100vw !important;
    max-height: var(--mobile-safe-height) !important;
    border-radius: 0 !important;
    z-index: 10000 !important;
  }

  /* ENHANCED: Responsive canvas-overlay panels */
  .gh-panel[data-anchor*="canvas-overlay"] {
    font-size: 11px !important; /* smaller base font in overlays */
  }

  .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-body {
    padding: 6px 8px !important;
    font-size: 11px !important;
  }

  /* ENHANCED: Smaller buttons in canvas-overlay panels */
  .gh-panel[data-anchor*="canvas-overlay"] .gh-btn {
    height: 30px !important; /* override global fixed 34px */
    min-height: 30px !important;
    font-size: 11px !important;
    padding: 6px 10px !important;
    min-width: 86px !important;
    max-width: none;
  }

  /* Panel headers for canvas-overlay */
  .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-header {
    height: 36px !important;
    font-size: 12px !important;
    padding: 0 8px !important;
  }

  .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-title {
    font-size: 11px !important;
    letter-spacing: 0.35px;
  }

  /* Smaller close/collapse buttons for canvas-overlay */
  .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-collapse,
  .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-close {
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
  }

  /* Missions panel specific adjustments */
  .gh-panel[data-anchor*="canvas-overlay"] .mission-card {
    font-size: 12px !important;
    padding: 10px !important;
  }

  .gh-panel[data-anchor*="canvas-overlay"] .mission-name {
    font-size: 13px !important;
  }

  .gh-panel[data-anchor*="canvas-overlay"] .mission-description {
    font-size: 11px !important;
    line-height: 1.3 !important;
  }

  /* Settings panel adjustments */
  .gh-panel[data-anchor*="canvas-overlay"] .audio-section h4 {
    font-size: 12px !important;
  }

  .gh-panel[data-anchor*="canvas-overlay"] .audio-control > label {
    font-size: 11px !important;
  }

  /* Sector map adjustments */
  .gh-panel[data-anchor*="canvas-overlay"] #sectorMapGraphContainer {
    font-size: 11px !important;
  }

  /* Storage/Equipment panels */
  .gh-panel[data-anchor*="canvas-overlay"] .storage-cell,
  .gh-panel[data-anchor*="canvas-overlay"] .equip-table {
    font-size: 12px !important;
  }

  /* Player panel stats */
  .gh-panel[data-anchor*="canvas-overlay"] .pp-row,
  .gh-panel[data-anchor*="canvas-overlay"] .ship-stats {
    font-size: 11px !important;
  }

  /* Enlarge buttons for touch (general mobile buttons, not canvas-overlay) */
  .gh-btn:not(.gh-panel[data-anchor*="canvas-overlay"], .gh-btn) {
    min-height: 44px !important;
    font-size: 14px !important;
    padding: 12px 16px !important;
    min-width: 120px;
    max-width: none;
  }

  /* Panel headers easier to tap (general, not canvas-overlay) */
  .gh-panel-header:not(
    .gh-panel[data-anchor*="canvas-overlay"],
    .gh-panel-header
  ) {
    height: 48px !important;
    font-size: 15px;
    padding: 0 12px;
  }

  .gh-panel-title:not(
    .gh-panel[data-anchor*="canvas-overlay"],
    .gh-panel-title
  ) {
    font-size: 14px;
  }

  /* Larger close/collapse buttons (general, not canvas-overlay) */
  .gh-panel-collapse:not(
    .gh-panel[data-anchor*="canvas-overlay"],
    .gh-panel-collapse
  ),
  .gh-panel-close:not(
    .gh-panel[data-anchor*="canvas-overlay"],
    .gh-panel-close
  ) {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px;
  }
}

/* NEW: Tiny phone adjustments (<480px) */
@media (max-width: 479px) {
  .gh-panel-header {
    height: 44px !important;
    font-size: 14px;
    padding: 0 10px;
  }

  .gh-panel-title {
    font-size: 13px;
  }

  .gh-btn {
    font-size: 13px !important;
    padding: 10px 14px !important;
    min-width: 100px;
  }

  .gh-panel-body {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* NEW: Landscape mobile orientation */
@media (max-width: 767px) and (orientation: landscape) {
  /* Let JS scaler control canvas size; avoid forcing 100vh which can cause overflow */
  #gameCanvas {
    height: auto !important;
    max-height: none !important;
  }
  .canvasWrapper {
    padding: 0 !important;
  }
}

/* NEW: Mobile-only class helpers */
@media (min-width: 768px) {
  .mobile-only {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .desktop-only {
    display: none !important;
  }
}

/* ========================================
   MOBILE FAB (Floating Action Button)
   ======================================== */

.mobile-fab-container {
  position: fixed;
  bottom: 10px; /* lowered from 20px */
  right: 20px;
  z-index: 23000; /* Above chat drawer (20002) */
  display: none; /* Hidden by default, shown via JS on mobile */
}
@supports (bottom: env(safe-area-inset-bottom)) {
  .mobile-fab-container {
    bottom: calc(env(safe-area-inset-bottom) + 10px);
  }
}

/* Main FAB button */
.mobile-fab-main {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4da3ff 0%, #357ae8 100%);
  border: none;
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(66, 133, 244, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
}

.mobile-fab-main:active {
  transform: scale(0.95);
}

.mobile-fab-main:hover {
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.5),
    0 4px 12px rgba(66, 133, 244, 0.4);
}

/* FAB icon states */
.fab-icon {
  color: #fff;
  transition: all 0.25s ease;
  position: absolute;
}

.fab-icon-menu {
  opacity: 1;
  transform: rotate(0deg);
}

.fab-icon-close {
  opacity: 0;
  transform: rotate(90deg);
}

.mobile-fab-main.expanded .fab-icon-menu {
  opacity: 0;
  transform: rotate(-90deg);
}

.mobile-fab-main.expanded .fab-icon-close {
  opacity: 1;
  transform: rotate(0deg);
}

.mobile-fab-main.expanded {
  background: linear-gradient(135deg, #ff5252 0%, #d32f2f 100%);
}

/* FAB menu container */
.mobile-fab-menu {
  position: absolute;
  bottom: 70px;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.mobile-fab-container.expanded .mobile-fab-menu {
  pointer-events: auto;
}

/* Menu item buttons */
.mobile-fab-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px 0 12px;
  height: 48px;
  background: rgba(30, 30, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(calc(var(--fab-index) * -8px));
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
  min-width: 48px; /* Ensure touch-friendly minimum */
}

.mobile-fab-container.expanded .mobile-fab-menu-item {
  opacity: 1;
  transform: translateY(0);
  transition-delay: calc(var(--fab-index) * 0.04s);
}

.mobile-fab-menu-item:active {
  transform: scale(0.96);
}

.mobile-fab-menu-item:hover {
  background: rgba(40, 40, 40, 0.95);
  border-color: rgba(77, 163, 255, 0.5);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(77, 163, 255, 0.2);
}

/* Danger button (logout) */
.mobile-fab-menu-item.fab-danger {
  background: rgba(176, 48, 48, 0.95);
  border-color: rgba(211, 76, 76, 0.5);
}

.mobile-fab-menu-item.fab-danger:hover {
  background: rgba(200, 60, 60, 0.95);
  border-color: rgba(255, 100, 100, 0.6);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 12px rgba(255, 82, 82, 0.3);
}

/* Label text */
.fab-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.25px;
}

/* Icon inside menu items */
.mobile-fab-menu-item .fab-icon {
  position: static;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Show on mobile viewports only */
@media (max-width: 767px) {
  .mobile-fab-container {
    display: block;
  }
}

/* Adjust for small phones */
@media (max-width: 479px) {
  .mobile-fab-container {
    bottom: 16px;
    right: 16px;
  }

  .mobile-fab-main {
    width: 52px;
    height: 52px;
  }

  .mobile-fab-menu-item {
    height: 44px;
    padding: 0 14px 0 10px;
    font-size: 13px;
  }

  .fab-label {
    font-size: 13px;
  }
}

/* Landscape adjustments */
@media (max-width: 767px) and (orientation: landscape) {
  .mobile-fab-container {
    bottom: 12px;
    right: 12px;
  }

  .mobile-fab-menu {
    bottom: 60px;
  }
}

/* Prevent text selection on FAB */
.mobile-fab-main,
.mobile-fab-menu-item,
.fab-label {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Add ripple effect on tap (optional enhancement) */
@keyframes fab-ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.mobile-fab-main::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  opacity: 0;
  pointer-events: none;
}

.mobile-fab-main:active::after {
  animation: fab-ripple 0.6s ease-out;
}

/* ========================================
   MOBILE TOP BAR (Player Stats)
   ======================================== */

.mobile-topbar-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10500;
  display: none; /* Hidden by default, shown via JS on mobile */
  flex-direction: column;
}

/* Compact bar (always visible) */
.mobile-topbar-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  background: linear-gradient(
    180deg,
    rgba(20, 20, 20, 0.98) 0%,
    rgba(25, 25, 25, 0.96) 100%
  );
  border-bottom: 1px solid rgba(77, 163, 255, 0.25);
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.topbar-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
}

.topbar-stat-power .topbar-icon {
  color: var(--color-power);
}

.topbar-stat-hp .topbar-icon {
  color: var(--color-hp);
}

.topbar-stat-shields .topbar-icon {
  color: var(--color-shields);
}

.topbar-stat-level .topbar-icon {
  fill: #ffd700;
}

.topbar-stat-credits .topbar-icon {
  color: #51cf66;
}

.topbar-value {
  min-width: 32px;
  text-align: left;
}

/* Toggle button */
.topbar-toggle {
  width: 44px;
  height: 44px;
  background: rgba(77, 163, 255, 0.15);
  border: 1px solid rgba(77, 163, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.topbar-toggle:active {
  transform: scale(0.95);
}

.topbar-toggle .topbar-icon {
  color: #4da3ff;
}

.topbar-icon-expand {
  display: block;
}

.topbar-icon-collapse {
  display: none;
}

.mobile-topbar-container.expanded .topbar-icon-expand {
  display: none;
}

.mobile-topbar-container.expanded .topbar-icon-collapse {
  display: block;
}

/* Expanded panel */
.mobile-topbar-expanded {
  max-height: 0;
  overflow: hidden;
  background: rgba(20, 20, 20, 0.98);
  border-bottom: 1px solid rgba(77, 163, 255, 0.15);
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.mobile-topbar-container.expanded .mobile-topbar-expanded {
  max-height: calc(100vh - 52px);
  overflow-y: auto;
}

.topbar-expanded-content {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Section styling */
.topbar-section {
  background: rgba(30, 30, 30, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 12px;
}

.topbar-section-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--panel-accent);
  margin: 0 0 12px 0;
  text-transform: uppercase;
}

/* Meters in expanded panel */
.topbar-meters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar-meter {
  position: relative;
  height: 24px;
  background: rgba(31, 31, 31, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

.topbar-meter-bar {
  position: absolute;
  inset: 0;
  width: calc(var(--pct, 0) * 100%);
  transition: width 0.3s ease;
}

.topbar-meter--power .topbar-meter-bar {
  background: linear-gradient(
    90deg,
    var(--color-power) 0%,
    rgba(255, 165, 0, 0.8) 100%
  );
}

.topbar-meter--shields .topbar-meter-bar {
  background: linear-gradient(
    90deg,
    var(--color-shields) 0%,
    rgba(42, 163, 255, 0.8) 100%
  );
}

.topbar-meter--armor .topbar-meter-bar {
  background: linear-gradient(
    90deg,
    var(--color-armor) 0%,
    rgba(194, 143, 44, 0.8) 100%
  );
}

.topbar-meter--hp .topbar-meter-bar {
  background: linear-gradient(
    90deg,
    var(--color-hp) 0%,
    rgba(255, 64, 64, 0.8) 100%
  );
}

.topbar-meter-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  font-size: 12px;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  font-weight: 600;
  pointer-events: none;
}

.m-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.m-val {
  font-size: 12px;
}

/* Info grid */
.topbar-info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topbar-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.topbar-info-label {
  font-size: 12px;
  color: var(--panel-text-faint);
}

.topbar-info-value {
  font-size: 12px;
  color: var(--panel-text);
  font-weight: 600;
}

/* Stats grid */
.topbar-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.topbar-stat-row {
  display: flex;
  flex-direction: column;
  padding: 8px;
  background: rgba(40, 40, 40, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
}

.topbar-stat-label {
  font-size: 10px;
  color: var(--panel-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

.topbar-stat-value {
  font-size: 13px;
  color: var(--panel-text);
  font-weight: 600;
}

/* Scrollbar styling for expanded panel */
.mobile-topbar-expanded::-webkit-scrollbar {
  width: 6px;
}

.mobile-topbar-expanded::-webkit-scrollbar-thumb {
  background: rgba(77, 163, 255, 0.4);
  border-radius: 3px;
}

.mobile-topbar-expanded::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

/* Show on mobile viewports only */
@media (max-width: 767px) {
  .mobile-topbar-container {
    display: flex;
  }
}

/* Force-show the top bar when mobile UI is explicitly active, regardless of width */
html.gh-mobile-mode .mobile-topbar-container {
  display: flex !important;
}

/* Small phone adjustments */
@media (max-width: 479px) {
  .mobile-topbar-compact {
    height: 48px;
    padding: 0 10px;
  }

  .topbar-stats {
    gap: 12px;
  }

  .topbar-stat {
    font-size: 13px;
    gap: 4px;
  }

  .topbar-icon {
    width: 14px;
    height: 14px;
  }

  .topbar-toggle {
    width: 40px;
    height: 40px;
  }

  .topbar-section-title {
    font-size: 12px;
  }

  .topbar-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Landscape mode */
@media (max-width: 767px) and (orientation: landscape) {
  .mobile-topbar-compact {
    height: 44px;
  }

  .topbar-stats {
    gap: 14px;
  }

  .topbar-stat {
    font-size: 12px;
  }

  /* IMPORTANT: only give the expanded panel height when container is expanded */
  .mobile-topbar-container.expanded .mobile-topbar-expanded {
    max-height: calc(100vh - 44px);
  }

  .topbar-expanded-content {
    padding: 12px 10px;
  }
}

/* Prevent text selection */
.mobile-topbar-compact,
.mobile-topbar-expanded,
.topbar-value,
.topbar-info-value,
.topbar-stat-value {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Animation for expand/collapse */
@keyframes topbar-slide-down {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.mobile-topbar-container.expanded .topbar-expanded-content {
  animation: topbar-slide-down 0.3s ease;
}

/* Mobile Drawer (Chat) */
#mobile-drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20002;
  display: none;
  --drawer-height: 52px;
}
#mobile-drawer.collapsed {
  height: 52px;
}
#mobile-drawer.expanded {
  height: var(--drawer-height);
}
#mobile-drawer .drawer-tab {
  height: 52px;
  background: linear-gradient(180deg, #1f2937, #111827);
  color: #e5e7eb;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#mobile-drawer.dragging .drawer-tab {
  cursor: ns-resize;
}
#mobile-drawer .drawer-tab-title {
  font-weight: 600;
  letter-spacing: 0.2px;
}
#mobile-drawer .drawer-badge {
  background: #ef4444;
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  margin-left: 8px;
}
#mobile-drawer .drawer-tab-drag {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}
#mobile-drawer .drawer-content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--drawer-height) - 52px);
  background: rgba(17, 24, 39, 0.96);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
#mobile-drawer .drawer-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.35;
  color: #e5e7eb;
}
#mobile-drawer .drawer-input {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b1020;
}
#mobile-drawer .drawer-input input {
  flex: 1;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid #374151;
  background: #0f172a;
  color: #e5e7eb;
  padding: 0 12px;
  outline: none;
}
#mobile-drawer .drawer-input button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 600;
  color: #0b1020;
  background: #60a5fa;
  border: 0;
}
#mobile-drawer .msg {
  margin: 4px 0;
}
#mobile-drawer .msg .t {
  opacity: 0.6;
  margin-right: 6px;
  font-size: 12px;
}
#mobile-drawer .msg .from {
  color: #93c5fd;
  margin-right: 4px;
}
#mobile-drawer .msg.channel-system .from {
  color: #f59e0b;
}

@media (min-width: 768px) {
  #mobile-drawer {
    display: none !important;
  }
}

/* When mobile UI is explicitly active, always show the drawer regardless of width */
html.gh-mobile-mode #mobile-drawer {
  display: block !important;
}

/* Optional: Add root-class driven mobile overrides so colors/appearance can flip as soon as manager toggles class; tie drawer visibility to mobile root class for safety. */
:root.gh-mobile-mode body,
.gh-mobile-mode body {
  background-color: #000;
}

/* Prevent any page scroll in mobile mode */
html.gh-mobile-mode,
html.gh-mobile-mode body {
  height: 100%;
  overflow: hidden;
}

/* Fullscreen prompt overlay (mobile small viewport) */
.mobile-fullscreen-prompt {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 22000;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.mobile-fullscreen-prompt .box {
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px 18px;
  color: #fff;
  width: min(520px, 90vw);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.mobile-fullscreen-prompt .msg {
  font-size: 15px;
  margin-bottom: 12px;
}
.mobile-fullscreen-prompt .go-btn {
  min-height: 44px;
  min-width: 180px;
  padding: 10px 16px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid rgba(77, 163, 255, 0.4);
  background: linear-gradient(180deg, #4da3ff, #357ae8);
  color: #fff;
  cursor: pointer;
}
.mobile-fullscreen-prompt .go-btn:active {
  transform: scale(0.98);
}
.mobile-fullscreen-prompt .hint {
  margin-top: 10px;
  font-size: 12px;
  color: #ccc;
  opacity: 0.85;
}

/* ========================================
   XP DISPLAY SYSTEM
   ======================================== */

/* XP Display Styles */
.xp-display {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.xp-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.7);
  padding: 10px 15px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 50px;
}

.level-number {
  font-size: 24px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.level-number.level-up-flash {
  animation: levelFlash 1s ease-out;
}

@keyframes levelFlash {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
    color: #fff;
  }
}

.tier-indicator {
  font-size: 12px;
  font-weight: bold;
  margin-top: 2px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(100, 100, 100, 0.8);
}

.tier-indicator.tier-1 {
  background: rgba(150, 150, 150, 0.8);
}
.tier-indicator.tier-2 {
  background: rgba(76, 175, 80, 0.8);
}
.tier-indicator.tier-3 {
  background: rgba(33, 150, 243, 0.8);
}
.tier-indicator.tier-4 {
  background: rgba(156, 39, 176, 0.8);
}
.tier-indicator.tier-5 {
  background: rgba(255, 152, 0, 0.8);
}

.xp-bar-container {
  min-width: 300px;
}

.xp-bar-bg {
  position: relative;
  height: 30px;
  background: rgba(50, 50, 50, 0.8);
  border-radius: 15px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.xp-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  transition: width 0.3s ease-out;
  border-radius: 15px;
}

.xp-bar-text {
  position: absolute;
  width: 100%;
  text-align: center;
  line-height: 30px;
  color: white;
  font-weight: bold;
  font-size: 14px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  z-index: 1;
}

/* Level-Up Overlay Styles */
.level-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.5s ease-in;
}

.level-up-overlay.active {
  opacity: 1;
}

.level-up-content {
  text-align: center;
  z-index: 2;
  animation: levelUpBounce 0.8s ease-out;
}

@keyframes levelUpBounce {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.level-up-title {
  font-size: 72px;
  font-weight: bold;
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.6);
  margin-bottom: 20px;
  animation: titlePulse 2s ease-in-out infinite;
}

@keyframes titlePulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.level-up-level {
  font-size: 48px;
  color: white;
  margin-bottom: 30px;
}

.level-up-level .level-number {
  font-size: 64px;
  color: #ffd700;
  font-weight: bold;
}

.tier-unlock-message {
  font-size: 36px;
  color: #ff9800;
  margin: 20px 0;
  text-shadow: 0 0 10px rgba(255, 152, 0, 0.8);
}

.tier-unlock-subtitle {
  font-size: 18px;
  color: #ccc;
  margin-bottom: 20px;
}

.level-up-rewards {
  margin: 30px 0;
}

.reward-item {
  display: inline-block;
  padding: 10px 20px;
  margin: 5px;
  background: rgba(76, 175, 80, 0.3);
  border: 2px solid #4caf50;
  border-radius: 5px;
  color: white;
  font-size: 18px;
}

.level-up-continue {
  margin-top: 40px;
  font-size: 16px;
  color: #aaa;
  animation: continueBlink 2s ease-in-out infinite;
}

@keyframes continueBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Particles */
.level-up-particles {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: radial-gradient(circle, #ffd700, transparent);
  border-radius: 50%;
  animation: particleRise 3s ease-out infinite;
  opacity: 0.8;
}

@keyframes particleRise {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(1);
    opacity: 0;
  }
}

/* XP Gain Effect Styles */
.xp-gain-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9000;
}

.xp-gain-number {
  position: absolute;
  text-align: center;
  opacity: 0;
  transform: translateY(0);
  transition: all 0.5s ease-out;
}

.xp-gain-number.active {
  opacity: 1;
  transform: translateY(-100px);
}

.xp-gain-number.fade-out {
  opacity: 0;
}

.xp-amount {
  font-size: 36px;
  font-weight: bold;
  color: #ffd700;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.8),
    0 2px 5px rgba(0, 0, 0, 0.8);
  margin-bottom: 5px;
}

.xp-reason-label {
  font-size: 18px;
  color: white;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  font-weight: bold;
}

/* Contextual colors by reason */
.xp-reason-kill_ai .xp-amount,
.xp-reason-kill_player .xp-amount {
  color: #f44336; /* Red for combat */
}

.xp-reason-mining .xp-amount {
  color: #2196f3; /* Blue for mining */
}

.xp-reason-flag_capture .xp-amount,
.xp-reason-capture .xp-amount {
  color: #4caf50; /* Green for objectives */
}

.xp-reason-exploration .xp-amount {
  color: #9c27b0; /* Purple for exploration */
}

/* Combo Indicator Styles */
.combo-indicator-container {
  position: fixed;
  top: 100px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.combo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  animation: comboSlideIn 0.3s ease-out;
  min-width: 220px;
  position: relative;
}

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

.combo-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.6));
}

.combo-details {
  flex: 1;
}

.combo-title {
  font-size: 14px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.6);
  margin-bottom: 4px;
}

.combo-count {
  font-size: 18px;
  color: white;
  font-weight: bold;
}

.combo-multiplier {
  font-size: 12px;
  color: #4caf50;
  font-weight: bold;
}

.combo-timer-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.combo-timer-fill {
  height: 100%;
  background: #4caf50;
  transition:
    width 0.3s linear,
    background 0.3s ease;
}

.kill-combo {
  border-color: rgba(244, 67, 54, 0.6);
}

.mining-combo {
  border-color: rgba(33, 150, 243, 0.6);
}

/* Daily Bonus Notification Styles */
.daily-bonus-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 9500;
  opacity: 0;
  transition: all 0.5s ease-out;
}

.daily-bonus-notification.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.daily-bonus-content {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 25px;
  background: linear-gradient(
    135deg,
    rgba(255, 152, 0, 0.9),
    rgba(255, 193, 7, 0.9)
  );
  border-radius: 10px;
  border: 3px solid #ffd700;
  box-shadow: 0 5px 20px rgba(255, 215, 0, 0.5);
}

.daily-bonus-icon {
  font-size: 48px;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.8));
  animation: bonusIconPulse 1.5s ease-in-out infinite;
}

@keyframes bonusIconPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.daily-bonus-title {
  font-size: 20px;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.daily-bonus-multiplier {
  font-size: 28px;
  font-weight: bold;
  color: #ffd700;
  text-shadow:
    0 0 10px rgba(255, 215, 0, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Mobile responsive adjustments for XP UI */
@media (max-width: 767px) {
  .xp-display {
    bottom: 80px; /* Move above mobile controls */
  }

  .xp-container {
    padding: 8px 12px;
  }

  .xp-bar-container {
    min-width: 200px;
  }

  .level-up-title {
    font-size: 48px;
  }

  .level-up-level {
    font-size: 32px;
  }

  .level-up-level .level-number {
    font-size: 48px;
  }

  .combo-indicator-container {
    top: 70px; /* Move below mobile top bar */
    right: 10px;
  }

  .combo-item {
    min-width: 180px;
    padding: 10px 12px;
  }

  .daily-bonus-notification {
    top: 70px; /* Move below mobile top bar */
  }
}

/* Audio Settings Panel */
.audio-settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.audio-section {
  background: rgba(30, 30, 30, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 14px;
}

.audio-section h4 {
  margin: 0 0 14px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--panel-accent);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.audio-control {
  margin-bottom: 14px;
}

.audio-control:last-child {
  margin-bottom: 0;
}

.audio-control > label:first-child {
  display: block;
  font-size: 12px;
  color: var(--panel-text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.audio-checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px !important;
  color: var(--panel-text) !important;
  margin-bottom: 0 !important;
}

.audio-checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--panel-accent);
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.audio-control input[type="range"] {
  flex: 1;
  height: 8px;
  background: rgba(50, 50, 50, 0.8);
  border-radius: 4px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.audio-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--panel-accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.audio-control input[type="range"]::-webkit-slider-thumb:hover {
  background: #6fb7ff;
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(77, 163, 255, 0.4);
}

.audio-control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--panel-accent);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.audio-control input[type="range"]::-moz-range-thumb:hover {
  background: #6fb7ff;
  transform: scale(1.1);
  box-shadow: 0 3px 8px rgba(77, 163, 255, 0.4);
}

.volume-value {
  min-width: 50px;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--panel-text);
}

.test-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.test-btn {
  min-width: 0 !important;
  max-width: none !important;
  font-size: 11px;
  padding: 8px 10px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  transition: all 0.15s ease;
}

.test-btn:hover {
  background: #3d3d3d;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.test-btn:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Mobile responsive adjustments */
@media (max-width: 767px) {
  .audio-section {
    padding: 12px;
  }

  .test-buttons {
    grid-template-columns: 1fr;
  }

  .test-btn {
    padding: 12px 14px;
    font-size: 13px;
    min-height: 44px;
  }

  .audio-control input[type="range"]::-webkit-slider-thumb,
  .audio-control input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
  }
}

/* Tier Unlock Notification */
.tier-unlock-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  z-index: 9600;
  opacity: 0;
  transition: all 0.5s ease-out;
}

.tier-unlock-notification.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.tier-unlock-content {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 30px;
  background: linear-gradient(
    135deg,
    rgba(156, 39, 176, 0.9),
    rgba(103, 58, 183, 0.9)
  );
  border-radius: 12px;
  border: 3px solid #ba68c8;
  box-shadow: 0 6px 24px rgba(156, 39, 176, 0.5);
  min-width: 400px;
}

.tier-unlock-content.tier-2 {
  background: linear-gradient(
    135deg,
    rgba(76, 175, 80, 0.9),
    rgba(104, 159, 56, 0.9)
  );
  border-color: #8bc34a;
  box-shadow: 0 6px 24px rgba(76, 175, 80, 0.5);
}

.tier-unlock-content.tier-3 {
  background: linear-gradient(
    135deg,
    rgba(33, 150, 243, 0.9),
    rgba(30, 136, 229, 0.9)
  );
  border-color: #64b5f6;
  box-shadow: 0 6px 24px rgba(33, 150, 243, 0.5);
}

.tier-unlock-content.tier-4 {
  background: linear-gradient(
    135deg,
    rgba(156, 39, 176, 0.9),
    rgba(103, 58, 183, 0.9)
  );
  border-color: #ba68c8;
  box-shadow: 0 6px 24px rgba(156, 39, 176, 0.5);
}

.tier-unlock-content.tier-5 {
  background: linear-gradient(
    135deg,
    rgba(255, 152, 0, 0.9),
    rgba(251, 140, 0, 0.9)
  );
  border-color: #ffb74d;
  box-shadow: 0 6px 24px rgba(255, 152, 0, 0.5);
}

.tier-unlock-icon {
  font-size: 64px;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
  animation: unlockIconPulse 2s ease-in-out infinite;
}

@keyframes unlockIconPulse {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
}

.tier-unlock-text {
  flex: 1;
}

.tier-unlock-title {
  font-size: 28px;
  font-weight: bold;
  color: white;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  margin-bottom: 4px;
}

.tier-unlock-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
}

.tier-unlock-hint {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

/* Mobile responsive */
@media (max-width: 767px) {
  .tier-unlock-content {
    min-width: 320px;
    padding: 16px 20px;
    top: 70px; /* Move below mobile top bar */
  }

  .tier-unlock-icon {
    font-size: 48px;
  }

  .tier-unlock-title {
    font-size: 22px;
  }

  .tier-unlock-subtitle {
    font-size: 14px;
  }
}

/* Mobile overlay sizing based on root class (applies regardless of width) */
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"],
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] {
  font-size: 11px !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] .gh-panel-body,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-body {
  padding: 6px 8px !important;
  font-size: 11px !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] .gh-btn,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] .gh-btn {
  height: 30px !important; /* override global fixed 34px */
  min-height: 30px !important;
  font-size: 11px !important;
  padding: 6px 10px !important;
  min-width: 86px !important;
  max-width: none !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] .gh-panel-header,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-header {
  height: 36px !important;
  font-size: 12px !important;
  padding: 0 8px !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] .gh-panel-title,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-title {
  font-size: 11px !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] .gh-panel-collapse,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] .gh-panel-close {
  width: 30px !important;
  height: 30px !important;
  font-size: 14px !important;
}

/* Sector Map controls within overlay in mobile mode */
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] #sectorMapZoomIn,
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] #sectorMapZoomOut,
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] #sectorMapReset,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] #sectorMapZoomIn,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] #sectorMapZoomOut,
html.gh-mobile-mode .gh-panel[data-anchor*="canvas-overlay"] #sectorMapReset {
  font-size: 11px !important;
  padding: 4px 6px !important;
  min-height: 28px !important;
}
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] #sectorMapZoomLevel,
html.gh-mobile-mode .gh-panel[data-anchor="canvas-overlay"] #sectorMapAlphaVal,
html.gh-mobile-mode
  .gh-panel[data-anchor*="canvas-overlay"]
  #sectorMapZoomLevel,
html.gh-mobile-mode
  .gh-panel[data-anchor*="canvas-overlay"]
  #sectorMapAlphaVal {
  font-size: 11px !important;
}

/* Station Panel: scroll container adjustments */
#stationPanel {
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}
#stationPanel .gh-panel-body {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important; /* critical: allows overflow to work inside flex container */
  height: auto !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}
#stationPanel .station-panel-inner {
  flex: 1 0 auto !important;
  min-height: 0 !important;
}

/* Ensure docked players are visible on mobile/compact layouts */
#stationPanel.compact-layout .station-docked-players,
html.gh-mobile-mode #stationPanel .station-docked-players {
  display: block !important;
}

/* Make the docked players list scrollable within the panel on small screens */
#stationPanel .docked-players-list {
  max-height: 220px !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  padding-right: 6px !important;
}

/* Slightly reduce height when compact to avoid taking too much space */
#stationPanel.compact-layout .docked-players-list {
  max-height: 140px !important;
}
