:root {
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --card-bg: #ffffff;
    --highlight-color: #FF3030; /* More vibrant yellow */
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    
    /* 浅灰色背景 */
    background-color: #f0f0f0;
    
    /* Prevent horizontal scroll */
    overflow-x: hidden;
    width: 100vw;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Home Page Grid */
.container {
    width: 100%;
    max-width: 100%; /* Ensure it fits in viewport */
    margin: 0;
    padding: 20px 10px; /* Reduced side padding */
}

.product-grid {
    display: grid;
    /* Force 3 columns that fit in screen */
    grid-template-columns: repeat(3, minmax(0, 1fr)); /* Use minmax(0, 1fr) to prevent content overflow */
    gap: 20px 10px; /* Reduce horizontal gap */
    justify-items: center;
    width: 100%;
}

/* Responsive grid for larger screens */
@media (min-width: 600px) {
    .product-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 30px 20px;
        max-width: 800px;
        margin: 0 auto;
    }
}

.product-item {
    text-align: center;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease;
    width: 100%;
    position: relative; /* For badge positioning */
}

.product-item:active {
    transform: scale(0.98);
}

.product-img-wrapper {
    width: 100%;
    /* Use padding-top hack to force square aspect ratio across all browsers */
    padding-top: 100%; 
    height: 0;
    position: relative;
    
    overflow: hidden;
    border-radius: 0;
    margin-bottom: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    background: #fff;
    transition: box-shadow 0.3s ease;
}

.product-item:hover .product-img-wrapper {
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.product-img {
    /* Absolute position to fill the wrapper */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-name {
    background-color: var(--highlight-color);
    padding: 4px 5px; /* Reduced padding */
    font-size: 12px; /* Slightly smaller font to fit */
    font-weight: 700;
    color: #FFFAFA;
    border-radius: 4px;
    line-height: 1.2;
    
    /* Strict Uniform Size */
    display: block;
    width: 100%; /* Occupy full width of the grid item */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Selection State Styles */
.product-item.selected .product-img-wrapper {
    box-shadow: 0 0 0 4px #ff0000; /* Red border effect */
    transform: scale(0.95);
}

/* Floating Confirm Button */
.confirm-btn-wrapper {
    position: fixed;
    bottom: 30px;
    right: 20px;
    z-index: 1000;
    display: none; /* Hidden by default */
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confirm-btn-fab {
    background-color: #ff0000; /* Red as per user request implied */
    color: white;
    font-weight: bold;
    padding: 15px 25px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    border: 2px solid white;
}

.confirm-btn-fab:active {
    transform: scale(0.95);
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Selection badge */
.select-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: #ff0000;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border: 2px solid white;
    z-index: 10; /* Ensure on top */
}

.product-item.selected .select-badge {
    display: flex;
}

/* Detail Page */
.detail-container {
    width: 100%;
    max-width: 600px; /* Mobile focused */
    margin: 0 auto;
    padding-bottom: 90px; /* Space for fixed bottom bar */
    /* background: #fff; Removed to show background image */
    min-height: 100vh;
}

.detail-images {
    width: 100%;
    font-size: 0; /* Remove gap between images */
}

.detail-images img {
    width: 100%;
    height: auto;
    display: block;
}

.detail-info {
    padding: 25px 20px;
    background: rgba(255, 255, 255, 0.9); /* Add transparency */
    margin: 20px;
    border-radius: 10px;
}

.description {
    font-size: 15px;
    line-height: 1.8;
    color: #444;
    margin-bottom: 10px;
    white-space: pre-wrap; /* Preserve line breaks */
}

/* Fixed Bottom Bar for Contact Button */
.fixed-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: center;
    backdrop-filter: blur(5px);
    z-index: 100;
}

.contact-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    background-color: var(--primary-color);
    color: white;
    padding: 14px 0;
    text-align: center;
    text-decoration: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transition: background-color 0.2s, transform 0.1s;
}

.contact-btn:hover {
    background-color: var(--primary-hover);
}

.contact-btn:active {
    transform: scale(0.98);
}

/* Contact Page */
.contact-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    /* background-color: var(--bg-color); Removed */
}

.contact-card {
    background: rgba(255, 255, 255, 0.95); /* Semi-transparent */
    padding: 40px 30px;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    text-align: left;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.contact-card h1 {
    margin-top: 0;
    font-size: 22px;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.contact-item {
    margin-bottom: 15px;
    font-size: 16px;
}

.contact-label {
    font-weight: bold;
    color: #666;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.contact-value {
    font-size: 18px;
    color: #000;
}

.back-link {
    margin-top: 30px;
    display: inline-block;
    color: #fff; /* White text on background image */
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    font-size: 14px;
    text-decoration: underline;
}

.back-link:hover {
    color: #eee;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-item {
    animation: fadeIn 0.5s ease backwards;
}

.product-item:nth-child(1) { animation-delay: 0.05s; }
.product-item:nth-child(2) { animation-delay: 0.1s; }
.product-item:nth-child(3) { animation-delay: 0.15s; }
.product-item:nth-child(4) { animation-delay: 0.2s; }
.product-item:nth-child(5) { animation-delay: 0.25s; }
.product-item:nth-child(6) { animation-delay: 0.3s; }
.product-item:nth-child(n+7) { animation-delay: 0.35s; }
