@import url('https://fonts.googleapis.com/css2?family=ZCOOL+KuaiLe&display=swap');

:root {
    --retro-yellow: #fbe064;
    --retro-blue: #50b8c6;
    --retro-red: #eb5a47;
    --retro-orange: #eb7a34;
    --retro-green: #6bb577;
    --retro-light: #fef9cc;
    --retro-bg: #f9f6f0;
    --text-dark: #333333;
    --text-gray: #666666;
}

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

body {
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    background-color: var(--retro-bg);
    color: var(--text-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    /* 半色调网点背景装饰 (还原插画的印刷感) */
    background-image: radial-gradient(rgba(0,0,0,0.05) 20%, transparent 20%);
    background-size: 10px 10px;
}

/* 默认隐藏移动端专属元素 */
.mobile-only {
    display: none;
}

/* 品牌区域 */
.brand-header {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin-bottom: -10px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    overflow: hidden;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-name {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 2px;
    line-height: 1.2;
    color: var(--retro-red);
    text-shadow: 2px 2px 0px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
}

.rules-btn {
    margin-left: auto;
    background: white;
    color: var(--retro-red);
    border: 3px solid var(--retro-red);
    box-shadow: 2px 2px 0 var(--retro-red);
    padding: 6px 12px; /* 稍微减小内边距 */
    border-radius: 20px;
    font-size: 14px; /* 字体稍微调小防止挤换行 */
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
    white-space: nowrap; /* 强制不换行 */
    flex-shrink: 0; /* 防止被挤压 */
}

.rules-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 var(--retro-red);
}

.container {
    width: calc(100vw - 60px);
    height: calc(100vh - 60px);
    background: white;
    border-radius: 24px;
    border: 4px solid var(--retro-blue);
    box-shadow: 8px 8px 0 rgba(80,184,198,1);
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

/* 装饰点 */
.container::before, .container::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--retro-yellow);
    border: 1px solid #d4b220;
    z-index: 10; /* 确保装饰点层级合理，但如果在小屏幕挡住可适当隐藏 */
}
.container::before { top: 15px; left: 15px; }
.container::after { top: 15px; right: 15px; }

/* 顶部统计 */
.stats-header {
    display: flex;
    justify-content: space-around;
    background: var(--retro-light);
    padding: 15px;
    border-radius: 16px;
    border: 3px solid var(--retro-yellow);
    box-shadow: 4px 4px 0 var(--retro-yellow);
}

.stat-item {
    text-align: center;
}

.stat-item .label {
    display: block;
    font-size: 16px;
    color: var(--text-gray);
    margin-bottom: 5px;
    font-family: sans-serif;
    font-weight: bold;
}

.stat-item .value {
    display: block;
    font-size: 22px;
    font-weight: bold;
    color: var(--retro-red);
}

/* 主体内容区 */
.main-content {
    display: flex;
    gap: 30px;
    align-items: center;
    flex: 1;
    min-height: 0;
}

/* 左侧规则说明区 */
.rules-section {
    width: 280px;
    min-width: 320px;
    background: var(--retro-bg);
    border-radius: 16px;
    border: 3px solid var(--retro-blue);
    box-shadow: inset -4px -4px 0 rgba(0,0,0,0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
}

.rules-section h3 {
    color: var(--retro-red);
    text-align: center;
    margin-bottom: 15px;
    font-size: 22px;
    letter-spacing: 2px;
}

.rules-content h4 {
    color: var(--retro-blue);
    margin: 15px 0 8px 0;
    font-size: 18px;
}

.rules-content ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.rules-content li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
    font-size: 15px;
    color: var(--text-gray);
    line-height: 1.6;
    font-family: sans-serif;
    font-weight: bold;
}

.rules-content li::before {
    content: "•";
    color: var(--retro-red);
    position: absolute;
    left: 0;
    top: 0;
    font-size: 18px;
}

/* 中间九宫格 */
.grid-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    height: 100%;
    min-height: 0;
    min-width: 0;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 16px;
    
    /* 核心修复：基于高度自动计算宽度，并配合 aspect-ratio 强制正方形 */
    height: 100%;
    max-height: 560px; /* 限制最大尺寸，防止在大屏上过于夸张 */
    width: auto;
    aspect-ratio: 1 / 1;
    
    background: var(--retro-yellow);
    padding: 24px;
    border-radius: 24px;
    border: 4px solid #e0c238;
    box-shadow: 8px 8px 0 rgba(224, 194, 56, 1), inset 0 5px 15px rgba(0,0,0,0.1);
}

.grid-item {
    background: #fff;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--retro-red);
    text-align: center;
    border: 3px solid rgba(0,0,0,0.05);
    box-shadow: 0 6px 0 rgba(0,0,0,0.1);
    transition: all 0.1s ease;
    padding: 10px;
}

