/* --- 1. GLOBAL VARIABLES --- */
:root {
   /* We break #b6ff00 into RGB numbers (182, 255, 0) for opacity manipulation */
   --accent-rgb: 182, 255, 0;
   --accent-color: rgba(var(--accent-rgb), 0.8);
   --color-base: #0a0e13;
   --bg-base: #010404;
   --terminal-green: #20ff40;
   --color-text-primary: #f8fafc;
   --color-text-secondary: #cbd5e1;
   --radius-xs: 2px;
   --transition-base: 0.3s;
   /* Engagement Tokens */
   --dark-010: rgba(10, 14, 19, 0.95);
   --dialog-shadow: 0 20px 50px rgba(0, 0, 0, 1), 0 0 40px rgba(var(--accent-rgb), 0.1);
}

/* --- 2. BASE SETUP --- */
body,
html {
   margin: 0;
   padding: 0;
   width: 100vw;
   min-height: 100vh;
   font-family: 'Segoe UI', sans-serif;
   color: var(--color-text-primary);
   background-color: var(--color-base);
   overflow-x: hidden;
   overflow-y: auto;
   scroll-behavior: smooth;
}

/* --- 2.1 CUSTOM HUD SCROLLBAR --- */
::-webkit-scrollbar {
   display: none;
}

/* Firefox */
* {
   scrollbar-width: none;
   -ms-overflow-style: none;
   /* IE/Edge */
}

/* --- 3. ATMOSPHERIC LAYERS --- */
#particle-canvas {
   position: fixed;
   inset: 0;
   z-index: 1;
}

.grid-overlay {
   position: fixed;
   inset: 0;
   z-index: 2;
   pointer-events: none;
   background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
   background-image:
      linear-gradient(rgba(var(--accent-rgb), 0.08) 1px, transparent 1px),
      linear-gradient(90deg, rgba(var(--accent-rgb), 0.08) 1px, transparent 1px),
      linear-gradient(rgba(var(--accent-rgb), 0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(var(--accent-rgb), 0.02) 1px, transparent 1px);
   mask-image: radial-gradient(ellipse at 50% 50%, black 10%, transparent 80%);
}

.ambient-glow {
   position: fixed;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   width: 60vw;
   height: 60vh;
   background: radial-gradient(circle, var(--accent-color) 0%, transparent 70%);
   opacity: 0.15;
   filter: blur(100px);
   z-index: 3;
   pointer-events: none;
}

/* --- 4. HUD INTERFACE COMPONENTS --- */

/* Top Bar: Command Header */
.hud-top-bar {
   position: fixed;
   top: 0;
   left: 0;
   width: 100vw;
   height: 60px;
   display: flex;
   justify-content: space-between;
   align-items: center;
   padding: 0 40px;
   box-sizing: border-box;
   z-index: 100;
   background: linear-gradient(to bottom, rgba(var(--accent-rgb), 0.05), transparent);
   border-bottom: 1px solid rgba(var(--accent-rgb), 0.1);
   backdrop-filter: blur(2px);
}

.is-glossy-text {
   font-size: 1.1rem;
   text-transform: uppercase;
   letter-spacing: 6px;
   color: var(--accent-color);
   margin: 0;
   font-weight: 900;
   text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.3);
}

.hud-status,
.hud-version {
   font-family: 'Courier New', Courier, monospace;
   font-size: 0.65rem;
   letter-spacing: 2px;
   color: var(--color-text-secondary);
   opacity: 0.6;
}

/* --- Game Sync Telemetry Bar --- */
.sync-status-bar {
   position: relative;
   display: flex;
   flex-direction: column;
   width: 100%;
   max-width: 510px;
   /* Exact match for 3 cards + gaps */
   margin: 10px auto 0;
   padding: 12px 20px;
   background: rgba(var(--accent-rgb), 0.03);
   border: 1px solid rgba(var(--accent-rgb), 0.1);
   border-radius: 2px;
   backdrop-filter: blur(5px);
   -webkit-backdrop-filter: blur(5px);
   overflow: hidden;
   z-index: 5;
   box-sizing: border-box;
}

.sync-status-inner {
   display: flex;
   justify-content: space-between;
   align-items: center;
   gap: 15px;
   font-family: 'Courier New', monospace;
}

.sync-label {
   color: var(--color-text-secondary);
   font-size: 0.6rem;
   letter-spacing: 2px;
   opacity: 0.6;
}

.sync-separator {
   flex-grow: 1;
   height: 1px;
   background: linear-gradient(to right, transparent, rgba(var(--accent-rgb), 0.2), transparent);
}

