* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    font-family: 'Arial', sans-serif;
    background: #ffffff;
    overflow: hidden;
    cursor: default;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    /* Enhanced mobile optimizations */
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;
    /* Improved scrolling and animation performance */
    -webkit-overflow-scrolling: touch;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    will-change: transform;
    /* Page transition animations */
    opacity: 0;
    animation: fadeInPage 0.5s ease-in-out forwards;
}


@keyframes fadeInPage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Page exit animation class */
body.page-exit {
    animation: fadeOutPage 0.3s ease-in-out forwards;
}

@keyframes fadeOutPage {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

#container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.navigation {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 20px);
    height: 40px;
    z-index: 1001;
    border-radius: 4px;
    background: #FFF;
    box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: auto;
    /* Enhanced mobile touch priority */
    touch-action: manipulation;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    justify-content: flex-start;
}

.nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.nav-box {
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: auto;
    flex: 1;
    justify-content: flex-end;
}

.offline-nav-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-text {
    font-family: "Inter";
    font-size: 12px;
    font-weight: 600;
    color: #000;
    white-space: nowrap;
}

.nav-toggle-switch {
    position: relative;
    width: 32px;
    height: 18px;
    background: #E5E5EA;
    border-radius: 9px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.nav-toggle-switch.active {
    background: #007AFF;
}

.nav-toggle-slider {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.nav-toggle-switch.active .nav-toggle-slider {
    transform: translateX(14px);
}


.nav-logo {
    height: 20px;
    width: auto;
}

.nav-title {
    text-decoration: none;
font-family: "Inter";
font-size: 12px;
    color: #000;
font-style: normal;
font-weight: 600;
line-height: 137%; /* 16.44px */
letter-spacing: -0.12px;
}

.nav-title:hover {

        color:white;
text-shadow: 0 0 3.6px rgba(0, 0, 0, 0.25);

}


.nav-item {
    text-decoration: none;
font-family: "Inter";
font-size: 12px;
font-style: normal;
font-weight: 600;
line-height: 137%; /* 16.44px */
letter-spacing: -0.12px;
    color: #000;
    cursor: pointer;
    white-space: nowrap;

    padding: 1px 12px;
    border-radius: 0;
}

.nav-item:hover {
    color:white;
text-shadow: 0 0 3.6px rgba(0, 0, 0, 0.25);

}

#navLibraryBtn {
    background: black;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-weight: 600;
}

#navLibraryBtn:hover {
    background: white;
    color: black;
    text-shadow: none;
}



.color-coordinate-btn {
    background: #000;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-family: "Times New Roman", serif;
    font-size: 14px;
    margin-right: 20px;
    user-select: none;
}

.color-coordinate-btn:hover {
    background: #333;
}

/* Book Modal */
.book-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000000;
    display: none;
    align-items: center;
    justify-content: center;
}

.book-modal-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.95;

background: rgba(255, 255, 255);
    pointer-events: none;
}

.book-modal-content {
    position: relative;
    max-width: fit-content;
    max-height: 80vh;
    z-index: 10000;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 0 auto;
}

.book-modal-image {
    max-width: 400px;
    max-height: 80vh;
    object-fit: contain;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.library-card {
    position: relative;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 10001;
    flex-shrink: 0;
    background: none;
}

.mobile-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000001;
    background: none;
    box-shadow: none;
    border: none;
    width: 40px;
    height: 40px;
    color: #000;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s ease;
}

.mobile-close-btn:hover {
    color: #666;
}

.card-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label {
    font-family: 'Cutive Mono', monospace;
    font-size: 11px;
    color: rgba(0, 0, 0, 0.6);
    text-transform: uppercase;
    font-weight: bold;
}

.field-value {

    color: black;


font-family: "Inter";
font-size: 12px;
font-style: normal;
font-weight: 600;
line-height: 137%; /* 16.44px */
letter-spacing: -0.12px;
    
}

.ui-overlay {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    color: #000000;
    font-size: 14px;
    opacity: 0.9;
    user-select: none;
    pointer-events: auto;
    background: rgba(255,255,255,0.8);
    padding: 15px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
}

