* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.game-container {
    max-width: 900px;
    margin: 0 auto;
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.game-header h1 {
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.main-content {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.canvas-wrapper {
    position: relative;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 10px;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

#gameCanvas:hover {
    transform: scale(1.02);
}

.click-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    animation: pulse 2s ease-in-out infinite;
    z-index: 10;
}

.transition-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0);
    pointer-events: none;
    z-index: 20;
    transition: background 0.5s ease;
}

.transition-overlay.active {
    background: rgba(255, 255, 255, 1);
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.status-panel {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 25px;
    width: 320px;
    min-width: 280px;
}

.status-item {
    margin-bottom: 20px;
}

.status-item label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 500;
}

.sprite-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.sprite-element {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    color: white;
}

.element-fire { background: linear-gradient(135deg, #ff6b35, #f7931e); }
.element-water { background: linear-gradient(135deg, #48dbfb, #0abde3); }
.element-grass { background: linear-gradient(135deg, #1dd1a1, #10ac84); }
.element-light { background: linear-gradient(135deg, #ffd93d, #ff9500); }
.element-crystal { background: linear-gradient(135deg, #54a0ff, #2e86de); }
.element-dark { background: linear-gradient(135deg, #2c3e50, #34495e); }
.element-legend { background: linear-gradient(135deg, #fd79a8, #e84393); }

.affection-bar-container {
    position: relative;
    height: 30px;
    background: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
}

.affection-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff6b6b, #feca57, #48dbfb, #1dd1a1);
    border-radius: 15px;
    transition: width 0.3s ease;
    width: 0%;
}

.affection-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    color: #333;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
}

.sprite-status {
    font-size: 1rem;
    color: #444;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    min-height: 45px;
    transition: all 0.3s ease;
}

.sprite-stats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-tag {
    padding: 4px 10px;
    background: #f0f0f0;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #666;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-warning {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(240, 147, 251, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

.btn-danger:active {
    transform: translateY(1px);
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #a0aec0 0%, #718096 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(160, 174, 192, 0.4);
}

.confirm-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.confirm-modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: slideIn 0.3s ease;
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.modal-content h3 {
    color: #333;
    margin-bottom: 10px;
}

.modal-content p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-buttons {
    display: flex;
    gap: 15px;
}

.modal-buttons .btn {
    flex: 1;
}

.cg-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.cg-modal.show {
    display: flex;
}

.cg-content {
    background: white;
    border-radius: 25px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

.cg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, #ffd93d, #ff9500);
    color: white;
}

.cg-header h3 {
    margin: 0;
    font-size: 1.3rem;
}

.close-btn {
    background: rgba(255, 255, 255, 0.3);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.5);
}

.cg-image-container {
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.cg-frame {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    position: relative;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cg-sprite {
    font-size: 80px;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 10px 30px rgba(0,0,0,0.2));
}

.cg-text {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #666;
    font-style: italic;
    animation: fadeInUp 0.5s ease 0.3s both;
}

.cg-info {
    padding: 20px 25px;
    text-align: center;
}

.cg-sprite-name {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.cg-description {
    font-size: 0.95rem;
    color: #666;
    line-height: 1.5;
}

.cg-buttons {
    display: flex;
    gap: 15px;
    padding: 20px 25px;
    border-top: 1px solid #eee;
}

.cg-buttons .btn {
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0; 
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sprite-backpack {
    margin-top: 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 25px;
}

.backpack-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.backpack-header h3 {
    font-size: 1.3rem;
    color: #333;
}

.backpack-count {
    font-size: 0.9rem;
    color: #666;
    background: #f0f0f0;
    padding: 4px 12px;
    border-radius: 15px;
}

.backpack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.backpack-item {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 15px;
    overflow: hidden;
}

.backpack-item:hover {
    transform: translateY(-5px);
}

.backpack-item.selected {
    box-shadow: 0 0 0 3px #667eea, 0 5px 20px rgba(102, 126, 234, 0.3);
    transform: scale(1.05);
}

.backpack-item.empty {
    background: #f0f0f0;
    border: 2px dashed #ddd;
    cursor: default;
}

.backpack-item.empty:hover {
    transform: none;
}

.backpack-item .sprite-preview {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    position: relative;
}

.backpack-item .sprite-preview.has-bg {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
}

.backpack-item .sprite-info {
    padding: 10px;
    background: #f8f9fa;
    text-align: center;
}

.backpack-item .sprite-info .name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
}

.backpack-item .sprite-info .affection {
    font-size: 0.7rem;
    color: #666;
    margin-top: 2px;
}

.backpack-item .select-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #667eea;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.backpack-item.selected .select-indicator {
    opacity: 1;
}

.backpack-item .evolution-level {
    position: absolute;
    bottom: 5px;
    left: 5px;
    font-size: 10px;
    display: flex;
    gap: 1px;
}

.sprite-collection {
    margin-top: 30px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 25px;
}

.sprite-collection h3 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 15px;
}

.collection-item {
    text-align: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 15px;
    transition: all 0.3s ease;
    position: relative;
}

.collection-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.collection-item.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.collection-item .emoji {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

.collection-item .name {
    font-size: 0.85rem;
    color: #333;
    font-weight: 500;
}

.collection-item .rarity {
    font-size: 0.7rem;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 10px;
    display: inline-block;
}

.rarity-common { background: #e0e0e0; color: #666; }
.rarity-rare { background: #d6eaf8; color: #2980b9; }
.rarity-legendary { background: #fef5e7; color: #f39c12; }

.collection-item .progress {
    font-size: 0.7rem;
    color: #999;
    margin-top: 4px;
}

.milestone-message {
    animation: fadeInOut 1.5s ease forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        align-items: center;
    }
    
    .status-panel {
        width: 100%;
        max-width: 400px;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .backpack-grid,
    .collection-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes sparkle {
    0%, 100% { opacity: 0; transform: scale(0); }
    50% { opacity: 1; transform: scale(1); }
}

@keyframes glow {
    0%, 100% { filter: drop-shadow(0 0 5px currentColor); }
    50% { filter: drop-shadow(0 0 20px currentColor); }
}