.sync-value {
   font-size: 0.75rem;
   font-weight: 900;
   letter-spacing: 1px;
   color: var(--accent-color);
   text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

.sync-pulse-line {
   position: absolute;
   bottom: 0;
   left: -100%;
   width: 100%;
   height: 1px;
   background: linear-gradient(to right, transparent, var(--accent-color), transparent);
   animation: h-pulse 4s linear infinite;
   opacity: 0.5;
}

@keyframes h-pulse {
   0% {
      left: -100%;
   }

   30% {
      left: 100%;
   }

   100% {
      left: 100%;
   }
}

/* Advisory State for the Bar */
.sync-status-bar.advisory {
   border-color: rgba(245, 158, 11, 0.4);
   background: rgba(245, 158, 11, 0.05);
}

.sync-status-bar.advisory .sync-value {
   color: #f59e0b;
   text-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
   animation: advisory-glitch 4s infinite;
}

.sync-status-bar.advisory .sync-pulse-line {
   background: linear-gradient(to right, transparent, #f59e0b, transparent);
}

@keyframes advisory-glitch {

   0%,
   90%,
   100% {
      transform: none;
      opacity: 1;
   }

   92% {
      transform: skewX(10deg);
      color: #fff;
   }

   94% {
      transform: skewX(-10deg);
   }

   96% {
      transform: none;
      opacity: 1;
   }
}

/* Offline/Error State for the Bar */
.sync-status-bar.offline {
   border-color: rgba(239, 68, 68, 0.4);
   background: rgba(239, 68, 68, 0.05);
}

.sync-status-bar.offline .sync-value {
   color: #ef4444;
   text-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

.sync-status-bar.offline .sync-pulse-line {
   background: linear-gradient(to right, transparent, #ef4444, transparent);
}

/* Mobile Responsiveness for Sync Bar */
@media (max-width: 600px) {
   .sync-status-bar {
      width: 90vw;
      padding: 15px;
   }

   .sync-status-inner {
      flex-direction: column;
      gap: 5px;
      text-align: center;
   }

   .sync-separator {
      width: 50%;
      height: 1px;
      flex-grow: 0;
   }
}

.hud-status {
   display: flex;
   align-items: center;
   gap: 8px;
}

.status-dot {
   width: 6px;
   height: 6px;
   background: var(--accent-color);
   border-radius: 50%;
   box-shadow: 0 0 8px var(--accent-color);
   animation: pulse 2s infinite;
}

@keyframes pulse {

   0%,
   100% {
      opacity: 0.4;
      transform: scale(1);
   }

   50% {
      opacity: 1;
      transform: scale(1.1);
   }
}

/* Spinner: Classic | / - \ */
.hud-spinner {
   display: inline-block;
   min-width: 1ch;
   font-weight: 100;
   /* Ultra-thin as requested */
   color: var(--accent-color);
   font-size: 1.1rem;
   margin-left: 10px;
   vertical-align: middle;
   transform: translateY(-2px);
}

.hud-spinner::after {
   content: "|";
   animation: spin-chars 0.8s steps(4) infinite;
}

@keyframes spin-chars {
   0% {
      content: "|";
   }

   25% {
      content: "/";
   }

   50% {
      content: "-";
   }

   75% {
      content: "\\";
   }
}

/* Main Hub Title Styling */
#main-title {
   display: flex;
   gap: 0;
   overflow: visible;
   margin: 0;
   min-height: 1.2rem;
   text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

/* Character Reveal for Optic Convergence */
#main-title {
   display: flex;
   gap: 0;
   overflow: visible;
}

.char {
   display: inline-block;
   opacity: 0;
   filter: blur(12px);
   transform: translateY(4px) scale(0.9);
   animation: char-reveal 1.2s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

@keyframes char-reveal {
   0% {
      opacity: 0;
      filter: blur(12px);
      transform: translateY(4px) scale(0.9);
   }

   30% {
      opacity: 0.5;
      filter: blur(6px);
   }

   100% {
      opacity: 1;
      filter: blur(0);
      transform: translateY(0) scale(1);
   }
}

/* Center Core: Logic Cluster */
.hud-center-cluster {
   position: relative;
   display: flex;
   flex-direction: column;
   align-items: center;
   padding: 100px 30px;
   /* More top padding to clear the fixed header */
   z-index: 10;
   width: 100%;
   box-sizing: border-box;
}

/* Stats Dashboard */
.stats-dashboard {
   position: relative;
   display: flex;
   flex-wrap: wrap;
   justify-content: center;
   gap: 20px 30px;
   padding: 20px;
   /* Reduced from 40px to bring brackets in */
   width: 100%;
   max-width: 550px;
   /* Snapped to exact width of cards + spacing */
   margin: 0 auto;
}

.stats-dashboard::before,
.stats-dashboard::after {
   content: "";
   position: absolute;
   left: 0;
   right: 0;
   height: 3px;
   /* Shared Radioactive Core Aesthetic */
   background: repeating-linear-gradient(45deg, var(--accent-color) 0 4px, transparent 4px 8px);
   background-size: 100% 100%;
   /* Holographic Tapering */
   -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
   mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
   pointer-events: none;
   z-index: 1;
   box-shadow: 0 0 15px var(--accent-color);
   opacity: 0.9;
}

/* TOP: True Countersweep (Left) */
.stats-dashboard::before {
   top: -8px;
   animation:
      toxic-flicker 0.1s infinite alternate,
      hazard-sweep-reverse 4s ease-in-out infinite;
}

/* BOTTOM: Normal Sweep (Right) */
.stats-dashboard::after {
   bottom: -8px;
   animation:
      toxic-flicker 0.1s infinite alternate,
      hazard-sweep 4s ease-in-out infinite;
}

@keyframes hazard-sweep {

   0%,
   100% {
      background-position: 0 0;
   }

   50% {
      background-position: 24px 0;
   }
}

@keyframes hazard-sweep-reverse {

   0%,
   100% {
      background-position: 0 0;
   }

   50% {
      background-position: -24px 0;
   }
}

@keyframes toxic-flicker {
   0% {
      opacity: 0.6;
      transform: scaleY(0.95);
      filter: contrast(1.2);
   }

   100% {
      opacity: 1;
      transform: scaleY(1.05);
      filter: contrast(1);
   }
}


.stat-card {
   position: relative;
   width: 150px;
   aspect-ratio: 1 / 0.75;
   background: rgba(var(--accent-rgb), 0.05);
   border: 1px solid rgba(var(--accent-rgb), 0.2);
   border-radius: 2px;
   cursor: pointer;
   transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
   overflow: hidden;
   /* Fixed blur logic for iOS/Chromium (GPU forced) */
   backdrop-filter: blur(2px);
   -webkit-backdrop-filter: blur(2px);
   transform: translateZ(0);
}

.stat-card-inner {
   width: 100%;
   height: 100%;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   background:
      linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
      linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
   background-size: 8px 8px;
}

/* Card Decor */
.stat-card::before {
   content: "L_MOD";
   position: absolute;
   top: 6px;
   left: 8px;
   font-family: monospace;
   font-size: 6px;
   color: var(--accent-color);
   opacity: 0.4;
}

.stat-card::after {
   content: "";
   position: absolute;
   bottom: -1px;
   right: -1px;
   width: 20px;
   height: 20px;
   border-right: 2px solid var(--accent-color);
   border-bottom: 2px solid var(--accent-color);
   opacity: 0.3;
   transition: 0.3s;
}

/* Glitch Scanning */
.glitch-line {
   position: absolute;
   width: 100%;
   height: 2px;
   background: var(--accent-color);
   box-shadow: 0 0 10px var(--accent-color);
   top: 0;
   opacity: 0;
   pointer-events: none;
}

/* Interactive States */
.stat-card:hover {
   transform: translateY(-5px);
   border-color: var(--accent-color);
   background: rgba(var(--accent-rgb), 0.1);
}

.stat-card:hover::after {
   opacity: 0.8;
   width: 30px;
   height: 30px;
}

.stat-card:hover .glitch-line {
   opacity: 0.2;
   animation: scan-smooth 3s ease-in-out infinite;
}

.stat-card:hover .stat-value {
   text-shadow: 0 0 15px var(--accent-color);
   transition: text-shadow 0.5s ease;
}

@keyframes scan-smooth {
   0% {
      top: -10%;
      opacity: 0;
   }

   10%,
   90% {
      opacity: 0.2;
   }

   50% {
      top: 105%;
   }

   100% {
      top: -10%;
      opacity: 0;
   }
}

/* Typography */
.stat-label {
   font-size: 0.6rem;
   text-transform: uppercase;
   letter-spacing: 4px;
   color: var(--color-text-secondary);
   opacity: 0.6;
   margin-bottom: 4px;
}

.stat-value {
   font-size: 2rem;
   font-weight: 900;
   color: var(--accent-color);
   text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
   font-family: 'Courier New', monospace;
}

/* Side Info Displays */
.hud-decor-side {
   position: fixed;
   bottom: 40px;
   font-family: monospace;
   font-size: 0.6rem;
   color: var(--accent-color);
   opacity: 0.3;
   display: flex;
   flex-direction: column;
   gap: 15px;
}

.hud-decor-side.left {
   left: 40px;
}

.hud-decor-side.right {
   right: 40px;
   text-align: right;
}

.decor-block {
   padding: 8px;
   border-left: 2px solid var(--accent-color);
   background: linear-gradient(to right, rgba(var(--accent-rgb), 0.05), transparent);
}

.hud-decor-side.right .decor-block {
   border-left: none;
   border-right: 2px solid var(--accent-color);
   background: linear-gradient(to left, rgba(var(--accent-rgb), 0.05), transparent);
}

/* --- 5. DYNAMIC MOD BROWSER & TACTICAL OS --- */
.mod-search-wrapper {
   position: relative;
   margin: 40px auto 25px;
   /* Scaled down top gap slightly for better mobile flow */
   width: 480px;
   max-width: 90vw;
   display: flex;
   align-items: center;
}

.mod-search-wrapper::before,
.mod-search-wrapper::after {
   content: "";
   position: absolute;
   left: 0;
   width: 100%;
   height: 2px;
   background: repeating-linear-gradient(90deg, var(--accent-color) 0, var(--accent-color) 10px, transparent 10px, transparent 15px);
   opacity: 0.1;
}

.mod-search-wrapper::before {
   top: -10px;
}

.mod-search-wrapper::after {
   bottom: -10px;
}

#mod-search {
   width: 100%;
   background: rgba(var(--bg-base), 0.4);
   border: 1px solid rgba(var(--accent-rgb), 0.2);
   padding: 15px 15px 15px 50px;
   color: var(--accent-color);
   font-family: 'Courier New', monospace;
   font-size: 0.85rem;
   letter-spacing: 3px;
   outline: none;
   transition: all 0.3s;
   text-transform: uppercase;
   box-shadow: inset 0 0 20px rgba(var(--accent-rgb), 0.05);
}

#mod-search:focus {
   border-color: var(--accent-color);
   box-shadow: inset 0 0 20px rgba(var(--accent-rgb), 0.1), 0 0 15px rgba(var(--accent-rgb), 0.1);
}

/* Category Filters */
.category-filter-container {
   display: flex;
   flex-wrap: wrap;
   justify-content: center;
   gap: 10px;
   margin: 0 auto 0px;
   max-width: 800px;
}

.filter-btn {
   font-family: 'Courier New', monospace;
   font-size: 0.75rem;
   font-weight: 400;
   text-transform: uppercase;
   letter-spacing: 3px;
   color: var(--btn-color, var(--accent-color));
   display: flex;
   align-items: center;
   gap: 8px;
   padding: 10px 18px;
   background: rgba(var(--btn-color-rgb, 255, 255, 255), 0.03);
   border: 1px solid rgba(var(--btn-color-rgb, 255, 255, 255), 0.15);
   box-shadow: inset 0 0 10px rgba(var(--btn-color-rgb, 255, 255, 255), 0.02);
   border-radius: 2px;
   /* Very subtle geometric corner */
   transition: all 0.3s;
   cursor: pointer;
   position: relative;
   outline: none;
}

.filter-btn .filter-icon {
   font-size: 0.75rem;
   opacity: 0.7;
}

/* Bottom accent line — mirrors search bar underline */
.filter-btn::after {
   content: "";
   position: absolute;
   bottom: 0;
   left: 0;
   width: 0;
   height: 1px;
   background: var(--btn-color, var(--accent-color));
   box-shadow: 0 0 10px var(--btn-color, var(--accent-color));
   transition: width 0.3s ease;
}

.filter-btn:hover {
   border-color: rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.6);
   box-shadow: inset 0 0 20px rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.1),
      0 0 15px rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.15);
}

