:root {
  --bg-gradient: linear-gradient(135deg, #0a0a0a, #1a0b2e, #2d0b4e);
  --primary: #a855f7;
  --primary-glow: rgba(168, 85, 247, 0.3);
  --primary-hover: #7c3aed;
  --text-light: #f5f5f5;
  --text-muted: #9ca3af;
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --dropdown-bg: rgba(15, 10, 25, 0.98);
  --matrix-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(168, 85, 247, 0.25) #07040d;
  overflow-x: hidden;
  width: 100%;
}

html::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-track {
  background: #07040d;
}

html::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.25);
  border-radius: 10px;
}

html::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.5);
}

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, sans-serif;
  background: #07040d var(--bg-gradient) fixed !important;
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  width: 100%;
}

body.loading {
  overflow: hidden;
}

/* === PRELOADER === */
#preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #07040d;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
  transition: opacity 0.5s var(--matrix-ease);
}

.preloader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #a855f7;
  border-radius: 50%;
  box-shadow: 0 0 20px #a855f7;
  animation: preloaderPulse 1.5s infinite ease-in-out;
}

.preloader-text {
  color: #a855f7;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  opacity: 0.7;
}

/* === HEADER & NAV === */
header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 15px 40px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
  opacity: 0;
}

body.loaded header {
  animation: futuristicReveal 0.8s var(--matrix-ease) forwards;
  animation-delay: 0.1s;
}

.logo {
  justify-self: start;
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
  transition: color 0.2s ease;
}

.logo-svg {
  height: 38px;
  width: 38px;
  display: block;
  fill: currentColor;
  overflow: visible;
}

.logo-user-back {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.logo-user-front {
  transition:
    transform 0.2s ease,
    color 0.2s ease,
    filter 0.2s ease;
}

.logo:hover {
  color: var(--text-light);
}
.logo:hover .logo-user-back {
  opacity: 0.2;
}
.logo:hover .logo-user-front {
  color: var(--text-light);
  transform: translateY(-1px);
  filter: drop-shadow(0 2px 8px var(--primary));
}

.nav-menu {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 25px;
}

.nav-link {
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: var(--primary);
}

.header-right {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* === DROPDOWNS & BUTTONS === */
.lang-dropdown {
  position: relative;
  display: inline-block;
  user-select: none;
}

.dropbtn {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  padding: 9px 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 95px;
  transition: all 0.3s ease;
  line-height: 1;
}

.dropbtn:hover {
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.08);
}

.dropdown-content {
  display: none;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 8px);
  background: var(--dropdown-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  min-width: 115px;
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
  z-index: 101;
  overflow: hidden;
}

.dropdown-content a {
  color: var(--text-light);
  padding: 12px 16px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
  transition: 0.2s ease;
}

.dropdown-content a:hover {
  background: var(--primary);
  color: white;
}

.dropdown-content.show {
  display: block;
  animation: dropdownFadeIn 0.2s var(--matrix-ease) forwards;
}

.auth-container {
  display: flex;
  align-items: center;
}
.guest-zone,
.user-zone {
  display: flex;
  gap: 10px;
}

.btn-login {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: white;
  padding: 9px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15);
}

.btn-login:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.35);
  transform: translateY(-1px);
}

.btn-register {
  background: transparent;
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  padding: 9px 20px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s ease;
}

.btn-register:hover {
  border-color: var(--primary);
  background: rgba(168, 85, 247, 0.05);
  transform: translateY(-1px);
}

.avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
  object-fit: cover;
}
.avatar-img:hover {
  border-color: var(--primary);
}
.user-dropdown {
  position: relative;
  display: inline-block;
}

.hidden {
  display: none !important;
}

/* === IDLE MODAL === */
.idle-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 3, 10, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.idle-modal-content {
  background: rgba(20, 14, 36, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.25);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.8),
    0 0 40px rgba(168, 85, 247, 0.15);
  padding: 50px 40px;
  border-radius: 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: modalSlideIn 0.5s var(--matrix-ease) forwards;
}

.idle-hud-timer {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 30px auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.idle-hud-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.idle-hud-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.03);
  stroke-width: 4;
}
.idle-hud-pulse {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 276;
  stroke-dashoffset: 40;
  transform-origin: center;
  animation: hudRotate 4s linear infinite;
}

.idle-hud-display {
  font-family: monospace;
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
}

.idle-modal-content h2 {
  font-size: 26px;
  margin: 0 0 12px 0;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
}

.idle-modal-content p {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.6;
  margin: 0 0 30px 0;
}

.idle-analytics-panel {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 16px 20px;
  margin-bottom: 35px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.idle-panel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
}
.idle-panel-row span:first-child {
  color: var(--text-muted);
  font-weight: 500;
}
.idle-panel-value {
  font-family: monospace;
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: 25px;
  border-top: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-size: 13.5px;
  user-select: none;
  opacity: 0;
}

body.loaded footer {
  animation: futuristicReveal 0.8s var(--matrix-ease) forwards;
  animation-delay: 0.8s;
}

/* === ANIMATIONS === */
@keyframes preloaderPulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
}
@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes hudRotate {
  to {
    transform: rotate(360deg);
  }
}
@keyframes futuristicReveal {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    filter: blur(12px) brightness(0.7);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0) brightness(1);
  }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px;
    background: rgba(7, 4, 13, 0.7);
  }
  .logo {
    align-self: center;
    font-size: 22px;
  }
  .nav-menu {
    gap: 20px;
  }
  .nav-link {
    font-size: 14px;
  }
  .header-right {
    width: 100%;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--glass-border);
    padding-top: 16px;
  }
  .auth-container {
    flex: 1;
  }
  .guest-zone {
    width: 100%;
    gap: 8px;
  }
  .btn-login,
  .btn-register {
    flex: 1;
    padding: 11px 12px;
    font-size: 13px;
    border-radius: 12px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .dropbtn {
    height: 40px;
    padding: 0 14px;
    font-size: 13px;
    border-radius: 12px;
    min-width: 85px;
  }
  .idle-modal-overlay {
    padding: 16px;
  }
  .idle-modal-content {
    padding: 35px 24px;
    border-radius: 24px;
  }
  .idle-hud-timer {
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
  }
  .idle-hud-display {
    font-size: 20px;
  }
  .idle-modal-content h2 {
    font-size: 22px;
  }
  .idle-modal-content p {
    font-size: 14px;
    margin-bottom: 24px;
  }
  .idle-analytics-panel {
    padding: 14px 16px;
    margin-bottom: 28px;
    gap: 10px;
  }
  .idle-panel-row {
    font-size: 12.5px;
  }
  .idle-panel-value {
    font-size: 13px;
  }
}
