* {
    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;
    padding: 10px;
    overflow-x: hidden;
}

.game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 20px;
    max-width: 800px;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    color: #667eea;
    font-size: 2em;
    margin-bottom: 15px;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.info-item {
    background: #f0f4ff;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 1.1em;
}

.info-item .label {
    color: #666;
    margin-right: 5px;
}

.info-item .value {
    color: #667eea;
    font-weight: bold;
    font-size: 1.2em;
}

.game-board-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
    min-height: 400px;
}

#game-canvas {
    border: 3px solid #667eea;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    background: #f9f9f9;
    max-width: 100%;
    height: auto;
}

.game-controls {
    margin: 20px 0;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.control-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: 600;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

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

/* 虚拟方向键 */
.virtual-controls {
    display: none;
    justify-content: center;
    margin: 20px 0;
}

.dpad {
    position: relative;
    width: 200px;
    height: 200px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 5px;
}

.dpad-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    font-size: 2em;
    cursor: pointer;
    border-radius: 10px;
    transition: transform 0.1s, opacity 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.dpad-up {
    grid-column: 2;
    grid-row: 1;
}

.dpad-left {
    grid-column: 1;
    grid-row: 2;
}

.dpad-right {
    grid-column: 3;
    grid-row: 2;
}

.dpad-down {
    grid-column: 2;
    grid-row: 3;
}

.dpad-center {
    grid-column: 2;
    grid-row: 2;
    background: rgba(102, 126, 234, 0.2);
    border-radius: 50%;
}

.instructions {
    background: #f0f4ff;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.instructions h3 {
    color: #667eea;
    margin-bottom: 10px;
}

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

.instructions li {
    padding: 5px 0;
    color: #555;
}

.instructions strong {
    color: #667eea;
}

/* 胜利提示模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease-out;
}

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

.modal-content h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s;
    font-weight: 600;
}

.modal-btn.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-btn:not(.primary) {
    background: #f0f4ff;
    color: #667eea;
}

.modal-btn:hover {
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .game-container {
        padding: 15px;
        border-radius: 15px;
    }
    
    .game-header h1 {
        font-size: 1.5em;
    }
    
    .game-info {
        gap: 15px;
    }
    
    .info-item {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    
    .control-btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
    
    .virtual-controls {
        display: flex !important;
    }
    
    .instructions {
        padding: 15px;
    }
    
    .instructions h3 {
        font-size: 1em;
    }
    
    .instructions li {
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 1.3em;
    }
    
    .game-info {
        gap: 10px;
    }
    
    .info-item {
        padding: 6px 12px;
        font-size: 0.85em;
    }
    
    .control-buttons {
        gap: 8px;
    }
    
    .control-btn {
        padding: 8px 16px;
        font-size: 0.85em;
    }
    
    .dpad {
        width: 180px;
        height: 180px;
    }
    
    .dpad-btn {
        font-size: 1.5em;
    }
    
    .modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .modal-content h2 {
        font-size: 1.5em;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .virtual-controls {
        display: flex !important;
    }
    
    .control-btn,
    .modal-btn,
    .dpad-btn {
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }
}