.filter-btn:hover::after,
.filter-btn.active::after {
   width: 100%;
}

.filter-btn.active {
   border-color: rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.2);
   box-shadow: inset 0 0 20px rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.15),
      0 0 12px rgba(var(--btn-color-rgb, var(--accent-rgb)), 0.15);
   text-shadow: 0 0 8px var(--btn-color, var(--accent-color));
}

#mod-search:focus {
   background: rgba(var(--accent-rgb), 0.1);
   border-color: var(--accent-color);
   box-shadow: 0 0 15px rgba(var(--accent-rgb), 0.2);
}

.search-icon {
   position: absolute;
   left: 15px;
   color: var(--accent-color);
   opacity: 0.6;
}

.search-line {
   position: absolute;
   bottom: 0;
   left: 0;
   height: 1px;
   width: 0;
   background: var(--accent-color);
   transition: width 0.3s ease;
   box-shadow: 0 0 10px var(--accent-color);
}

#mod-search:focus~.search-line {
   width: 100%;
}

.mod-grid-container {
   width: 90vw;
   max-width: 1200px;
   margin-top: 10px;
   margin-bottom: 200px;
   /* Space at bottom for side decor */
   padding: 20px;
   display: flex;
   flex-direction: column;
   gap: 80px;
   /* Reduced gap between categories */
}