.ui-overlay h1 {
    font-size: 20px;
    font-weight: 300;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.instructions {
    font-size: 11px;
    opacity: 0.7;
    line-height: 1.4;
    margin-bottom: 12px;
}

.organize-btn {
    background: #000;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.organize-btn:hover {
    background: #333;
    transform: translateY(-1px);
}

.organize-btn:disabled {
    background: #999;
    cursor: not-allowed;
    transform: none;
}

.library-btn {
    background: #000;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s ease;
    touch-action: manipulation;
    margin-top: 8px;
}

.library-btn:hover {
    background: #333;
    transform: translateY(-1px);
}
#qrcode{
      position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999999999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

#loading.hidden {
  opacity: 0;
  display: none !important;
}

#loadingVideo {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
  /* Safari-specific optimizations */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  /* Mobile optimizations */
  opacity: 1;
  visibility: visible;
}

/* Hide all video controls for clean autoplay */
#loadingVideo::-webkit-media-controls {
  display: none !important;
}

#loadingVideo::-webkit-media-controls-panel {
  display: none !important;
}

#loadingVideo::-webkit-media-controls-play-button {
  display: none !important;
}

#loadingVideo::-webkit-media-controls-start-playback-button {
  display: none !important;
}

/* Mobile-specific video optimizations */
@media (max-width: 768px) {
  #loadingVideo {
    /* Force hardware acceleration on mobile */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    /* Mobile Safari specific */
    -webkit-overflow-scrolling: touch;
    /* Ensure video dimensions on mobile */
    min-width: 100%;
    min-height: 100%;
  }
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;

}


.loading-content {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: white;
  text-align: center;
}
.loading-logo-box{
    display: flex;
width: 42px;
height: 42px;
padding: 10px;
align-items: center;
gap: 30.377px;
    border-radius: 4px;
background: #FFF;
box-shadow: 0 5.85px 10.896px 0 rgba(0, 0, 0, 0.20);
}

.qr-logo-box{
    display: flex;
width: 60px;
height: 60px;
padding: 12px;
align-items: center;
gap: 30.377px;
    border-radius: 4px;
background: #FFF;
box-shadow: 0 5.85px 10.896px 0 rgba(0, 0, 0, 0.20);
}

.loading-logo {
  width: 120px;
  height: auto;
  color:black;
}
.loading-counter-box{
      color:black;
      height:42px;
    display: flex;
    border-radius: 4px;
background: #FFF;
box-shadow: 0 11.701px 21.792px 0 rgba(0, 0, 0, 0.20);
width: 400px;
padding: 8px 14px;
justify-content: space-between;
align-items: center;
 font-family: 'Inter', sans-serif;
font-size: 12.511px;
font-style: normal;
font-weight: 600;
line-height: 137%; /* 17.14px */
letter-spacing: -0.375px;
  margin: 0;
}


@media (max-width: 768px) {

.loading-content{
    gap:4px;
    width:90%;
}
.loading-counter-box {
    font-size: 12px;
}

}

/* About Page Styling */
body.about-page {
  overflow: visible;
  height: 100vh;
}

@media (max-width: 768px) {
  body.about-page {
    height: -webkit-fill-available;
  }
}

body.about-page .navigation {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  z-index: 1001;
}

body.about-page #container {
  height: 100vh;
  height: -webkit-fill-available;
  overflow-y: auto;
  padding-top: 70px;
  position: relative;
  padding-bottom: 0 !important;
}

/* Main content layout */
.main-content {
  display: flex;
  width: 100%;
  height: calc(100vh - 80px - 20vh); /* Subtract nav and marquee height */
  align-items: flex-start;
  justify-content: center;
  padding: 2rem;
}

.content-sections {
            flex-direction: column;

    gap:40px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.title-section {
  flex: 1;
}

.main-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size:30px;
font-style: normal;
font-weight: 600;
line-height: 125%; /* 21.8px */
letter-spacing: -0.2px;
}

.text-section {
  color: #000;
flex: 1;
  display: flex;
  justify-content: start;
  align-items: flex-start;
}

.database-text {
    width:350px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;

  font-size:16px;
font-style: normal;
font-weight: 600;
line-height: 125%; /* 21.8px */
letter-spacing: -0.2px;

}

.database-text img {
  height: 0.8em; /* Proportional to text size */
  width: auto;
  vertical-align: end;
  display: inline;
}

.database-text a {
  color: black;
  text-decoration: underline;
}
.database-text a:hover {
        color:white;
text-shadow: 0 0 3.6px rgba(0, 0, 0, 0.25);

}

