/* Global design tokens */
:root {
  --dt-font-base: 'Cinzel', serif;
  --dt-font-ui: 'Cinzel', serif;
  --dt-color-text: #f9fafb;
  --dt-color-muted: #d1d5db;
  --dt-color-heading: #fcd34d;
  --dt-color-accent: #f59e0b;
  --dt-color-accent-strong: #b45309;
  --dt-surface-1: rgba(31, 41, 55, 0.82);
  --dt-surface-2: rgba(55, 65, 81, 0.72);
  --dt-surface-3: rgba(17, 24, 39, 0.9);
  --dt-border-soft: rgba(251, 191, 36, 0.28);
  --dt-border-strong: rgba(251, 191, 36, 0.55);
  --dt-ring: rgba(252, 211, 77, 0.45);
  --dt-shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.35);
  --dt-shadow-strong: 0 14px 30px rgba(0, 0, 0, 0.45);
}

html {
  scroll-behavior: smooth;
}

::selection {
  background: rgba(245, 158, 11, 0.35);
  color: #fff;
}

/* Premium scrollbar styling */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.55) rgba(17, 24, 39, 0.65);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: rgba(17, 24, 39, 0.65);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.8), rgba(180, 83, 9, 0.78));
  border-radius: 999px;
  border: 2px solid rgba(17, 24, 39, 0.7);
}

