* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 40px;
    border: 1px solid #f0f0f0;
    position: relative;
}

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #13c2c2;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.back-link:hover {
    color: #36cfc9;
    transform: translateX(-3px);
}

.back-link::before {
    content: '←';
    font-size: 18px;
}

h1 {
    text-align: center;
    color: #13c2c2;
    margin-bottom: 10px;
    font-size: 2em;
    font-weight: 700;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 0.9em;
}

.search-section {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.search-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #13c2c2;
}

.category-filter {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
    min-width: 150px;
}

.category-filter:focus {
    outline: none;
    border-color: #13c2c2;
}

.ranking-section {
    margin-bottom: 30px;
}

.ranking-header {
    display: grid;
    grid-template-columns: 60px 1fr 120px 100px;
    gap: 15px;
    padding: 15px;
    background: #13c2c2;
    color: white;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    font-size: 0.95em;
}

.ranking-list {
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.ranking-item {
    display: grid;
    grid-template-columns: 60px 1fr 120px 100px;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.3s;
    align-items: center;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-item:hover {
    background: #f0f9ff;
}

.ranking-item.top3 {
    background: linear-gradient(90deg, #fff7e6 0%, #fff 100%);
}

.ranking-item.top3 .rank-number {
    color: #ffa940;
    font-weight: bold;
}

.rank-number {
    text-align: center;
    font-weight: 600;
    color: #666;
    font-size: 1.1em;
}

.rank-number.top1 {
    color: #ffa940;
    font-size: 1.3em;
}

.rank-number.top2 {
    color: #ff7875;
    font-size: 1.2em;
}

.rank-number.top3 {
    color: #ffa940;
    font-size: 1.1em;
}

.food-name {
    font-weight: 500;
    color: #333;
    font-size: 1em;
}

.carb-value {
    text-align: center;
    font-weight: 600;
    color: #13c2c2;
    font-size: 1.1em;
}

.carb-unit {
    font-size: 0.85em;
    color: #999;
    margin-left: 3px;
}

.category-tag {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    text-align: center;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    user-select: none;
}

.category-tag:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.category-tag.主食 {
    background: #fff7e6;
    color: #ffa940;
}

.category-tag.薯类 {
    background: #fff1f0;
    color: #ff7875;
}

.category-tag.水果 {
    background: #f6ffed;
    color: #52c41a;
}

.category-tag.蔬菜 {
    background: #e6f7ff;
    color: #40a9ff;
}

.category-tag.豆类 {
    background: #f0f5ff;
    color: #597ef7;
}

.category-tag.坚果 {
    background: #fffbe6;
    color: #faad14;
}

.category-tag.其他 {
    background: #f9f0ff;
    color: #9254de;
}

.reference-section {
    background: #fafafa;
    border-radius: 15px;
    padding: 25px;
    border: 1px solid #f0f0f0;
}

.reference-title {
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.reference-content {
    color: #666;
    font-size: 0.95em;
    line-height: 1.8;
}

.reference-content p {
    margin-bottom: 10px;
}

.reference-content p:last-child {
    margin-bottom: 0;
}

.reference-content strong {
    color: #13c2c2;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1em;
}

@media (max-width: 768px) {
    .container {
        padding: 25px 15px;
    }

    h1 {
        font-size: 1.5em;
    }

    .search-section {
        flex-direction: column;
    }

    .category-filter {
        width: 100%;
    }

    .ranking-header,
    .ranking-item {
        grid-template-columns: 50px 1fr 100px 80px;
        gap: 10px;
        padding: 12px;
        font-size: 0.9em;
    }

    .rank-number {
        font-size: 1em;
    }

    .carb-value {
        font-size: 1em;
    }

    .category-tag {
        font-size: 0.75em;
        padding: 3px 8px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px 10px;
    }

    h1 {
        font-size: 1.3em;
    }

    .ranking-header,
    .ranking-item {
        grid-template-columns: 40px 1fr 80px 70px;
        gap: 8px;
        padding: 10px;
        font-size: 0.85em;
    }

    .food-name {
        font-size: 0.9em;
    }

    .carb-value {
        font-size: 0.9em;
    }

    .category-tag {
        font-size: 0.7em;
        padding: 2px 6px;
    }
}