/* Image marquee at bottom */
.image-marquee {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 20vh;
  overflow: hidden;
  background: transparent;
  z-index: 100;
}

/* Desktop marquee - only show on desktop */
.image-marquee-desktop {
  display: none;
}

@media (min-width: 769px) {
  .image-marquee {
    display: none !important;
  }

  .image-marquee-desktop {
    display: block !important;
    position: fixed !important;
    bottom: 0px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 150px !important;
    overflow: hidden !important;
    background: transparent !important;
    z-index: 9999 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }
}

/* Safari mobile-specific marquee fix - ONLY FOR ABOUT PAGE */
@supports (-webkit-touch-callout: none) {
  body.about-page .image-marquee {
    /* Use dvh (dynamic viewport height) for Safari iOS */
    bottom: 0;
    position: fixed;
  }

  body.about-page {
    height: 100dvh;
  }

  body.about-page #container {
    height: 100dvh;
  }
}

.marquee-content {
  display: flex;
  height: 100%;
  animation: marqueeScroll 30s linear infinite;
  will-change: transform;
  align-items: flex-end;
  transform: translateX(50%); /* Start from middle */
}

.marquee-image {
    height: auto;
    width: 60px;
  object-fit: contain;
  margin-right: 20px;
  flex-shrink: 0;
}

@keyframes marqueeScroll {
  0% {
    transform: translateX(0%);
  }
  100% {
    transform: translateX(-100%);
  }
}

/* Mobile responsive layout */
@media (max-width: 768px) {
  .content-sections {
    flex-direction: column;
    gap: 2rem;
  }

  .text-section {

    justify-content: flex-start;
  }
  .database-text{
        font-size: 16px;
font-style: normal;
font-weight: 600;
line-height: 120%; /* 19.04px */
letter-spacing: -0.48px;

  }
}

/* Responsive scaling based on 1200px baseline */
@media (max-width: 1400px) {
  .about-text {
    font-size: calc(80px * 0.9); /* ~72px */
  }
}

@media (max-width: 1200px) {
  .about-text {
    font-size: 80px; /* Baseline size */
  }
}

@media (max-width: 1000px) {
  .about-text {
    font-size: calc(80px * 0.8); /* ~64px */
  }
}

@media (max-width: 800px) {
  .about-text {
    font-size: calc(80px * 0.6); /* ~48px */
  }
}

@media (max-width: 600px) {
  .about-text {
    font-size: calc(80px * 0.5); /* ~40px */
  }
}

@media (max-width: 400px) {
  .about-text {
    font-size: calc(80px * 0.4); /* ~32px */
  }
}

