:root {
    --board-width: 320px;
    --board-height: 400px;
    --block-unit: 80px;
    --gap: 2px;
    --primary-color: #8d6e63;
    --bg-color: #efebe9;
    --wood-color: #d7ccc8;
    --highlight-color: #ff7043;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    touch-action: none;
    /* Prevent default scroll execution */
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 480px;
}

header {
    text-align: center;
    margin-bottom: 20px;
    color: #4e342e;
}

.board {
    position: relative;
    width: var(--board-width);
    height: var(--board-height);
    box-sizing: content-box;
    /* Fix for border checking */
    background-color: #5d4037;
    border: 8px solid #3e2723;
    border-radius: 4px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.block {
    position: absolute;
    background-color: var(--wood-color);
    border: 1px solid #a1887f;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #3e2723;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1), 2px 2px 4px rgba(0, 0, 0, 0.2);
    cursor: grab;
    transition: transform 0.2s ease, top 0.1s, left 0.1s;
    /* Smooth transition for solver playback */
}

.block:active {
    cursor: grabbing;
}

.block.caocao {
    background-color: #ffab91;
    z-index: 10;
}

.block.general-h,
.block.general-v {
    background-color: #ffccbc;
}

.block.soldier {
    background-color: #d7ccc8;
}

.controls {
    margin-top: 30px;
    display: flex;
    gap: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 24px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.1s, background-color 0.2s;
    font-weight: bold;
}

.btn:active {
    transform: scale(0.95);
}

.btn.primary {
    background-color: var(--highlight-color);
    color: white;
}

.btn.secondary {
    background-color: #bcaaa4;
    color: #3e2723;
}

.message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 8px;
    z-index: 100;
}

.loading {
    margin-top: 10px;
    color: #5d4037;
    font-weight: bold;
}

.hidden {
    display: none;
}