:root {
    --bg: #fdfaf7;
    --accent: #0078d4;
    --card-white: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    margin: 0;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* --- Header Row (Logo + Title Centered) --- */
.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.header-row h1 {
    margin: 0;
}

.site-logo {
    width: 176px;
    height: 176px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 3px solid #ffffff;
    background-color: var(--card-white);
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.site-logo:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}

/* --- Header & Controls --- */
.controls-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 50px;
    align-items: flex-end;
    max-width: 900px;
}

.input-group { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 0.85rem; font-weight: bold; color: #666; }

input, select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

button#respin {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s;
}

button#respin:hover { transform: translateY(-2px); background-color: #0063b1; }

/* --- Polaroid Gallery --- */
#gallery {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    max-width: 1100px;
    min-height: 200px; /* Helps prevent layout shift */
}

.polaroid {
    background: var(--card-white);
    padding: 15px 15px 35px 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    width: 200px;
    border: 1px solid #f0f0f0;
    position: relative;
    overflow: hidden;
    opacity: 0; 
    animation: popIn 0.5s forwards;
}

.polaroid::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 0;
}

.polaroid > * {
    position: relative;
    z-index: 1;
}

/* --- Sex hues --- */
.polaroid.male {
    border-color: rgba(0, 120, 212, 0.25);
}

.polaroid.male::before {
    opacity: 1;
    background:
        radial-gradient(120% 80% at 20% 15%, rgba(0, 120, 212, 0.16), rgba(0, 120, 212, 0) 65%),
        linear-gradient(180deg, rgba(0, 120, 212, 0.08), rgba(0, 120, 212, 0.02));
}

.polaroid.female {
    border-color: rgba(232, 62, 140, 0.25);
}

.polaroid.female::before {
    opacity: 1;
    background:
        radial-gradient(120% 80% at 20% 15%, rgba(232, 62, 140, 0.16), rgba(232, 62, 140, 0) 65%),
        linear-gradient(180deg, rgba(232, 62, 140, 0.08), rgba(232, 62, 140, 0.02));
}

.polaroid:nth-child(3n+1) { transform: rotate(-3deg); }
.polaroid:nth-child(3n+2) { transform: rotate(2deg); }
.polaroid:nth-child(3n+3) { transform: rotate(-1deg); }

.polaroid:hover {
    transform: scale(1.1) rotate(0deg) translateY(-10px);
    z-index: 10;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.name-text {
    font-family: 'Georgia', serif;
    font-size: 1.6rem;
    color: #222;
    margin-bottom: 10px;
    text-align: center;
}

.trait-container {
    border-top: 1px solid #eee;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trait {
    font-size: 0.8rem;
    color: #777;
    text-transform: capitalize;
    display: flex;
    align-items: center;
}

.trait::before { content: "✨"; margin-right: 5px; font-size: 0.7rem; }

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

.loading-text { font-style: italic; color: #888; }
