* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f3f6fb;
    min-height: 100vh;
    padding: 20px;
    color: #1f2937;
}

.viewer-container {
    max-width: 1400px;
    margin: 0 auto;
}

.viewer-header {
    text-align: center;
    margin-bottom: 30px;
    background: #ffffff;
    padding: 22px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

h1 {
    color: #111827;
    font-size: 2em;
    margin-bottom: 0;
    text-shadow: none;
}

.round-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.round-selector label {
    font-size: 16px;
    font-weight: 600;
    color: #666;
}

.round-select {
    padding: 10px 20px;
    font-size: 16px;
    border: 2px solid #667eea;
    border-radius: 10px;
    background: white;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.round-select:hover {
    background: #667eea;
    color: white;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
    background: #ffffff;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat-label {
    font-size: 16px;
    color: #4b5563;
    font-weight: 500;
}

.stat-value {
    font-size: 22px;
    color: #1d4ed8;
    font-weight: bold;
}

.card-area-container {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 30px;
}

.side-text-area {
    flex-shrink: 0;
    width: 200px;
    background: #ffffff;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.side-text-content {
    color: #333;
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 14px;
    padding: 16px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin-bottom: 20px;
    flex: 1;
}

@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(10, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    .card-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .card-area-container {
        flex-direction: column;
    }
    
    .side-text-area {
        width: 100%;
    }
}

.card {
    aspect-ratio: 3/4;
    position: relative;
    perspective: 1000px;
    transform-style: preserve-3d;
    overflow: hidden;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    transform-origin: center center;
    will-change: transform;
}

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

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.card-front {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    position: relative;
    overflow: hidden;
}

.card-front::before {
    content: '';
    display: none;
}

/* 卡牌背面的数字 */
.card-number {
    position: absolute;
    right: 8px;
    bottom: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    background: rgba(0, 0, 0, 0.35);
    z-index: 2;
}

.card-back-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    pointer-events: none;
}

/* 卡牌正面的图片 */
.card-prize-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* 卡牌正面的文字（如果没有图片） */
.card-prize-text {
    font-size: 14px;
    font-weight: bold;
    padding: 5px;
    word-wrap: break-word;
}

.card-back {
    background: white;
    transform: rotateY(180deg) translateZ(1px);
    padding: 10px;
    text-align: center;
    word-wrap: break-word;
    font-size: 14px;
}

/* 不同奖品等级的颜色 */
.card-back.prize-grand {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.card-back.prize-first {
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    color: white;
}

.card-back.prize-second {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    color: #333;
}

.card-back.prize-third {
    background: linear-gradient(135deg, #d299c2 0%, #fef9d7 100%);
    color: #333;
}

.card-back.prize-none {
    background: #f0f0f0;
    color: #999;
}

.viewer-notice {
    text-align: center;
    background: #ffffff;
    padding: 15px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.viewer-notice p {
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    white-space: pre-wrap;
    line-height: 1.6;
}

.prize-image-container {
    margin-bottom: 30px;
    text-align: center;
    background: #ffffff;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

.prize-image-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

/* 中奖弹窗 */
.prize-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.prize-modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    text-align: center;
}

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

.prize-modal-close {
    float: right;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    line-height: 20px;
}

.prize-modal-close:hover {
    color: #000;
}

.prize-modal-image {
    margin-bottom: 20px;
}

.prize-modal-image img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 12px;
}

.prize-modal-title {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2em;
}

.prize-modal-text {
    font-size: 1.5em;
    color: #333;
    padding: 20px;
}

/* 动画效果 */
@keyframes flipIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.card {
    animation: flipIn 0.5s ease-out;
    animation-fill-mode: both;
}

.card:nth-child(n) {
    animation-delay: calc(0.02s * var(--card-index));
}

/* 新翻牌高亮动画 */
@keyframes highlightFlip {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
}

.card.just-flipped .card-inner {
    animation: highlightFlip 1s ease-in-out;
}

.card.matched::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 4px solid rgba(239, 68, 68, 0.98);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(239, 68, 68, 0.35);
    pointer-events: none;
    z-index: 4;
}

.card.matched::after {
    content: '已匹配';
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: rgba(220, 38, 38, 0.95);
    box-shadow: 0 2px 8px rgba(127, 29, 29, 0.45);
    pointer-events: none;
}

/* 主题：专业风（默认） */
body.theme-professional .viewer-header,
body.theme-professional .stats,
body.theme-professional .side-text-area,
body.theme-professional .card-grid,
body.theme-professional .viewer-notice,
body.theme-professional .prize-image-container {
    border-color: #e5e7eb;
}

/* 主题：游戏风 */
body.theme-game {
    background: radial-gradient(circle at top, #1d4ed8 0%, #312e81 45%, #0f172a 100%) !important;
}

body.theme-game .viewer-header,
body.theme-game .stats,
body.theme-game .side-text-area,
body.theme-game .card-grid,
body.theme-game .viewer-notice,
body.theme-game .prize-image-container {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(56, 189, 248, 0.45);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.15), 0 8px 26px rgba(14, 116, 144, 0.2);
}

body.theme-game h1,
body.theme-game .stat-value,
body.theme-game .viewer-notice p {
    color: #e2e8f0;
}

body.theme-game .stat-label,
body.theme-game .side-text-content {
    color: #cbd5e1;
}

body.theme-game .card-front {
    box-shadow: 0 0 16px rgba(14, 165, 233, 0.45);
}

/* 响应式 */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8em;
    }
    
    .card-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 10px;
        padding: 12px;
    }
    
    .card-back {
        font-size: 12px;
    }
}