.grid-item .prize-name {
    font-size: 26px; /* 相应放大奖项名称字号 */
    font-weight: bold;
    margin-top: 8px;
}

/* 优惠券样式 */
.coupon-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 6px;
    filter: drop-shadow(2px 2px 0px rgba(0,0,0,0.15));
}

.prize-coupon {
    width: 90px;
    height: 45px;
    transition: transform 0.2s ease;
}

.grid-item.active .prize-coupon {
    transform: scale(1.1) rotate(-5deg);
}

.modal-coupon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 15px 0 20px 0;
    filter: drop-shadow(4px 4px 0px rgba(0,0,0,0.15));
    animation: floatCoupon 2s ease-in-out infinite alternate;
}

.modal-coupon-container .prize-coupon {
    width: 150px;
    height: 75px;
}

@keyframes floatCoupon {
    0% { transform: translateY(0px) rotate(0deg); }
    100% { transform: translateY(-5px) rotate(2deg); }
}

.grid-item .desc {
    font-size: 16px; /* 相应放大描述字号 */
    font-weight: normal;
    color: var(--text-gray);
    margin-top: 4px;
    font-family: sans-serif;
}

.grid-item.active {
    background: var(--retro-light);
    border-color: var(--retro-red);
    box-shadow: 0 6px 0 var(--retro-red);
    color: var(--retro-orange);
    transform: translateY(4px);
}

.draw-btn {
    background: var(--retro-red);
    color: white;
    border: 3px solid #b33927;
    box-shadow: 0 8px 0 #b33927;
    cursor: pointer;
    outline: none;
    font-size: 28px;
    font-weight: 900;
    padding: 0;
    letter-spacing: 2px;
}

.draw-btn .btn-text {
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

.draw-btn:focus, .draw-btn:hover {
    background: #f76e5d;
}

.draw-btn:active {
    box-shadow: 0 2px 0 #b33927;
    transform: translateY(6px);
}

.draw-btn.disabled {
    background: #ccc;
    border-color: #999;
    box-shadow: 0 6px 0 #999;
    color: #666;
    cursor: not-allowed;
}

.draw-btn.disabled .btn-text {
    text-shadow: none;
}

/* 右侧记录 */
.records-section {
    width: 320px;
    min-width: 280px;
    background: var(--retro-bg);
    border-radius: 16px;
    border: 3px solid var(--retro-blue);
    box-shadow: inset -4px -4px 0 rgba(0,0,0,0.05);
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
}

.records-section h3 {
    text-align: center;
    color: var(--retro-red);
    margin-bottom: 15px;
    font-size: 22px;
    letter-spacing: 2px;
    border-bottom: 2px dashed var(--retro-blue);
    padding-bottom: 10px;
}

.records-container {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-right: 5px;
}

.records-container::-webkit-scrollbar {
    width: 6px;
}
.records-container::-webkit-scrollbar-track {
    background: transparent;
}
.records-container::-webkit-scrollbar-thumb {
    background-color: var(--retro-blue);
    border-radius: 4px;
}

.records-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 抽奖记录空状态 */
.empty-state {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 150px;
    color: var(--text-gray);
    font-size: 16px;
    font-family: sans-serif;
    font-weight: bold;
    text-align: center;
    border: 2px dashed #ddd;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.5);
}

.records-list li {
    padding: 12px 14px;
    background: white;
    border-radius: 12px;
    border: 2px solid var(--retro-light);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.05);
    font-size: 16px;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.records-list li .record-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.records-list li .time {
    color: var(--text-gray);
    font-size: 14px;
    font-family: sans-serif;
}
.records-list li .prize {
    color: var(--retro-red);
    font-weight: bold;
    font-size: 18px;
}
.records-list li .desc {
    font-size: 15px;
    color: var(--text-gray);
    font-family: sans-serif;
}

/* 弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(249, 246, 240, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 24px;
    text-align: center;
    min-width: 320px;
    width: 85vw; /* 限制最大宽度，确保左右有留白 */
    max-width: 400px;
    border: 4px solid var(--retro-blue);
    box-shadow: 8px 8px 0 rgba(80,184,198,1);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    position: relative;
    margin: 0 20px; /* 强制左右外边距留白 */
}

.modal-content::before, .modal-content::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--retro-yellow);
    border: 1px solid #d4b220;
}
.modal-content::before { top: 12px; left: 12px; }
.modal-content::after { top: 12px; right: 12px; }

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; margin-top: 20px; }
    to { transform: scale(1); opacity: 1; margin-top: 0; }
}

.modal-content h2 {
    color: var(--retro-red);
    margin-bottom: 20px;
    font-size: 32px;
    letter-spacing: 2px;
}

.modal-content p {
    font-size: 18px;
    margin-bottom: 25px;
    color: var(--text-gray);
    background: var(--retro-bg);
    padding: 15px;
    border-radius: 12px;
    border: 2px solid #eee;
    font-family: sans-serif;
    font-weight: bold;
}

