/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a5568;
    --secondary-color: #ed64a6;
    --success-color: #48bb78;
    --info-color: #4299e1;
    --warning-color: #ed8936;
    --light-bg: #e0e5ec;
    --dark-bg: #2d3748;
    --card-bg: #e0e5ec;
    --border-color: #d1d9e6;
    --text-color: #4a5568;
    --radius: 20px;
    
    /* Neumorphism Shadows */
    --nm-shadow-out: 9px 9px 16px rgb(163,177,198,0.6), -9px -9px 16px rgba(255,255,255, 0.5);
    --nm-shadow-in: inset 6px 6px 10px 0 rgba(0, 0, 0, 0.1), inset -6px -6px 10px 0 rgba(255, 255, 255, 0.5);
    --nm-shadow-small: 4px 4px 8px rgb(163,177,198,0.5), -4px -4px 8px rgba(255,255,255, 0.5);

    /* 响应式卡牌尺寸变量 */
    --card-width: 90px;
    --card-height: 130px;
}

body.dark-mode {
    --primary-color: #a0aec0;
    --light-bg: #2c313c;
    --card-bg: #2c313c;
    --text-color: #e2e8f0;
    --border-color: #3e4451;
    --nm-shadow-out: 9px 9px 16px rgba(0,0,0,0.4), -9px -9px 16px rgba(255,255,255, 0.05);
    --nm-shadow-in: inset 6px 6px 10px 0 rgba(0, 0, 0, 0.3), inset -6px -6px 10px 0 rgba(255, 255, 255, 0.05);
    --nm-shadow-small: 4px 4px 8px rgba(0,0,0,0.3), -4px -4px 8px rgba(255,255,255, 0.05);
}

body {
    font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--light-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.game-container {
    width: 100%;
    max-width: 1400px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--nm-shadow-out);
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 95vh;
    overflow: hidden;
    touch-action: none;
    border: 1px solid rgba(255,255,255,0.2);
}

/* 头部 */
.game-header {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 6px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.game-header h1 {
    font-size: 1.1rem;
    margin: 0;
}

.header-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}

.stats-group {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 3px 12px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--nm-shadow-in);
}

.game-stats {
    font-weight: 600;
    font-size: 12px;
}

/* 主游戏区域 */
.game-board {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    background: var(--card-bg);
    overflow: hidden;
    user-select: none;
}

.tableau-container {
    flex: 1;
    display: flex;
    align-items: flex-start;
    overflow: auto;
    padding: 20px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--nm-shadow-in);
}

.tableau {
    display: flex;
    gap: 15px;
    width: max-content;
}

/* 牌堆 */
.column {
    min-height: 200px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    padding: 10px;
    background: var(--card-bg);
    box-shadow: var(--nm-shadow-out);
    position: relative;
    transition: all 0.3s ease;
    min-width: var(--card-width);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.column.can-drop {
    box-shadow: inset 0 0 10px var(--success-color);
}

.column.drag-over {
    transform: scale(1.02);
    box-shadow: 0 0 15px var(--info-color);
}

/* 卡牌 */
.card {
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 12px;
    cursor: grab;
    position: relative;
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.1), -2px -2px 6px rgba(255, 255, 255, 0.6);
    margin-bottom: -95px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.1s ease;
}

.card.back {
    background-image: url('img/f-1.png');
    background-size: cover;
    background-position: center;
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: -115px;
}

.card:last-child {
    margin-bottom: 0;
}

.card:hover:not(.dragging) {
    transform: translateY(-5px);
    box-shadow: 6px 6px 12px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card.dragging {
    opacity: 0.7;
    transform: scale(0.95);
    z-index: 1000;
}

/* 卡牌内部装饰 */
.card-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 4px;
}

.card-top, .card-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
}

.card-bottom { transform: rotate(180deg); }

.card-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-rank { font-weight: bold; font-size: 16px; }
.card-suit-small { font-size: 12px; }
.card-suit-large { font-size: 48px; opacity: 0.15; }

/* 卡牌颜色 */
.card.hearts, .card.diamonds { color: #e53e3e; }
.card.clubs, .card.spades { color: #2d3748; }

/* 按钮 */
.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--nm-shadow-small);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 4px 4px 10px rgb(163,177,198,0.6), -4px -4px 10px rgba(255,255,255, 0.6);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--nm-shadow-in);
}

.btn-primary { color: var(--info-color); }
.btn-secondary { color: var(--primary-color); }
.btn-info { color: var(--warning-color); }

.difficulty-options {
    display: flex;
    gap: 8px;
    padding: 4px 10px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--nm-shadow-in);
}

.radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.radio-option input {
    margin-right: 6px;
}

/* 发牌堆容器 */
#stockPileContainer {
    position: fixed !important;
    right: 40px !important;
    bottom: 40px !important;
    left: auto !important;
    z-index: 1000;
    width: var(--card-width);
    height: var(--card-height);
    cursor: pointer;
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--nm-shadow-out);
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.3);
}