/* Category Section */
.mod-category {
   display: flex;
   flex-direction: column;
   gap: 20px;
   /* Entrance animation removed globally to restore native Chromium composite integrity */
}

@keyframes mod-reveal {
   100% {
      opacity: 1;
      transform: none;
   }
}

.category-header {
   display: flex;
   align-items: center;
   gap: 15px;
   border-bottom: 1px solid var(--cat-color, var(--accent-color));
   padding-bottom: 10px;
   position: relative;
}

.category-header i {
   font-size: 1.5rem;
   color: var(--cat-color, var(--accent-color));
   filter: drop-shadow(0 0 5px var(--cat-color, var(--accent-color)));
}

.category-title {
   font-size: 1.2rem;
   font-weight: 800;
   text-transform: uppercase;
   letter-spacing: 3px;
   color: var(--cat-color, var(--accent-color));
}

.category-desc {
   font-size: 0.7rem;
   color: var(--color-text-secondary);
   opacity: 0.6;
   margin-left: auto;
   font-family: monospace;
}

/* Mod Grid */
.mod-grid {
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
   gap: 20px;
}

/* Mod Module (Card) */
.mod-module {
   position: relative;
   background: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.03);
   border: 1px solid rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.15);
   padding: 25px 20px 20px;
   display: flex;
   flex-direction: column;
   gap: 8px;
   /* Reduced gap for tighter layout */
   transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
   /* Native glassmorphism logic */
   backdrop-filter: blur(2px);
   -webkit-backdrop-filter: blur(2px);
   transform: translateZ(0);
   /* Tiny bg grid */
   background-image:
      radial-gradient(rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.05) 1px, transparent 1px);
   background-size: 10px 10px;
   /* Corner Brackets using pseudos */
   overflow: visible;

   /* Staggered Reveal Logic */
   opacity: 0;
   transform: translateY(15px);
}

.mod-module.is-revealed {
   animation: module-fade-in 0.6s ease-out forwards;
}

@keyframes module-fade-in {
   0% {
      opacity: 0;
      transform: translateY(15px);
   }

   100% {
      opacity: 1;
      transform: translateY(0);
   }
}

.mod-module::before,
.mod-module::after {
   content: "";
   position: absolute;
   width: 12px;
   height: 12px;
   border: 1px solid var(--cat-color, var(--accent-color));
   transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
   opacity: 0.3;
   pointer-events: none;
}

/* Top Left Bracket */
.mod-module::before {
   top: -1px;
   left: -1px;
   border-right: none;
   border-bottom: none;
}

/* Bottom Right Bracket */
.mod-module::after {
   bottom: -1px;
   right: -1px;
   border-left: none;
   border-top: none;
}

