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

:root {
    --primary-color: #1e293b;
    --secondary-color: #0f172a;
    --accent-color: #10b981;
    --accent-light: #34d399;
    --danger-color: #ef4444;
    --text-color: #f1f5f9;
    --text-muted: #cbd5e1;
    --border-color: #334155;
    --gradient-1: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-2: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gradient-2);
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 1400px;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--primary-color);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.header {
    text-align: center;
    padding: 30px 20px;
    background: var(--gradient-2);
    border-bottom: 1px solid var(--border-color);
}

.header h1 {
    font-size: 3em;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95em;
    letter-spacing: 0.5px;
}

.game-wrapper {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 20px;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 3px;
}

.stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.05) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.stat-item:hover {
    border-color: var(--accent-color);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(52, 211, 153, 0.1) 100%);
}

.stat-label {
    font-size: 0.85em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--accent-light);
    font-family: 'Courier New', monospace;
}

.controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: var(--accent-light);
    border: 2px solid var(--accent-color);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.1);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.instructions {
    padding: 16px;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.8) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.instructions h3 {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    color: var(--accent-light);
}

.instructions ul {
    list-style: none;
    margin-bottom: 12px;
}

.instructions li {
    font-size: 0.85em;
    padding: 6px 0;
    color: var(--text-muted);
    line-height: 1.5;
}

.instructions strong {
    color: var(--accent-light);
}

.tip {
    font-size: 0.8em;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.5) 0%, rgba(30, 41, 59, 0.5) 100%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    overflow: hidden;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 12px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    display: block;
}

.footer {
    text-align: center;
    padding: 16px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85em;
    background: var(--gradient-2);
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .game-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
    }

    .stats {
        grid-template-columns: repeat(3, 1fr);
        flex: 1;
        gap: 10px;
    }

    .stat-item {
        flex-direction: column;
        text-align: center;
        padding: 12px;
    }

    .controls {
        grid-template-columns: repeat(3, 1fr);
        flex: 0.5;
    }

    .instructions {
        display: none;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }

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

    .controls {
        grid-template-columns: repeat(3, 1fr);
    }

    .btn {
        padding: 10px 12px;
        font-size: 0.8em;
    }
}

/* 游戏结束动画 */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.game-over {
    animation: pulse 0.5s ease;
}
