* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #1a472a 0%, #2d5a3d 50%, #1a472a 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
    overflow-x: hidden;
}

/* ========== Loading Screen ========== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #1a472a 0%, #0d2818 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-logo {
    font-size: 80px;
    margin-bottom: 15px;
    animation: logoFloat 2s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.loading-title {
    font-size: 42px;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    margin-bottom: 8px;
    font-weight: bold;
}

.loading-subtitle {
    font-size: 16px;
    color: #98D8AA;
    margin-bottom: 40px;
}

.loading-bar-container {
    width: 280px;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
    border: 2px solid #4a7c59;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ffd700, #ffaa00, #ffd700);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    transition: width 0.3s;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-text {
    color: #fff;
    font-size: 14px;
    margin-bottom: 40px;
}

.start-btn {
    padding: 16px 60px;
    font-size: 22px;
    background: linear-gradient(145deg, #ffd700, #ff8c00);
    border: none;
    border-radius: 30px;
    color: #333;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(255,215,0,0.4);
    transition: all 0.3s;
    display: none;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(255,215,0,0.6);
}

.start-btn.show {
    display: block;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.loading-tips {
    position: absolute;
    bottom: 60px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    text-align: center;
    line-height: 1.5;
}

.loading-game-link {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 30px;
    padding: 10px 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid rgba(255,215,0,0.3);
}

.loading-game-link:hover {
    background: rgba(255,215,0,0.2);
    border-color: #ffd700;
}

.loading-game-link .link-icon {
    font-size: 24px;
}

.loading-game-link .link-text {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}

/* ========== Game Container Wrapper ========== */
.game-container-wrapper {
    display: none;
    flex-direction: column;
    align-items: center;
}

.game-container-wrapper.show {
    display: flex;
}

/* ========== Game Container 800x600 ========== */
.game-container {
    width: 800px;
    height: 600px;
    background: linear-gradient(180deg, #1e5631 0%, #2d5a3d 50%, #1a472a 100%);
    border-radius: 16px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5), inset 0 0 60px rgba(0,0,0,0.2);
    border: 3px solid #0d3d18;
    position: relative;
    overflow: hidden;
}