body {
  font-family: var(--dt-font-base) !important;
  color: var(--dt-color-text);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Add some depth to cards */
.rounded-lg {
    box-shadow: var(--dt-shadow-soft);
    border-radius: 10px;
}

/* Simple animation for resource cards */
.bg-gray-700:hover {
    transform: translateY(-2px);
    transition: transform 0.3s ease;
}

html, body {
			margin: 0;
			padding: 0;
			overflow-x: hidden;
		}

		body {
			font-family: var(--dt-font-base);
			background:
				linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55)),
				url('../assets/backgrounds/background2.png') center center no-repeat;
			background-size: cover;
			background-attachment: fixed;
			min-height: 100vh;
			color: #fff;
		}

		/* Prevent layout shifts */
		* {
			box-sizing: border-box;
		}

		/* Headings with slight text shadow & letter spacing */
		h1, h2, h3 {
			text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
			letter-spacing: 1px;
      color: var(--dt-color-heading);
		}

    h4, h5, h6 {
      color: #f8d27a;
      letter-spacing: 0.4px;
    }

		/* Make sections slightly transparent so background is more visible */
		.semi-transparent {
			background-color: var(--dt-surface-1) !important;
      border: 1px solid var(--dt-border-soft) !important;
      border-radius: 10px;
			backdrop-filter: blur(4px);
      box-shadow: var(--dt-shadow-soft);
		}

		/* More see-through for inner cards */
		.inner-card {
			background-color: var(--dt-surface-2) !important;
      border: 1px solid rgba(148, 163, 184, 0.25) !important;
      border-radius: 8px;
			backdrop-filter: blur(2px);
		}

    /* Cross-page compatibility aliases for legacy page classes */
    .dark-card,
    .inventory-container,
    .info-section {
      background: var(--dt-surface-1) !important;
      border: 1px solid var(--dt-border-soft) !important;
      border-radius: 10px;
      box-shadow: var(--dt-shadow-soft);
    }

    .dark-card h2,
    .dark-card h3,
    .dark-card h4,
    .dark-card h5,
    .dark-card h6,
    .inventory-container h2,
    .info-section h2 {
      color: var(--dt-color-heading);
    }

    .flash-message {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      border-radius: 10px;
      padding: 0.75rem 1rem;
      margin-bottom: 1rem;
      color: #fff;
      border: 1px solid rgba(255, 255, 255, 0.12);
      backdrop-filter: blur(3px);
      box-shadow: var(--dt-shadow-soft);
    }

    .flash-success {
      background: linear-gradient(135deg, rgba(21, 128, 61, 0.72), rgba(22, 163, 74, 0.58));
    }

    .flash-error {
      background: linear-gradient(135deg, rgba(127, 29, 29, 0.8), rgba(185, 28, 28, 0.62));
    }

    .tab-btn {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.2);
      border-radius: 8px;
      color: #fff;
      font-weight: 700;
      transition: all 0.2s ease;
    }

    .tab-btn:hover {
      background: rgba(255, 255, 255, 0.18);
      transform: translateY(-1px);
    }

    .tab-btn.active {
      background: rgba(245, 158, 11, 0.18);
      border-color: var(--dt-border-strong);
      color: #fde68a;
    }

    .btn-theme-primary {
      background: linear-gradient(180deg, #f59e0b, #b45309);
      color: #fff;
      border: 1px solid rgba(251, 191, 36, 0.65);
      border-radius: 8px;
      font-weight: 700;
      box-shadow: 0 6px 14px rgba(180, 83, 9, 0.32);
    }

    .btn-theme-primary:hover {
      filter: brightness(1.07);
      transform: translateY(-1px);
    }

    /* Global section/card polish used by rankings, pve and other pages */
    .bg-gray-800.bg-opacity-75.backdrop-blur-sm,
    .bg-gray-800.bg-opacity-80.backdrop-blur-sm,
    .bg-gray-900.bg-opacity-70.backdrop-blur-sm {
      background: linear-gradient(160deg, rgba(31, 41, 55, 0.88), rgba(17, 24, 39, 0.9)) !important;
      border: 1px solid var(--dt-border-soft) !important;
      border-radius: 12px !important;
      box-shadow: var(--dt-shadow-soft);
    }

    /* Better table readability across ranking and history pages */
    table {
      border-collapse: separate;
      border-spacing: 0;
      border-radius: 10px;
      overflow: hidden;
    }

    th {
      color: #fde68a;
      letter-spacing: 0.4px;
      font-weight: 700;
    }

    tbody tr {
      transition: background-color 0.2s ease, transform 0.2s ease;
    }

    tbody tr:hover {
      background-color: rgba(55, 65, 81, 0.45);
    }

    /* High-quality form controls for auth + game forms */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
      background-color: rgba(17, 24, 39, 0.8);
      border: 1px solid rgba(148, 163, 184, 0.35);
      color: #f9fafb;
      border-radius: 8px;
      transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    }

    input:focus,
    textarea:focus,
    select:focus {
      outline: none;
      border-color: var(--dt-border-strong);
      box-shadow: 0 0 0 3px var(--dt-ring);
      background-color: rgba(17, 24, 39, 0.92);
    }

    /* Buttons feel consistent without breaking page-specific colors */
    button,
    .btn,
    input[type="submit"] {
      border-radius: 8px;
      transition: transform 0.18s ease, filter 0.18s ease, box-shadow 0.18s ease;
    }

    button:hover,
    .btn:hover,
    input[type="submit"]:hover {
      transform: translateY(-1px);
      filter: brightness(1.04);
    }

    button:active,
    .btn:active,
    input[type="submit"]:active {
      transform: translateY(0);
    }

    /* Generic content shell used by auth/landing pages */
    .medieval-border,
    .content-card,
    .login-wrapper > div,
    .register-wrapper > div {
      border-radius: 12px !important;
      border-color: rgba(184, 134, 11, 0.45) !important;
      box-shadow: var(--dt-shadow-soft);
    }

    /* Keep motion tasteful and accessible */
    @media (prefers-reduced-motion: reduce) {
      *,
      *::before,
      *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
      }
    }
		
		
		
		
		/* Floating Sidebar CSS */
		.floating-sidebar {
		  position: fixed;
		  top: 50%;
		  right: 0;
		  transform: translateY(-50%);
		  background: rgba(31, 41, 55, 0.95); /* dark semi-transparent */
		  padding: 10px;
		  border-radius: 8px 0 0 8px;
		  z-index: 1000;
		  width: 220px;
		  font-family: 'Cinzel', serif;
		  color: #fff;
		  box-shadow: -2px 2px 8px rgba(0,0,0,0.5);
		  transition: right 0.3s ease;
		}

		/* When collapsed, hide off screen */
		.floating-sidebar.collapsed {
		  right: -190px; /* Adjust to hide sidebar while leaving toggle visible */
		}

		/* Sidebar Header */
		.floating-sidebar .sidebar-header {
		  display: flex;
		  align-items: center;
		  justify-content: space-between;
		  margin-bottom: 10px;
		  border-bottom: 1px solid #555;
		  padding-bottom: 5px;
		}

		.floating-sidebar .sidebar-header .sidebar-title {
		  font-size: 1rem;
		  font-weight: bold;
		}

		.floating-sidebar .sidebar-header .toggle-btn {
		  cursor: pointer;
		  font-size: 1.2rem;
		  background: #444;
		  padding: 2px 6px;
		  border-radius: 4px;
		  transition: background 0.2s ease;
		}

		.floating-sidebar .sidebar-header .toggle-btn:hover {
		  background: #666;
		}

		/* Sidebar Content */
		.floating-sidebar .resource-item {
		  display: flex;
		  align-items: center;
		  margin-bottom: 8px;
		}

		.floating-sidebar .resource-item img {
		  width: 24px;
		  height: 24px;
		  margin-right: 6px;
		}

		.floating-sidebar .resource-item .resource-name {
		  font-size: 0.85rem;
		  margin-right: 4px;
		  color: #ccc;
		}

		.floating-sidebar .resource-item .resource-value {
		  font-size: 0.85rem;
		  font-weight: bold;
		  color: #FDE047;
		}
		
		/* Mobile Responsive Styles */
		@media (max-width: 768px) {
		  /* General layout fixes */
		  .container {
			padding-left: 10px;
			padding-right: 10px;
		  }
		  
		  /* All sections need more breathing room */
		  section {
			margin-bottom: 15px;
			padding: 15px;
		  }
		  
		  /* Make most grid items full width on mobile */
		  .grid {
			grid-template-columns: 1fr !important;
		  }
		  
		  /* Fix buttons to be more touch-friendly */
		  button, 
		  .btn, 
		  a.btn, 
		  input[type="submit"] {
			min-height: 44px;
			padding: 8px 16px;
		  }
		  
		  /* Adjust font sizes for readability */
		  h2 {
			font-size: 1.5rem !important;
		  }
		  
		  /* Adjust the floating sidebar */
		  .floating-sidebar {
			right: -190px; /* Default to collapsed state on mobile */
			box-shadow: -3px 3px 10px rgba(0,0,0,0.7);
		  }
		  
		  /* Kingdom Level section - 2-column resource display */
		  section:first-of-type .grid-cols-6 {
			grid-template-columns: repeat(2, 1fr) !important;
		  }
		  
		  /* Resource cards more compact */
		  section:first-of-type .grid-cols-6 > div {
			margin-top: 25px;
		  }
		  
		  /* Full-width forms */
		  form {
			width: 100%;
		  }
		  
		  /* Table adjustments */
		  table {
			display: block;
			overflow-x: auto;
		  }
		  
		  /* Building tabs on mobile */
		  #buildingTabs {
			flex-wrap: wrap;
		  }
		  
		  #buildingTabs li {
			margin-bottom: 5px;
		  }
		  
		  /* Army section adjustments */
		  .army-statistics {
			overflow-x: auto;
		  }
		  
		  /* Adjustments for modals */
		  #queueExpansionModal > div,
		  #speedupModal > div,
		  #trainingSpeedupModal > div,
		  #disbandUnitModal > div,
		  #welcomeModal > div {
			max-width: 90%;
			width: 90%;
		  }
		}

		/* Even smaller devices */
		@media (max-width: 480px) {
		  section:first-of-type .grid-cols-6 {
			grid-template-columns: 1fr !important;
		  }
		  
		  #buildingTabs button {
			padding: 8px;
		  }
		  
		  #buildingTabs button img {
			width: 18px;
			height: 18px;
		  }
		  
		  #buildingTabs button span {
			font-size: 12px;
		  }
		}
		
		/* Medieval theme styles for daily login system */
		#dailyLoginModal .font-serif {
		  font-family: 'Cinzel', serif;
		}

		#dailyLoginModal {
		  font-family: 'Cinzel', serif;
		}

		#dailyLoginCalendar .aspect-square {
		  position: relative;
		  padding-bottom: 100%;
		  height: 0;
		  overflow: hidden;
		}

		#dailyLoginCalendar .aspect-square > * {
		  position: absolute;
		  top: 0;
		  left: 0;
		  width: 100%;
		  height: 100%;
		  display: flex;
		  flex-direction: column;
		  align-items: center;
		  justify-content: center;
		}
		
		/* Mobile responsiveness for daily login modal */
		@media (max-width: 768px) {
		  /* Ensure the modal is scrollable on small screens */
		  #dailyLoginModal {
			align-items: flex-start;
			padding-top: 2rem;
			padding-bottom: 2rem;
		  }
		  
		  /* Make cell sizes appropriate for touch */
		  #dailyLoginCalendar .aspect-square {
			min-height: 40px;
			min-width: 40px;
		  }
		  
		  /* Make day cells clickable with padding */
		  #dailyLoginCalendar [data-day] {
			padding: 4px;
			cursor: pointer;
		  }
		  
		  #dailyLoginModal h3 {
			font-size: 1.25rem;
		  }
		  
		  #dailyLoginModal h4 {
			font-size: 1rem;
		  }
		  
		  #dailyLoginModal .grid-cols-2 {
			grid-template-columns: 1fr;
		  }
		  
		  #dailyLoginCalendar {
			margin-bottom: 1rem;
		  }
		  
		  #dailyLoginModal .aspect-square {
			min-height: 36px;
		  }
		  
		  #dailyRewardInfo .flex-wrap {
			justify-content: space-around;
		  }
		  
		  /* Ensure claim button is large enough for touch */
		  #claimRewardBtn {
			min-height: 60px;
			margin-top: 1rem;
			margin-bottom: 1rem;
			font-size: 1.25rem;
		  }
		}

		@media (max-width: 480px) {
		  #dailyLoginModal {
			padding: 0.5rem;
		  }
		  
		  #dailyLoginCalendar .text-xs {
			font-size: 0.65rem;
		  }
		  
		  #dailyLoginCalendar .text-sm {
			font-size: 0.75rem;
		  }
		}
		
		header {
    transition: all 0.3s ease;
  }
  .header-scrolled {
    padding-top: 0.35rem !important;
    padding-bottom: 0.35rem !important;
    background-color: rgba(17, 24, 39, 0.95);
  }
  .header-scrolled img {
    width: 2.25rem;
    height: 2.25rem;
    transition: all 0.3s ease;
  }
  .compact-nav {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
  .compact-nav i {
    margin-right: 0.25rem;
  }
  /* Dropdown styles */
  .dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    width: 12rem;
    background-color: #1f2937; /* gray-800 */
    border: 1px solid #374151; /* gray-700 */
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 50;
    overflow: hidden;
    transition: all 0.2s ease;
  }
  .dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #e5e7eb; /* gray-200 */
    font-size: 0.75rem;
    transition: all 0.15s ease;
  }
  .dropdown-item:hover {
    background-color: #374151; /* gray-700 */
  }
  .dropdown-item i {
    margin-right: 0.5rem;
  }
  .dropdown-divider {
    border-top: 1px solid #374151; /* gray-700 */
    margin: 0.25rem 0;
  }
  
  .milestone-preview {
    display: none;
    position: absolute;
    left: -50px; /* Adjusted to center larger preview */
    bottom: 100%;
    margin-bottom: 8px;
    z-index: 9999;
    width: 300px; /* Increased from 200px */
  }
  
  .milestone-name:hover .milestone-preview {
    display: block;
  }
  
  .milestone-preview img {
    width: 100%;
    height: auto;
    max-height: 200px; /* Added max height */
    object-fit: cover;
  }
  
  .milestone-preview .preview-title {
    font-size: 16px; /* Increased from default */
    padding: 5px 0;
  }
  
  .pointer {
    position: absolute;
    width: 12px; /* Slightly larger pointer */
    height: 12px;
    background: #111827;
    border-right: 1px solid #b45309;
    border-bottom: 1px solid #b45309;
    left: 70px; /* Adjusted to align with the wider preview */
    bottom: -6px;
    transform: rotate(45deg);
  }
  
  @media (max-width: 768px) {
  /* Army statistics grid scrollable on mobile */
  .army-stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr)) !important;
    overflow-x: auto;
    padding-bottom: 10px;
    gap: 8px;
    scrollbar-width: thin;
  }
  
  /* Unit card adjustments */
  .unit-card-content {
    flex-direction: column;
    text-align: center;
  }
  
  .unit-image {
    margin-right: 0;
    margin-bottom: 10px;
    width: 60px;
    height: 60px;
  }
  
  .unit-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 40px;
  }
  
  /* Stats container for unit cards */
  .unit-stats-container {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  
  .unit-stat {
    margin: 2px !important;
    font-size: 0.85rem;
  }
  
  /* Footer alignment in unit cards */
  .unit-footer {
    flex-direction: column;
    gap: 8px;
    align-items: center;
  }
  
  .unit-footer button {
    width: 100%;
    padding: 8px;
    font-size: 0.9rem;
  }
  
  /* Army composition adjustments */
  .composition-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  
  .composition-unit-name {
    width: 100%;
    margin-bottom: 4px;
  }
  
  .composition-bar {
    width: 100%;
    margin: 0;
  }
  
  .composition-value {
    width: 100%;
    text-align: left;
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
  }
  
  /* Training form adjustments */
  .cost-requirements-grid {
    grid-template-columns: 1fr !important;
  }
  
  .time-preview {
    text-align: left;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  
  .time-preview p:first-child {
    justify-content: flex-start;
  }
  
  #preview-afford {
    justify-content: flex-start;
  }
  
  .quantity-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .quantity-buttons button {
    padding: 10px 0;
  }
  
  /* Make select options more readable on mobile */
  #unit option {
    font-size: 14px;
    padding: 8px;
  }
  
  /* Increase touch target sizes */
  input[type="number"],
  select,
  button[type="submit"] {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  /* Even smaller screens */
  .army-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Unified navigation style across all pages */
header nav ul li > a,
header nav ul li > button {
  background: linear-gradient(180deg, rgba(55, 65, 81, 0.95), rgba(31, 41, 55, 0.95)) !important;
  border: 1px solid rgba(148, 163, 184, 0.32) !important;
  border-radius: 8px !important;
  color: #f9fafb !important;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.25);
}

header nav ul li > a:hover,
header nav ul li > button:hover {
  background: linear-gradient(180deg, rgba(75, 85, 99, 0.96), rgba(31, 41, 55, 0.96)) !important;
  border-color: rgba(251, 191, 36, 0.4) !important;
}

header nav ul li a[href*="donate.php"] {
  background: linear-gradient(180deg, #f59e0b, #b45309) !important;
  border-color: rgba(251, 191, 36, 0.7) !important;
  color: #fff !important;
}

#mobileMenuDropdown a {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
}


