/* --- MODERN SPECIFICATION STYLINGS --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-main: #060a13;
  --panel-glass: rgba(17, 24, 39, 0.55);
  --panel-border: rgba(0, 229, 255, 0.15);
  --neon-cyan: #00e5ff;
  --neon-glow: rgba(0, 229, 255, 0.35);
  --text-primary: #f3f4f6;
  --text-muted: #9ca3af;
}

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg-main);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.04) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(147, 51, 234, 0.04) 0%, transparent 40%);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  min-height: 100vh;
}

/* --- HIGH-END GLASS HEADER --- */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  background: rgba(6, 10, 19, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* --- BRAND DROPDOWN DRAWER SYSTEM --- */
.brand-dropdown-wrapper {
  position: relative;
  display: inline-block;
  cursor: pointer;
  padding-bottom: 10px;
}

.logo {
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 30%, var(--neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.dropdown-arrow {
  font-size: 10px;
  color: var(--text-muted);
  -webkit-text-fill-color: var(--text-muted);
  transition: transform 0.3s ease, color 0.3s ease;
}

.brand-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  width: 260px;
  background: #0d0f14;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 500;
  text-align: left;
}

.brand-dropdown-wrapper:hover .brand-dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.brand-dropdown-wrapper:hover .dropdown-arrow {
  transform: rotate(180deg);
  color: var(--neon-cyan);
  -webkit-text-fill-color: var(--neon-cyan);
}

.dropdown-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dropdown-links li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  color: #9ca3af;
  transition: all 0.2s ease;
  user-select: none;
}

.dropdown-links li .link-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.dropdown-links li:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

.badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge.updated {
  background: rgba(212, 175, 55, 0.1);
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.15);
}

/* --- ADMIN PANEL ROUTER TOGGLE BUTTON --- */
.brand-container #adminPanelBtn {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  background: rgba(0, 229, 255, 0.06);
  color: var(--neon-cyan);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  transition: all 0.3s ease;
}

.brand-container #adminPanelBtn:hover {
  background: rgba(0, 229, 255, 0.15);
  box-shadow: 0 0 12px var(--neon-glow);
  transform: translateY(-1px);
}

/* --- PREMIUM INPUTS & SEARCH --- */
input {
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: white;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: all 0.3s ease;
}

input:focus {
  border-color: var(--neon-cyan);
  background: rgba(0, 229, 255, 0.02);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.1);
}

/* --- USER PROFILES --- */
.user-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.user-profile.is-admin {
  background: #090e1a !important;
  border: 1.5px solid #d4af37 !important;
  animation: adminGlowPulse 2.5s infinite alternate ease-in-out;
}

.user-profile.is-admin .user-name {
  color: #ffd700 !important;
  font-weight: bold;
}

.admin-glow-text {
  color: #ffd700 !important;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.user-profile.is-admin #userProfileIcon {
  display: inline-block;
  font-size: 15px;
  animation: crownFloat 2s infinite ease-in-out;
  transform-origin: bottom center;
}

@keyframes adminGlowPulse {
  0% {
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.25), 
                inset 0 0 4px rgba(255, 215, 0, 0.1);
    border-color: #cb9b2b !important;
  }
  100% {
    box-shadow: 0 0 22px rgba(255, 204, 0, 0.65), 
                inset 0 0 10px rgba(255, 204, 0, 0.3);
    border-color: #fff275 !important;
  }
}

@keyframes crownFloat {
  0% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(6deg) scale(1.08); }
  100% { transform: translateY(0) rotate(0deg); }
}

/* --- BUTTONS --- */
button {
  padding: 12px 24px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #00f0ff 0%, #00b0ff 100%);
  color: #030712;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.25);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.4);
  filter: brightness(1.1);
}

button:active { transform: translateY(0); }

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-radius: 50%;
  border-top-color: #030712; 
  animation: buttonSpinAnimation 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes buttonSpinAnimation {
  to { transform: rotate(360deg); }
}

/* --- GRID SECTIONS --- */
section { padding: 40px 32px 20px 32px; }

section h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

#gamesGrid, #featuredRow {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  padding: 0;
}

/* --- PREMIUM GAME TILES --- */
.card {
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px; 
  padding: 16px;       
  box-sizing: border-box;
  display: flex;         
  flex-direction: column;
  align-items: center;   
  gap: 12px;            
  width: 100%;           
  cursor: pointer;         
  user-select: none;        
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover {
  transform: translateY(-6px) scale(1.02); 
  background: rgba(17, 24, 39, 0.85);
  border-color: rgba(0, 229, 255, 0.3);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 229, 255, 0.05);
}

.gameImage-container {
  width: 100%;
  aspect-ratio: 16 / 10; 
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden; 
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.gameImage {
  width: 100%;
  height: 100%;
  object-fit: cover;   
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover .gameImage { transform: scale(1.06); }

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  text-align: center;   
  margin: 4px 0 0 0;   
}

/* --- DOCKABLE OVERLAY MODALS --- */
#adminPanel, #authModal {
  position: fixed; inset: 0;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex; justify-content: center; align-items: center; z-index: 9999;
}

