:root {
    --primary-color: #3498db;
    --secondary-color: #e74c3c;
    --player1-color: #e74c3c; /* 玩家A红色 */
    --player2-color: #3498db; /* 玩家B蓝色 */
    --card-back: #ffd700; /* 金黄色纸牌背景 */
    --card-front: #ecf0f1;
    --text-color: #333;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: #f5f5f5;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 60px;
}

.keyboard-hint {
    font-size: 0.9rem;
    color: #666;
    margin-top: 5px;
    font-style: italic;
}

.footer {
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: #666;
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: rgba(255,255,255,0.8);
}

.game-container {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
    margin: 0 auto; /* 主体内容左右居中 */
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    color: #2c3e50;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    background-color: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.player {
    text-align: center;
    padding: 10px 20px;
    border-radius: 8px;
    width: 200px;
}

.player1 {
    background-color: rgba(52, 152, 219, 0.1);
    border: 2px solid var(--player1-color);
}

.player2 {
    background-color: rgba(231, 76, 60, 0.1);
    border: 2px solid var(--player2-color);
}

.player h2 {
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.player1 h2 {
    color: var(--player1-color);
}

.player2 h2 {
    color: var(--player2-color);
}

.game-status {
    text-align: center;
}

.game-status p {
    font-size: 1.2rem;
    margin: 5px 0;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 3.125%; /* 纸牌间距精确调整为10%纸牌宽度 */
    margin: 0 auto 30px;
    max-width: 600px;
}

.card {
    aspect-ratio: 3/4;
    perspective: 1000px;
    cursor: pointer;
    height: 150px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 10px;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
}

.card-back {
    background-color: var(--card-back);
    background-image: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    color: white;
}

.card-front {
    transform: rotateY(180deg);
}

.card-front.player1 {
    background-color: rgba(231, 76, 60, 0.8);
    color: white;
}

.card-front.player2 {
    background-color: rgba(52, 152, 219, 0.8);
    color: white;
}

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

button {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: white;
    transition: background-color 0.3s;
}

.flip-button.player1 {
    background-color: var(--player1-color);
}

.flip-button.player2 {
    background-color: var(--player2-color);
}

.flip-button.player1:hover:not(:disabled) {
    background-color: #c0392b;
}

.flip-button.player2:hover:not(:disabled) {
    background-color: #2980b9;
}

#next-round {
    background-color: #2ecc71; /* 绿色按钮 */
}

#next-round:hover:not(:disabled) {
    background-color: #27ae60;
}

button:hover:not(:disabled) {
    opacity: 0.9;
}

button:disabled {
    background-color: #bdc3c7 !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #ffd700; /* 金黄色背景 */
    background-image: linear-gradient(135deg, #ffd700 0%, #ffb900 100%);
    padding: 60px; /* 扩大面积2倍 */
    border-radius: 20px;
    text-align: center;
    position: relative;
    animation: modalOpen 0.5s;
    min-width: 400px; /* 最小宽度 */
    min-height: 300px; /* 最小高度 */
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

@keyframes modalOpen {
    from {opacity: 0; transform: translateY(-50px);}
    to {opacity: 1; transform: translateY(0);}
}

#trophy {
    font-size: 8rem;
    margin: 20px 0;
    animation: trophyFloat 2s infinite alternate;
}

@keyframes trophyFloat {
    from {transform: translateY(0);}
    to {transform: translateY(-20px);}
}

#play-again {
    margin-top: 20px;
    padding: 15px 30px;
    font-size: 1.2rem;
    color: #006400; /* 深绿色文字 */
}

/* 烟花效果 */
.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

@keyframes fall {
    0% {transform: translateY(-50px) rotate(0deg);}
    100% {transform: translateY(100vh) rotate(360deg);}
}

@keyframes starFall {
    0% {transform: translateY(0) rotate(0deg);}
    100% {transform: translateY(100vh) rotate(360deg);}
}

@keyframes twinkle {
    0% {opacity: 0.5; transform: scale(0.8);}
    100% {opacity: 1; transform: scale(1.2);}
}

@keyframes explode {
    0% {transform: scale(0); opacity: 1;}
    100% {transform: scale(15); opacity: 0;}
}

/* 当前玩家高亮效果 */
.current-turn {
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
    transform: scale(1.05);
    transition: all 0.3s;
}

/* 得分动画 */
.score-animation {
    animation: scorePopup 0.5s ease-out;
}

@keyframes scorePopup {
    0% {transform: scale(1);}
    50% {transform: scale(1.5);}
    100% {transform: scale(1);}
}