.mod-module:hover::before,
.mod-module:hover::after {
   opacity: 1;
   width: 18px;
   height: 18px;
   border-width: 2px;
   filter: drop-shadow(0 0 5px var(--cat-color, var(--accent-color)));
}

/* Module Header */
.mod-card-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: -5px;
}

.mod-id {
   font-family: 'Courier New', monospace;
   font-size: 0.6rem;
   color: var(--cat-color, var(--accent-color));
   opacity: 0.5;
   letter-spacing: 1px;
}

/* Mod Icon Frame */
/* Mod Title Group: Layout for Side-by-Side Icon & Name */
.mod-title-group {
   display: flex;
   align-items: center;
   /* Center icon vertically with the first line of text */
   gap: 12px;
   margin-bottom: 0px;
   /* High-density data read-out: pull description up closer to title */
}

/* Mod Icon Frame */
.mod-icon-frame {
   position: relative;
   flex: 0 0 42px;
   /* Slightly smaller for better integration */
   width: 42px;
   height: 42px;
   background: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.05);
   border: 1px solid rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.2);
   border-radius: 4px;
   overflow: hidden;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
   z-index: 2;
}

.mod-icon-img {
   width: 100%;
   height: 100%;
   object-fit: cover;
   opacity: 0.8;
   filter: grayscale(0.2) contrast(1.1);
   transition: all 0.4s;
}

.mod-icon-fallback {
   font-size: 1.2rem;
   color: var(--cat-color, var(--accent-color));
   opacity: 0.6;
}

/* HUD Scanline Overlay */
.mod-icon-scan {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background: linear-gradient(to bottom,
         transparent 0%,
         rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.1) 50%,
         transparent 100%);
   background-size: 100% 200%;
   animation: icon-scan 4s linear infinite;
   pointer-events: none;
   z-index: 3;
}

@keyframes icon-scan {
   0% {
      background-position: 0 -200%;
   }

   100% {
      background-position: 0 200%;
   }
}

.mod-status-pulse {
   width: 4px;
   height: 4px;
   background: var(--cat-color, var(--accent-color));
   border-radius: 50%;
   box-shadow: 0 0 5px var(--cat-color, var(--accent-color));
   animation: pulse 1.5s infinite;
   z-index: 4;
}

.mod-module:hover .mod-icon-frame {
   border-color: var(--cat-color, var(--accent-color));
   box-shadow: 0 0 15px rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.2);
   transform: scale(1.05);
}

.mod-module:hover .mod-icon-img {
   opacity: 1;
   filter: grayscale(0) contrast(1.2);
}

.mod-module:hover {
   transform: translateY(-5px);
   border-color: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.4);
   background-color: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.05);
}

.mod-name {
   font-size: 1.1rem;
   font-weight: 500;
   color: rgba(var(--cat-color-rgb), 0.8);
   text-transform: uppercase;
   letter-spacing: 2px;
   overflow-wrap: break-word;
   word-break: break-word;
   white-space: normal;
   text-shadow: 0 0 15px rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.3);
   margin: 0;
   flex: 1;
   line-height: 1.1;
}

.mod-description {
   font-size: 0.7rem;
   line-height: 1.5;
   color: var(--color-text-secondary);
   opacity: 0.7;
   height: 3em;
   overflow: hidden;
   display: -webkit-box;
   -webkit-line-clamp: 2;
   line-clamp: 2;
   -webkit-box-orient: vertical;
}

/* Mod Meta & Buttons */
.mod-meta {
   display: flex;
   justify-content: flex-start;
   align-items: stretch;
   gap: 4px;
   margin-top: auto;
   padding-top: 15px;
   border-top: 1px solid rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.1);
}

.mod-badges {
   display: flex;
   flex-direction: column;
   gap: 4px;
}

.mod-version,
.mod-week {
   font-family: monospace;
   font-size: 0.6rem;
   color: var(--cat-color, var(--accent-color));
   padding: 2px 8px;
}

.mod-version {
   background: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.1);
   border: 1px solid rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.2);
}

.mod-week {
   background: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.05);
   border: 1px dashed rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.3);
   opacity: 0.8;
}

/* Beveled Engaging Button */
.mod-link {
   font-family: 'Segoe UI', sans-serif;
   font-size: 0.65rem;
   font-weight: 900;
   text-transform: uppercase;
   text-decoration: none;
   color: var(--cat-color, var(--accent-color));
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0 20px;
   flex-grow: 1;
   background: rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.1);
   position: relative;
   border: 1px solid rgba(var(--cat-color-rgb, var(--accent-rgb)), 0.4);
   transition: all 0.3s;
   letter-spacing: 2px;
}

.mod-link::before {
   content: ">>";
   margin-right: 5px;
   font-size: 0.6rem;
   opacity: 0.6;
}

.mod-link:hover {
   background: var(--cat-color, var(--accent-color));
   color: var(--bg-base);
   box-shadow: 0 0 20px var(--cat-color, var(--accent-color));
}

/* Dialog Footer & Dual Buttons */
.dialog-footer {
   display: flex;
   justify-content: space-between;
   align-items: center;
   gap: 20px;
   margin-top: 20px;
   padding-top: 20px;
   border-top: 1px solid rgba(var(--accent-rgb), 0.1);
}

