/* ============================================
   贪吃蛇游戏 - 暗黑霓虹主题样式
   ============================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    /* 动态呼吸背景 */
    background: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #0a0a1a 100%);
    background-size: 200% 200%;
    animation: bgBreathe 15s ease infinite alternate;
    color: #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

@keyframes bgBreathe {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ---------- Game Container ---------- */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    max-width: 640px;
    width: 100%;
    animation: containerIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes containerIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Header ---------- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 440px;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(0, 255, 136, 0.15);
    border-radius: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(0, 255, 136, 0.5));
}

.title {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 2px;
}

.header-right {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 20px;
    font-weight: 900;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
}

.stat-value.highlight {
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
}

/* ---------- Canvas Wrapper ---------- */
.canvas-wrapper {
    position: relative;
    border: 2px solid rgba(0, 255, 136, 0.3);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 
        0 0 30px rgba(0, 255, 136, 0.1),
        inset 0 0 30px rgba(0, 0, 0, 0.5);
    animation: canvasGlow 4s ease-in-out infinite alternate;
    line-height: 0;
}

@keyframes canvasGlow {
    from { box-shadow: 0 0 20px rgba(0, 255, 136, 0.1), inset 0 0 20px rgba(0, 0, 0, 0.4); border-color: rgba(0, 255, 136, 0.2); }
    to { box-shadow: 0 0 40px rgba(0, 255, 136, 0.25), inset 0 0 40px rgba(0, 0, 0, 0.6); border-color: rgba(0, 255, 136, 0.45); }
}

canvas {
    display: block;
    border-radius: 10px;
}

/* ---------- Overlays ---------- */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(10, 10, 26, 0.80);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 10;
    line-height: 1.5;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ---------- Panel (毛玻璃) ---------- */
.panel {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(0, 255, 136, 0.25);
    border-top: 1px solid rgba(0, 255, 136, 0.4);
    border-radius: 20px;
    padding: 32px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    min-width: 260px;
    max-width: 320px;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow:
        0 0 50px rgba(0, 255, 136, 0.12),
        0 12px 40px rgba(0, 0, 0, 0.5);
    animation: panelBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes panelBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.panel-title {
    font-size: 28px;
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 0 10px rgba(0, 255, 136, 0.4));
    letter-spacing: 4px;
}

.panel-subtitle {
    font-size: 13px;
    color: #94a3b8;
    margin-top: -8px;
    letter-spacing: 2px;
}

.pause-title {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.4));
}

.gameover-title {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 10px rgba(255, 71, 87, 0.4));
}

/* ---------- Buttons ---------- */
.btn {
    width: 100%;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #00ff88, #00cc6a);
    color: #0a0a1a;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.4), rgba(255,255,255,0));
    transform: skewX(-25deg);
    transition: left 0.5s ease;
    z-index: -1;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 255, 136, 0.5);
    background: linear-gradient(135deg, #1aff9c, #00e676);
}

.btn-primary:hover::after {
    left: 150%;
}

.btn-primary:active {
    transform: translateY(1px) scale(0.97);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: #94a3b8;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

/* ---------- Difficulty Group ---------- */
.diff-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.diff-label {
    font-size: 13px;
    color: #94a3b8;
    margin-right: 4px;
}

.diff-btn {
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.diff-btn:hover {
    border-color: rgba(0, 255, 136, 0.4);
    color: #e2e8f0;
}

.diff-btn.active {
    background: rgba(0, 255, 136, 0.15);
    border-color: #00ff88;
    color: #00ff88;
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.15);
}

/* ---------- Menu Info ---------- */
.menu-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
}

.info-row {
    color: #e2e8f0;
}

.info-row.dim {
    color: #64748b;
    font-size: 12px;
}

/* ---------- Score Display (Game Over) ---------- */
.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    width: 100%;
}

.score-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 16px;
}

.score-final {
    font-weight: 900;
    font-size: 22px;
    color: #e2e8f0;
}

.score-high {
    font-weight: 700;
    color: #ffd700;
}

.new-record {
    font-size: 16px;
    font-weight: 700;
    color: #ffd700;
    text-align: center;
    animation: recordPulse 0.6s ease-in-out infinite alternate;
}

@keyframes recordPulse {
    from {
        text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
        transform: scale(1);
    }
    to {
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.7);
        transform: scale(1.05);
    }
}

/* ---------- Footer ---------- */
.game-footer {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 440px;
    padding: 6px 16px;
    font-size: 12px;
}

.footer-info {
    color: #94a3b8;
}

.footer-info.dim {
    color: #475569;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .game-container {
        padding: 8px;
        gap: 8px;
    }

    .game-header {
        padding: 6px 12px;
        border-radius: 8px;
    }

    .title {
        font-size: 15px;
    }

    .stat-value {
        font-size: 17px;
    }

    .canvas-wrapper {
        border-radius: 8px;
    }

    .panel {
        padding: 24px 24px;
        min-width: 220px;
        border-radius: 16px;
    }

    .panel-title {
        font-size: 22px;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
}

@media (max-height: 640px) {
    .game-container {
        gap: 6px;
        padding: 6px;
    }

    .game-header {
        padding: 4px 12px;
    }

    .panel {
        padding: 20px 24px;
        gap: 10px;
    }
}
