/* 基本样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #2c5530, #4a7c59);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.game-container {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    padding: 20px;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    color: #2c5530;
    margin-bottom: 15px;
    font-size: 28px;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
}

.info-item {
    background: #e8f5e9;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.info-item span:first-child {
    color: #2c5530;
    margin-right: 5px;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background: #4a7c59;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
}

.controls button:hover {
    background: #2c5530;
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

/* 游戏棋盘 */
.game-board {
    position: relative;
    min-height: 500px;
}

/* 基础牌堆区域 */
.foundation-area {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 15px;
    background: rgba(74, 124, 89, 0.1);
    border-radius: 10px;
}

.foundation {
    width: 80px;
    height: 110px;
    border: 2px dashed #4a7c59;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.3);
    position: relative;
}

.foundation.has-card {
    border: 2px solid #4a7c59;
    background: rgba(255, 255, 255, 0.8);
}

/* 库存牌堆和废牌堆区域 */
.stock-waste-area {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}

.stock-pile, .waste-pile {
    width: 80px;
    height: 110px;
    position: relative;
}

.stock-pile {
    cursor: pointer;
}

.card-back {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #8B0000, #B22222);
    border-radius: 8px;
    border: 2px solid #fff;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 24px;
}

.card-back::before {
    content: "♠";
}

/* 表格牌堆区域 */
.tableau-area {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.tableau-column {
    width: 80px;
    min-height: 110px;
    position: relative;
}

.tableau-slot {
    width: 80px;
    height: 110px;
    border: 2px dashed #4a7c59;
    border-radius: 8px;
    margin-bottom: 15px;
    position: relative;
    background: rgba(255, 255, 255, 0.3);
}

.tableau-slot.has-card {
    border: 2px solid #4a7c59;
    background: rgba(255, 255, 255, 0.8);
}

/* 纸牌样式 */
.card {
    width: 80px;
    height: 110px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    position: absolute;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.card.face-down {
    background: linear-gradient(135deg, #8B0000, #B22222);
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 24px;
}

.card.face-down::before {
    content: "♠";
}

.card.red {
    color: #d32f2f;
}

.card.black {
    color: #333;
}

.card-top, .card-bottom {
    font-size: 14px;
    font-weight: bold;
}

.card-bottom {
    transform: rotate(180deg);
}

.card-center {
    font-size: 24px;
    align-self: center;
    margin: auto;
}

/* 选中的纸牌 */
.card.selected {
    box-shadow: 0 0 0 3px #ffeb3b, 0 8px 15px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

/* 拖拽相关样式 */
.card.dragging {
    opacity: 0.8;
    z-index: 1000;
    transform: rotate(5deg);
}

.drop-zone {
    background: rgba(76, 175, 80, 0.3);
    border: 2px dashed #4CAF50;
}

/* 游戏说明 */
.instructions {
    margin-top: 30px;
    padding: 20px;
    background: #e8f5e9;
    border-radius: 10px;
}

.instructions h3 {
    color: #2c5530;
    margin-bottom: 10px;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    line-height: 1.5;
}

/* 游戏结束界面 */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.game-over.show {
    opacity: 1;
    pointer-events: all;
}

.game-over-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.game-over-content h2 {
    color: #2c5530;
    margin-bottom: 20px;
}

.game-over-content p {
    margin-bottom: 20px;
    font-size: 18px;
}

.game-over-content button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: #4a7c59;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-over-content button:hover {
    background: #2c5530;
    transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
        margin: 0;
        border-radius: 0;
        min-width: 100vw;
        max-width: 100vw;
    }
    
    .game-header h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }
    
    .game-info {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-around;
    }
    
    .info-item {
        padding: 6px 12px;
        font-size: 14px;
        flex: 1;
        min-width: 80px;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .controls button {
        padding: 8px 16px;
        font-size: 14px;
        flex: 1;
        min-width: 80px;
    }
    
    .game-board {
        min-height: auto;
        overflow-x: hidden;
    }
    
    .foundation-area, .stock-waste-area, .tableau-area {
        gap: 8px;
        flex-wrap: wrap;
    }
    
    .foundation-area {
        justify-content: space-around;
    }
    
    .stock-waste-area {
        justify-content: center;
    }
    
    .tableau-area {
        justify-content: space-around;
        overflow-x: auto;
        padding-bottom: 10px;
    }
    
    .tableau-column {
        min-width: 60px;
        width: auto;
    }
    
    .card {
        width: 60px;
        height: 85px;
        min-width: 60px;
    }
    
    .card-top, .card-bottom {
        font-size: 10px;
    }
    
    .card-center {
        font-size: 18px;
    }
    
    .tableau-slot, .foundation, .stock-pile, .waste-pile {
        width: 60px;
        height: 85px;
        min-width: 60px;
    }
    
    .instructions {
        padding: 15px;
        margin-top: 20px;
    }
    
    .instructions h3 {
        font-size: 18px;
    }
    
    .instructions li {
        font-size: 14px;
        margin-bottom: 6px;
    }
}

/* 针对小屏幕设备的进一步优化 */
@media (max-width: 480px) {
    body {
        padding: 10px 5px;
    }
    
    .game-container {
        padding: 8px;
    }
    
    .game-header h1 {
        font-size: 20px;
    }
    
    .info-item {
        padding: 5px 10px;
        font-size: 12px;
        min-width: 70px;
    }
    
    .controls button {
        padding: 6px 12px;
        font-size: 12px;
        min-width: 70px;
    }
    
    .card {
        width: 50px;
        height: 75px;
        min-width: 50px;
    }
    
    .card-top, .card-bottom {
        font-size: 8px;
    }
    
    .card-center {
        font-size: 16px;
    }
    
    .tableau-slot, .foundation, .stock-pile, .waste-pile {
        width: 50px;
        height: 75px;
        min-width: 50px;
    }
    
    .foundation-area, .stock-waste-area {
        gap: 5px;
    }
    
    .tableau-area {
        gap: 5px;
    }
}

/* 防止内容溢出 */
.game-container {
    overflow-x: hidden;
    max-width: 100vw;
}

.tableau-area {
    overflow-x: auto;
    max-width: 100%;
}