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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 910px;
    margin: 0 auto;
    padding: 20px;
}

.page {
    display: none;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 40px;
    text-align: center;
}

.page.active {
    display: block;
}

/* 授权页面样式 */
.auth-container h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.auth-buttons {
    margin: 20px 0;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.auth-buttons .btn {
    margin: 5px;
    min-width: 120px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.auth-buttons .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.qr-container {
    margin: 30px 0;
}

.qr-code {
    display: inline-block;
    padding: 20px;
    background: white;
    border: 2px solid #eee;
    border-radius: 10px;
    margin-bottom: 15px;
}

.qr-code img {
    width: 200px;
    height: 200px;
    display: block;
}

/* 首页二维码显示样式 */
.qr-code-display {
    margin: 30px auto;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #e9ecef;
    max-width: 300px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.qr-code-display .qr-header {
    margin-bottom: 15px;
    padding: 0;
    background: none;
    border: none;
    justify-content: center;
}

.qr-code-display .qr-header span {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
}

.qr-code-display .qr-image {
    text-align: center;
}

.qr-code-display .qr-image img {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.qr-code-display .qr-tip {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
    text-align: center;
}

.user-list {
    margin-top: 30px;
    text-align: left;
}

.user-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.user-list h3 {
    color: #333;
    margin: 0;
    text-align: center;
    flex: 1;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8em;
    min-width: auto;
}

#user-list-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 10px;
    height: 320px;
    overflow: hidden;
    position: relative;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

/* 当用户数量超过16个时的滚动容器 */
#user-list-container.scrollable {
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* 循环滚动效果 */
#user-list-container.auto-scroll {
    overflow: hidden;
    position: relative;
    height: 400px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
    border: 2px solid #e1e8ed;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

#user-list-container.auto-scroll .user-scroll-content {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    padding: 15px;
    animation: scrollUpGrid 30s linear infinite;
}

/* 循环滚动响应式设计 */
@media (max-width: 768px) {
    #user-list-container.auto-scroll {
        height: 300px;
    }
    
    #user-list-container.auto-scroll .user-scroll-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    #user-list-container.auto-scroll {
        height: 250px;
    }
    
    #user-list-container.auto-scroll .user-scroll-content {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    #user-list-container.auto-scroll .user-item {
        min-height: 70px;
        padding: 10px 6px;
    }
    
    #user-list-container.auto-scroll .user-item img {
        width: 35px;
        height: 35px;
    }
    
    #user-list-container.auto-scroll .user-item span {
        font-size: 11px;
    }
}

@keyframes scrollUpGrid {
    0% {
        transform: translateY(0%);
    }
    100% {
        transform: translateY(-50%);
    }
}

/* 暂停动画当鼠标悬停 */
#user-list-container.auto-scroll:hover .user-scroll-content {
    animation-play-state: paused;
}

/* 循环滚动时的用户项布局 */
#user-list-container.auto-scroll .user-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    min-height: 80px;
    backdrop-filter: blur(10px);
    text-align: center;
}

#user-list-container.auto-scroll .user-item:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

#user-list-container.auto-scroll .user-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-bottom: 8px;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#user-list-container.auto-scroll .user-item span {
    font-size: 12px;
    color: #333;
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

/* 滚动条样式 */
#user-list-container::-webkit-scrollbar {
    width: 6px;
}

#user-list-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#user-list-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

#user-list-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 响应式设计 */
@media (max-width: 768px) {
    #user-list-container {
        grid-template-columns: repeat(3, 1fr);
        grid-template-rows: repeat(3, 1fr);
        height: 240px;
    }
    
    /* 移动端超过9个用户时启用滚动 */
    #user-list-container.mobile-scrollable {
        overflow-y: auto;
        scroll-behavior: smooth;
    }
}

@media (max-width: 480px) {
    #user-list-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 1fr);
        height: 160px;
    }
    
    .user-item {
        min-height: 60px;
        padding: 6px;
    }
    
    .user-item img {
        width: 28px;
        height: 28px;
    }
    
    .user-item span {
        font-size: 10px;
    }
}

.user-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 70px;
    position: relative;
}

.user-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.user-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-bottom: 4px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.user-item span {
    font-size: 11px;
    color: #333;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

/* 抽奖页面样式 */
.lottery-container h1 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.lottery-display {
    margin: 40px 0;
}

.avatar-display {
    display: inline-block;
    padding: 30px;
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
}

.avatar-display:hover {
    transform: scale(1.05);
}

#lottery-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 4px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto 15px;
}

#lottery-name {
    color: white;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.lottery-controls {
    margin: 30px 0;
}

.lottery-controls .btn {
    margin: 0 10px;
}

/* 中奖显示样式 */
.winner-display {
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(45deg, #ff9a9e, #fecfef);
    border-radius: 15px;
    animation: celebration 2s ease-in-out;
}

@keyframes celebration {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.winner-display h2 {
    color: #d63384;
    margin-bottom: 20px;
    font-size: 2em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.winner-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

#winner-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

#winner-name {
    font-size: 24px;
    font-weight: bold;
    color: #d63384;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
}

.btn-success {
    background: linear-gradient(45deg, #56ab2f, #a8e6cf);
    color: white;
}

.btn-danger {
    background: linear-gradient(45deg, #ff416c, #ff4b2b);
    color: white;
}

.btn-secondary {
    background: linear-gradient(45deg, #bdc3c7, #2c3e50);
    color: white;
}

.btn-link {
    background: transparent;
    color: #667eea;
    text-decoration: underline;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* 抽奖动画 */
.lottery-spinning {
    animation: spin 0.1s linear infinite;
}

@keyframes spin {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* 右上角二维码样式 */
.qr-code-corner {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 2px solid #e9ecef;
    z-index: 100;
    animation: slideInRight 0.3s ease-out;
}

.qr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid #e9ecef;
}

.qr-header span {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
}

.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.qr-image {
    padding: 15px;
    text-align: center;
}

.qr-image img {
    width: 150px;
    height: 150px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.qr-tip {
    text-align: center;
    font-size: 11px;
    color: #6c757d;
    margin: 0;
    padding: 0 15px 15px 15px;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* 确保抽奖容器有相对定位 */
.lottery-container {
    position: relative;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .page {
        padding: 20px;
    }
    
    .auth-container h1,
    .lottery-container h1 {
        font-size: 2em;
    }
    
    #lottery-avatar {
        width: 100px;
        height: 100px;
    }
    
    .winner-info {
        flex-direction: column;
        gap: 10px;
    }
    
    #user-list-container {
        grid-template-columns: 1fr;
    }
    
    .lottery-controls .btn {
        margin: 5px;
        display: block;
        width: 100%;
    }
    
    /* 移动设备上的二维码样式调整 */
    .qr-code-corner {
        position: fixed;
        top: 10px;
        right: 10px;
        width: 160px;
        z-index: 1000;
    }
    
    .qr-image img {
        width: 120px;
        height: 120px;
    }
    
    .qr-header span {
        font-size: 11px;
    }
    
    .qr-tip {
        font-size: 10px;
    }
    
    .qr-modal {
        padding: 20px;
        margin: 20px;
    }
    
    .qr-code img {
        max-width: 150px;
    }
    
    .qr-actions {
        flex-direction: column;
    }
    
    .qr-actions button {
        width: 100%;
    }
}