body {
    background: #222;
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    color: #eee;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

#game-ui {
    display: flex;
    gap: 15px;
    padding: 20px;
    border-radius: 12px;
    background: transparent;
    backdrop-filter: none;
    border: 0;
}

.sidebar {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#canvas-container {
    border: 2px solid rgba(135, 206, 235, 0.45);
    background: transparent;
    box-shadow: none;
    position: relative;
}

.stat-box, .objective-box, .hint-box {
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

h3, p {
    color: #ffffff;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    font-weight: 600;
    margin: 5px 0;
}
h3 { font-size: 14px; }
p { font-size: 12px; line-height: 1.4; }

#start-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

#start-overlay.hidden {
    display: none;
}

#restart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}

#restart-overlay.hidden {
    display: none;
}

#restart-button {
    width: 100%;
    padding: 8px 10px;
    background: #f1c40f;
    border: 0;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.start-card {
    width: 220px;
    padding: 16px;
    background: #1e1e1e;
    border: 2px solid #666;
    border-radius: 8px;
    text-align: center;
}

.start-card h2 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #f1c40f;
}

.start-card p {
    margin: 0 0 12px;
    font-size: 12px;
}

#start-button {
    width: 100%;
    padding: 8px 10px;
    background: #f1c40f;
    border: 0;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

#start-button:hover {
    background: #f5d34e;
}

.start-tip {
    margin-top: 8px;
    font-size: 10px;
    color: #999;
}

.hidden {
    display: none;
}

#shop-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

/* NPC：参考像素图，增加围裙和深浅色差 */
#shop-npc {
    position: absolute;
    left: 12px;
    bottom: 12px;
    width: 48px;
    height: 64px;
    background: #6d5c98;
    border: 3px solid #1a1a1a;
    box-shadow:
        inset -4px 0px 0px rgba(0,0,0,0.2),
        0 4px 0px rgba(0,0,0,0.3);
    pointer-events: auto;
    image-rendering: pixelated;
}

/* NPC 头部：像素感更强的方形感 */
#shop-npc::before {
    content: "";
    position: absolute;
    top: -24px;
    left: 4px;
    width: 34px;
    height: 34px;
    background: #f5d7b3;
    border: 3px solid #1a1a1a;
    box-shadow:
        inset 0 8px 0 #7e4a35,
        inset 0 -6px 0 #5c3526;
}

/* 货架：模拟木质纹理和分层感 */
#shop-shelf {
    position: absolute;
    left: 70px;
    bottom: 18px;
    padding: 8px 16px;
    background: #a67c52;
    color: #fff;
    background-image: repeating-linear-gradient(
        rgba(255,255,255,0.05) 0px,
        rgba(255,255,255,0.05) 2px,
        transparent 2px,
        transparent 4px
    );
    border: 3px solid #4a3421;
    box-shadow:
        inset 2px 2px 0 rgba(255,255,255,0.2),
        inset -2px -2px 0 rgba(0,0,0,0.2),
        0 4px 0 #2a1a0c;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.1s;
}

#shop-shelf:hover {
    transform: translateY(-2px);
    background-color: #b58d63;
}

/* 商店面板：磨砂木质质感 */
#shop-panel {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 420px;
    background: #c29a6a;
    border: 4px solid #3d2a16;
    box-shadow:
        0 0 0 4px #c29a6a,
        0 20px 40px rgba(0,0,0,0.6);
    padding: 16px;
    z-index: 10;
}

.shop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.shop-title {
    font-weight: bold;
    font-size: 16px;
}

#shop-close {
    background: #f1c40f;
    border: 0;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: bold;
}

.shop-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
    background: rgba(0,0,0,0.1);
    font-size: 12px;
}

.shop-table th,
.shop-table td {
    border: 1px solid rgba(0,0,0,0.25);
    padding: 6px;
    text-align: left;
    vertical-align: top;
}

.shop-table td {
    background: rgba(255,255,255,0.1);
    border-top: 1px solid rgba(255,255,255,0.2);
    border-bottom: 1px solid rgba(0,0,0,0.2);
    padding: 8px;
}

