html, body {
  width: 100%; /* Ensure html and body take full viewport width */
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
  background: #fff;
  color: #111;
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  padding: 0;
}
header {
  background: #111;
  color: #fff;
  display: flex;
  align-items: flex-end; /* Align logo and tabs at the bottom */
  flex-direction: row;
  padding: 2rem 0 2rem 0;
  position: relative;
}
.logo-link {
  display: flex;
  align-items: flex-start;
  margin-right: 2rem;
  margin-left: 2rem;
  height: 150px; /* Increased from 140px for 10px lower alignment */
}
.logo {
  width: 150px;
  height: 150px;
  border-radius: 0;
  box-shadow: 0 16px 48px 0 rgba(0,0,0,0.32), 0 8px 16px 0 rgba(0,0,0,0.28);
  filter: drop-shadow(0 4px 16px rgba(255,255,255,0.18));
}
.tabs {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 150px; /* Increased from 140px */
  width: 100%;
  max-width: 1100px;
  margin-top: 0;
  margin-bottom: 0;
}
.tabs-inner {
  position: relative;
  height: 150px; /* 3 rows of 50px each */
  width: 100%;
  max-width: 1100px;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease-in-out;
}

/* Improved dropdown styles */
.tab-dropdown {
  display: none;
  width: calc(100% - 2rem);
  margin: 0 1rem;
  padding: 0.8rem;
  font-size: 1rem;
  border: 2px solid #111;
  border-radius: 12px;
  background-color: #fff;
  color: #111;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.tab-dropdown:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tab-dropdown option {
  padding: 8px;
  font-weight: 600;
}

