:root {
  --primary-bg: #1e1e2f;
  --secondary-bg: #232336;
  --nav-bg: #1e1e2f;

  --accent-color: #ff8f32;
  --accent-hover: #ff9c45;
  --accent-glow: rgba(255, 143, 50, 0.1);

  --highlight-cyan: #39c7d9;
  --highlight-purple: #b073e1;

  --text-color: #f5f7f9;
  --text-secondary: #b1b5d2;
  --text-muted: #878ca9;

  --message-color: #b1a0d3;

  --chat-width: 320px;
  --header-height: 45px;

  --glow-orange: 0 0 12px rgba(255, 143, 50, 0.12);
  --glow-cyan: 0 0 10px rgba(57, 199, 217, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
  font-size: 13px;
}

body::before {
  content: '';
  background-image: url('./cdn/background_fainted.png');
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.025;
  /* control faintness */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  /* put behind content */
  pointer-events: none;
}

body {
  background-color: var(--primary-bg);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  position: relative;
  z-index: 0;
}

#header-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 20;
  background: var(--primary-bg);
  height: var(--header-height);
}

.hcaptcha-container {
  margin: 1rem 0;
  display: flex;
  justify-content: center;
}

.main-content {
  --padding: 20px;
  margin-right: var(--chat-width);
  margin-top: var(--header-height);
  padding-top: var(--padding);
  padding-left: var(--padding);
  padding-right: var(--padding);
  min-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  flex: 1;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.main-content.chat-hidden {
  margin-right: 0;
}

.side-menu {
  background-color: var(--nav-bg);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 50;
  position: relative;
}

/* Chat sidebar styles */
.left-menu {
  position: fixed;
  right: 0;
  top: var(--header-height);
  bottom: 0;
  width: 320px;
  z-index: 10;
  background: var(--nav-bg);
  border-left: 1px solid var(--secondary-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@media screen and (min-width: 1440px) {
  .left-menu.desktop-hidden {
    display: none !important;
  }

  .main-content {
    margin-right: var(--chat-width);
  }

  .main-content.chat-hidden {
    margin-right: 0 !important;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media screen and (min-width: 1440px) {
  .left-menu {
    right: 0;
    left: auto;
    transform: translateX(0) !important;
  }

  .left-menu.desktop-hidden {
    right: 0;
    left: auto;
    transform: translateX(100%) !important;
    pointer-events: none;
  }

  .main-content.chat-hidden {
    margin-right: 0 !important;
  }
}

@media screen and (max-width: 1440px) {
  #header-container {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  .game-history {
    width: 100% !important;
  }

  .main-content {
    margin-right: 0px !important;
    padding-bottom: 100px !important;
    /* Account for bottom bar */
  }

  /* Hide chat by default on mobile */
  .side-menu:not(.active) {
    transform: translateX(100%);
  }

  /* Active states for mobile */
  .side-menu.active {
    transform: translateX(0);
    z-index: 1001;
    height: calc(100vh - 70px);
    top: 0;
  }

  #chat_menu {
    top: 0 !important;
    /* Start from top on mobile */
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  }

  #chat_menu.active {
    transform: translateX(0) !important;
    z-index: 1001 !important;
  }

  #chat_menu.hidden {
    transform: translateX(100%) !important;
  }

  #chat_menu .side-menu {
    height: calc(100vh - 70px) !important;
    /* Account for bottom bar */
  }

  footer {
    padding-bottom: 6rem !important;
  }

  /* Prevent body scroll when chat is open */
  body.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }
}