/* 购买按钮：精致的像素黄/橙渐变 */
.shop-item {
    background: #f1c40f;
    color: #4a3421;
    border: 2px solid #3d2a16;
    padding: 6px 10px;
    font-weight: bold;
    box-shadow:
        inset 0 -3px 0 rgba(0,0,0,0.2),
        inset 0 3px 0 rgba(255,255,255,0.4);
    cursor: pointer;
    width: 100%;
    text-transform: uppercase;
    font-size: 11px;
}

.shop-item:hover {
    background: #ffdb4d;
    transform: scale(1.02);
}

.shop-item:active {
    box-shadow: inset 0 2px 0 rgba(0,0,0,0.3);
    transform: translateY(2px);
}

.shop-footer {
    margin-top: 8px;
    font-size: 11px;
    color: #2c1a0c;
}

#pause-button,
#backpack-button {
    width: 100%;
    padding: 8px 10px;
    background: #f1c40f;
    border: 0;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

#backpack-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 360px;
    background: #8b6b3e;
    border: 3px solid #5a3f22;
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.5);
    color: #1d1308;
    padding: 12px;
    z-index: 10;
}

.backpack-list {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 6px;
    padding: 8px;
    font-size: 12px;
    min-height: 120px;
}

.backpack-item {
    display: block;
    width: 100%;
    margin: 4px 0;
    padding: 6px 8px;
    background: #3d2a16;
    color: #fff;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
}

#shop-confirm {
    margin-top: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 6px;
}

.confirm-text {
    font-size: 12px;
    margin-bottom: 6px;
}

.confirm-actions {
    display: flex;
    gap: 8px;
}

#confirm-buy,
#confirm-cancel {
    flex: 1;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

#confirm-buy {
    background: #f1c40f;
}

#confirm-cancel {
    background: #3d2a16;
    color: #fff;
}

#canvas-container.cursor-item {
    cursor: crosshair;
}

#canvas-container.cursor-plumb {
    cursor: crosshair;
}

#canvas-container.cursor-plaster {
    cursor: cell;
}

#canvas-container.cursor-chisel {
    cursor: not-allowed;
}

#shop-effects {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 7;
}

#selection-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 8;
}

#selection-overlay.hidden {
    display: none;
}

.selection-cell {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(46, 204, 113, 0.9);
    box-sizing: border-box;
    background: rgba(46, 204, 113, 0.15);
}

.selection-row {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    border: 2px solid rgba(52, 152, 219, 0.9);
    background: rgba(52, 152, 219, 0.15);
    box-sizing: border-box;
}

.selection-col {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40px;
    border: 2px solid rgba(241, 196, 15, 0.9);
    background: rgba(241, 196, 15, 0.15);
    box-sizing: border-box;
}

.selection-area {
    position: absolute;
    border: 2px solid rgba(155, 89, 182, 0.9);
    background: rgba(155, 89, 182, 0.15);
    box-sizing: border-box;
}

.selection-counter {
    position: absolute;
    padding: 2px 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 10px;
    border-radius: 4px;
    pointer-events: none;
}

.laser-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180deg, rgba(255,80,80,0.0), rgba(255,80,80,0.9), rgba(255,80,80,0.0));
    box-shadow: 0 0 12px rgba(255,80,80,0.8);
    animation: laserPulse 0.6s ease-out;
}

.dust-burst {
    position: absolute;
    width: 120px;
    height: 40px;
    background: radial-gradient(circle, rgba(180,180,180,0.8), rgba(180,180,180,0.0));
    animation: dustFade 0.8s ease-out;
}

.chip-burst {
    position: absolute;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, rgba(255,220,150,0.9), rgba(255,220,150,0.0));
    animation: chipFade 0.6s ease-out;
}

@keyframes laserPulse {
    0% { opacity: 0; }
    30% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes dustFade {
    0% { opacity: 0.9; transform: scale(0.8); }
    100% { opacity: 0; transform: scale(1.2); }
}

@keyframes chipFade {
    0% { opacity: 0.9; transform: scale(0.7); }
    100% { opacity: 0; transform: scale(1.1); }
}

/* 动态层级背景 - 逻辑控制 */
.bg-ground { background: #4a3728; }
.bg-stars  { background: #1a1a2e; }
.bg-moon   { background: #2d3436; }
.bg-sun    { background: #e67e22; }