/* Media query for smaller screens */
@media (max-width: 700px) {
  .tabs-inner {
    display: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab-dropdown {
    display: block;
    padding: 1.1rem 0.8rem;
    font-size: 1.15rem;
    margin: 0 1rem;
    max-width: calc(100% - 2rem);
    min-height: 48px;
  }
  
  header {
    padding: 1rem 0;
  }
  
  .logo-link {
    height: 100px;
  }
  
  .logo {
    width: 100px;
    height: 100px;
  }
}

@media (max-width: 900px) {
  .tab {
    font-size: 0.9rem;
    padding: 0 0.8rem;
  }
}

@media (max-width: 700px) {
  .tab {
    font-size: 0.8rem;
    padding: 0 0.6rem;
  }
}

.tab {
  position: absolute;
  height: 52px;
  min-height: 44px;
  width: 160px;
  /* Only visual styles below */
  background: #fff;
  color: #111;
  border: 2px solid #111;
  border-bottom: none;
  border-radius: 12px 12px 0 0 !important; /* Only top corners rounded for all tabs */
  padding: 0 1.2rem;
  cursor: pointer;
  font-weight: 600;
  transition: 
    background 0.2s ease-in-out, 
    color 0.2s ease-in-out, 
    box-shadow 0.2s ease-in-out,
    transform 0.2s ease-in-out;
  text-align: left;
  box-shadow: 0 2px 8px 0 rgba(0,0,0,0.04), 0 1px 2px 0 rgba(0,0,0,0.06);
  z-index: 1;
  display: flex;
  align-items: center;
  text-shadow: 0 2px 6px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.22);
  box-sizing: border-box;
  transform-origin: bottom;
  outline: none; /* Remove default browser outline */
}
.tab:first-child {
  margin-left: 0;
}
.tab:nth-child(7n+1) {
  margin-left: 0; /* No overlap for first tab in each row */
}
.tab:not(:nth-child(7n)) {
  margin-right: -12px;
}
.tab img {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  margin-left: -8px;
}
.tab span {
  display: inline-block;
  margin-left: 0px; /* Adjusted to prevent overlap with icon */
}
.tab.active {
  background: var(--tab-active-bg, #232323);
  color: #fff;
  border: 2px solid #111; /* Ensure border color stays black when active */
  border-bottom: none;
  z-index: 2;
  box-shadow: 0 12px 48px 0 rgba(0,0,0,0.38), 0 6px 24px 0 rgba(0,0,0,0.40);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  outline: none;
}

/* Handle both focus and active states */
.tab.active:focus {
  border-color: #111;
  outline: none;
  /* Keep the active tab's shadow */
  box-shadow: 0 12px 48px 0 rgba(0,0,0,0.38), 0 6px 24px 0 rgba(0,0,0,0.40);
}

.tab-icon {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
  margin-left: 0;
  width: 20px;
  height: 20px;
  object-fit: contain;
}
.tab-content-inner {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  background: none;
  border-radius: 0;
  box-shadow: none;
  animation: fadeIn 0.3s ease-in-out;
}
.tab-content-text {
  flex: 1 1 0;
}
.tab-content-image {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
}
.tab-content-image img {
  transition: opacity 0.3s ease-in-out;
}
.tab-content-image img[loading] {
  opacity: 0.5;
}
.main-tab-image {
  width: 180px;
  height: 180px;
  opacity: 0.75;
  border-radius: 18px;
  box-shadow: 0 8px 32px 0 rgba(0,0,0,0.22), 0 2px 8px 0 rgba(0,0,0,0.18);
  background: #fff;
  object-fit: contain;
}
@media (max-width: 1200px) {
  .tabs-inner {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}
@media (max-width: 900px) {
  .tabs-inner {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
  .tab-content-inner {
    flex-direction: column;
    align-items: stretch; /* Stretch items horizontally in column layout */
    width: 100%; /* Ensure flex container takes full width */
    box-sizing: border-box; /* Include padding and border in width */
    gap: 0; /* Remove gap on mobile */
  }
  .tab-content-image {
    justify-content: center;
    margin-top: 1.5rem;
  }
  .main-tab-image {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 900px) {
  .tab-content-inner > div { /* Target direct div children within tab-content-inner */
    max-width: 100%; /* Ensure cards don't exceed container width */
    box-sizing: border-box; /* Include padding and border in width */
  }
}

@media (max-width: 900px) {
  .tab-content-inner > div { /* Target direct div children within tab-content-inner */
    max-width: 100%; /* Ensure cards don't exceed container width */
    box-sizing: border-box; /* Include padding and border in width */
  }
}

@media (max-width: 700px) {
  .tabs-inner {
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}
@media (max-width: 600px) {
  .tabs-inner {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
}
@media (max-width: 500px) {
  .tabs-inner {
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(3, 1fr);
  }
  .tab {
    font-size: 0.85rem;
    padding: 0.4rem 0.3rem;
  }
}
main {
  min-height: 300px;
  padding: 2rem;
  /* Add a lighter center to the radial gradient for a lifted effect */
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.38) 0%, rgba(0,0,0,0) 65%, rgba(0,0,0,0.18) 100%);
  border-radius: 0 0 16px 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  margin: 0 2rem 2rem 2rem;
  box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* Only apply the texture for the kylemayer.me tab's main page */
#tab-content .tab-content-inner {
  background: none;
}
#tab-content.kylemayerme-bg .tab-content-inner {
  background: none;
}

:root {
  --kylemayer-tab-color: #b8bec5;
  --minecraft-tab-color: #b3e5fc;
  --project-tab-color-0: #dee2e6;
  --project-tab-color-1: #ced4da;
  --project-tab-color-2: #adb5bd;
  --project-tab-color-3: #6c757d;
  --project-tab-color-4: #495057;
  --project-tab-color-5: #343a40;
  --project-tab-color-6: #212529;
  --project-tab-color-7: #fff3cd;
  --project-tab-color-8: #ffeeba;
  --project-tab-color-9: #ffdf7e;
  --project-tab-color-10: #ffd966;
  --project-tab-color-11: #ffc107;
  --project-tab-color-12: #ffb300;
  --project-tab-color-13: #ff9800;
  --project-tab-color-14: #ff7043;
  --project-tab-color-15: #ff5722;
  --project-tab-color-16: #e57373;
  --project-tab-color-17: #f06292;
}

/* Improve keyboard focus styles */
.tab:focus {
  outline: none; /* Remove default browser outline */
  border-color: #111; /* Keep border black when focused */
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Add subtle shadow for focus indication */
}

/* Optimize transitions */
.tab:hover:not(.active) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Preload animation for tab content */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .tab {
    border: 2px solid currentColor;
    box-shadow: none;
  }
  
  .tab.active {
    border-color: currentColor;
    box-shadow: none;
  }
  
  .main-tab-image {
    opacity: 1;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .tab,
  .tab-content-image img,
  .tab-content-inner {
    transition: none;
    animation: none;
  }
  
  .tab:hover:not(.active) {
    transform: none;
  }
}

/* Adjust mobile breakpoint */
@media (max-width: 768px) {
  .tabs-inner {
    display: none !important;
  }
  
  .tab-dropdown {
    display: block;
  }
  
  .logo-link {
    height: 120px;
    margin: 1rem;
  }
  
  .logo {
    width: 120px;
    height: 120px;
  }
  
  header {
    padding: 1rem 0;
    flex-direction: column;
    align-items: center;
  }
  
  .tabs {
    width: 100%;
    height: auto;
    margin: 1rem 0;
  }
  
  main {
    margin: 1rem 0 !important; /* Remove all horizontal margin */
    padding: 1rem 0 !important; /* Remove all horizontal padding */
    width: 100vw; /* Set width to 100% of viewport width */
    position: relative; /* Needed for potential positioning adjustments */
    left: 50%; /* Move element to the horizontal center */
    transform: translateX(-50%); /* Adjust position to truly center */
    min-height: 200px;
  }
}

/* Additional mobile optimizations */
@media (max-width: 480px) {
  .logo-link {
    height: 100px;
    margin: 0.5rem;
  }
  
  .logo {
    width: 100px;
    height: 100px;
  }
  
  .tab-content-inner {
    padding: 0.5rem 0; /* Adjust horizontal padding for very small screens */
  }
  
  main {
    margin: 0.5rem 0 !important; /* Remove all horizontal margin */
    padding: 0.5rem 0 !important; /* Remove all horizontal padding */
    width: 100vw; /* Set width to 100% of viewport width */
    position: relative; /* Needed for potential positioning adjustments */
    left: 50%; /* Move element to the horizontal center */
    transform: translateX(-50%); /* Adjust position to truly center */
    min-height: 120px;
  }
  
  h2 {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
  }
}