.download-source-btn {
   font-family: 'Segoe UI', sans-serif;
   font-size: 0.7rem;
   font-weight: 900;
   text-transform: uppercase;
   text-decoration: none;
   color: var(--accent-color);
   padding: 10px 25px;
   background: rgba(var(--accent-rgb), 0.05);
   border: 1px solid var(--accent-color);
   transition: all 0.3s;
   letter-spacing: 2px;
}

.download-source-btn:hover {
   background: var(--accent-color);
   color: var(--bg-base);
   box-shadow: 0 0 20px var(--accent-color);
}

.mod-category {
   --cat-color: var(--accent-color);
   /* Fallback */
   --cat-color-rgb: var(--accent-rgb);
   /* Fallback */
}


/* Loader Styling */
.loader-text {
   font-family: 'Courier New', monospace;
   color: var(--accent-color);
   font-size: 0.8rem;
   letter-spacing: 4px;
   text-align: center;
   width: 100%;
   animation: blink 1s infinite;
}

@keyframes blink {
   50% {
      opacity: 0.3;
   }
}

/* --- 6. ENGAGED/* Engagement Modal - Dynamic Theming */
#mod-details-dialog {
   /* Variables injected in style attribute by JS based on category */
   --accent-color: #42f566;
   /* Default boot green */
   --accent-rgb: 66, 245, 102;
   width: 90vw;
   max-width: 800px;
   background: var(--dark-010);
   border: 1px solid rgba(var(--accent-rgb), 0.3);
   box-shadow: var(--dialog-shadow);
   color: var(--color-text-primary);
   padding: 0;
   overflow: hidden;
   outline: none;
   position: fixed;
}

#mod-details-dialog::backdrop {
   background: rgba(0, 0, 0, 0.4);
   backdrop-filter: blur(5px);
}

.dialog-inner {
   padding: 60px 40px 40px;
   /* Top padding for bar */
   height: 70vh;
   overflow-y: auto;
   scrollbar-width: none;
   /* Firefox */
   position: relative;
   display: flex;
   flex-direction: column;
   gap: 20px;
   overscroll-behavior: contain;
   /* Prevent background scroll leakage */
}

.dialog-inner::-webkit-scrollbar {
   display: none;
   /* Chrome/Safari */
}

/* Scroll Progression Bar */
#scroll-progress-container {
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 4px;
   background: rgba(var(--accent-rgb), 0.05);
   z-index: 100;
}

#scroll-progress-bar {
   height: 100%;
   width: 0%;
   background: var(--accent-color);
   box-shadow: 0 0 15px var(--accent-color);
   transition: width 0.1s ease-out;
}

/* Modal Brackets - Fixed to frame */
.dialog-bracket {
   position: absolute;
   width: 20px;
   height: 20px;
   border: 2px solid var(--accent-color);
   pointer-events: none;
   z-index: 10;
}

.dialog-bracket.tl {
   top: 10px;
   left: 10px;
   border-right: none;
   border-bottom: none;
}

.dialog-bracket.tr {
   top: 10px;
   right: 10px;
   border-left: none;
   border-bottom: none;
}

.dialog-bracket.bl {
   bottom: 10px;
   left: 10px;
   border-right: none;
   border-top: none;
}

.dialog-bracket.br {
   bottom: 10px;
   right: 10px;
   border-left: none;
   border-top: none;
}

.dialog-content-header {
   border-bottom: 2px solid rgba(var(--accent-rgb), 0.3);
   padding-bottom: 25px;
   margin-bottom: 30px;
   display: flex;
   justify-content: center;
   position: relative;
}

.dialog-content-header::after {
   content: "MODULE_ENGAGED";
   position: absolute;
   bottom: -8px;
   right: 0;
   font-family: monospace;
   font-size: 0.5rem;
   background: var(--bg-base);
   padding: 0 10px;
   color: var(--accent-color);
   letter-spacing: 2px;
}

.dialog-title {
   font-size: 1.8rem;
   font-weight: 900;
   letter-spacing: 4px;
   color: var(--accent-color);
   text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.4);
}

.markdown-body {
   font-size: 0.9rem;
   line-height: 1.6;
   color: var(--color-text-secondary);
}

.markdown-body h1,
.markdown-body h2 {
   color: var(--accent-color);
   text-transform: uppercase;
   letter-spacing: 2px;
   margin-top: 30px;
   border-bottom: 1px dashed rgba(var(--accent-rgb), 0.2);
   padding-bottom: 10px;
   text-align: center;
   /* Center headers as often found in READMEs */
}

.markdown-body p {
   margin-bottom: 20px;
   line-height: 1.8;
   text-align: center;
   /* Centered for badges as seen in GitHub reference */
}

/* Tactical Images & Badges (GitHub Style Flow) */
.markdown-body img {
   max-width: 100%;
   height: auto;
   display: inline-block;
   /* Inline-block for horizontal badge flow */
   margin: 5px;
   /* Tight spacing between badges */
   vertical-align: middle;
   filter: drop-shadow(0 0 5px rgba(var(--accent-rgb), 0.1));
}

/* Specific centering for the "header" badges line */
.markdown-body p:has(img) {
   margin-top: -10px;
   margin-bottom: 30px;
}

/* Special styling for small badges to keep them inline-ish */
.markdown-body img[src*="shields.io"] {
   display: inline-block;
   margin: 5px;
   border: none;
   background: transparent;
   padding: 0;
}