/* Mobile Responsive Fixes */
@media (max-width: 768px) {
  :root {
    --chat-width: 280px;
    --header-height: 56px;
  }

  body {
    flex-direction: column;
    overflow-x: hidden;
  }

  #header-container {
    position: fixed;
    height: var(--header-height);
  }

  #main-container {
    margin-top: var(--header-height);
    padding: 0.5rem;
    min-height: calc(100vh - var(--header-height));
  }

  /* Header mobile fixes */
  header {
    padding: 0 0.75rem;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: initial;
  }

  header>div:first-child {
    gap: 0.5rem;
    min-width: 0;
  }

  header>div:last-child {
    gap: 0.25rem;
    flex-shrink: 0;
  }

  /* Logo adjustments */
  .logo-container {
    margin-right: 0.5rem;
  }

  .logo-container img {
    height: 24px;
  }

  /* Navigation dropdown mobile */
  .nav-dropdown-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }

  .nav-dropdown-btn span {
    font-size: 1rem;
  }

  #nav-dropdown-menu {
    left: 0;
    right: 0;
    max-width: calc(100vw - 2rem);
  }

  /* Menu items mobile */
  #header-menu-items-asdsd {
    display: none !important;
  }

  /* Buttons mobile sizing */
  .nav-menu-btn {
    padding: 0.5rem;
    font-size: 0.8rem;
  }

  .nav-menu-btn span {
    display: none;
  }

  .nav-menu-btn i {
    margin: 0;
  }

  /* Daily spin button mobile */
  #daily-spin-button {
    padding: 0.5rem;
    height: 2.5rem;
  }

  #daily-spin-button span {
    display: none;
  }

  /* Balance display mobile */
  .balance-container {
    height: 2.5rem;
    padding: 0 0.5rem;
  }

  /* Auth buttons mobile */
  #auth-buttons-container {
    height: 2.5rem;
  }

  .login-button {
    padding: 0 0.75rem;
    height: 2.5rem;
  }

  .login-button span {
    display: none;
  }

  /* User profile mobile */
  #user-profile-container {
    height: 2.5rem;
  }

  #user-profile-container .flex {
    height: 2.5rem;
    padding: 0 0.5rem;
  }

  /* Chat toggle mobile */
  #desktop-chat-toggle {
    padding: 0.5rem;
    height: 2.5rem;
  }
}

@media (max-width: 480px) {
  :root {
    --chat-width: 260px;
  }

  header {
    padding: 0 0.5rem;
  }

  .logo-container img {
    height: 20px;
  }

  /* Even more compact for very small screens */
  .nav-dropdown-btn span {
    font-size: 0.9rem;
  }

  /* Hide secondary menu items on very small screens */
  #header-menu-items-asdsd a:not(:first-child) {
    display: none;
  }

  /* Compact balance display */
  .balance-container .deposit-button {
    display: none !important;
  }
}

/* Game specific mobile fixes */
@media (max-width: 768px) {

  /* Cases page mobile */
  .cases-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .case-card {
    padding: 0.75rem;
  }

  /* Case opening mobile */
  .case-opening-container {
    padding: 0.5rem;
  }

  .case-spinner {
    height: 200px;
    margin: 1rem 0;
  }

  /* Crash game mobile */
  .crash-container {
    padding: 0.5rem;
    flex-direction: column;
  }

  .game-section {
    flex-direction: column;
  }

  .game-controls {
    order: 1;
    margin-bottom: 1rem;
  }

  .crash-game {
    order: 2;
    height: 300px;
  }

  /* Mines game mobile */
  .mines-grid {
    max-width: 300px;
    margin: 0 auto;
  }

  .mine-tile {
    height: 40px;
    font-size: 1rem;
  }

  /* Chat mobile */
  .chat-container {
    width: 100%;
    height: 400px;
    position: relative;
    transform: none;
  }

  /* Modal mobile fixes */
  .modal-content {
    width: calc(100vw - 2rem);
    max-width: none;
    margin: 1rem;
    max-height: calc(100vh - 4rem);
  }

  .modal-overlay {
    padding: 1rem;
  }

  /* Form inputs mobile */
  input[type="number"],
  input[type="text"],
  select,
  button {
    min-height: 44px;
    font-size: 16px;
    /* Prevent zoom on iOS */
  }

  /* Table responsive */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 100%;
    font-size: 0.875rem;
  }

  /* Quick modal mobile */
  .quick-modal {
    width: calc(100vw - 2rem);
    max-width: none;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    transform: none;
  }
}