.modal-content button {
    background: white;
    color: var(--text-gray);
    border: 2px solid #ccc;
    box-shadow: 0 4px 0 #ccc;
    padding: 10px 40px;
    border-radius: 24px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'ZCOOL KuaiLe', cursive, sans-serif;
}

.modal-content button:hover {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #ccc;
    background: #f9f9f9;
}

.rules-modal-content {
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.rules-modal-scroll {
    overflow-y: auto;
    text-align: left;
    margin-bottom: 20px;
    padding-right: 10px;
}

.rules-modal-scroll::-webkit-scrollbar {
    width: 6px;
}
.rules-modal-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.rules-modal-scroll::-webkit-scrollbar-thumb {
    background-color: var(--retro-blue);
    border-radius: 4px;
}

/* 响应性适配 */

/* 平板端 (Tablet) */
@media (max-width: 1024px) {
    .container {
        height: auto;
        min-height: 95vh;
        overflow-y: auto;
        border-width: 3px;
        box-shadow: 6px 6px 0 rgba(80,184,198,1);
    }
    
    .main-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .rules-section {
        width: 100%;
        max-width: 420px;
        min-width: auto; /* 在平板/手机端取消最小宽度限制，避免撑破屏幕 */
        height: auto;
        max-height: none;
    }
    
    .grid-section {
        width: 100%;
        max-width: 500px;
        flex: none;
    }
    
    .grid-container {
        width: 100%;
        height: auto;
        max-width: 420px;
        max-height: none; /* 平板及以下优先以宽度为基准计算 */
        aspect-ratio: 1 / 1;
        padding: 16px;
        gap: 12px;
    }
    
    .grid-item .prize-name {
        font-size: 18px;
    }
    
    .prize-coupon {
        width: 60px;
        height: 30px;
    }
    
    .grid-item .desc {
        font-size: 12px;
    }
    
    .draw-btn {
        font-size: 24px;
    }

    .brand-header {
        top: 24px;
        left: 30px;
        gap: 12px;
        max-width: 45%; 
    }
    .brand-logo {
        width: 48px;
        height: 48px;
        border-radius: 50%;
    }
    .brand-name {
        font-size: 22px;
        letter-spacing: 1px;
    }
    
    .records-section {
        width: 100%;
        flex: 1;
        min-height: 200px;
        max-width: 420px;
        min-width: auto; /* 在平板/手机端取消最小宽度限制 */
    }
}

/* 移动端 (Mobile) */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding-top: 20px;
        height: auto;
        min-height: 100vh;
        overflow: auto; 
    }
    
    .brand-header {
        margin-bottom: 0;
    }
    .brand-logo {
        width: 36px;
        height: 36px;
    }
    .brand-name {
        font-size: 18px;
        letter-spacing: 0.5px;
    }

    .container {
        margin: 0 auto;
        padding: 15px;
        gap: 15px;
        height: auto;
        width: 95vw;
        border-radius: 16px;
        border-width: 3px;
        box-shadow: 6px 6px 0 rgba(80,184,198,1);
    }

    /* 手机端隐藏装饰点防止遮挡 Logo */
    .container::before, .container::after {
        display: none;
    }

    .main-content {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        flex: 1;
        overflow: visible;
    }
    
    .mobile-only {
        display: block;
    }

    .rules-section {
        display: none; /* 移动端隐藏原规则容器，改用弹窗 */
    }

    .grid-section {
        padding: 0;
        width: 100%;
        max-width: 340px;
        height: auto;
        flex: none;
    }
    
    .grid-container {
        padding: 10px;
        gap: 8px;
        border-radius: 16px;
        aspect-ratio: 1 / 1;
        max-height: none;
    }
    
    .grid-item {
        border-radius: 12px;
        padding: 5px;
        border-width: 2px;
        box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    }
    
    .grid-item .prize-name {
        font-size: 14px;
        margin-top: 2px;
    }
    
    .prize-coupon {
        width: 56px;
        height: 28px;
        margin-bottom: 2px;
    }
    
    .grid-item .desc {
        font-size: 10px;
        margin-top: 0;
    }
    
    .draw-btn {
        font-size: 18px;
        border-width: 2px;
        box-shadow: 0 6px 0 #b33927;
    }
    
    .draw-btn:active {
        box-shadow: 0 2px 0 #b33927;
        transform: translateY(4px);
    }

    .stats-header {
        flex-wrap: wrap;
        gap: 5px;
        padding: 10px;
    }

    .stat-item {
        width: 45%; 
        margin-bottom: 5px;
    }

    .records-section {
        width: 100%;
        max-width: 340px;
        flex: 1;
        margin-top: 0; 
        display: flex;
        flex-direction: column;
        min-height: 0; 
    }
    
    .records-container {
        height: 0; 
        flex: 1;
    }
}
