* {
    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%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
}

.screen {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
}

.hidden {
    display: none !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

#main-menu {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

h1 {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 40px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
}

.menu-btn {
    padding: 18px 40px;
    font-size: 1.2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.back-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #5a6268;
}

.instructions {
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-top: 30px;
}

.instructions h3 {
    color: #667eea;
    margin-bottom: 10px;
}

.instructions p {
    color: #666;
    margin: 8px 0;
    font-size: 0.95rem;
}

#mode-screen {
    max-width: 800px;
    margin: 0 auto;
}

#mode-title {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
}

.level-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

.level-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.level-item:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.level-item.locked {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

.level-item.locked:hover {
    transform: none;
}

.level-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.level-preview {
    width: 100px;
    height: 100px;
    background: #2c3e50;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.level-preview svg {
    width: 100%;
    height: 100%;
}

.custom-badge {
    display: inline-block;
    background: #ff9800;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    margin-left: 8px;
    vertical-align: middle;
}

.delete-level-btn {
    background: #dc3545;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.delete-level-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

.level-stars {
    margin-top: 10px;
    font-size: 1.2rem;
}

.star {
    color: #ffd700;
}

.star.empty {
    color: #ccc;
}

#game-screen {
    max-width: 1000px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.score-display {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.player-score {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 3px solid transparent;
    transition: all 0.3s ease;
}

.player-score.active {
    border-color: #667eea;
    background: #e8ecff;
}

.player-color {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #333;
}

.player1 .player-color {
    background: #ff6b6b;
}

.player2 .player-color {
    background: #4ecdc4;
}

.player3 .player-color {
    background: #ffe66d;
}

.player-name {
    font-weight: bold;
    color: #333;
}

.score {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.turn-indicator {
    padding: 10px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-weight: bold;
}

.game-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #2c3e50;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    overflow: auto;
}

#game-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.game-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.game-info {
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    color: #666;
}

.restart-btn {
    padding: 10px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    background: #5568d3;
}

#game-over {
    max-width: 500px;
    margin: 0 auto;
    text-align: center;
}

#game-over h2 {
    color: #667eea;
    margin-bottom: 30px;
}

#final-scores {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.final-score-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background: white;
    border-radius: 8px;
}

#winner-text {
    color: #28a745;
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.level-stars-award {
    margin-bottom: 20px;
}

.stars-award {
    font-size: 1.5rem;
    color: #ffd700;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }

    #app {
        max-height: none;
        overflow-y: visible;
    }

    .screen {
        padding: 15px;
        max-height: none;
    }

    h1 {
        font-size: 2.5rem;
    }

    .menu-btn {
        padding: 15px 30px;
        font-size: 1rem;
    }

    .game-header {
        flex-direction: column;
    }

    .score-display {
        width: 100%;
        justify-content: center;
        gap: 10px;
    }

    .level-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        max-height: 50vh;
    }

    .game-container {
        padding: 10px;
    }

    #game-canvas {
        width: 100%;
        max-width: 100%;
    }

    .turn-indicator {
        font-size: 0.9rem;
        padding: 8px 15px;
    }

    .player-score {
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}

/* 自定义地图编辑器样式 */
#custom-map-screen {
    max-width: 900px;
    margin: 0 auto;
}

.custom-map-info {
    background: #e3f2fd;
    border-left: 4px solid #667eea;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
}

.custom-map-info p {
    color: #1976d2;
    font-size: 0.9rem;
    line-height: 1.5;
}

.custom-map-info code {
    background: rgba(102, 126, 234, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.custom-map-controls {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-group label {
    font-weight: bold;
    color: #333;
    font-size: 0.9rem;
}

.control-group input,
.control-group select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background: white;
    transition: border-color 0.3s ease;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.control-buttons {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.control-btn {
    padding: 10px 20px;
    font-size: 1rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.custom-map-preview {
    background: #2c3e50;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: auto;
}

#custom-map-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    cursor: crosshair;
}

.saved-maps-list {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.no-maps {
    text-align: center;
    color: #666;
    padding: 20px;
    font-style: italic;
}

.saved-map-item {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.map-info h4 {
    color: #667eea;
    margin-bottom: 5px;
}

.map-info p {
    color: #666;
    font-size: 0.9rem;
}

.map-actions {
    display: flex;
    gap: 8px;
}

.map-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.load-btn {
    background: #667eea;
    color: white;
}

.load-btn:hover {
    background: #5568d3;
}

.play-btn {
    background: #28a745;
    color: white;
}

.play-btn:hover {
    background: #218838;
}

.delete-btn {
    background: #dc3545;
    color: white;
}

.delete-btn:hover {
    background: #c82333;
}

@media (max-width: 768px) {
    .custom-map-controls {
        grid-template-columns: 1fr;
    }

    .saved-map-item {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .map-actions {
        width: 100%;
        justify-content: center;
    }
}
