/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(to bottom, #87CEEB 0%, #4682B4 50%, #191970 100%);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    /* Safe area support for notched devices */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Game container */
#gameContainer {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Canvas styling */
#gameCanvas {
    background: linear-gradient(to bottom, #87CEEB 0%, #4682B4 30%, #1e3a8a 100%);
    display: block;
    flex: 1;
    width: 100%;
    cursor: pointer;
    touch-action: none;
}

/* HUD (Heads Up Display) */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

/* Top bar with stats */
#topBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    color: white;
    font-weight: 600;
    font-size: 16px;
    pointer-events: auto;
}

#coinsDisplay, #fishDisplay {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 20px;
    min-width: 80px;
}

#settingsButton {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#settingsButton:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

#settingsButton:active {
    transform: scale(0.95);
}

/* Food cooldown indicator */
#foodCooldown {
    position: absolute;
    top: 80px;
    left: 16px;
    right: 16px;
    height: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    overflow: hidden;
    pointer-events: none;
}

#cooldownBar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #ffa500);
    border-radius: 3px;
    transition: width 0.1s linear;
    width: 0%;
}

/* Shop button */
#shopButton {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 16px 24px;
    border: none;
    border-radius: 30px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: auto;
    min-width: 120px;
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#shopButton:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#shopButton:active {
    transform: translateX(-50%) translateY(0px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* Floating texts for animations */
#floatingTexts {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.floating-text {
    position: absolute;
    color: #ffd700;
    font-weight: bold;
    font-size: 24px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: floatUp 2s ease-out forwards;
    pointer-events: none;
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-80px) scale(1.2);
    }
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: auto;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0px) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #eee;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.close {
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close:hover {
    color: #333;
    background: #f0f0f0;
}

.modal-body {
    padding: 20px 24px 24px;
}

/* Shop item styling */
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 16px;
    background: #f9f9f9;
}

.item-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.item-icon {
    font-size: 48px;
    background: #e3f2fd;
    border-radius: 50%;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-details h3 {
    margin: 0 0 4px 0;
    color: #333;
    font-size: 18px;
}

.item-details p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.item-price button {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
    min-height: 48px;
}

.item-price button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.item-price button:active:not(:disabled) {
    transform: translateY(0px);
}

.item-price button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Settings styling */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid #eee;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.danger-button {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 48px;
}

.danger-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.danger-button:active {
    transform: translateY(0px);
}

.info-text {
    width: 100%;
}

.info-text p {
    margin: 8px 0;
    color: #666;
    font-size: 14px;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 15px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    z-index: 200;
    animation: notificationPop 3s ease-out forwards;
    pointer-events: none;
}

@keyframes notificationPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.05);
    }
    80% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #topBar {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    #coinsDisplay, #fishDisplay {
        padding: 6px 10px;
        min-width: 70px;
    }
    
    #shopButton {
        bottom: 16px;
        padding: 14px 20px;
        font-size: 16px;
        min-height: 52px;
    }
    
    .modal-content {
        margin: 10px;
        max-height: 85vh;
    }
    
    .shop-item {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
    
    .item-price {
        width: 100%;
    }
    
    .item-price button {
        width: 100%;
    }
}

/* High DPI display support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    #gameCanvas {
        image-rendering: -webkit-crisp-edges;
        image-rendering: crisp-edges;
    }
}

/* Landscape orientation on mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #topBar {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    #shopButton {
        bottom: 12px;
        padding: 10px 16px;
        font-size: 14px;
        min-height: 44px;
    }
}
