/* 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(135deg, #f0fdf4 0%, #dbeafe 50%, #d1fae5 100%);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.tutorial-overlay.hidden {
    display: none;
}

.tutorial-content {
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 32rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.tutorial-icon {
    width: 4rem;
    height: 4rem;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    animation: pulse 2s infinite;
}

.tutorial-content h2 {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 1rem;
}

.tutorial-content p {
    color: #6b7280;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.scoring-guide {
    text-align: left;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.score-item.special {
    border-top: 1px solid #e5e7eb;
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.points.positive {
    color: #10b981;
    font-weight: bold;
}

.points.negative {
    color: #ef4444;
    font-weight: bold;
}

.points.special {
    color: #8b5cf6;
    font-weight: bold;
}

.start-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.start-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.logo-section {
    display: flex;
    align-items: center;
}

.logo {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 0.75rem;
    animation: pulse 2s infinite;
}

.title-section h1 {
    font-size: 1.875rem;
    font-weight: bold;
    color: #1f2937;
    margin: 0;
}

.title-section p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0;
}

.header-buttons {
    display: flex;
    gap: 0.75rem;
}

.btn {
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.btn-blue {
    background: #3b82f6;
    color: white;
}

.btn-blue:hover {
    background: #2563eb;
}

.btn-red {
    background: #ef4444;
    color: white;
}

.btn-red:hover {
    background: #dc2626;
}

.btn-gray {
    background: #6b7280;
    color: white;
}

.btn-gray:hover {
    background: #4b5563;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Main Layout */
.main-content {
    padding: 2rem 0;
}

.game-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

/* Game Area */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Score Board */
.score-board {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.main-score {
    text-align: center;
    margin-bottom: 1.5rem;
}

.score-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #3b82f6;
    margin-bottom: 0.5rem;
    animation: pulse 2s infinite;
}

.score-value.complete {
    color: #10b981;
    animation: bounce 1s infinite;
}