/* Tactical Dividers (Scanlines) */
.markdown-body hr {
   border: none;
   height: 1px;
   background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
   margin: 40px 0;
   opacity: 0.4;
   box-shadow: 0 0 10px var(--accent-color);
}

/* Tactical Tables */
.markdown-body table {
   width: 100%;
   border-collapse: collapse;
   margin: 20px 0;
   font-family: 'Courier New', monospace;
   font-size: 0.8rem;
   background: rgba(var(--accent-rgb), 0.02);
}

.markdown-body th {
   text-align: left;
   padding: 10px;
   background: rgba(var(--accent-rgb), 0.1);
   color: var(--accent-color);
   border: 1px solid rgba(var(--accent-rgb), 0.2);
   text-transform: uppercase;
   letter-spacing: 1px;
}

.markdown-body td {
   padding: 8px 10px;
   border: 1px solid rgba(var(--accent-rgb), 0.1);
   color: var(--color-text-secondary);
}

.markdown-body tr:hover td {
   background: rgba(var(--accent-rgb), 0.05);
   color: var(--color-text-primary);
}

.markdown-body code {
   background: rgba(var(--accent-rgb), 0.1);
   color: var(--accent-color);
   padding: 2px 6px;
   font-family: monospace;
}

/* Dialog Footer */
.dialog-footer {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-top: 30px;
   padding-top: 20px;
   border-top: 1px solid rgba(var(--accent-rgb), 0.1);
}

/* Main Page Scroll Progression Sidebar */
#main-progress-container {
   position: fixed;
   top: 60px;
   /* Directly under the HUD Header */
   left: 0;
   width: 100vw;
   height: 4px;
   background: rgba(var(--accent-rgb), 0.05);
   z-index: 90;
}

#main-progress-bar {
   height: 100%;
   width: 0%;
   background: var(--accent-color);
   box-shadow: 0 0 15px var(--accent-color);
   transition: width 0.1s ease-out;
}

/* Shared HUD Button Styles */
.close-dialog-btn,
.download-source-btn,
.hud-top-btn {
   font-family: 'Segoe UI', sans-serif;
   font-size: 0.7rem;
   font-weight: 900;
   text-transform: uppercase;
   text-decoration: none;
   color: var(--accent-color);
   padding: 12px 20px;
   background: rgba(var(--accent-rgb), 0.05);
   border: 1px solid var(--accent-color);
   transition: all 0.3s;
   letter-spacing: 2px;
   cursor: pointer;
   text-align: center;
   line-height: 1;
}

.hud-top-btn {
   background: rgba(var(--accent-rgb), 0.05);
   backdrop-filter: blur(8px);
   padding: 12px 15px;
   font-size: 1rem;
   box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
   opacity: 0;
   pointer-events: none;
   transform: translateY(10px) scale(0.9);
}

.hud-top-btn:hover {
   background: var(--accent-color);
   color: var(--bg-base);
   box-shadow: 0 0 20px var(--accent-color);
   opacity: 1;
   /* Ensure visible on hover */
}

/* Match Hover Effects for Engagement Dialog Buttons */
.close-dialog-btn:hover,
.download-source-btn:hover {
   background: var(--accent-color);
   color: var(--bg-base);
   box-shadow: 0 0 20px var(--accent-color);
}

.hud-top-btn.visible {
   opacity: 1;
   pointer-events: auto;
   transform: translateY(0) scale(1);
}

/* Main Page Back to Top - Floating Fixed Positioning */
#back-to-top-main {
   position: fixed;
   bottom: 125px;
   /* Safely above the UPTIME/FLX readouts */
   right: 40px;
   z-index: 1000;
   min-width: 45px;
}

/* Popup Middle Button - Floating Absolute Positioning */
#jump-to-top-popup {
   position: absolute;
   bottom: 40px;
   /* Aligns visually with the padding/height of the dialog footer */
   left: 50%;
   transform: translateX(-50%) translateY(10px) scale(0.9);
   min-width: 45px;
   z-index: 100;
}

#jump-to-top-popup.visible {
   transform: translateX(-50%) translateY(0) scale(1);
}

