/* =====================================================
   Snake Game - Modern Design System
   ===================================================== */

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

:root {
    /* Primary Colors */
    --primary-gradient: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    --snake-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --food-color: #ff6b6b;

    /* Background Colors */
    --bg-dark: #0a0a1a;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Effects */
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glow-green: 0 0 20px rgba(56, 239, 125, 0.4);

    /* Sizes */
    --border-radius: 20px;
    --border-radius-sm: 12px;
}

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* =====================================================
   Background Animation
   ===================================================== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(17, 153, 142, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(56, 239, 125, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(0, 210, 255, 0.1) 0%, transparent 60%);
    animation: gradientShift 15s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
    }
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.3;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: linear-gradient(135deg, #11998e, #38ef7d);
    top: -50px;
    right: -50px;
    animation: float1 20s ease-in-out infinite;
}

.shape-2 {
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, #00d2ff, #3a7bd5);
    bottom: 10%;
    left: -50px;
    animation: float2 25s ease-in-out infinite;
}

.shape-3 {
    width: 200px;
    height: 200px;
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    top: 40%;
    right: 10%;
    animation: float3 18s ease-in-out infinite;
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-50px, 50px) rotate(120deg); }
    66% { transform: translate(-30px, 80px) rotate(240deg); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(60px, -40px); }
}

@keyframes float3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 30px) scale(1.1); }
}

/* =====================================================
   Container & Layout
   ===================================================== */
.container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =====================================================
   Header
   ===================================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.back-btn {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.title-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.game-icon {
    font-size: 2rem;
    animation: snakeWiggle 2s ease-in-out infinite;
}

@keyframes snakeWiggle {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.game-title {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--snake-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   Game Container
   ===================================================== */
.game-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* =====================================================
   Score Panel
   ===================================================== */
.score-panel {
    display: flex;
    justify-content: space-around;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 15px;
    backdrop-filter: blur(10px);
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.score-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--snake-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* =====================================================
   Canvas Wrapper
   ===================================================== */
.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 2px solid var(--glass-border);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

/* =====================================================
   Game Overlay
   ===================================================== */
.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    transition: opacity 0.3s ease;
}

.game-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 30px;
}

#overlay-title {
    font-size: 2rem;
    margin-bottom: 15px;
    background: var(--snake-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#overlay-message {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.start-btn {
    padding: 15px 40px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    background: var(--snake-gradient);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--glow-green);
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(56, 239, 125, 0.6);
}

.start-btn:active {
    transform: scale(0.98);
}

/* =====================================================
   Mobile Controls
   ===================================================== */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
}

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

.control-btn {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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

/* =====================================================
   Control Hints
   ===================================================== */
.control-hints {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 15px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.hint-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.hint-keys {
    font-family: monospace;
    background: var(--bg-card);
    padding: 5px 10px;
    border-radius: 5px;
    border: 1px solid var(--glass-border);
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .game-title {
        font-size: 1.2rem;
    }

    .score-value {
        font-size: 1.2rem;
    }

    .mobile-controls {
        display: flex;
    }

    .control-hints {
        display: none;
    }
}

@media (max-width: 480px) {
    .header {
        justify-content: center;
    }

    .back-btn {
        position: absolute;
        left: 15px;
        top: 20px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .title-area {
        margin-top: 40px;
    }

    .score-panel {
        padding: 12px;
    }

    .score-label {
        font-size: 0.65rem;
    }

    .score-value {
        font-size: 1rem;
    }

    .control-btn {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    #overlay-title {
        font-size: 1.5rem;
    }

    #overlay-message {
        font-size: 0.85rem;
    }

    .start-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

/* =====================================================
   Touch device optimization
   ===================================================== */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        display: flex;
    }

    .control-hints {
        display: none;
    }
}