/* ========== Header ========== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    flex-shrink: 0;
}

h1 {
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    font-size: 24px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-info {
    display: flex;
    gap: 10px;
    color: #fff;
    font-size: 13px;
    background: rgba(0,0,0,0.3);
    padding: 6px 12px;
    border-radius: 12px;
}

.timer {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(0,0,0,0.5);
    padding: 6px 14px;
    border-radius: 16px;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
}

.timer.warning {
    background: linear-gradient(145deg, #ff4757, #c0392b);
    animation: timerPulse 0.5s infinite;
}

@keyframes timerPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* ========== Level Select ========== */
.level-select {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.level-select button {
    padding: 5px 14px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    background: rgba(255,255,255,0.9);
    color: #333;
}

.level-select button.active {
    background: linear-gradient(145deg, #ffd700, #ffa500);
    color: #333;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255,215,0,0.4);
}

.level-select button.locked {
    background: rgba(100,100,100,0.5);
    color: #777;
    cursor: not-allowed;
}

.level-select button.unlocked {
    background: rgba(255,255,255,0.9);
    color: #333;
}

/* ========== Game Area ========== */
.game-area {
    flex: 1;
    background: linear-gradient(180deg, #3d6b4f 0%, #2d5a3d 50%, #1a472a 100%);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.4);
    border: 2px solid #1a472a;
    min-height: 300px;
}

.stats-panel {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

/* ========== Items ========== */
.item {
    position: absolute;
    width: 42px;
    height: 42px;
    font-size: 24px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #ffffff, #e8e8e8);
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.8);
    transition: transform 0.1s, box-shadow 0.1s, filter 0.15s;
}

.item.surface {
    cursor: pointer;
    box-shadow: 2px 3px 6px rgba(0,0,0,0.4);
}

.item.surface:hover {
    transform: scale(1.12) translateY(-2px);
    box-shadow: 0 0 16px rgba(255,215,0,1), 0 6px 16px rgba(0,0,0,0.4);
    z-index: 100 !important;
}

.item.blocked {
    cursor: not-allowed;
    filter: brightness(0.55) saturate(0.6);
    box-shadow: 1px 2px 3px rgba(0,0,0,0.3);
}

.item.collected {
    animation: flyToBasket 0.25s ease-in forwards;
    pointer-events: none;
}

@keyframes flyToBasket {
    to { 
        transform: scale(0.2) translateY(150px); 
        opacity: 0; 
    }
}

/* ========== Progress ========== */
.progress-container {
    margin: 8px 0;
    flex-shrink: 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0,0,0,0.4);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00b894, #55efc4);
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    color: rgba(255,255,255,0.8);
    font-size: 11px;
    margin-top: 2px;
}

/* ========== Basket ========== */
.basket-container {
    background: linear-gradient(145deg, #8B4513, #5D3A1A);
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    border: 2px solid #3d2510;
    flex-shrink: 0;
}

.basket {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.basket-slot {
    width: 42px;
    height: 42px;
    background: linear-gradient(145deg, #654321, #4a3015);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
    border: 2px solid #3d2510;
}

.basket-slot.filled {
    background: linear-gradient(145deg, #FFEAA7, #FDCB6E);
    animation: popIn 0.2s ease;
}

.basket-slot.clearing {
    animation: clearPop 0.25s ease forwards;
}

@keyframes popIn {
    0% { transform: scale(0.5); }
    70% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@keyframes clearPop {
    50% { transform: scale(1.2); }
    100% { transform: scale(0); opacity: 0; }
}

/* ========== Buttons ========== */
.buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
    flex-shrink: 0;
}

.btn {
    padding: 10px 20px;
    font-size: 13px;
    border: none;
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-moveback { 
    background: linear-gradient(145deg, #a29bfe, #6c5ce7); 
    color: white; 
}

.btn-restart { 
    background: linear-gradient(145deg, #55efc4, #00b894); 
    color: white; 
}

.btn-games { 
    background: linear-gradient(145deg, #fd79a8, #e84393); 
    color: white; 
}

.btn:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 5px 15px rgba(0,0,0,0.4); 
}

.btn:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
    transform: none; 
}

/* ========== How to Play - Outside Container ========== */
.how-to-play {
    margin-top: 15px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    padding: 12px 20px;
    max-width: 800px;
    width: 100%;
}

.how-to-play-title {
    color: #ffd700;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
}

.how-to-play-content {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.how-to-play-content span {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    background: rgba(255,255,255,0.1);
    padding: 5px 12px;
    border-radius: 10px;
}

/* ========== Message Modal ========== */
.message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9990;
}

.message-box {
    background: linear-gradient(145deg, #fff, #f5f5f5);
    padding: 28px 36px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    max-width: 400px;
    animation: modalPopIn 0.3s ease;
}

@keyframes modalPopIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.message-box .icon { 
    font-size: 50px; 
    margin-bottom: 12px;
}

.message-box .text { 
    font-size: 22px; 
    color: #333; 
    margin-bottom: 6px; 
    font-weight: bold; 
}

.message-box .subtext { 
    font-size: 14px; 
    color: #666; 
    margin-bottom: 18px; 
}

.message-box button {
    padding: 12px 28px;
    font-size: 15px;
    border: none;
    border-radius: 20px;
    background: linear-gradient(145deg, #fdcb6e, #f39c12);
    cursor: pointer;
    font-weight: bold;
    color: #333;
    margin: 4px;
    transition: transform 0.2s;
}

.message-box button:hover {
    transform: scale(1.03);
}

.message-box button.secondary {
    background: linear-gradient(145deg, #dfe6e9, #b2bec3);
}

.message-box .game-ads {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.message-box .ads-label {
    font-size: 12px;
    color: #999;
}

.message-box .game-ad {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #f8f8f8, #e8e8e8);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    transition: transform 0.3s;
    border: 2px solid #ddd;
}

.message-box .game-ad:hover {
    transform: scale(1.1);
    border-color: #ffd700;
}

/* ========== Responsive ========== */
@media (max-width: 820px) {
    .game-container {
        width: 100%;
        max-width: 800px;
        height: auto;
        min-height: 600px;
    }
}

@media (max-width: 600px) {
    .game-container {
        padding: 8px 10px;
    }
    
    h1 {
        font-size: 18px;
    }
    
    .level-select button {
        padding: 4px 8px;
        font-size: 10px;
    }
    
    .game-area {
        min-height: 280px;
    }
    
    .item {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    
    .basket-slot {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .btn {
        padding: 8px 14px;
        font-size: 11px;
    }
    
    .loading-title {
        font-size: 32px;
    }
    
    .loading-logo {
        font-size: 60px;
    }
}