/* =========================
   RESET AND BASE STYLES
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: Arial, sans-serif;
    touch-action: none;
}

/* =========================
   GAME CANVAS
   ========================= */
#gameCanvas {
    border: 1px solid #333;
    background: #2d5a3d;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    max-width: 100vw;
    max-height: 100vh;
}

/* =========================
   DEBUG AND INFO
   ========================= */
#debugInfo {
    position: absolute;
    top: 10px;
    left: 10px;
    color: white;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 3px;
    display: none;
    font-family: monospace;
    z-index: 30;
    border: 1px solid #555;
}

#topRightUI {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    z-index: 30;
}

#fpsCounter {
    color: white;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 3px;
    font-family: monospace;
    border: 1px solid #555;
}

#debugIcon {
    color: white;
    font-size: 12px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px;
    border-radius: 3px;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 1px solid #555;
}

#debugIcon:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
    border-color: #888;
}

#debugIcon.active {
    background: rgba(76, 175, 80, 0.8);
    color: #fff;
    border-color: #4CAF50;
}

/* =========================
   LOADING SCREEN
   ========================= */
#loadingScreen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-family: 'Press Start 2P', cursive;
    transition: opacity 0.5s ease-out;
    z-index: 100;
}

#gameTitle {
    font-size: 3em;
    margin-bottom: 20px;
    color: #FFD700; /* Gold color */
    text-shadow: 3px 3px 0px #A04000;
    text-align: center;
}

.loading-bar {
    width: 300px;
    height: 8px;
    background: #444;
    margin-top: 10px;
    border-radius: 4px;
    overflow: hidden;
    display: block; /* Show by default */
    border: 1px solid #666;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A);
    width: 0%;
    transition: width 0.3s ease;
}

#startPrompt {
    margin-top: 30px;
    font-size: 1.2em;
    color: #FFF;
    text-shadow: 2px 2px 0px #000;
    display: none; /* Hidden until loading is complete */
    animation: blink-animation 1.5s steps(2, start) infinite;
    cursor: pointer;
    user-select: none;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 5px;
    transition: all 0.3s ease;
}

#startPrompt:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #FFD700;
}

@keyframes blink-animation {
    to {
        visibility: hidden;
    }
}

/* =========================
   PROGRESS BAR (Chopping)
   ========================= */
#progressBarContainer {
    position: absolute;
    display: none; /* Hidden by default */
    width: 50px;
    height: 8px;
    background-color: #555;
    border: 1px solid #fff;
    border-radius: 4px;
    overflow: hidden;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

#progressBar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #66BB6A); /* Green gradient */
    transition: width 0.1s linear;
}

/* =========================
   RESOURCE UI
   ========================= */
#resourceUI {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 5px;
    z-index: 20;
    visibility: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
}

#lumberIcon {
    width: 32px;
    height: 16px;
    background-image: url('https://sword-of-satoshi.s3.us-east-1.amazonaws.com/assets/images/Outdoor decoration/Outdoor_Decor.png');
    background-position: 80px -112px;
    margin-right: 10px;
    transform: scale(1.5);
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#lumberCount {
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    text-shadow: 1px 1px 0px #000;
    min-width: 20px;
}

/* =========================
   UTILITY CLASSES
   ========================= */
.hidden {
    display: none !important;
}

.invisible {
    visibility: hidden !important;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.fade-out {
    animation: fadeOut 0.5s ease-out;
}

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

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

/* =========================
   DISMOUNT BUTTON (Mobile)
   ========================= */
#dismountButton {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    z-index: 50;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(2px);
}

#dismountButton:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.5);
}

#dismountButton:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.dismount-emoji {
    position: absolute;
    font-size: 1em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    z-index: 2;
    top: 13%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.dismount-icon {
    position: absolute;
    width: 64px;
    height: 64px;
    background-image: url('https://sword-of-satoshi.s3.us-east-1.amazonaws.com/assets/images/Animals/Horse/Horse_01.png');
    background-position: 0 0; /* First frame (0,0) */
    background-size: 512px 576px; /* Scale up: 8 columns × 64px = 512px, 9 rows × 64px = 576px */
    background-repeat: no-repeat;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 1;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* =========================
   MOBILE OPTIMIZATIONS
   ========================= */
@media (max-width: 768px) {
    #gameTitle {
        font-size: 2em;
    }
    
    #startPrompt {
        font-size: 1em;
        padding: 15px;
    }
    
    #resourceUI {
        top: 5px;
        left: 5px;
        padding: 6px;
    }
    
    #lumberCount {
        font-size: 12px;
    }
    
    #debugInfo,
    #fpsCounter {
        font-size: 10px;
        padding: 3px;
    }
    
    #debugIcon {
        width: 28px;
        height: 28px;
        font-size: 14px;
        top: 35px;
    }

    .loading-bar {
        width: 250px;
    }
    
    #dismountButton {
        width: 70px;
        height: 70px;
        bottom: 15px;
        right: 15px;
    }
    
    .dismount-emoji {
        font-size: 1em;
    }
    
    .dismount-icon {
        width: 56px;
        height: 56px;
        background-size: 448px 504px; /* Mobile scale: 8 columns × 56px = 448px, 9 rows × 56px = 504px */
    }
}

/* =========================
   DESKTOP DISMOUNT INSTRUCTIONS
   ========================= */
.desktop-instructions {
    position: absolute;
    bottom: 20px;
    left: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 10px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    padding: 5px 8px;
    border-radius: 3px;
    text-shadow: 1px 1px 0px rgba(0, 0, 0, 0.8);
    z-index: 30;
    backdrop-filter: blur(2px);
}

/* Hide on mobile */
@media (max-width: 768px) {
    .desktop-instructions {
        display: none !important;
    }
}

/* Landscape mobile orientation */
@media (orientation: landscape) and (max-height: 500px) {
    #gameTitle {
        font-size: 1.5em;
        margin-bottom: 10px;
    }
    
    #startPrompt {
        margin-top: 15px;
        font-size: 0.9em;
    }

    .loading-bar {
        width: 200px;
        height: 6px;
    }
}

/* =========================
   HIGH DPI DISPLAYS
   ========================= */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #gameCanvas {
        image-rendering: pixelated;
        image-rendering: -moz-crisp-edges;
        image-rendering: crisp-edges;
    }
    
    #lumberIcon {
        image-rendering: pixelated;
        image-rendering: -moz-crisp-edges;
        image-rendering: crisp-edges;
    }
}

/* =========================
   ACCESSIBILITY
   ========================= */
@media (prefers-reduced-motion: reduce) {
    .loading-progress {
        transition: none;
    }
    
    #startPrompt {
        animation: none;
    }
    
    #progressBar {
        transition: none;
    }
    
    .fade-in,
    .fade-out {
        animation: none;
    }
}

/* Focus styles for accessibility */
#startPrompt:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
    background: rgba(76, 175, 80, 0.2);
}

/* =========================
   GAME ANIMATIONS
   ========================= */
.tree-shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* =========================
   NOTIFICATION SYSTEM
   ========================= */
.notification {
    position: absolute;
    top: 50px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 25;
    backdrop-filter: blur(5px);
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    border-left: 4px solid #4CAF50;
}

.notification.warning {
    border-left: 4px solid #FFC107;
}

.notification.error {
    border-left: 4px solid #F44336;
} 