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

body {
    font-family: 'Microsoft YaHei', 'SimHei', Arial, sans-serif;
    background: url('xy.png') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #d4a574;
    overflow: hidden;
    touch-action: none;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(26, 10, 0, 0.75);
    z-index: -1;
}

.container {
    text-align: center;
    padding: 10px;
}

.start-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #1a0a00;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.start-screen h1 {
    font-size: 48px;
    margin-bottom: 5px;
}

.start-screen .subtitle {
    font-size: 18px;
    margin-bottom: 30px;
}

.start-info {
    margin-bottom: 25px;
    color: #8b7355;
    line-height: 2;
}

.start-info p {
    font-size: 15px;
}

.start-screen select {
    padding: 10px 24px;
    font-size: 16px;
    background: linear-gradient(145deg, #8b4513, #a0522d);
    color: #ffd700;
    border: 1px solid #daa520;
    border-radius: 8px;
    font-family: inherit;
    font-weight: bold;
    margin-bottom: 20px;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23ffd700' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.start-screen select option {
    background: #2d1810;
    color: #d4a574;
}

.start-btn {
    padding: 14px 48px;
    font-size: 22px;
    background: linear-gradient(145deg, #b8860b, #daa520);
    color: #4a0000;
    border: 2px solid #ffd700;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    letter-spacing: 4px;
    transition: all 0.2s;
    box-shadow: 0 0 20px rgba(255,215,0,0.3);
}

.start-btn:hover {
    background: linear-gradient(145deg, #daa520, #ffd700);
    box-shadow: 0 0 30px rgba(255,215,0,0.5);
    transform: scale(1.05);
}

.start-btns {
    display: flex;
    gap: 12px;
    align-items: center;
}

.settings-btn {
    padding: 12px 24px;
    font-size: 16px;
    background: linear-gradient(145deg, #555, #777);
    color: #ffd700;
    border: 1px solid #888;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: linear-gradient(145deg, #666, #999);
}

.settings-box {
    background: #2d1810;
    padding: 24px;
    border-radius: 12px;
    border: 2px solid #8b4513;
    width: 300px;
}

.settings-box h2 {
    font-size: 22px;
    color: #ffd700;
    margin-bottom: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.setting-item label {
    font-size: 16px;
    color: #d4a574;
}

.setting-item select {
    padding: 6px 12px;
    font-size: 14px;
    background: #1a0a00;
    color: #ffd700;
    border: 1px solid #8b4513;
    border-radius: 6px;
    font-family: inherit;
}

.setting-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.setting-btns button {
    padding: 8px 24px;
    font-size: 15px;
}

#saveSettingsBtn {
    background: linear-gradient(145deg, #228b22, #32cd32);
    border-color: #32cd32;
}

h1 {
    font-size: 36px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    margin-bottom: 2px;
    letter-spacing: 6px;
}

.subtitle {
    font-size: 16px;
    color: #d4a574;
    font-weight: normal;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

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

.stat {
    background: rgba(139,69,19,0.5);
    padding: 5px 16px;
    border-radius: 6px;
    border: 1px solid #8b4513;
    color: #ffd700;
    font-size: 16px;
}

.stat.timer-warning {
    color: #ff4444;
    border-color: #ff4444;
    animation: timerPulse 1s ease-in-out infinite alternate;
}

@keyframes timerPulse {
    from { background: rgba(139,69,19,0.5); }
    to { background: rgba(255,0,0,0.3); }
}

.board-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
}

.board {
    width: 341px;
    height: 424px;
    background: #2a1508;
    padding: 6px;
    border-radius: 8px;
    border: 2px solid #8b4513;
    box-shadow: 0 0 20px rgba(139,69,19,0.4), inset 0 0 10px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.exit-hint {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 83px;
    height: 6px;
    background: linear-gradient(to bottom, #ffd700, transparent);
    border-radius: 0 0 4px 4px;
    animation: exitGlow 1.5s ease-in-out infinite alternate;
}

@keyframes exitGlow {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

.block {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    cursor: pointer;
    user-select: none;
    border-radius: 5px;
    position: absolute;
    transition: box-shadow 0.2s, border-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.block::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 35%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.12), transparent);
    border-radius: 4px 4px 0 0;
    pointer-events: none;
}

.block.selected {
    box-shadow: 0 0 12px 3px rgba(255,215,0,0.7) !important;
    border-color: #ffd700 !important;
    z-index: 5;
}

.block.dragging {
    opacity: 0.85;
    z-index: 20;
    transition: none;
}

.block.cao-cao {
    background: linear-gradient(145deg, #b8860b, #daa520);
    font-size: 20px;
    border: 2px solid #ffd700;
    color: #4a0000;
}

.block.horizontal {
    background: linear-gradient(145deg, #8b0000, #cc0000);
    border: 2px solid #ff4444;
}

.block.vertical {
    background: linear-gradient(145deg, #006400, #228b22);
    border: 2px solid #32cd32;
}

.block.pawn {
    background: linear-gradient(145deg, #4a3728, #6b4c3b);
    border: 2px solid #8b7355;
    font-size: 13px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

button, select {
    padding: 8px 18px;
    font-size: 15px;
    background: linear-gradient(145deg, #8b4513, #a0522d);
    color: #ffd700;
    border: 1px solid #daa520;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    transition: background 0.2s;
}

button:hover:not(:disabled), select:hover {
    background: linear-gradient(145deg, #a0522d, #cd853f);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

select {
    appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23ffd700' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

select option {
    background: #2d1810;
    color: #d4a574;
}

.tips {
    font-size: 12px;
    color: #8b7355;
}

.win-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.win-message {
    background: linear-gradient(145deg, #8b0000, #cc0000);
    padding: 30px 40px;
    border-radius: 12px;
    border: 2px solid #ffd700;
    box-shadow: 0 0 40px rgba(255,215,0,0.4);
    text-align: center;
}

.win-message h2 {
    font-size: 28px;
    color: #ffd700;
    margin-bottom: 15px;
}

.win-message p {
    font-size: 18px;
    margin-bottom: 18px;
}

.win-message button {
    font-size: 18px;
    padding: 10px 28px;
}

.lose-message {
    background: linear-gradient(145deg, #333, #555);
    border-color: #ff4444;
    box-shadow: 0 0 40px rgba(255,0,0,0.3);
}

.lose-message h2 {
    color: #ff4444;
}

.lose-message p {
    color: #ccc;
}

@media (max-width: 400px) {
    .board {
        width: 294px;
        height: 364px;
        padding: 4px;
    }
    h1 { font-size: 28px; }
}