/* Landscape mobile specific */
@media (max-width: 768px) and (orientation: landscape) {
  :root {
    --header-height: 48px;
  }

  #main-container {
    margin-top: var(--header-height);
  }

  /* Optimize for landscape gaming */
  .crash-game,
  .mines-container,
  .case-opening-container {
    height: calc(100vh - var(--header-height) - 2rem);
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

  /* Increase touch targets */
  button,
  .clickable,
  .mine-tile,
  .case-card {
    min-height: 44px;
    min-width: 44px;
  }

  /* Remove hover states on touch devices */
  .hover-bg:hover {
    background-color: transparent;
  }

  /* Better touch feedback */
  button:active,
  .clickable:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* Fix for viewport units on mobile */
@supports (-webkit-touch-callout: none) {
  .vh-100 {
    height: -webkit-fill-available;
  }
}

/* Game Container Styles */
.game-container {
  background: var(--secondary-bg);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.game-container:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 0 12px var(--accent-glow);
  border-color: var(--accent-glow);
}

.game-container img {
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
}

.game-container:hover img {
  transform: scale(1.05);
}

.game-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background: linear-gradient(to top,
      rgba(19, 20, 31, 0.95),
      rgba(19, 20, 31, 0));
  color: var(--text-color);
}

.game-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--text-color);
}

.game-provider {
  font-size: 12px;
  color: var(--accent-color);
  opacity: 0.9;
}

.game-stats {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(19, 20, 31, 0.85);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--accent-color);
  backdrop-filter: blur(4px);
  border: 1px solid var(--accent-glow);
  display: flex;
  align-items: center;
  gap: 4px;
}

.game-stats i {
  font-size: 10px;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px;
}

@media (max-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px;
  }
}

/* SPA Router Loading States */
.spa-loading {
  pointer-events: none;
  overflow: hidden;
}

.spa-loading .main-content {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.spa-loading::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg,
      transparent,
      var(--accent-color),
      transparent);
  z-index: 10000;
  animation: spa-loading-bar 1s ease-in-out infinite;
}

@keyframes spa-loading-bar {
  0% {
    transform: translateX(-100%);
  }

  50% {
    transform: translateX(0%);
  }

  100% {
    transform: translateX(100%);
  }
}

/* SPA Error States */
.spa-error-container {
  background: var(--secondary-bg);
  border-radius: 12px;
  border: 1px solid rgba(255, 77, 79, 0.2);
  margin: 2rem auto;
  max-width: 500px;
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}

.modal-content {
  background: var(--secondary-bg);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-title {
  color: var(--text-color);
  font-size: 1.25rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: var(--accent-color);
  color: #000;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.game-info-section {
  margin-bottom: 1.5rem;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.info-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 143, 50, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-color);
  flex-shrink: 0;
}

.info-content h3 {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.info-content p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.strategy-section {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.strategy-section h3 {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.strategy-section p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.limits-section h4 {
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

/* Page transition animations */
.main-content {
  transition: opacity 0.15s ease;
}

.spa-loading .main-content {
  opacity: 0.6;
}

/* Smooth scrolling for SPA navigation */
html {
  scroll-behavior: smooth;
}

#bg-glow-cursor {
  position: relative;
  border: 1px solid transparent;
  transition: border-color 0.2s ease;
  background: var(--primary-bg);
}

#bg-glow-cursor::after {
  content: "";
  position: absolute;
  top: calc(var(--cursor-y) - 250px);
  left: calc(var(--cursor-x) - 250px);
  background: var(--highlight-purple);
  opacity: 0;
  border-radius: 50%;
  width: 500px;
  height: 500px;
  filter: blur(999px);
  transition: opacity 0.2s ease;
}

#bg-glow-cursor:hover::after {
  opacity: 0.3;
}

/* House Edge Display Styles */
.house-edge-display {
  font-size: 14px;
  border: 1px solid rgba(255, 143, 50, 0.2);
  background: linear-gradient(135deg,
      rgba(42, 45, 63, 0.8) 0%,
      rgba(35, 38, 54, 0.8) 100%);
  transition: all 0.3s ease;
}

.house-edge-display:hover {
  border-color: rgba(255, 143, 50, 0.4);
  background: linear-gradient(135deg,
      rgba(42, 45, 63, 1) 0%,
      rgba(35, 38, 54, 1) 100%);
}

.house-edge-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 143, 50, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.house-edge-icon i {
  font-size: 14px;
}

/* Item Rarity Glow Effects */
.item-common {
  box-shadow: 0 0 15px rgba(128, 128, 128, 0.5);
  border: 1px solid rgba(128, 128, 128, 0.3);
}

.item-uncommon {
  box-shadow: 0 0 15px rgba(30, 255, 0, 0.5);
  border: 1px solid rgba(30, 255, 0, 0.3);
}

.item-rare {
  box-shadow: 0 0 15px rgba(0, 112, 221, 0.5);
  border: 1px solid rgba(0, 112, 221, 0.3);
}

.item-epic {
  box-shadow: 0 0 15px rgba(163, 53, 238, 0.5);
  border: 1px solid rgba(163, 53, 238, 0.3);
}

.item-legendary {
  box-shadow: 0 0 15px rgba(255, 165, 0, 0.5);
  border: 1px solid rgba(255, 165, 0, 0.3);
}

.item-mythic {
  box-shadow: 0 0 15px rgba(255, 20, 147, 0.5);
  border: 1px solid rgba(255, 20, 147, 0.3);
}

.item-exotic {
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.5);
  border: 1px solid rgba(255, 0, 0, 0.3);
}