.admin-content, .login-content {
  background: #0d1321; 
  padding: 40px; 
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08); 
  width: 90%; 
  max-width: 420px;
  max-height: 85vh; 
  overflow-y: auto; 
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 229, 255, 0.03);
  animation: modalScaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.admin-content input, .login-content input {
  width: 100%; 
  box-sizing: border-box; 
  margin-bottom: 16px;
  padding: 14px; 
  border-radius: 12px; 
  background: rgba(255, 255, 255, 0.03);
  color: white; 
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-checkbox-label {
  display: flex; align-items: center; gap: 10px; margin: 20px 0;
  cursor: pointer; font-size: 14px; color: var(--text-muted); user-select: none;
}

.admin-checkbox-label input { width: auto; margin: 0; }
.admin-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.admin-actions button { width: 100%; padding: 14px; border-radius: 12px; }

/* --- SUBMENU DRAWERS --- */
.admin-game-selector-container {
  background: rgba(0, 0, 0, 0.2); border-radius: 14px; padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05); margin-top: 16px;
}

.admin-game-list {
  max-height: 180px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}

.admin-game-list-item {
  background: rgba(255, 255, 255, 0.03); padding: 12px 16px; border-radius: 10px;
  cursor: pointer; display: flex; justify-content: space-between;
  align-items: center; font-size: 13px; border: 1px solid transparent;
  text-align: left;
  transition: all 0.2s ease;
}

.admin-game-list-item:hover { background: rgba(255, 255, 255, 0.08); }
.admin-game-list-item.active { background: rgba(0, 229, 255, 0.08); border-color: rgba(0, 229, 255, 0.4); }

.menu-nav-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
  color: white !important; font-size: 14px; font-weight: 500; margin-top: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2) !important;
}

