* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Microsoft YaHei', sans-serif;
}

body {
    background: linear-gradient(135deg, #114a94 0%, #0d3a7a 100%);
    color: #fff;
    min-height: 100vh;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 600px;
    text-align: center;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
}

.logo {
    margin-bottom: 20px;
    padding: 0 10px;
}

.logo h1 {
    font-size: clamp(24px, 6vw, 32px);
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    color: #ffeb3b;
}

.logo p {
    font-size: clamp(14px, 4vw, 16px);
    opacity: 0.9;
    line-height: 1.4;
}

.card-selection {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 30px;
    padding: 0 10px;
}

.card-option {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    width: 100%;
}

.card-option:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.card-option h2 {
    font-size: clamp(18px, 5vw, 22px);
    margin-bottom: 8px;
    color: #ffeb3b;
}

.card-option p {
    font-size: clamp(12px, 3.5vw, 14px);
    opacity: 0.9;
    line-height: 1.4;
}

.card-option-img {
    width: 100%;
    max-width: 180px;
    height: 180px;
    object-fit: contain;
    margin-bottom: 12px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.draw-page {
    display: none;
    width: 100%;
    padding: 0 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100vh;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 5px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 25px;
    cursor: pointer;
    font-size: clamp(12px, 3.5vw, 14px);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s;
    min-width: 70px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 已保留技能卡区域 */
.stored-cards-container {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.stored-cards-container h3 {
    margin-bottom: 15px;
    font-size: clamp(16px, 4.5vw, 18px);
    color: #ffeb3b;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.stored-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    justify-items: center;
}

.stored-card {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.stored-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.stored-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.stored-card-use-btn {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(76, 175, 80, 0.9);
    color: white;
    border: none;
    padding: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.stored-card-use-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.main-card-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
    flex-wrap: wrap;
    flex: 1;
    align-items: center;
    justify-content: center;
}

.card-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
    max-width: 220px;
}

.current-card-column {
    flex: 1;
    display: flex;
    justify-content: center;
}

.history-card-column {
    flex: 0 0 auto;
}

.card-column h3 {
    margin-bottom: 12px;
    font-size: clamp(16px, 4.5vw, 18px);
    color: #ffeb3b;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.draw-area {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 100%; /* 1:1 比例 */
    perspective: 1000px;
    margin: 0 auto;
}

.card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

.card-back {
    background: #f5f5f5;
}

.card-front {
    background: white;
    transform: rotateY(180deg);
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.button-group {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
    padding: 0 10px;
    flex-shrink: 0;
}

.draw-btn {
    background: #ffeb3b;
    color: #114a94;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}

.draw-btn:hover {
    background: #ffd600;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.history-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}

.history-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.history-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.use-btn {
    background: #ff9800;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}

.use-btn:hover {
    background: #f57c00;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.store-btn {
    background: #9c27b0;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: clamp(14px, 4vw, 16px);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    flex: 1;
    max-width: 200px;
}

.store-btn:hover {
    background: #7b1fa2;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.card-counter {
    margin-top: 15px;
    font-size: clamp(12px, 3.5vw, 14px);
    opacity: 0.9;
    padding: 0 10px;
    flex-shrink: 0;
}

/* 魔法效果遮罩层 */
.magic-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.magic-effect {
    font-size: clamp(24px, 8vw, 48px);
    color: #ffeb3b;
    text-shadow: 0 0 20px #ff9800, 0 0 30px #ff5722;
    animation: magicPulse 1s ease-in-out infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes magicPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* 小屏幕手机适配 */
@media (max-width: 480px) {
    body {
        padding: 10px;
        justify-content: center;
    }
    
    .container {
        padding: 0 5px;
    }
    
    .logo {
        margin-bottom: 15px;
    }
    
    .card-selection {
        margin-top: 20px;
        gap: 12px;
    }
    
    .card-option {
        padding: 15px 10px;
        border-radius: 10px;
    }
    
    .card-option-img {
        max-width: 150px;
        height: 150px;
        margin-bottom: 10px;
    }
    
    .stored-cards-container {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .stored-card {
        width: 70px;
        height: 70px;
    }
    
    .main-card-container {
        gap: 10px;
        margin: 15px 0;
    }
    
    .card-column {
        min-width: 120px;
    }
    
    .button-group {
        gap: 10px;
        margin-top: 15px;
    }
    
    .draw-btn, .history-btn, .use-btn, .store-btn {
        padding: 10px 15px;
        min-width: 110px;
        border-radius: 20px;
    }
    
    .page-header {
        margin-bottom: 15px;
    }
    
    .back-btn {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* 超小屏幕适配 */
@media (max-width: 360px) {
    body {
        padding: 8px;
    }
    
    .card-option {
        padding: 12px 8px;
    }
    
    .card-option-img {
        max-width: 130px;
        height: 130px;
    }
    
    .stored-card {
        width: 60px;
        height: 60px;
    }
    
    .draw-btn, .history-btn, .use-btn, .store-btn {
        padding: 8px 12px;
        min-width: 100px;
        font-size: 13px;
    }
    
    .main-card-container {
        flex-direction: column;
        align-items: center;
    }
    
    .card-column {
        margin-bottom: 15px;
        max-width: 180px;
    }
}

/* 横屏适配 */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 10px;
        justify-content: flex-start;
    }
    
    .logo {
        margin-bottom: 10px;
    }
    
    .logo h1 {
        font-size: 20px;
    }
    
    .card-selection {
        flex-direction: row;
        margin-top: 15px;
    }
    
    .card-option {
        padding: 15px;
    }
    
    .main-card-container {
        margin: 15px 0;
    }
    
    .draw-area {
        max-width: 180px;
        margin: 0 auto;
    }
    
    .stored-cards-container {
        margin-bottom: 10px;
        padding: 10px;
    }
}

/* 平板适配 */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 700px;
    }
    
    .card-column {
        max-width: 250px;
    }
    
    .card-option-img {
        max-width: 220px;
        height: 220px;
    }
    
    .draw-area {
        max-width: 250px;
    }
    
    .stored-card {
        width: 90px;
        height: 90px;
    }
}

/* 防止图片加载时的布局抖动 */
.card-img {
    background: #f5f5f5;
}

/* 改善触摸体验 */
@media (hover: none) {
    .card-option:hover {
        transform: none;
        background: rgba(255, 255, 255, 0.15);
    }
    
    .draw-btn:hover, .history-btn:hover, .use-btn:hover, .store-btn:hover {
        transform: none;
    }
    
    .back-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .stored-card:hover {
        transform: none;
    }
}

/* 大屏手机优化 */
@media (min-width: 481px) and (max-width: 767px) {
    .draw-area {
        max-width: 280px;
        margin: 0 auto;
    }
}

/* 确保首页也在视觉中心 */
.home-page {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}