/* 完成牌副容器 - 与发牌堆对称 */
#foundationContainer {
    position: fixed !important;
    left: 40px !important;
    bottom: 40px !important;
    right: auto !important;
    z-index: 1000;
    width: var(--card-width);
    height: var(--card-height);
    background: var(--card-bg);
    border-radius: 15px;
    box-shadow: var(--nm-shadow-out);
    padding: 8px;
    border: 1px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.foundation-card {
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    position: absolute;
    left: 8px;
    top: 8px;
    border-radius: 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    background-color: var(--card-bg);
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255,255,255,0.5);
    z-index: 1;
}

/* 收牌动画 - 飞向左下角 */
@keyframes collectFly {
    0% { transform: translate(0, 0) scale(1); opacity: 1; z-index: 2000; }
    100% { transform: translate(var(--dx), var(--dy)) scale(0.6); opacity: 0.5; z-index: 2000; }
}
.collect-fly { animation: collectFly 0.7s cubic-bezier(0.55, 0.055, 0.675, 0.19) forwards; }

.stock-card {
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    position: absolute;
    left: 8px;
    top: 8px;
    border-radius: 10px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
    background-image: url('img/f-1.png');
    background-size: cover;
    background-position: center;
}

.stock-count-badge {
    position: absolute;
    bottom: -12px;
    right: -5px;
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    z-index: 100;
}

.game-footer {
    background: var(--card-bg);
    padding: 20px;
    display: flex;
    justify-content: center;
    gap: 30px;
    border-top: 1px solid var(--border-color);
}

/* 模态框 */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 20px 20px 60px rgba(0,0,0,0.15), -20px -20px 60px rgba(255,255,255,0.7);
    max-width: 90%;
    width: 450px;
    border: 1px solid rgba(255,255,255,0.3);
}

.settings-group {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 20px;
    box-shadow: var(--nm-shadow-in);
    margin-bottom: 30px;
    text-align: left;
}

.checkbox-option {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-option input {
    margin-right: 10px;
}

/* Toast */
#toastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}
.toast {
    background: var(--card-bg);
    color: var(--text-color);
    padding: 12px 20px;
    margin-top: 10px;
    border-radius: 12px;
    box-shadow: var(--nm-shadow-out);
    animation: toastFadeIn 0.3s forwards, toastFadeOut 0.3s forwards 1.7s;
}

/* 特效 */
.confetti {
    position: fixed;
    width: 8px;
    height: 12px;
    pointer-events: none;
    z-index: 3000;
}

/* 归位瞬间化 */
.no-transition {
    transition: none !important;
}

/* 提示高亮动画 */
@keyframes hintPulse {
    0% { box-shadow: 4px 4px 10px rgba(0,0,0,0.1), 0 0 0px #ed8936; border-color: rgba(255,255,255,0.4); }
    50% { box-shadow: 0 0 25px #ed8936, 0 0 10px #ed8936; border-color: #ed8936; transform: scale(1.02); }
    100% { box-shadow: 4px 4px 10px rgba(0,0,0,0.1), 0 0 0px #ed8936; border-color: rgba(255,255,255,0.4); }
}
.hint-highlight {
    animation: hintPulse 0.6s ease-in-out 3;
    z-index: 2000 !important;
}

/* 响应式媒体查询 */
@media (max-width: 768px) {
    .game-container { height: 100vh; max-height: none; border-radius: 0; }
    .game-header { padding: 10px; }
    .game-header h1 { font-size: 18px; }
    .header-controls { gap: 8px; }
    .btn { padding: 8px 12px; font-size: 11px; }

    .card { width: 60px; height: 85px; margin-bottom: -60px; }
    .card.back { margin-bottom: -70px; }
    .card-rank { font-size: 12px; }
    .card-suit-large { font-size: 28px; }
    .column { min-width: 60px; min-height: 120px; }
    
    #stockPileContainer { right: 20px !important; bottom: 20px !important; width: 60px; height: 85px; }
}

@media (max-width: 480px) {
    .game-header { flex-direction: column; padding: 15px; }
    .header-controls { width: 100%; justify-content: center; flex-wrap: wrap; }
    .card { width: 50px; height: 70px; margin-bottom: -50px; }
    .card.back { margin-bottom: -55px; }
    .column { min-width: 50px; padding: 5px; }
    .tableau { gap: 8px; }
    #stockPileContainer { width: 50px; height: 70px; }
}

/* 动画帧 */
@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastFadeIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastFadeOut { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

@keyframes dealFly {
    0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
    100% { transform: translate(var(--dx), var(--dy)) scale(1); opacity: 1; }
}
.deal-fly { animation: dealFly 0.6s ease-out forwards; }

@keyframes dealerDeal {
    0% { transform: translate(0, 0) scale(0.95); }
    100% { transform: translate(var(--dx), var(--dy)) scale(1); }
}
.dealer-fly { 
    animation: dealerDeal 0.45s cubic-bezier(0.2, 0, 0.2, 1) forwards; 
    z-index: 5000 !important; 
}

@keyframes fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

@keyframes cardFlip {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0); }
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--light-bg); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
