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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

.main-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.create-vote-section h2,
.qr-section h2 {
    margin-bottom: 20px;
    color: #667eea;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}

input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

.option-input {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.option-input .option {
    flex: 1;
}

.remove-option {
    padding: 12px 20px;
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.remove-option:hover {
    background: #ff3838;
}

.add-option-btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.add-option-btn:hover {
    background: #5568d3;
}

.submit-btn,
.submit-vote-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 20px;
}

.submit-btn:hover,
.submit-vote-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.qr-code-container {
    text-align: center;
    margin: 20px 0;
}

.qr-code-container img {
    max-width: 300px;
    border: 5px solid #667eea;
    border-radius: 10px;
    padding: 10px;
    background: white;
}

.vote-url {
    margin: 20px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    word-break: break-all;
}

.copy-btn,
.new-vote-btn,
.view-results-btn,
.refresh-btn {
    padding: 12px 24px;
    margin: 10px 5px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.copy-btn:hover,
.new-vote-btn:hover,
.view-results-btn:hover,
.refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.refresh-btn {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    font-size: 16px;
}

.scan-section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.scan-section h2 {
    margin-bottom: 20px;
    color: #667eea;
    text-align: center;
}

.scanner-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto 20px;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

#video {
    width: 100%;
    display: block;
}

#scanner-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 3px solid #00ff00;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.scan-btn {
    display: block;
    width: 200px;
    margin: 20px auto;
    padding: 15px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.scan-btn:hover {
    background: #5568d3;
}

.scan-result {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 8px;
    font-weight: 600;
}

.vote-page {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    min-height: 500px;
}

.loading {
    text-align: center;
    padding: 50px;
    font-size: 18px;
    color: #667eea;
}

.vote-form h2 {
    margin-bottom: 20px;
    color: #667eea;
}

.options-list {
    margin-bottom: 20px;
}

.option-item {
    padding: 15px;
    margin-bottom: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.option-item:hover {
    border-color: #667eea;
    background: #f0f0ff;
}

.option-item input[type="radio"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.option-item label {
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.success-message {
    text-align: center;
    padding: 30px;
}

.success-message h2 {
    color: #2ecc71;
    margin-bottom: 10px;
}

.results-section {
    margin-top: 30px;
    animation: fadeIn 0.5s ease-in;
}

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

.results-section h2 {
    margin-bottom: 25px;
    color: white;
    font-size: 1.8em;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

.results-section h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.results-header {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.results-header .total-votes {
    font-size: 1.2em;
    font-weight: 600;
    margin-top: 5px;
}

.results-list {
    margin-bottom: 20px;
}

.result-item {
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
}

.result-item.first::before {
    background: linear-gradient(180deg, #f39c12 0%, #e67e22 100%);
}

.result-item.second::before {
    background: linear-gradient(180deg, #95a5a6 0%, #7f8c8d 100%);
}

.result-item.third::before {
    background: linear-gradient(180deg, #cd7f32 0%, #b87333 100%);
}

.result-rank {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    color: white;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.result-item.first .result-rank {
    background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.3);
    font-size: 18px;
}

.result-item.second .result-rank {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 0 2px 8px rgba(149, 165, 166, 0.3);
}

.result-item.third .result-rank {
    background: linear-gradient(135deg, #cd7f32 0%, #b87333 100%);
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.3);
}

.result-content {
    padding-right: 50px;
}

.result-item .option-name {
    font-weight: 600;
    font-size: 18px;
    color: #333;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.result-item .option-name::before {
    content: '▸';
    color: #667eea;
    margin-right: 8px;
    font-size: 14px;
}

.result-item.first .option-name::before {
    content: '🥇';
    margin-right: 8px;
}

.result-item.second .option-name::before {
    content: '🥈';
    margin-right: 8px;
}

.result-item.third .option-name::before {
    content: '🥉';
    margin-right: 8px;
}

.result-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.result-item .vote-count {
    color: #667eea;
    font-weight: 700;
    font-size: 20px;
    display: flex;
    align-items: center;
}

.result-item.first .vote-count {
    color: #f39c12;
}

.result-item.second .vote-count {
    color: #95a5a6;
}

.result-item.third .vote-count {
    color: #cd7f32;
}

.result-percentage {
    color: #666;
    font-size: 14px;
    font-weight: 600;
}

.result-bar {
    height: 35px;
    background: #f0f0f0;
    border-radius: 18px;
    overflow: hidden;
    margin: 12px 0;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
}

.result-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 12px;
    color: white;
    font-weight: 700;
    font-size: 13px;
    position: relative;
    overflow: hidden;
}

.result-bar-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.result-item.first .result-bar-fill {
    background: linear-gradient(90deg, #f39c12 0%, #e67e22 100%);
}

.result-item.second .result-bar-fill {
    background: linear-gradient(90deg, #95a5a6 0%, #7f8c8d 100%);
}

.result-item.third .result-bar-fill {
    background: linear-gradient(90deg, #cd7f32 0%, #b87333 100%);
}

.error-message {
    text-align: center;
    padding: 30px;
    color: #ff4757;
}

.error-message h2 {
    margin-bottom: 10px;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }
    
    .main-content,
    .scan-section,
    .vote-page {
        padding: 20px;
    }
    
    .qr-code-container img {
        max-width: 250px;
    }
}
/* 查看结果区域 */
.view-results-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    border: 1px solid #e9ecef;
    display: none;
}

.view-results-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.results-input-group {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.hint-text {
    font-size: 14px;
    color: #6c757d;
    margin-top: 10px;
}

/* 结果区域头部 */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
}

.vote-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.vote-id {
    font-size: 14px;
    color: #6c757d;
    font-family: monospace;
    background: #f8f9fa;
    padding: 3px 8px;
    border-radius: 4px;
}

/* 结果操作按钮 */
.results-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.close-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.close-btn:hover {
    background: #5a6268;
}

/* 加载和错误状态 */
.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 16px;
}

.error {
    text-align: center;
    padding: 40px;
    color: #dc3545;
    font-size: 16px;
    background: #f8d7da;
    border-radius: 5px;
    margin: 10px 0;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #6c757d;
    font-size: 16px;
    background: #f8f9fa;
    border-radius: 5px;
    margin: 10px 0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .results-input-group {
        flex-direction: column;
        gap: 10px;
    }

    #voteIdInput {
        width: 100% !important;
        margin-right: 0 !important;
    }

    .view-results-btn {
        width: 100%;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .vote-info {
        align-items: flex-start;
    }
}
/* 横向结果列表 - 紧凑版 */
.results-list.horizontal-list {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 0;
    gap: 10px; /* 减小间距 */
    margin-bottom: 20px;
    align-items: stretch; /* 使所有框高度一致 */
}

.results-list.horizontal-list .result-item {
    flex: 0 0 auto;
    width: 150px; /* 减小宽度 */
    min-height: 180px; /* 减小高度 */
    flex-direction: column;
    justify-content: space-between;
    margin-bottom: 0;
    padding: 12px; /* 减小内边距 */
}

.results-list.horizontal-list .result-rank {
    width: 28px; /* 减小排名圆圈大小 */
    height: 28px;
    font-size: 14px;
    margin-bottom: 8px;
}

.results-list.horizontal-list .result-content {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.results-list.horizontal-list .option-name {
    height: 36px; /* 减小高度 */
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* 最多显示2行 */
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
    font-size: 13px; /* 减小字体 */
    line-height: 1.3;
}

.results-list.horizontal-list .result-bar {
    margin: 8px 0;
    height: 8px; /* 减小进度条高度 */
}

.results-list.horizontal-list .result-bar-fill {
    font-size: 11px; /* 减小百分比字体 */
}

.results-list.horizontal-list .result-bar-fill span {
    line-height: 8px; /* 调整行高 */
}

.results-list.horizontal-list .result-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    font-size: 12px; /* 减小统计字体 */
}

.results-list.horizontal-list .result-percentage {
    font-size: 13px; /* 调整百分比字体 */
    font-weight: bold;
}

.results-list.horizontal-list .vote-count {
    font-size: 12px; /* 调整票数字体 */
    color: #666;
}

/* 针对排名靠前的特殊样式 */
.results-list.horizontal-list .result-item.first {
    width: 160px; /* 第一名稍微宽一点 */
    background: linear-gradient(135deg, #fff8e1 0%, #ffecb3 100%);
    border: 1px solid #ffc107;
}

.results-list.horizontal-list .result-item.second {
    width: 155px; /* 第二名稍微宽一点 */
    background: linear-gradient(135deg, #f5f5f5 0%, #e0e0e0 100%);
    border: 1px solid #6c757d;
}

.results-list.horizontal-list .result-item.third {
    width: 155px; /* 第三名稍微宽一点 */
    background: linear-gradient(135deg, #f3e5d2 0%, #e6d0b8 100%);
    border: 1px solid #cd7f32;
}

/* 确保普通排名也有渐变背景 */
.results-list.horizontal-list .result-item:not(.first):not(.second):not(.third) {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .results-list.horizontal-list .result-item {
        width: 130px; /* 手机端更窄 */
        min-height: 160px;
        padding: 10px;
    }

    .results-list.horizontal-list .result-item.first {
        width: 140px;
    }

    .results-list.horizontal-list .result-item.second,
    .results-list.horizontal-list .result-item.third {
        width: 135px;
    }

    .results-list.horizontal-list .option-name {
        height: 32px;
        font-size: 12px;
    }
}
