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

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

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

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    pointer-events: auto;
}

.modal-content {
    background: linear-gradient(135deg, #2d2d4a 0%, #1a1a2e 100%);
    border-radius: 20px;
    padding: 25px;
    max-width: 500px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    color: #fff;
    font-size: 20px;
}

.modal-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(255,100,100,0.4);
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
}

.modal-item {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    padding: 15px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-item:hover:not(.locked) {
    transform: scale(1.1);
    background: rgba(255,255,255,0.2);
    border-color: #ffd700;
}

.modal-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.modal-item-emoji {
    font-size: 36px;
    margin-bottom: 5px;
}

.modal-item-name {
    color: #fff;
    font-size: 11px;
    font-weight: bold;
}

.modal-item-count {
    color: #667eea;
    font-size: 10px;
    font-weight: bold;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    pointer-events: auto;
}

.user-stats {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 10px 18px;
    border-radius: 50px;
    border: 2px solid rgba(255,255,255,0.3);
}

.stat-icon {
    font-size: 24px;
}

.stat-value {
    color: #fff;
    font-weight: bold;
    font-size: 16px;
}

.exp-bar-container {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}

.exp-bar {
    flex: 1;
    height: 20px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.3);
}

.exp-fill {
    height: 100%;
    background: linear-gradient(90deg, #f093fb 0%, #f5576c 100%);
    border-radius: 10px;
    transition: width 0.5s ease-out;
    width: 0%;
}

.exp-text {
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    min-width: 70px;
}

.tools-bar {
    position: absolute;
    top: 80px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.tool-btn:hover {
    transform: scale(1.05);
    background: rgba(255,255,255,0.25);
}

.tool-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #fff;
    transform: scale(1.1);
}

.tool-btn.harvest-all {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-color: #ffd700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255,215,0,0.4);
    }
    50% {
        box-shadow: 0 0 20px 10px rgba(255,215,0,0.2);
    }
}

.tool-emoji {
    font-size: 28px;
}

.tool-label {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
}

.skill-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid rgba(255,255,255,0.4);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.skill-btn:hover:not(.disabled) {
    transform: scale(1.15);
    box-shadow: 0 6px 25px rgba(102,126,234,0.5);
}

.skill-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.skill-emoji {
    font-size: 32px;
    margin-bottom: -5px;
}

.skill-name {
    font-size: 10px;
    color: #fff;
    font-weight: bold;
    text-align: center;
    line-height: 1;
}

.bottom-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    padding: 20px;
    padding-top: 40px;
    pointer-events: auto;
}

.panel-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.tab-btn {
    padding: 12px 28px;
    background: rgba(255,255,255,0.1);
    border: 2px solid transparent;
    border-radius: 50px;
    color: #fff;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.2);
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #fff;
}

.panel-content {
    max-height: 180px;
    overflow-y: hidden;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
}

.item-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 50%;
    padding: 20px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: visible;
}

.item-card:hover {
    transform: translateY(-5px) scale(1.05);
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
}

.item-card.selected {
    border-color: #ffd700;
    background: rgba(255,215,0,0.2);
    box-shadow: 0 0 20px rgba(255,215,0,0.4);
}

.item-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.item-emoji {
    font-size: 48px;
    margin-bottom: 5px;
    position: relative;
    z-index: 2;
}

.item-name {
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 3px;
}

.item-info {
    color: rgba(255,255,255,0.8);
    font-size: 11px;
}

.item-price {
    color: #ffd700;
    font-weight: bold;
}

.item-count {
    color: #667eea;
    font-weight: bold;
}

#floating-tips {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

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

.floating-text.persistent {
    animation: none;
}

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

.speech-bubble {
    position: absolute;
    background: #fff;
    border-radius: 20px;
    padding: 12px 18px;
    max-width: 220px;
    font-size: 13px;
    color: #333;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    pointer-events: none;
    z-index: 1000;
    animation: bubblePop 0.3s ease-out;
    font-weight: 500;
    line-height: 1.4;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #fff transparent transparent;
}

.speech-bubble.excited {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #333;
    font-weight: bold;
    box-shadow: 0 4px 25px rgba(255,215,0,0.4);
}

.speech-bubble.excited::after {
    border-color: #ffd700 transparent transparent;
}

.speech-bubble.thought {
    background: rgba(255,255,255,0.95);
    border-radius: 25px;
}

.speech-bubble.thought::after {
    display: none;
}

.speech-bubble.thought::before {
    content: '';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 14px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

@keyframes bubblePop {
    0% {
        opacity: 0;
        transform: scale(0.6) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 768px) {
    .tools-bar {
        top: auto;
        bottom: 230px;
        left: 10px;
        right: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .tool-btn {
        flex-direction: row;
        padding: 10px 15px;
    }
    
    .tool-emoji {
        font-size: 22px;
    }
    
    .user-stats {
        justify-content: center;
    }
    
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    }
    
    .skill-btn {
        width: 60px;
        height: 60px;
    }
    
    .skill-emoji {
        font-size: 26px;
    }
}
