/* 颜色变量 */
:root {
    --primary-color: #3b82f6;
    --secondary-color: #10b981;
    --accent-color: #06d6a0;
}

/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    background-attachment: fixed;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="60" height="60" viewBox="0 0 60 60" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><g fill="%23ffffff" fill-opacity="0.05"><path d="M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z"/></g></g></svg>');
    z-index: -1;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部控制区 */
.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.header-controls h1 {
    text-align: left;
    color: #ffffff;
    font-size: 2.8rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    margin: 0;
}

/* 语言选择器 */
.lang-select {
    background: #ffffff;
    color: #2c3e50;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    width: 120px;
    height: 36px;
    padding: 6px 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.lang-select:hover {
    background: #f8f9fa;
    border-color: #3498db;
    color: #3498db;
}

.lang-select:focus {
    outline: none;
    border-color: #3498db;
}

.lang-select:active {
    background: #e9ecef;
}

/* 设置面板 */
.setup-panel {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.input-group {
    margin: 4px;
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    min-width: 0;
    flex: 0 1 auto;
}

.input-group label {
    margin-right: 6px;
    font-weight: 600;
    color: #2c3e50;
    white-space: nowrap;
}

input[type="number"], select {
    width: 60px;
    padding: 6px 8px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

select {
    width: 85px;
}

input[type="number"]:hover, select:hover {
    border-color: #3498db;
}

input[type="number"]:focus, select:focus {
    outline: none;
    border-color: #3498db;
}

button {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
    margin: 4px;
    flex: 0 1 auto;
}

button:hover {
    background: linear-gradient(135deg, #2980b9 0%, #21618c 100%);
}

button:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

#generate-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

#reset-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

#reset-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

#reset-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

/* 游戏容器 */
.game-container {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.game-board {
    display: grid;
    grid-gap: 3px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* 棋盘格子样式 */
.cell {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.water {
    background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
}

.grass {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    position: relative;
}

.grass::after {
    content: '🌿';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.7;
}

.rock {
    background: linear-gradient(135deg, #7f8c8d 0%, #95a5a6 100%);
    position: relative;
}

.rock::after {
    content: '🪨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.7;
}

.siren {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    position: relative;
}

.siren::after {
    content: '🦅';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.7;
}

.ship {
    background: linear-gradient(135deg, #d4a574 0%, #cd853f 100%);
    position: relative;
}

.ship::after {
    content: '🚢';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.7;
}

.fleece {
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    position: relative;
}

.fleece::after {
    content: '🐏';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.8;
}

/* 键盘提示 */
.keyboard-hint {
    text-align: center;
    margin-top: 20px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.keyboard-hint p {
    font-size: 14px;
    color: #6c757d;
    font-weight: 500;
}

/* 优化提示功能 */
.hint-panel {
    position: relative;
    margin-top: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.hint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f39c12;
}

.hint-title {
    display: flex;
    align-items: center;
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin: 0;
}

.hint-icon {
    width: 24px;
    height: 24px;
    margin-right: 10px;
    color: #f39c12;
}


#hint-btn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

#hint-btn:hover {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

#hint-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.3);
}

#hint-btn:active {
    /* 移除点击效果 */
}

.hint-content {
    margin-top: 15px;
    padding: 15px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: none;
    border: 1px solid #e9ecef;
}


.hint-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    margin: 0;
}

.path-hint {
    font-weight: bold;
    color: #e67e22;
    background-color: #fef9e7;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin: 0 2px;
}

.hint-warning {
    background-color: #fef5e7;
    border-left-color: #e74c3c;
    color: #7f8c8d;
    font-style: italic;
}

.hint-success {
    background-color: #eafaf1;
    border-left-color: #27ae60;
    color: #27ae60;
}

.hint-progress {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
    color: #6c757d;
}

.hint-steps {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.hint-step {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e9ecef;
    border-radius: 8px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.hint-step svg {
    stroke: #6c757d;
}

/* 游戏指南面板 */
.game-guide {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
}

.guide-header {
    border-bottom: 2px solid #f39c12;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.guide-header h2 {
    color: #2c3e50;
    margin: 0;
    font-size: 1.5rem;
    text-align: center;
}

.guide-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.rules-section, .legend-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.rules-section h3, .legend-section h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.rules-section p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #555;
}

.rules-section ul {
    padding-left: 20px;
    margin-bottom: 15px;
}

.rules-section li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: #555;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: #f8f9fa;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.legend-item:hover {
    background-color: #e9ecef;
}

.legend-item .cell {
    width: 30px;
    height: 30px;
    margin-right: 10px;
    flex-shrink: 0;
}

/* 错误弹窗样式 */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}


.error-modal .modal-header {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
}

.modal-body {
    padding: 20px;
    text-align: center;
}

.modal-body p {
    margin-bottom: 15px;
    color: #333;
    font-size: 1rem;
}

.modal-body ul {
    text-align: left;
    margin: 15px 0;
    padding-left: 20px;
    color: #555;
}

.modal-body li {
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.modal-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #eee;
}

#close-error-btn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s ease;
}

#close-error-btn:hover {
    background: linear-gradient(135deg, #c0392b 0%, #a93226 100%);
}

#close-error-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.error-suggestions {
    background: linear-gradient(135deg, #fef5e7 0%, #fadbd8 100%);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid #e74c3c;
}

/* 胜利弹窗样式 */
.victory-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.victory-modal .modal-content {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    width: 90%;
}

.victory-modal .modal-header {
    background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    text-align: center;
}

.victory-modal .modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
}

.victory-modal .modal-body {
    padding: 20px;
    text-align: center;
}

.victory-modal .modal-body p {
    margin-bottom: 15px;
    color: #333;
    font-size: 1rem;
}

.victory-stats {
    background: linear-gradient(135deg, #fef5e7 0%, #fadbd8 100%);
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    border-left: 4px solid #ffd700;
}

.victory-stats p {
    margin: 8px 0;
    color: #2c3e50;
    font-size: 0.95rem;
}

.victory-stats strong {
    color: #ffd700;
}

.rating {
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 10px !important;
}

.rating.excellent {
    color: #ffd700;
}

.rating.good {
    color: #f39c12;
}

.rating.normal {
    color: #e67e22;
}

.victory-modal .modal-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#close-victory-btn {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s ease;
}

#close-victory-btn:hover {
    background: linear-gradient(135deg, #7f8c8d 0%, #6c7b7d 100%);
}

#new-game-btn {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s ease;
}

#new-game-btn:hover {
    background: linear-gradient(135deg, #e67e22 0%, #d35400 100%);
}

#close-victory-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(149, 165, 166, 0.3);
}

#new-game-btn:focus {
    outline: none;
    box-shadow: 0 2px 4px rgba(243, 156, 18, 0.3);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header-controls h1 {
        font-size: 2.2rem;
    }
    
    .header-controls {
        margin-bottom: 25px;
    }
    
    .lang-select {
        font-size: 12px;
        width: 100px;
        height: 32px;
        padding: 4px 8px;
    }
    
    .cell {
        width: 40px;
        height: 40px;
        border-radius: 5px;
    }
    
    .setup-panel {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding: 15px;
        gap: 8px;
    }
    
    .input-group {
        margin: 0;
        padding: 6px 8px;
        flex: 1 1 calc(33% - 8px);
        min-width: 120px;
    }
    
    .input-group label {
        margin-right: 8px;
        font-size: 14px;
    }
    
    input[type="number"], select {
        width: 60px;
        padding: 6px 10px;
        font-size: 14px;
    }
    
    select {
        width: 90px;
    }
    
    button {
        margin: 4px;
        width: calc(50% - 8px);
        padding: 10px 16px;
        font-size: 15px;
        flex: 0 1 calc(50% - 8px);
    }
    
    .game-container {
        padding: 15px;
    }
    
    .game-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 10px 14px;
        font-size: 14px;
    }
    
    .board-container {
        padding: 8px;
    }
    
    .game-board {
        padding: 6px;
        grid-gap: 2px;
    }
    
    .keyboard-hint {
        padding: 10px 14px;
    }
    
    .keyboard-hint p {
        font-size: 13px;
    }
    
    .game-guide {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .guide-header h2 {
        font-size: 1.3rem;
    }
    
    .guide-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .rules-section, .legend-section {
        padding: 12px;
    }
    
    .legend-grid {
        grid-template-columns: 1fr;
    }
    
    .legend-item .cell {
        width: 25px;
        height: 25px;
    }
    
    .hint-panel {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .hint-btn {
        padding: 10px 16px;
        font-size: 15px;
    }
    
    .hint-content {
        padding: 12px;
    }
    
    .hint-step {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    .header-controls h1 {
        font-size: 1.8rem;
    }
    
    .header-controls {
        margin-bottom: 20px;
    }
    
    .lang-select {
        font-size: 12px;
        width: 100px;
        height: 32px;
        padding: 4px 8px;
    }
    
    .cell {
        width: 30px;
        height: 30px;
        border-radius: 4px;
    }
    
    .setup-panel {
        padding: 12px;
        gap: 6px;
    }
    
    .input-group {
        padding: 4px 6px;
        flex: 1 1 calc(50% - 6px);
        min-width: 100px;
    }
    
    .input-group label {
        font-size: 13px;
        margin-right: 6px;
    }
    
    input[type="number"], select {
        width: 50px;
        padding: 4px 8px;
        font-size: 13px;
    }
    
    select {
        width: 80px;
    }
    
    button {
        margin: 2px;
        padding: 8px 12px;
        font-size: 14px;
        width: calc(50% - 4px);
        flex: 0 1 calc(50% - 4px);
    }
    
    .game-container {
        padding: 12px;
    }
    
    .game-info {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .board-container {
        padding: 6px;
    }
    
    .game-board {
        padding: 4px;
        grid-gap: 1px;
    }
    
    .keyboard-hint {
        padding: 8px 12px;
    }
    
    .keyboard-hint p {
        font-size: 12px;
    }
    
    .game-guide {
        padding: 12px;
    }
    
    .guide-header h2 {
        font-size: 1.1rem;
    }
    
    .rules-section, .legend-section {
        padding: 10px;
    }
    
    .legend-item .cell {
        width: 20px;
        height: 20px;
    }
    
    .hint-panel {
        padding: 12px;
    }
    
    .hint-btn {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .hint-content {
        padding: 10px;
    }
    
    .hint-step {
        width: 36px;
        height: 36px;
    }
}