/* ========================================
   疯狂贪吃蛇 - 样式表
   ======================================== */

/* 全局样式 */
* {
    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%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    color: #fff;
}

/* 加载提示 */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loading p {
    margin-top: 20px;
    font-size: 18px;
    color: #fff;
}

/* 游戏容器 */
#gameContainer {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 640px;
    width: 100%;
}

/* 顶部信息栏 */
#topBar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.info-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.info-item .label {
    font-size: 12px;
    opacity: 0.8;
    margin-bottom: 5px;
}

.info-item .value {
    font-size: 20px;
    font-weight: bold;
    color: #ffd700;
}

/* 游戏画布 */
#gameCanvas {
    display: block;
    width: 100%;
    max-width: 600px;
    height: auto;
    aspect-ratio: 1;
    background: #1a1a2e;
    border-radius: 10px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    margin: 0 auto;
}

/* 道具栏 */
#powerUpBar {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.powerup-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    transition: all 0.3s;
}

.powerup-slot.active {
    background: rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    animation: pulse 1s infinite;
}

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

.powerup-icon {
    font-size: 32px;
    margin-bottom: 5px;
}

.powerup-time {
    font-size: 12px;
    color: #ffd700;
    font-weight: bold;
}

/* 控制按钮 */
#controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.control-btn {
    padding: 12px 24px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.control-btn:active {
    transform: translateY(0);
}

/* 移动端控制 */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
}

#mobileControls {
    margin-top: 20px;
}

.dpad {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

.dpad-btn {
    position: absolute;
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dpad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* 菜单样式 */
.menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.menu-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
    max-width: 500px;
    width: 90%;
    animation: slideUp 0.3s;
}

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

.game-title {
    font-size: 48px;
    margin-bottom: 10px;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    animation: titleBounce 2s infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-subtitle {
    font-size: 18px;
    opacity: 0.9;
    margin-bottom: 30px;
}

/* 模式选择 */
.mode-selection {
    display: flex;
    gap: 15px;
    margin: 30px 0;
}

.mode-btn {
    flex: 1;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.mode-icon {
    font-size: 48px;
}

.mode-name {
    font-size: 20px;
    font-weight: bold;
}

.mode-desc {
    font-size: 14px;
    opacity: 0.8;
}

/* 菜单统计 */
.menu-stats {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 18px;
}

/* 按钮样式 */
.primary-btn, .secondary-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    margin: 10px;
    min-width: 200px;
}

.primary-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(245, 87, 108, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-3px);
}

/* 游戏结束样式 */
.game-over-title {
    font-size: 42px;
    margin-bottom: 20px;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.game-over-stats {
    background: rgba(0, 0, 0, 0.3);
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
}

.game-over-stats p {
    font-size: 20px;
    margin: 10px 0;
}

.final-score {
    font-size: 28px !important;
    color: #ffd700;
    font-weight: bold;
}

.new-record {
    color: #00ff00;
    font-size: 24px !important;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 帮助内容 */
.help-content {
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

.help-content h2 {
    text-align: center;
    margin-bottom: 20px;
}

.help-section {
    margin: 20px 0;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.help-section h3 {
    margin-bottom: 10px;
    color: #ffd700;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
}

.help-section li {
    margin: 8px 0;
    padding-left: 25px;
    position: relative;
}

.help-section li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: #ffd700;
}

.help-icon {
    font-size: 20px;
    margin-right: 5px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #gameContainer {
        padding: 10px;
    }

    #topBar {
        padding: 10px;
    }

    .info-item {
        min-width: 60px;
    }

    .info-item .label {
        font-size: 10px;
    }

    .info-item .value {
        font-size: 16px;
    }

    .game-title {
        font-size: 36px;
    }

    .mode-selection {
        flex-direction: column;
    }

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

    .powerup-slot {
        width: 60px;
        height: 60px;
    }

    .powerup-icon {
        font-size: 24px;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
