:root {
    --primary: #DC143C;
    --primary-light: #FF6B6B;
    --primary-dark: #8B0000;
    --gold: #FFD700;
    --bg: #FFF5F5;
    --text: #333;
    --white: #fff;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    min-height: 100vh;
}

.page {
    display: none;
    min-height: 100vh;
    padding-bottom: 20px;
}

.page.active { display: block; }

/* 登录页 */
.login-container {
    padding: 60px 30px;
    text-align: center;
}

.login-container h1 {
    color: var(--primary);
    font-size: 32px;
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    color: var(--text);
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
}

.btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
}

/* 首页 */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 30px;
    border-radius: 0 0 20px 20px;
}

.points-card {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    background: rgba(255,255,255,0.2);
    padding: 15px;
    border-radius: 12px;
}

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

.points-item .label {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.points-item .value {
    display: block;
    font-size: 28px;
    font-weight: bold;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 20px;
}

.menu-item {
    background: var(--white);
    border-radius: 12px;
    padding: 20px 10px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
}

.menu-item .icon {
    display: block;
    font-size: 32px;
    margin-bottom: 8px;
}

.menu-item .text {
    font-size: 14px;
    color: var(--text);
}

/* 页面头部 */
.page-header {
    display: flex;
    align-items: center;
    padding: 15px;
    background: var(--primary);
    color: var(--white);
}

.back-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 16px;
    cursor: pointer;
    margin-right: 15px;
}

.page-header h2 {
    flex: 1;
    text-align: center;
}

.refresh-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.5);
    color: var(--white);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 14px;
    cursor: pointer;
}

/* 刷新倒计时 */
.refresh-countdown {
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    color: var(--white);
    text-align: center;
    padding: 8px;
    font-size: 13px;
}

.refresh-countdown #countdown-text {
    display: inline-block;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* 全员总积分和倒计时合并显示条 */