.btn-edit-details { background: linear-gradient(135deg, #f59e0b, #d97706) !important; color: white !important; }
.btn-toggle-featured { background: linear-gradient(135deg, #eab308, #ca8a04) !important; color: #030712 !important; }
.btn-delete { background: linear-gradient(135deg, #ef4444, #dc2626) !important; color: white !important; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2) !important; }

.hidden { display: none !important; }

/* --- TOAST NOTIFICATIONS --- */
#toastContainer {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 12px; z-index: 10000; pointer-events: none;
}

.toast {
  background: rgba(17, 24, 39, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: white; padding: 14px 24px; border-radius: 14px;
  font-weight: 600; font-size: 14px; 
  box-shadow: 0 10px 25px rgba(0,0,0,0.5), 0 0 1px rgba(255,255,255,0.1);
  transform: translateY(-120%) scale(0.9); opacity: 0; pointer-events: auto;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.toast.show { transform: translateY(0) scale(1); opacity: 1; }
.toast.error { border-top: 3px solid #ef4444; }
.toast.success { border-top: 3px solid #10b981; }

/* --- CUSTOM CONFIRMATION MODAL --- */
#customConfirmModal {
  position: fixed; inset: 0;
  background: rgba(3, 7, 18, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex; justify-content: center; align-items: center; z-index: 10001; 
}

.confirm-content {
  background: #0d1321; padding: 32px; border-radius: 20px;
  border: 1px solid rgba(239, 68, 68, 0.25); width: 90%; max-width: 360px;
  text-align: center; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.confirm-content h3 { color: #ef4444; margin-top: 0; font-size: 18px; margin-bottom: 12px; font-weight: 600; }
.confirm-content p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
.confirm-actions { display: flex; gap: 12px; justify-content: center; }
.confirm-actions button { flex: 1; padding: 12px; font-size: 14px; border-radius: 10px; }

@keyframes modalScaleIn {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* --- GAME VIEW PANEL SYSTEM --- */
#gameViewer {
  position: fixed; inset: 0; background: #000; z-index: 999; display: none; 
}

#gameViewer[style*="display: flex"], #gameViewer:fullscreen {
  display: flex !important; flex-direction: column !important;
  width: 100vw !important; height: 100vh !important;
  position: fixed !important; inset: 0 !important;
}

#viewerTop {
  position: absolute; top: 0; right: 0; left: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: rgba(6, 10, 19, 0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 10; transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#viewerTop.collapsed { transform: translateY(-100%); }
#gameTitle { flex: 1; font-weight: 600; font-size: 16px; color: #fff; }
#hideBarBtn { margin: 0 auto; background: rgba(255, 255, 255, 0.05); color: white; border: 1px solid rgba(255, 255, 255, 0.08); }
#hideBarBtn:hover { background: rgba(255, 255, 255, 0.15); }
.control-actions { flex: 1; display: flex; justify-content: flex-end; gap: 12px; }
.control-actions button { background: rgba(255, 255, 255, 0.05); color: white; border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: none; }
.control-actions button:hover { background: rgba(255, 255, 255, 0.15); }
#gameFrame { width: 100%; height: 100%; border: none; background: #000; }

/* FORCE HIDE HEADER BAR ON BROWSER EXCLUSIVELY */
[data-mode="browser"] #viewerTop {
  display: none !important;
}

/* Wrapper alignment space */
.mini-control-wrapper {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 101;
  display: inline-block;
  pointer-events: auto;
}

#miniShowBtn {
  position: relative; top: auto; right: auto; 
  width: 36px; height: 36px; background: rgba(6, 10, 19, 0.8) !important;
  color: var(--neon-cyan) !important; border: 1px solid rgba(0, 229, 255, 0.2) !important;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-radius: 50% !important; display: flex; align-items: center; justify-content: center;
  font-size: 14px; z-index: 9; opacity: 0; pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
  transition: all 0.3s ease;
}
#miniShowBtn:hover { transform: scale(1.1); background: rgba(6, 10, 19, 0.95) !important; border-color: var(--neon-cyan) !important; }

/* Trigger configurations to clear up browser visibility defaults */
#gameViewer:has(#viewerTop.collapsed) #miniShowBtn,
[data-mode="browser"] #miniShowBtn { 
  opacity: 1 !important; 
  pointer-events: auto !important;
}

/* CLICK UNBLOCKER FIXES */
#gameViewer:not(:has(#viewerTop.collapsed)) .mini-control-wrapper {
  pointer-events: none !important;
}

/* CRITICAL LAYER FIX WITH BROWSER MODE EXCLUSION OVERRIDE */
#gameViewer:not(:has(#viewerTop.collapsed)):not([data-mode="browser"]) #miniShowBtn {
  opacity: 0 !important;
  pointer-events: none !important;
}

/* FORCE EXPLICIT VISIBILITY ON BROWSER PROFILE ACTIVE SESSIONS */
#gameViewer[data-mode="browser"] #miniShowBtn {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* --- BROWSER DYNAMIC HOVER MENU --- */
.viewer-hover-menu {
  display: block !important; 
  position: absolute;
  top: 100%;
  right: 0;
  background: #0d0f14;
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 14px;
  padding: 4px 0; 
  min-width: 150px; 
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  z-index: 501;
  text-align: left;
  
  opacity: 0;
  visibility: hidden;
  transform: translateY(2px);
  transition: opacity 0.2s ease 1s, transform 0.2s ease 1s, visibility 0s linear 1.3s;
}

/* Invisible bridge to catch the mouse cursor seamlessly */
.viewer-hover-menu::before {
  content: '';
  position: absolute;
  top: -20px;      
  left: -20px;     
  right: -20px;
  height: 20px;    
  background: transparent;
}

.viewer-hover-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
  z-index: 502;
}

.viewer-hover-menu li {
  padding: 8px 14px; 
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px; 
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.viewer-hover-menu li:hover {
  background: rgba(255, 255, 255, 0.04);
  color: #ffffff;
}

/* --- CONDITIONAL MOVEMENT & HOVER BEHAVIORS FOR BROWSER ONLY --- */
#gameViewer[data-mode="browser"] .mini-control-wrapper {
  right: auto !important;
  left: 20px !important;
  padding-top: 2px; 
  padding-bottom: 20px; 
  pointer-events: auto !important;
}

#gameViewer[data-mode="browser"] .viewer-hover-menu {
  right: auto !important;
  left: 0 !important;
  margin-top: -8px; /* Pulled all the way up close to the + trigger */
}

#gameViewer[data-mode="browser"] .mini-control-wrapper:hover .viewer-hover-menu {
  opacity: 1 !important;
  visibility: visible !important;
  transform: translateY(0) !important;
  transition: opacity 0.15s ease 0s, transform 0.15s ease 0s, visibility 0s linear 0s !important;
}

/* --- ARCADE THEMED LOADING SYSTEM STYLINGS --- */
#loading {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #060a13;
  z-index: 50;
}

.arcade-spinner {
  width: 55px;
  height: 55px;
  border: 4px solid rgba(0, 229, 255, 0.08);
  border-left-color: var(--neon-cyan);
  border-right-color: #f59e0b;
  border-radius: 50%;
  animation: arcadeRotate 1s linear infinite;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.45);
}

.arcade-loading-text {
  margin-top: 18px;
  font-family: monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 229, 255, 0.7);
  letter-spacing: 3px;
  animation: arcadePulse 1.6s ease-in-out infinite;
}

@keyframes arcadeRotate {
  100% { transform: rotate(360deg); }
}

@keyframes arcadePulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* --- GAME MODE HOVER & POSITIONING SAFETY CONTROLS OVERRIDES --- */
#gameViewer[data-mode="game"] .mini-control-wrapper,
#gameViewer:not([data-mode]) .mini-control-wrapper {
  right: 20px !important;
  left: auto !important;
}

#gameViewer[data-mode="game"] .mini-control-wrapper:hover .viewer-hover-menu,
#gameViewer:not([data-mode]) .mini-control-wrapper:hover .viewer-hover-menu {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#gameViewer[data-mode="game"] #miniShowBtn,
#gameViewer:not([data-mode]) #miniShowBtn {
  cursor: pointer !important;
}