/* Enhanced glow on hover */
.item-common:hover {
  box-shadow: 0 0 25px rgba(128, 128, 128, 0.8);
}

.item-uncommon:hover {
  box-shadow: 0 0 25px rgba(30, 255, 0, 0.8);
}

.item-rare:hover {
  box-shadow: 0 0 25px rgba(0, 112, 221, 0.8);
}

.item-epic:hover {
  box-shadow: 0 0 25px rgba(163, 53, 238, 0.8);
}

.item-legendary:hover {
  box-shadow: 0 0 25px rgba(255, 165, 0, 0.8);
}

.item-mythic:hover {
  box-shadow: 0 0 25px rgba(255, 20, 147, 0.8);
}

.item-exotic:hover {
  box-shadow: 0 0 25px rgba(255, 0, 0, 0.8);
}

/* Case glow effects */
.case-glow {
  position: relative;
}

.case-glow::before {
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg,
      var(--accent-color),
      rgba(255, 144, 0, 0.6),
      var(--accent-color));
  border-radius: inherit;
  z-index: -1;
  filter: blur(8px);
  opacity: 0.7;
}

.case-glow:hover::before {
  filter: blur(12px);
  opacity: 1;
}

/* Mobile optimizations for glows */
@media (max-width: 768px) {

  /* Item Rarity Glow Effects */
  .item-common {
    box-shadow: 0 0 10px rgba(128, 128, 128, 0.5);
    border: 1px solid rgba(128, 128, 128, 0.3);
  }

  .item-uncommon {
    box-shadow: 0 0 10px rgba(30, 255, 0, 0.5);
    border: 1px solid rgba(30, 255, 0, 0.3);
  }

  .item-rare {
    box-shadow: 0 0 10px rgba(0, 112, 221, 0.5);
    border: 1px solid rgba(0, 112, 221, 0.3);
  }

  .item-epic {
    box-shadow: 0 0 10px rgba(163, 53, 238, 0.5);
    border: 1px solid rgba(163, 53, 238, 0.3);
  }

  .item-legendary {
    box-shadow: 0 0 10px rgba(255, 165, 0, 0.5);
    border: 1px solid rgba(255, 165, 0, 0.3);
  }

  .item-mythic {
    box-shadow: 0 0 10px rgba(255, 20, 147, 0.5);
    border: 1px solid rgba(255, 20, 147, 0.3);
  }

  .item-exotic {
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    border: 1px solid rgba(255, 0, 0, 0.3);
  }

  /* Enhanced glow on hover */
  .item-common:hover {
    box-shadow: 0 0 15px rgba(128, 128, 128, 0.8);
  }

  .item-uncommon:hover {
    box-shadow: 0 0 15px rgba(30, 255, 0, 0.8);
  }

  .item-rare:hover {
    box-shadow: 0 0 15px rgba(0, 112, 221, 0.8);
  }

  .item-epic:hover {
    box-shadow: 0 0 15px rgba(163, 53, 238, 0.8);
  }

  .item-legendary:hover {
    box-shadow: 0 0 15px rgba(255, 165, 0, 0.8);
  }

  .item-mythic:hover {
    box-shadow: 0 0 15px rgba(255, 20, 147, 0.8);
  }

  .item-exotic:hover {
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.8);
  }

  /* Case glow effects */
  .case-glow::before {
    filter: blur(6px);
    opacity: 0.8;
  }

  .case-glow:hover::before {
    filter: blur(10px);
    opacity: 1;
  }
}
