/* Base styles */
html {
    font: 400 16px / 24px "Helvetica Neue", Helvetica, Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    background: #000;
    color: #383e40;
    user-select: none;
    -moz-user-select: none;
    -webkit-user-select: none;
}

body {
    background: #000;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    /*scrollbar-color: #000 #333;*/
    overflow-x: auto;
    overscroll-behavior: none; /* Prevent pull-to-refresh */
    -webkit-overflow-scrolling: touch;
}

/* Custom scrollbar */
body::-webkit-scrollbar {
    width: 12px;
}

body::-webkit-scrollbar-track {
    background: #333;
}

body::-webkit-scrollbar-thumb {
    background-color: #c1a561;
    border-radius: 20px;
    border: 3px solid #333;
}

/* Navigation */
.uk-navbar {
    background: #000;
    color: #fff;
    border-bottom: 0px solid #c1a561;
}

/* Center navigation container */
.nav-container {
    max-width: 2034px;
    margin: 0 auto;
    display: flex;
    justify-content: left;
    align-items: left;
    padding: 10px 20px;
    gap: 0px;
}

.nav-container .uk-navbar-nav {
    margin: 0;
    display: flex;
    align-items: center;
}

/* Logo in navbar */
.nav-logo {
    display: flex;
    align-items: center;
}

.navbar-logo {
    height: 40px;
    width: auto;
    transition: opacity 0.3s ease;
}

.navbar-logo:hover {
    opacity: 0.8;
}

.uk-navbar-nav>li>a {
    padding: 0 15px;
    line-height: 37px;
    color: #fff;
    font-size: 14px;
    border-bottom: 2px solid #c1a561;
    margin-left: 10px;
    margin-top: 10px;
}

.uk-navbar-nav>li>a:hover {
    background: #c1a561;
    color: #000;
}

.uk-navbar-nav>li.uk-active>a {
    background-color: #000;
    color: #c1a561;
}

/* Page Selector */
.page-selector {
    margin: 20px 0;
}

.page-nav-desktop {
    display: flex;
    justify-content: center;
    gap: 2px;
    flex-wrap: wrap;
}

.page-nav-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
}

.page-buttons-container {
    display: flex;
    gap: 2px;
    flex: 1;
    justify-content: center;
    max-width: 300px;
}

.nav-arrow {
    background: #262626;
    border: 2px solid #444;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.nav-arrow:hover:not(:disabled) {
    background: #333;
    border-color: #c1a561;
    color: #c1a561;
}

.nav-arrow:disabled {
    background: #1a1a1a;
    border-color: #333;
    color: #555;
    cursor: not-allowed;
}

.nav-arrow:active:not(:disabled) {
    transform: scale(0.95);
}

.page-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 15px;
    background: #262626;
    border: 2px solid #444;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.page-button:hover {
    background: #333;
    border-color: #c1a561;
}

.page-button.active {
    background: #c1a561;
    border-color: #c1a561;
    color: #000;
}

.page-button.active .page-number,
.page-button.active .page-price {
    color: #000;
}

.page-number {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.page-price {
    font-size: 12px;
    color: #ccc;
    margin-top: 2px;
}

/* Grid Container */
#grid-viewport {
    position: relative;
    width: 2000px;
    height: 2000px;
    margin: 20px auto;
    border: 7px solid #c1a561;
    background: #fff;
    overflow: hidden;
    touch-action: manipulation; /* Allow page scrolling */
    box-sizing: border-box;
}

#grid-canvas, #selection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 2000px;
    height: 2000px;
    cursor: crosshair;
    display: block;
    box-sizing: border-box;
}

#selection-canvas {
    pointer-events: none;
    z-index: 10;
}

/* Loading Spinner */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none; /* Hidden by default */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    color: #fff;
}

.spinner-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #c1a561;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Payment Panel */
#payment-panel {
    position: fixed;
    top: 120px;
    right: 20px;
    width: 300px;
    background: #262626;
    border: 2px solid #c1a561;
    border-radius: 10px;
    padding: 20px;
    z-index: 100;
    color: #fff;
}

#payment-inner h3 {
    color: #c1a561;
    margin-top: 0;
    margin-bottom: 15px;
}

#selection-info {
    margin-bottom: 15px;
    font-size: 14px;
    line-height: 1.4;
}

.total-display {
    font-size: 24px;
    font-weight: bold;
    color: #000;
    text-align: center;
    margin: 15px 0;
    padding: 10px;
    background: rgba(193, 165, 97, 0.1);
    border-radius: 5px;
}

#checkout-button {
    background: #c1a561;
    color: #000;
    border: none;
    border-radius: 5px;
    font-weight: bold;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#checkout-button:hover:not(:disabled) {
    background: #d4b870;
}

#checkout-button:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

/* Mobile Instructions */
.mobile-instructions {
    background: #262626;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    margin: 20px;
    color: #fff;
}

.mobile-instructions p {
    margin: 5px 0;
    font-size: 14px;
}

/* Selection Visual States */
.grid-square-available {
    opacity: 0.8;
}

.grid-square-selected {
    outline: 2px solid #c1a561;
    outline-offset: -2px;
    box-sizing: border-box;
}

.grid-square-purchased {
    opacity: 1;
}

/* Fix hover pixel alignment */
#grid-canvas:hover {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* Ensure precise canvas rendering */
#grid-canvas, #selection-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
}

/* Touch interaction states */
.touch-selecting {
    touch-action: none;
    overflow: hidden;
}

/* Responsive Design */
@media (max-width: 768px) {
    #payment-panel {
        position: static;
        width: auto;
        margin: 20px;
        right: auto;
        top: auto;
        display: block !important; /* Override uk-hidden-small to always show on mobile */
    }
    
    #grid-viewport {
        width: calc(100vw - 40px);
        height: calc(100vw - 40px);
        max-width: 2000px;
        max-height: 2000px;
        margin: 20px auto;
    }
    
    #grid-canvas, #selection-canvas {
        width: 100%;
        height: 100%;
    }
    
    .page-nav-mobile .page-button {
        min-width: 60px;
        padding: 8px 10px;
        flex: 1;
        max-width: 80px;
    }
    
    .page-nav-mobile .page-number {
        font-size: 14px;
    }
    
    .page-nav-mobile .page-price {
        font-size: 10px;
    }
    
    .nav-arrow {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .page-nav-mobile .page-button {
        min-width: 50px;
        padding: 6px 8px;
    }
    
    .page-nav-mobile .page-number {
        font-size: 12px;
    }
    
    .page-nav-mobile .page-price {
        font-size: 9px;
    }
    
    .nav-arrow {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    .page-nav-mobile {
        gap: 8px;
        padding: 0 10px;
    }
}

/* Footer */
footer {
    text-align: center;
    margin: 40px 0;
    color: #fff;
}

footer a {
    color: #c1a561;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}