@keyframes slideUpFromBottom {
    0% {
        transform: translateY(500px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@-webkit-keyframes slideUpFromBottom {
    0% {
        -webkit-transform: translateY(500px);
        opacity: 0;
    }
    100% {
        -webkit-transform: translateY(0);
        opacity: 1;
    }
}


.loading-enter-row {
    width: 100%;
    border-top: 0.5px solid #787878;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

.enter-btn {
    background: #FFF;
    box-shadow: -2px -2px 0 0 #808080 inset, 2px 2px 0 0 #DFDFDF inset;
    color: #000;
    width: 100%;
    height: 40px;
    border: none;
    padding: 0;
    font-family: 'Cutive Mono', monospace;
    font-size: 12px;
    cursor: pointer;
    border-radius: 0px;
    font-weight: 400;
    letter-spacing: 0;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}

.enter-btn:hover {
    background: #C7C7C7;
    transform: rotate(-1deg);
}

.grid-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform;
}

.image-cell {
    position: absolute;
    cursor: pointer;
    transition: transform 0.25s ease;
    overflow: hidden;
    display: flex;
    /* Enhanced mobile performance */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    /* Smooth touch interactions */
    -webkit-tap-highlight-color: transparent;
    will-change: transform;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    animation: fadeInCell 0.5s ease forwards;
    /* Mobile performance optimizations */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
}

@keyframes fadeInCell {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.image-cell img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    /* Mobile performance optimizations */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    image-rendering: -webkit-optimize-contrast;
}

.image-cell.cluster-active {
    z-index: 10;
}


.glossary-box {
    height: 40px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: 1px;
    border: 0.5px solid #000;
    background: #FFF;
    cursor: pointer;
    white-space: nowrap;
    pointer-events: auto;
}

.glossary-text {
    font-family: "Times New Roman";
    font-size: 14px;
    font-style: italic;
    font-weight: 400;
    line-height: 23px;
    letter-spacing: -0.28px;
    color: #000;
}

.bracket-text {
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 23px;
    color: #000;
}

.toggle-icon {
    width: 12px;
    height: 12px;
}

.vertical-line {
    transition: opacity 0.3s ease;
}

.glossary-box.active .vertical-line {
    opacity: 0;
}


.circle-btn {
    width: 40px;
    height: 40px;
    border-radius: 0;
    background: #FFF;
    box-shadow: -2px -2px 0 0 #808080 inset, 2px 2px 0 0 #DFDFDF inset;
    color: #000;
    font-family: "Times New Roman";
    font-size: 12px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    text-decoration: none;
    position: relative;
    z-index: 1001;
    pointer-events: auto;
    padding: 2px 4px;
}

.circle-btn:hover {
    background: #C7C7C7;
}

.circle-btn.active {
    background: #C7C7C7;
    color: #000;
}

.circle-btn svg {
    width: 20px;
    height: 20px;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.circle-btn.active svg {
    opacity: 1;
}

.circle-btn.active svg rect {
    fill: #000;
}

.circle-btn.active svg g {
    opacity: 1 !important;
}




/* Glossary Panel */
.glossary-panel {
    position: fixed;
    top: 60px;
    right: 10px;
    transform: translateX(0%) translateY(100vh);
    width: 200px;
    height: calc(100vh - 80px);
    background: #C7C7C7;
    box-shadow: -2px -2px 0 0 #808080 inset, 2px 2px 0 0 #DFDFDF inset;
    z-index: 999;
    transition: transform 1s ease;
    overflow: hidden;
}

.glossary-panel.open {
    transform: translateX(0%) translateY(0);
}

.glossary-close-btn {
    position: absolute;
    top: 14px;
    right: 10px;
    width: 40px;
    height: 14px;
    border: none;
    background: transparent;
    font-family: "Arial";
    font-size: 10px;
    font-weight: 400;
    color: #000;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glossary-close-btn:hover {
   text-decoration: underline;
}

.glossary-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px;
    overflow-y: auto;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.glossary-content::-webkit-scrollbar {
    display: none;
}

.glossary-section {
    margin-bottom: 10px;
    flex-shrink: 0;
}

.glossary-section:last-child {
    margin-bottom: 60px;
}

.glossary-section h3 {
    font-family: "Times New Roman";
    font-size: 12px;
    font-style: normal;
    font-weight: 400;
    line-height:100%;
    letter-spacing: -0.28px;
    color: #000;
    cursor: default;
    white-space: nowrap;
    background: #c7c7c7;
    box-shadow: -2px -2px 0 0 #808080 inset, 2px 2px 0 0 #DFDFDF inset;
    padding: 4px 8px;
    border-radius: 0;
    margin: 0 0 12px 0;
    display: inline-block;
}

.tags-list {
    display: flex;
    flex-direction: column;
    gap: 0px;
    flex-shrink: 0;
}

.tags-list a {
    font-family: "Times New Roman";
    font-size: 14px;
    font-weight: 400;
    color: #000;
    line-height: 1.4;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: block;
}

.tags-list a:hover {
    text-decoration: underline;
}

.add-to-library-btn {
    border-radius: 4px;
   width: 150px;
    background: #FFF;
    box-shadow: 0 0 6px 0 rgba(0, 0, 0, 0.25);
    border: none;
    font-family: "Inter";
    font-size: 12px;
    font-weight: 600;
    color: #000;
    cursor: pointer;
    padding: 6px 12px;
    transition: background 0.2s ease;
    z-index: 1002;
    order: -1; /* Put checkout button first */
}

.add-to-library-btn:hover {
    background: black;
    color:white;
}

.fade-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, #FFF 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
}

/* Background overlay when glossary is open */
.glossary-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.9);
    z-index: 998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.glossary-overlay.active {
    opacity: 1;
    pointer-events: auto;
}


.grid-view #container {
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.grid-view #container::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.grid-view .grid-canvas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    align-items: end;
    justify-content: center;
    padding: 80px 80px 120px 80px;
    gap: 20px;
    overflow: visible;
    transform: none !important;
    grid-auto-rows: max-content;
}

.grid-view .image-cell {
    width: auto !important;
    height: auto !important;
    transition: transform 0.2s ease;
}

.grid-view .image-cell:hover {
    transform: translateY(-5px);
}

.grid-view .image-cell img {
    width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.grid-view .image-cell {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    margin: 0px;
    flex-shrink: 0;
}

body.grid-view {
    height: 100vh !important;
    overflow: hidden !important;
}



body.grid-view #glossaryPanel {
    display: none !important;
}

body.grid-view #glossaryPanel.open {
    display: block !important;
    transform: translateX(0%) translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.big-view .grid-canvas {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 0px;
    overflow-x: auto;
    overflow-y: hidden;
    transform: none !important;
    height: 100vh;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

.big-view .grid-canvas::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.big-view .image-cell {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    margin: 0px -80px 0px 0px;
    flex-shrink: 0;
    width: auto !important;
    height: auto !important;
box-shadow: -3px 0 1.5px 0 rgba(0, 0, 0, 0.25);
    transition: all 0.3s ease;
    z-index: 1;
}

.big-view .image-cell:hover {
    /* margin: 0px 60px 0px 100px; */
    z-index: 10;
    transform: translateY(-60px);
}

/* About page loading card */
.about-loading-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70vh;
    height: 70vh;
background: #FF7C3C;

    box-shadow: 0 0 4.4px 0 rgba(0, 0, 0, 0.25);
    z-index: 10;
}

.big-view .image-cell img {
    width: auto !important;
    height: auto !important;
    max-height: 40vh;
    object-fit: contain !important;
}

/* Loading Progress Styles */

.loading-percentage {
    font-family: "Times New Roman";
    font-size: 10px;
    color: #000;
    font-weight: bold;
}

@media (max-width: 768px) {
    .main-content {
        padding: 80px 1rem 1rem 1rem;
    }

    .ui-overlay {
        top: 10px;
        left: 10px;
        padding: 12px;
    }

    .ui-overlay h1 {
        font-size: 18px;
    }

    .instructions {
        font-size: 10px;
    }

    .organize-btn {
        padding: 10px 16px;
        font-size: 12px;
    }


    .enter-btn {
        font-size: 11px;
        height: 35px;
    }

    .grid-view .grid-canvas {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }


    /* Mobile optimizations for Big view */
    .big-view .grid-canvas {
        height: 90vh !important;
    }

    .big-view .image-cell img {
        max-height: 60vh !important;
        width: auto !important;
        height: auto !important;
    }

    /* Grid view mobile optimizations */
    .grid-view .grid-canvas {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }

    /* Mobile touch improvements */
    .circle-btn {
        min-height: 48px;
        min-width: 48px;
        width: 48px;
        height: 48px;
        -webkit-user-select: none;
        user-select: none;
        pointer-events: auto !important;
        z-index: 9999 !important;
        position: relative !important;
    }



    .glossary-box {
        pointer-events: auto !important;
        z-index: 9999;
    }

    /* Prevent canvas from blocking button touches */
    #container {
        position: relative;
    }

    .grid-canvas {
        pointer-events: auto;
        position: relative;
        z-index: 1;
    }

    .image-cell {
        pointer-events: auto;
        /* Enhanced mobile touch response */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Faster transitions on mobile */
        transition: transform 0.15s ease-out;
    }

    /* Add momentum scrolling support */
    #container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Optimize for mobile gestures */
    .image-cell:active {
        transition: transform 0.1s ease-out;
    }

    /* Better visual feedback for touch */
    .image-cell:hover {
        transform: scale(1.02) translateZ(0);
    }

    /* Enhanced touch handling for interactive elements */
    .navigation,
    .nav-item,
    .nav-title,
    .nav-logo,
    .offline-toggle-container,
    .toggle-switch,
    .toggle-label,
    .toggle-slider {
        pointer-events: auto !important;
        touch-action: manipulation !important;
        z-index: 1002 !important;
        position: relative;
    }
    .nav-item{
         padding:0;
    }

    /* Ensure buttons are above canvas */
    .navigation * {
        pointer-events: auto !important;
    }

}

