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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f2ed;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    width: 100%;
}

.main-content header {
    text-align: center;
    margin-bottom: 30px;
    color: #2c4a3c;
}

.logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 20px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1.2em;
    color: #5a6f5e;
    font-weight: 400;
}

main {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.main-content {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    flex: 0 1 700px;
    max-width: 700px;
}

/* Polaroid Styling */
.polaroid-container {
    flex: 0 0 250px;
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
}

.polaroid-left {
    align-items: flex-end;
}

.polaroid-right {
    align-items: flex-start;
}

.polaroid {
    background: white;
    padding: 15px 15px 45px 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.1);
    width: 200px;
    position: relative;
    transition: transform 0.1s ease-out;
    will-change: transform;
}

.polaroid img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: #e0e0e0; /* Placeholder color for missing images */
}

/* Individual Polaroid Rotations with Reduced Overlap */
.polaroid-1 {
    transform: rotate(-4deg);
    z-index: 3;
}
.polaroid-2 {
    transform: rotate(2deg);
    margin-top: -20px;
    z-index: 2;
}
.polaroid-3 {
    transform: rotate(-3deg);
    margin-top: -25px;
    z-index: 1;
}
.polaroid-4 {
    transform: rotate(3deg);
    margin-top: -10px;
    z-index: 3;
}
.polaroid-5 {
    transform: rotate(-2deg);
    margin-top: -20px;
    z-index: 2;
}
.polaroid-6 {
    transform: rotate(4deg);
    margin-top: -15px;
    z-index: 1;
}

.instruction {
    margin-bottom: 15px;
    text-align: center;
}

.instruction p {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 5px;
    color: #333;
}

.hint {
    font-size: 0.9em !important;
    color: #7a8f82 !important;
    font-weight: 400;
    margin-bottom: 0 !important;
}

#dogForm {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #d4cfc5;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: #2c4a3c;
}

button {
    background: #2c4a3c;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

button:hover {
    background: #3d6150;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

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

.secondary-btn {
    background: #7a8f82;
    margin: 20px auto 0 auto;
}

.secondary-btn:hover {
    background: #8da294;
}

.loader {
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top: 3px solid white;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.powered-by {
    text-align: center;
    margin-top: 30px;
    color: #7a8f82;
    font-size: 0.9em;
}

.results-section, .error-section {
    animation: fadeIn 0.5s ease;
}

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

.result-card {
    text-align: center;
}

.result-card h2 {
    color: #2c4a3c;
    margin-bottom: 30px;
    font-size: 2em;
}

#recommendation {
    background: #f5f2ed;
    padding: 30px;
    border-radius: 12px;
    text-align: left;
    margin-bottom: 20px;
}

.product-name {
    font-size: 1.5em;
    font-weight: 700;
    color: #2c4a3c;
    margin-bottom: 15px;
}

.product-details {
    color: #5a6f5e;
    line-height: 1.8;
    margin-bottom: 20px;
}

.product-details p {
    margin-bottom: 10px;
}

.product-details strong {
    color: #2c4a3c;
}

.recommendation-text {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #2c4a3c;
    margin-bottom: 20px;
}

.recommendation-text p {
    line-height: 1.6;
    margin-bottom: 10px;
    color: #333;
}

.cta-button {
    display: inline-block;
    background: #2c4a3c;
    color: white;
    text-decoration: none;
    padding: 15px 40px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.1em;
    transition: background 0.3s ease, transform 0.2s ease;
    margin-top: 10px;
}

.cta-button:hover {
    background: #3d6150;
    transform: translateY(-1px);
}

.error-card {
    text-align: center;
    padding: 20px;
}

.error-card h3 {
    color: #c84538;
    margin-bottom: 15px;
}

#errorMessage {
    color: #5a6f5e;
    margin-bottom: 20px;
}

footer {
    text-align: center;
    margin-top: 30px;
    color: #7a8f82;
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 1200px) {
    main {
        padding: 20px;
        flex-direction: column;
        gap: 30px;
    }

    .container {
        max-width: 700px;
    }

    .polaroid-container {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 15px;
        width: 100%;
        flex: none;
    }

    .polaroid-left {
        order: -1; /* Appears above main content */
    }

    .polaroid-right {
        order: 1; /* Appears below main content */
    }

    .main-content {
        order: 0;
    }

    .polaroid {
        width: 140px;
        padding: 10px 10px 35px 10px;
    }

    .polaroid img {
        height: 140px;
    }

    /* Adjust margins for horizontal layout */
    .polaroid-1,
    .polaroid-2,
    .polaroid-3,
    .polaroid-4,
    .polaroid-5,
    .polaroid-6 {
        margin-top: 0;
    }
}

@media (max-width: 600px) {
    body {
        padding: 15px;
        align-items: flex-start;
        padding-top: 20px;
    }

    main {
        gap: 20px;
    }

    .polaroid-container {
        gap: 10px;
    }

    .polaroid {
        width: 100px;
        padding: 8px 8px 25px 8px;
    }

    .polaroid img {
        height: 100px;
    }

    .main-content {
        padding: 30px 20px;
    }

    .main-content header {
        margin-bottom: 25px;
    }

    .logo {
        max-width: 140px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.75em;
        margin-bottom: 8px;
        line-height: 1.2;
    }

    .tagline {
        font-size: 1em;
        line-height: 1.4;
    }

    .instruction {
        margin-bottom: 12px;
    }

    .instruction p {
        font-size: 1em;
    }

    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px;
    }

    button {
        padding: 14px 24px;
        font-size: 1em;
    }

    .powered-by {
        font-size: 0.85em;
        margin-top: 20px;
    }

    footer {
        margin-top: 20px;
        font-size: 0.85em;
    }

    .product-name {
        font-size: 1.3em;
    }

    .recommendation-text {
        padding: 15px;
    }

    .result-card h2 {
        font-size: 1.5em;
    }
}