/* --- RESPONSIVE MOBILE CALIBRATION (PHONE OPTIMIZATION) --- */
@media (max-width: 768px) {

   /* 1. Declutter Ambient Telemetry */
   .hud-decor-side,
   #init-status,
   #init-version {
      display: none !important;
   }

   /* Tactical Search & Filters Responsive Shrink */
   .mod-search-wrapper {
      max-width: 95vw;
      margin-top: 30px;
   }

   #mod-search {
      padding: 12px 15px 12px 40px;
      font-size: 0.75rem;
      letter-spacing: 2px;
   }

   .search-icon {
      left: 12px;
   }

   .category-filter-container {
      gap: 8px;
   }

   .filter-btn {
      font-size: 0.65rem;
      padding: 8px 12px;
      letter-spacing: 2px;
   }

   /* 2. Top Header adjustments */
   .hud-top-bar {
      padding: 0 15px;
      justify-content: center;
   }

   .is-glossy-text {
      font-size: 0.9rem;
      letter-spacing: 2px;
      text-align: center;
   }

   /* 3. Logic Cluster adjustments */
   .hud-center-cluster {
      padding: 80px 15px 30px;
   }

   /* Fix off-center alignment: Align exactly like the search bar above it */
   .stats-dashboard {
      width: 480px;
      max-width: 90vw;
      margin: 10px auto 30px !important;
      padding: 0;
      /* Remove padding that was creating an offset */
      flex-direction: column;
      align-items: center;
      gap: 15px;
      display: flex;
      /* Ensure it's active */
   }


   .stat-card {
      width: 100%;
      max-width: 100%;
      /* Fill the 90vw container */
      aspect-ratio: 3.5 / 1;
      /* Sleeker widescreen profile for mobile */
   }

   .stat-value {
      font-size: 1.5rem;
   }

   /* 4. Mod Browser & Engagement Grids */
   .mod-grid {
      grid-template-columns: 1fr;
      /* Force 1 column on phone */
      gap: 15px;
   }

   .category-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 5px;
   }

   .category-desc {
      margin-left: 0;
   }

   /* 5. Engagement Modal Scaling */
   #mod-details-dialog {
      width: 95vw;
   }

   .dialog-inner {
      padding: 40px 15px 20px;
   }

   /* Footer Button Stacking */
   .dialog-footer {
      flex-direction: column;
      gap: 15px;
      align-items: stretch;
   }

   .dialog-footer .close-dialog-btn,
   .dialog-footer .download-source-btn {
      width: 100%;
      box-sizing: border-box;
   }

   /* Adjust floating popup button so it avoids stacked footer overlaps */
   #jump-to-top-popup {
      bottom: 20px;
      left: auto;
      right: 15px;
      transform: translateY(10px) scale(0.85);
      /* Off-center and scaled */
   }

   #jump-to-top-popup.visible {
      transform: translateY(0) scale(0.85);
   }

   /* Adjust main button anchor */
   #back-to-top-main {
      bottom: 20px;
      /* Dropped down to occupy freed telemetry space */
      right: 15px;
      transform: translateY(10px) scale(0.85);
   }

   #back-to-top-main.visible {
      transform: translateY(0) scale(0.85);
   }

   /* 6. Game Sync Bar Mobile Calibration */
   .sync-status-bar {
      width: 100%;
      max-width: 100%;
      /* Match the expanded stat cards */
      padding: 10px;
      margin-top: 0px;
   }

   .sync-status-inner {
      flex-direction: column;
      gap: 4px;
      text-align: center;
   }

   .sync-label {
      font-size: 0.5rem;
      letter-spacing: 1px;
   }

   .sync-separator {
      width: 40px;
      height: 1px;
      flex-grow: 0;
      margin: 2px 0;
   }

   .sync-value {
      font-size: 0.6rem;
      letter-spacing: 0.5px;
   }
}

/* --- 7. TERMINAL MODE & SENSOR SWEEP --- */
#terminal-overlay {
   position: fixed;
   top: 0;
   left: 0;
   width: 100vw;
   height: 100vh;
   pointer-events: none;
   z-index: 10000;
   opacity: 0;
   transition: opacity 0.5s ease;
   background:
      linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.05) 50%),
      linear-gradient(90deg, rgba(255, 0, 0, 0.01), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.01));
   background-size: 100% 4px, 3px 100%;
}

.terminal-active #terminal-overlay {
   opacity: 1;
   background-color: rgba(32, 255, 64, 0.03);
   backdrop-filter: brightness(0.9) contrast(1.1);
   -webkit-backdrop-filter: brightness(0.9) contrast(1.1);
}

#terminal-overlay::after {
   content: "";
   position: absolute;
   top: 0;
   left: 0;
   width: 100%;
   height: 100%;
   background: linear-gradient(0deg, transparent 0%, rgba(var(--accent-rgb), 0.05) 50%, transparent 100%);
   background-size: 100% 400%;
   animation: scan-drift 8s linear infinite;
}

@keyframes scan-drift {
   0% {
      background-position: 0 0%;
   }

   100% {
      background-position: 0 100%;
   }
}

.hud-header-right {
   display: flex;
   align-items: center;
   gap: 20px;
}

.terminal-btn {
   background: transparent;
   border: 1px solid rgba(var(--accent-rgb), 0.3);
   color: var(--accent-color);
   padding: 8px;
   cursor: pointer;
   position: relative;
   overflow: hidden;
   transition: all 0.3s;
}

.terminal-btn:hover {
   background: rgba(var(--accent-rgb), 0.1);
   border-color: var(--accent-color);
}

.terminal-btn.active {
   background: var(--accent-color);
   color: var(--bg-base);
   box-shadow: 0 0 15px var(--accent-color);
}

@media (max-width: 768px) {
   #terminal-toggle {
      display: none !important;
   }
}

/* Sensor Spectre (Oscilloscope) Container */
.sensor-spectre {
   width: 120px;
   height: 48px;
   background: rgba(var(--accent-rgb), 0.05);
   border: 1px solid rgba(var(--accent-rgb), 0.1);
   margin-bottom: 10px;
   overflow: hidden;
   position: relative;
}

.sensor-path {
   stroke: var(--accent-color);
   stroke-width: 1.2;
   fill: none;
   filter: drop-shadow(0 0 3px var(--accent-color));
}

.sensor-text {
   font-size: 7px;
   fill: var(--accent-color);
   font-family: "Courier New", monospace;
   opacity: 0.7;
   font-weight: 900;
}

.sensor-grid {
   stroke: rgba(var(--accent-rgb), 0.05);
   stroke-width: 0.5;
}

.sensor-dot {
   fill: var(--accent-color);
   filter: drop-shadow(0 0 5px var(--accent-color));
}