/* Available Offline Toggle */
.offline-toggle-container {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #000;
    border-radius: 4px;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.toggle-label {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: #808080;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid #000;
}

.toggle-switch.active {
    background: #007AFF;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    border: 1px solid #000;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(24px);
}

.toggle-switch:hover {
    opacity: 0.8;
}

@media screen and (max-width: 768px) {
    .offline-toggle-container {
        bottom: 80px;
        padding: 6px 12px;
    }

    .toggle-label {
        font-size: 12px;
    }

    .toggle-switch {
        width: 40px;
        height: 20px;
    }

    .toggle-slider {
        width: 16px;
        height: 16px;
    }

    .toggle-switch.active .toggle-slider {
        transform: translateX(20px);
    }
}

/* Online Button - Bottom positioning */
.online-btn {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Mobile Safari fixes */
    -webkit-transform: translateX(-50%);
    -moz-transform: translateX(-50%);
    -ms-transform: translateX(-50%);
    /* Ensure visibility on all mobile browsers */
    display: block;
    visibility: visible;
    opacity: 1;
}

.online-btn:hover {
    opacity: 0.8;
    transform: translateX(-50%) scale(1.05);
    -webkit-transform: translateX(-50%) scale(1.05);
}

@media screen and (max-width: 768px) {
    .navigation {
        height: 80px;
        flex-wrap: wrap;
        padding: 10px 20px;
        gap: 4px;
        align-content: space-between;
    }

    /* Top row: logo-container and nav-center side by side */
    .logo-container {
        flex: 1;
        min-width: 0;
    }

    .nav-center {
        flex: 1;
        justify-content: flex-end;
        min-width: 0;
    }


    /* Bottom row: nav-box spans full width */
    .nav-box {
        flex-basis: 100%;
        justify-content: space-between;
    }

    .online-btn {
        bottom: 30px;
    }

    /* Mobile modal fixes - Vertical stacking */
    .book-modal-content {
        max-width: 90vw !important;
        max-height: calc(100vh - 80px) !important;
        margin: 0 !important;
        position: fixed !important;
        top: 40px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 15px !important;
        padding: 20px !important;
        box-sizing: border-box !important;
        overflow-y: auto !important;
    }

    .book-modal-image {
        max-width: 100% !important;
        max-height: 40vh !important;
        width: auto !important;
        height: auto !important;
        flex-shrink: 0 !important;
    }


    .library-card .article-bg {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        padding: 4px 4px !important;
        display: flex !important;
        flex-direction: column !important;
        box-sizing: border-box !important;
    }

    .library-card .vertical {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 3rem !important;
        height: calc(100% - 4px) !important;
        border-right: 0.5px solid #787878 !important;
        margin-top: 4px !important;
        padding-left: 4px !important;
        padding-top: 2px !important;
        font-size: 9px !important;
        line-height: 1.2 !important;
    }

    .library-card .vertical-content {
        position: absolute !important;
        left: 3.5rem !important;
        top: 4px !important;
        padding-top: 2px !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        width: calc(100% - 4rem) !important;

    }

    .mobile-close-btn {
        display: block !important;
        position: fixed !important;
        top: 20px !important;
        right: 20px !important;
        z-index: 1000001 !important;
        background: none !important;
        box-shadow: none !important;
        border: none !important;
        font-family: 'Cutive Mono', monospace !important;
        font-size: 12px !important;
        font-weight: 400 !important;
        color: #000 !important;
        cursor: pointer !important;
        padding: 6px 12px !important;
        transition: color 0.2s ease !important;
    }

    .mobile-close-btn:hover {
        color: #666 !important;
    }



    .library-card {
           position: relative !important;
        margin: 10px auto 0 auto !important;

        flex-shrink: 0 !important;
        order: 3 !important;

        align-self: center !important;
    }
}

/* Offline Button - Center positioning */
.offline-btn {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.offline-btn:hover {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1.05);
}


.online-btn img,
.offline-btn img {
    display: block;
    max-height: 30px;
    width: auto;
    border: 2px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    padding: 2px;
}

/* Skeleton loading animation */
@keyframes pulse {
    0% {
        background: #f0f0f0;
    }
    100% {
        background: #e0e0e0;
    }
}

@-webkit-keyframes pulse {
    0% {
        background: #f0f0f0;
    }
    100% {
        background: #e0e0e0;
    }
}