.rank-info-bar {
    background: linear-gradient(135deg, #FFF8DC, #FFD700);
    color: #8B6914;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

.rank-info-bar .total-points {
    display: flex;
    align-items: center;
}

.rank-info-bar .total-points b {
    font-size: 20px;
    color: var(--primary);
    margin-left: 6px;
}

.rank-info-bar .countdown {
    font-size: 13px;
    color: #8B6914;
    opacity: 0.9;
    animation: pulse 1s ease-in-out infinite;
}

/* 积分榜样式 */
.rank-header {
    display: flex;
    background: var(--primary);
    color: var(--white);
    padding: 12px 15px;
    font-weight: bold;
    font-size: 14px;
}

.rank-header .rank-col { flex: 0 0 50px; text-align: center; }
.rank-header .name-col { flex: 1; text-align: center; }
.rank-header .points-col { flex: 0 0 70px; text-align: center; }

.list-container {
    padding: 0;
}

/* 活动卡片样式 */
.activity-card {
    background: var(--white);
    margin: 12px;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(220, 20, 60, 0.1);
    border: 1px solid rgba(220, 20, 60, 0.08);
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed rgba(220, 20, 60, 0.2);
}

.activity-name {
    flex: 1;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
    margin: 0;
}

.activity-points {
    background: linear-gradient(135deg, var(--gold), #FFA500);
    color: var(--white);
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 13px;
    font-weight: bold;
    white-space: nowrap;
    margin-left: 10px;
}

.activity-desc {
    color: var(--text);
    font-size: 14px;
    line-height: 2;
    margin-bottom: 15px;
    min-height: 40px;
}

.activity-desc br {
    margin-bottom: 8px;
    content: '';
    display: block;
}

.activity-footer {
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.activity-manager {
    flex: 1;
}

.manager-label {
    color: var(--text-light);
    font-size: 13px;
}

.manager-names {
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
}

.btn-generate-qr {
    width: 100%;
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    border-radius: 25px;
    font-size: 15px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-generate-qr:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(220, 20, 60, 0.3);
}

/* 二维码弹窗 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    width: 85%;
    max-width: 320px;
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 25px;
    text-align: center;
}

#qrcode {
    display: inline-block;
    padding: 15px;
    background: var(--white);
    border: 2px solid var(--primary-light);
    border-radius: 8px;
    margin-bottom: 15px;
}

#qrcode img, #qrcode canvas {
    display: block;
    margin: 0 auto;
}

.qr-tip {
    color: var(--text-light);
    font-size: 13px;
    margin-bottom: 8px;
}

.qr-expire {
    color: var(--primary);
    font-size: 12px;
}

/* 兑换页面样式 */
.exchange-container {
    padding: 15px;
}

.exchange-card {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    margin: 10px 0;
    box-shadow: 0 2px 12px rgba(220, 20, 60, 0.1);
    text-align: center;
}

.exchange-card h3 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 20px;
}

.exchange-icon {
    font-size: 64px;
    margin-bottom: 15px;
}

.exchange-desc {
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.exchange-select {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    font-size: 16px;
    background: var(--white);
    color: var(--text);
    margin-bottom: 20px;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23DC143C' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.exchange-info {
    background: var(--bg);
    border-radius: 12px;
    padding: 20px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-item .label {
    color: var(--text-light);
    font-size: 14px;
}

.info-item .value {
    color: var(--primary);
    font-size: 24px;
    font-weight: bold;
}

/* 投票页面样式 */
.vote-info-bar {
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    color: var(--white);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.vote-info-bar b {
    font-size: 18px;
    margin: 0 4px;
}

.vote-list-container {
    padding: 15px;
}

.vote-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 12px rgba(220, 20, 60, 0.1);
    position: relative;
}

.vote-card.voted {
    border: 2px solid var(--gold);
    background: linear-gradient(135deg, #FFF8DC, var(--white));
}

.vote-rank {
    position: absolute;
    top: -10px;
    left: 20px;
    background: linear-gradient(135deg, var(--gold), #FFA500);
    color: var(--white);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.vote-rank.top1 { background: linear-gradient(135deg, #FFD700, #FFA500); }
.vote-rank.top2 { background: linear-gradient(135deg, #C0C0C0, #808080); }
.vote-rank.top3 { background: linear-gradient(135deg, #CD7F32, #8B4513); }

.vote-activity-name {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 8px;
    padding-top: 20px;
}

.vote-activity-desc {
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 15px;
}

.vote-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

.vote-count {
    display: flex;
    align-items: center;
    gap: 5px;
}

.vote-count .icon {
    font-size: 20px;
}

.vote-count .num {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
}

.vote-count .label {
    font-size: 12px;
    color: var(--text-light);
}

.btn-vote {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--white);
    border: none;
    padding: 10px 25px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.3);
}

.btn-vote:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-vote.voted {
    background: linear-gradient(135deg, var(--gold), #FFA500);
}

/* NPC任务页面样式 */
.npc-container {
    padding: 15px;
}

.npc-card {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 12px rgba(220, 20, 60, 0.1);
    position: relative;
    overflow: hidden;
}

.npc-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.npc-card.status-0::before { background: #999; }
.npc-card.status-1::before { background: var(--gold); }

.npc-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.npc-name {
    font-size: 18px;
    font-weight: bold;
    color: var(--text);
    flex: 1;
}

.npc-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

.npc-status.inactive {
    background: #f0f0f0;
    color: #999;
}

.npc-status.active {
    background: linear-gradient(135deg, #FFF8DC, #FFD700);
    color: #8B6914;
}

.npc-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.npc-info-item {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: var(--text-light);
}

.npc-info-item .label {
    margin-right: 8px;
}

.npc-info-item .value {
    color: var(--text);
    font-weight: 500;
}

.npc-threshold {
    color: var(--primary);
    font-weight: bold;
}

.npc-trigger-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #eee;
    background: linear-gradient(135deg, #FFF8DC, #FFF5F5);
    margin: 15px -20px -20px;
    padding: 15px 20px 20px;
}

.npc-trigger-title {
    font-size: 14px;
    color: var(--gold);
    font-weight: bold;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.npc-lucky-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.npc-lucky-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), #FFA500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.npc-lucky-info {
    flex: 1;
}

.npc-lucky-name {
    font-size: 15px;
    font-weight: bold;
    color: var(--text);
}

.npc-lucky-phone {
    font-size: 12px;
    color: var(--text-light);
}

.npc-trigger-time {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

.npc-prize {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    font-size: 13px;
    color: #8B6914;
}

/* 积分记录页面样式 */
.records-container {
    padding: 15px;
    min-height: calc(100vh - 60px);
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .icon {
    font-size: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state .text {
    font-size: 14px;
}

.record-card {
    background: var(--white);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.record-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.record-icon.earn {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
}

.record-icon.spend {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
}

.record-content {
    flex: 1;
    min-width: 0;
}

.record-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.record-time {
    font-size: 12px;
    color: var(--text-light);
}

.record-points {
    text-align: right;
    flex-shrink: 0;
}

.record-points .value {
    font-size: 20px;
    font-weight: bold;
}

.record-points .value.earn {
    color: #4caf50;
}

.record-points .value.spend {
    color: var(--primary);
}

.record-points .label {
    font-size: 11px;
    color: var(--text-light);
}

.rank-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    background: var(--white);
    transition: background 0.2s;
}

.rank-item:active {
    background: #f5f5f5;
}

.rank-item .rank-num {
    flex: 0 0 50px;
    text-align: center;
    font-weight: bold;
    font-size: 16px;
}

.rank-item .name {
    flex: 1;
    text-align: center;
    font-size: 15px;
    color: var(--text);
    line-height: 1.4;
}

.rank-item .points {
    flex: 0 0 70px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--primary);
}

/* 前三名特殊样式 */
.rank-item.top-1 {
    background: linear-gradient(90deg, #FFF8DC 0%, #FFD70033 100%);
    border-left: 4px solid #FFD700;
}

.rank-item.top-1 .rank-num {
    color: #FFD700;
    font-size: 20px;
}

.rank-item.top-1 .points {
    color: #FFD700;
}

.rank-item.top-2 {
    background: linear-gradient(90deg, #F5F5F5 0%, #C0C0C033 100%);
    border-left: 4px solid #C0C0C0;
}

.rank-item.top-2 .rank-num {
    color: #C0C0C0;
    font-size: 20px;
}

.rank-item.top-3 {
    background: linear-gradient(90deg, #FFF5F0 0%, #CD7F3233 100%);
    border-left: 4px solid #CD7F32;
}

.rank-item.top-3 .rank-num {
    color: #CD7F32;
    font-size: 20px;
}

/* NPC积分扫码页面 */
.npc-scan-container { padding: 20px; }

.npc-scan-card {
    background: var(--white);
    border-radius: 16px;
    padding: 25px;
    margin: 10px 0;
    box-shadow: 0 2px 12px rgba(220, 20, 60, 0.1);
    text-align: center;
}

.npc-scan-card h3 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 10px;
}

.npc-scan-desc {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 25px;
}

.npc-task-select {
    margin-bottom: 20px;
    text-align: left;
}

.npc-task-select label {
    display: block;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 8px;
}

.npc-task-select select {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--primary-light);
    border-radius: 12px;
    font-size: 16px;
    background: var(--white);
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23DC143C' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
}

.npc-points-info {
    background: linear-gradient(135deg, #FFF8DC, #FFF5F5);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    font-size: 16px;
    color: var(--text);
}

.npc-points-info span:nth-child(2) {
    color: var(--primary);
    font-size: 28px;
    font-weight: bold;
    margin: 0 5px;
}