.score-label {
    font-size: 1.125rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.progress-bar {
    width: 100%;
    height: 1rem;
    background: #e5e7eb;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 0.5rem;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-fill.complete {
    background: linear-gradient(90deg, #10b981, #059669);
}

.progress-text {
    font-size: 0.875rem;
    color: #6b7280;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-item {
    text-align: center;
}

.stat-icon {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #1f2937;
}

.stat-value.warning {
    color: #ef4444;
    animation: pulse 1s infinite;
}

/* Planet Section */
.planet-section {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.planet-section h2 {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.planet-section p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

.game-status {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
}

.game-status.game-over {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.game-status.level-complete {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.planet-container {
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
}

.planet {
    position: relative;
    width: 16rem;
    height: 16rem;
    border-radius: 50%;
    overflow: hidden;
}

.sky {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, #93c5fd, #3b82f6);
    border-radius: 50%;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.1);
}

.sun {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 3rem;
    height: 3rem;
    background: #fbbf24;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.5);
    transition: all 1s ease;
}

.sun-inner {
    position: absolute;
    inset: 0.5rem;
    background: #f59e0b;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.pollution-cloud {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(75, 85, 99, 0.8) 0%, rgba(55, 65, 81, 0.6) 50%, transparent 70%);
    border-radius: 50%;
    transition: all 1s ease;
    opacity: 0;
}

.pollution-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.pollution-particle {
    position: absolute;
    width: 0.75rem;
    height: 0.75rem;
    background: #6b7280;
    border-radius: 50%;
    animation: float 3s ease-in-out infinite;
    opacity: 0;
    transition: opacity 1s ease;
}

.air-quality {
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

/* Game Grid Section */
.game-grid-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.grid-header {
    margin-bottom: 1rem;
}

.grid-header h2 {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 0.5rem;
}

.grid-header p {
    color: #6b7280;
    margin-bottom: 1rem;
}

.grid-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.control-buttons {
    display: flex;
    gap: 0.5rem;
}

.moves-left {
    font-size: 0.875rem;
    color: #6b7280;
}

.moves-left span {
    font-weight: bold;
    color: #3b82f6;
}

.moves-left span.warning {
    color: #ef4444;
    animation: pulse 1s infinite;
}

/* Game Grid */
.game-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
    background: #e5e7eb;
    padding: 0.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
}

.grid-cell {
    aspect-ratio: 1;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.grid-cell:hover {
    transform: scale(1.05);
}

.grid-cell.selected {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px white, 0 0 0 6px #3b82f6;
    z-index: 10;
}

.grid-cell.matched {
    animation: matchPulse 0.4s ease;
    transform: scale(0.75);
    opacity: 0.5;
}

.grid-cell.empty {
    background: #f3f4f6;
    cursor: not-allowed;
}

.grid-cell.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Hint System */
.hint-cell {
    box-shadow: 0 0 0 3px #fbbf24 !important;
    animation: hintPulse 1s infinite;
}

@keyframes hintPulse {
    0%, 100% { 
        box-shadow: 0 0 0 3px #fbbf24; 
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 6px #fbbf24; 
        transform: scale(1.05);
    }
}

/* Floating Text Animation */
@keyframes floatUp {
    0% { 
        transform: translate(-50%, -50%) scale(0.8); 
        opacity: 0; 
    }
    20% { 
        transform: translate(-50%, -50%) scale(1.1); 
        opacity: 1; 
    }
    100% { 
        transform: translate(-50%, -70px) scale(1); 
        opacity: 0; 
    }
}

/* Cell Types */
.cell-tree { background: linear-gradient(135deg, #10b981, #059669); }
.cell-bike { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.cell-recycle { background: linear-gradient(135deg, #10b981, #047857); }
.cell-water { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.cell-solar { background: linear-gradient(135deg, #f59e0b, #d97706); }
.cell-placeholder_recycle { 
    background: linear-gradient(135deg, #f0fdf4, #dcfce7); 
}
.cell-placeholder_water { 
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe); 
}
.cell-placeholder_solar { 
    background: linear-gradient(135deg, #fefce8, #fef3c7); 
}
.cell-garbage { background: linear-gradient(135deg, #4b5563, #374151); }
.cell-pipe { background: linear-gradient(135deg, #dc2626, #991b1b); }

/* Power-up Cells */
.cell-lightning { 
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
    animation: powerupGlow 2s ease-in-out infinite;
}

.cell-bomb { 
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
    animation: powerupGlow 2s ease-in-out infinite;
}

.cell-rainbow { 
    background: linear-gradient(135deg, #8b5cf6, #7c3aed, #3b82f6, #10b981, #f59e0b, #ef4444);
    background-size: 300% 300%;
    animation: rainbowShift 3s ease infinite, powerupGlow 2s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.6);
}

@keyframes powerupGlow {
    0%, 100% { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 15px rgba(251, 191, 36, 0.4); }
    50% { box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), 0 0 25px rgba(251, 191, 36, 0.8); }
}

@keyframes rainbowShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Scoring Reference */
.scoring-reference {
    background: #f9fafb;
    padding: 1rem;
    border-radius: 0.5rem;
}

.scoring-reference h3 {
    font-size: 0.875rem;
    font-weight: bold;
    color: #374151;
    margin-bottom: 0.75rem;
}

.scoring-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.scoring-column {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-ref-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
}

.score-ref-item.special {
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    border-left: 3px solid #8b5cf6;
}

.score-ref-item .icon {
    margin-right: 0.5rem;
}

.tips {
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.tips p {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.25rem;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Achievements */
.achievements-section {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.achievements-section h2 {
    font-size: 1.25rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.achievement-item {
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

.achievement-item.completed {
    background: #f0fdf4;
    border-color: #bbf7d0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.achievement-item:not(.completed) {
    background: #f9fafb;
    border-color: #e5e7eb;
}

.achievement-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.achievement-info {
    display: flex;
    align-items: center;
}

.achievement-icon {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    margin-right: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.achievement-icon.completed {
    background: #10b981;
    color: white;
}

.achievement-icon:not(.completed) {
    border: 2px solid #d1d5db;
    background: white;
}

.achievement-details h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

.achievement-details p {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
}

.achievement-reward {
    text-align: right;
}

.achievement-reward .reward-points {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f59e0b;
}

.achievement-reward .progress-text {
    font-size: 0.75rem;
    color: #6b7280;
}

.achievement-progress {
    margin-top: 0.75rem;
}

.achievement-progress-bar {
    width: 100%;
    height: 0.5rem;
    background: #e5e7eb;
    border-radius: 0.25rem;
    overflow: hidden;
}

.achievement-progress-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 0.25rem;
    transition: width 0.5s ease;
}

/* Impact Section */
.impact-section {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.impact-section h3 {
    font-size: 1.125rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 1rem;
}

.impact-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.impact-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.impact-item span:first-child {
    color: #6b7280;
    font-size: 0.875rem;
}

.impact-value {
    font-weight: bold;
    font-size: 0.875rem;
}

.impact-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.5rem 0;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% { transform: translate3d(0, 0, 0); }
    40%, 43% { transform: translate3d(0, -10px, 0); }
    70% { transform: translate3d(0, -5px, 0); }
    90% { transform: translate3d(0, -2px, 0); }
}

@keyframes matchPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(0.75); opacity: 0.5; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    33% { transform: translateY(-10px) rotate(120deg); }
    66% { transform: translateY(5px) rotate(240deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 0.5rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .scoring-grid {
        grid-template-columns: 1fr;
    }

    .planet {
        width: 12rem;
        height: 12rem;
    }

    .game-grid {
        gap: 0.125rem;
        padding: 0.25rem;
    }

    .grid-cell {
        font-size: 0.875rem;
    }

    .grid-controls {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .control-buttons {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem 0;
    }

    .game-area {
        gap: 1rem;
    }

    .sidebar {
        gap: 1rem;
    }

    .score-value {
        font-size: 2rem;
    }

    .planet {
        width: 10rem;
        height: 10rem;
    }

    .tutorial-content {
        max-width: 90vw;
        padding: 1.5rem;
    }
}