/* ===================================
   Game Styles - Pipe Snake Game
   =================================== */

/* CSS Variables */
:root {
    --primary-blue: #2c5f8d;
    --dark-blue: #1a4263;
    --accent-orange: #ff6b35;
    --success-green: #4caf50;
    --warning-red: #f44336;
    --light-bg: #f5f5f5;
    --white: #ffffff;
    --text-dark: #333333;
    --text-light: #666666;
    --game-bg: #e3f2fd;
    --grid-line: #d0d0d0;
    --snake-head: #1976d2;
    --snake-body: #42a5f5;
    --pipe-dark: #607d8b;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, var(--game-bg) 0%, #bbdefb 100%);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.game-header {
    background: var(--white);
    box-shadow: 0 2px 10px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar {
    padding: 1rem 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.nav-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.logo i {
    font-size: 1.8rem;
    color: var(--accent-orange);
}

.back-btn {
    background: var(--primary-blue);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-btn:hover {
    background: var(--dark-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

/* Game Section */
.game-section {
    flex: 1;
    padding: 2rem 0;
}

.game-header-content {
    text-align: center;
    margin-bottom: 2rem;
}

.game-title {
    font-size: 2.5rem;
    color: var(--primary-blue);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.game-title i {
    color: var(--accent-orange);
}

.game-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
}

/* Game Stats Display */
.game-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 4px 15px var(--shadow);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease;
}

.stat-box:hover {
    transform: translateY(-5px);
}

.stat-box i {
    font-size: 2rem;
    color: var(--accent-orange);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-blue);
}

/* Instructions Panel */
.instructions-panel {
    background: var(--white);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 8px 30px var(--shadow);
    text-align: center;
    margin-bottom: 2rem;
}

.instructions-panel.hidden {
    display: none;
}

.instructions-content h2 {
    color: var(--primary-blue);
    font-size: 2rem;
    margin-bottom: 2rem;
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2.5rem;
}

.instruction-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.instruction-item i {
    font-size: 3rem;
    color: var(--accent-orange);
}

.instruction-item p {
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1.5;
}

.instruction-item strong {
    color: var(--primary-blue);
}

/* Buttons */
.btn {
    padding: 15px 40px;
    border: none;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.btn-start {
    background: var(--success-green);
    color: var(--white);
    font-size: 1.3rem;
    padding: 18px 50px;
}

.btn-start:hover {
    background: #45a049;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.btn-restart {
    background: var(--accent-orange);
    color: var(--white);
}

.btn-restart:hover {
    background: #ff5722;
    transform: scale(1.05);
}

.btn-secondary {
    background: var(--primary-blue);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--dark-blue);
    transform: scale(1.05);
}

/* Game Container */
.game-container {
    display: none;
    margin-bottom: 2rem;
}

.game-container.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.game-area {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 8px 30px var(--shadow);
    border: 3px solid var(--primary-blue);
    position: relative;
    margin: 0 auto;
}

/* Grid Cell Styles */
.grid-cell {
    background: #fafafa;
    border: 1px solid var(--grid-line);
    position: relative;
    transition: background 0.1s ease;
}

/* Snake Styles */
.snake-head {
    background: var(--snake-head);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    position: relative;
    z-index: 2;
}

.snake-head i {
    color: var(--white);
    font-size: 14px;
}

.snake-body {
    background: linear-gradient(135deg, var(--snake-body) 0%, var(--primary-blue) 100%);
    border: none;
    position: relative;
    border-radius: 2px;
}

.pipe-connector {
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, var(--pipe-dark) 0%, var(--pipe-dark) 30%, transparent 30%, transparent 70%, var(--pipe-dark) 70%, var(--pipe-dark) 100%);
    opacity: 0.3;
}

/* Food/Collectible Styles */
.food-cell {
    background: #fff3e0;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1s ease-in-out infinite;
}

.food-cell i {
    font-size: 16px;
}

.item-wrench i {
    color: #ff9800;
}

.item-pipe i {
    color: #9e9e9e;
}

.item-faucet i {
    color: #00bcd4;
}

.item-toilet i {
    color: #e91e63;
}

.item-screwdriver i {
    color: #ff6b35;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

/* Collection Feedback */
.collect-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--success-green);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 100;
    animation: collectFeedback 1s ease forwards;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

@keyframes collectFeedback {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -70%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(1);
    }
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 1rem;
}

.control-row {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.control-btn {
    width: 60px;
    height: 60px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:active {
    transform: scale(0.95);
    background: var(--dark-blue);
}

.control-btn:hover {
    background: var(--dark-blue);
}

/* Game Over Panel */
.game-over-panel {
    display: none;
    background: var(--white);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 8px 30px var(--shadow);
    text-align: center;
}

.game-over-panel.active {
    display: block;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-over-content i {
    font-size: 4rem;
    color: var(--accent-orange);
    margin-bottom: 1rem;
}

.game-over-content h2 {
    color: var(--primary-blue);
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.final-stat {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.final-stat-label {
    font-size: 1rem;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
}

.final-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-blue);
}

.performance-message {
    background: var(--game-bg);
    padding: 1.5rem;
    border-radius: 15px;
    margin-bottom: 2rem;
    font-size: 1.2rem;
    color: var(--text-dark);
    font-weight: 600;
}

.game-over-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Footer */
.game-footer {
    background: var(--white);
    padding: 2rem 0;
    text-align: center;
    box-shadow: 0 -2px 10px var(--shadow);
    margin-top: auto;
}

.game-footer p {
    color: var(--text-light);
}

.game-footer a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
}

.game-footer a:hover {
    color: var(--accent-orange);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }

    .game-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .instructions-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .game-area {
        transform: scale(0.9);
        transform-origin: center;
    }

    .final-stats {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .instructions-panel,
    .game-over-panel {
        padding: 2rem 1rem;
    }

    .game-over-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .mobile-controls {
        display: flex;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 10px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .back-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .stat-box {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .game-area {
        transform: scale(0.75);
    }

    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .instruction-item i {
        font-size: 2rem;
    }

    .instruction-item p {
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .game-area {
        transform: scale(0.65);
    }
}