/* --- UNIVERSAL STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    direction: rtl;
    line-height: 1.6;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 80vh;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* --- GENERAL VIEW & INTERACTIVE ELEMENT STYLES --- */
.view {
    /* Base class for screens, handled by JS */
}

.view-content {
    padding: 30px;
}

.center-content {
    text-align: center;
    padding-top: 50px;
}

.action-btn {
    background: #667eea;
    color: #fff;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background .3s ease, transform 0.2s ease;
    font-size: 1.2rem;
    margin-top: 20px;
    display: inline-block;
}

.action-btn:hover {
    background: #5a6ecf;
    transform: translateY(-2px);
}

.action-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
}


/* --- SETUP SCREEN --- */
.player-selection {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.player-btn {
    background: #f1f1f1;
    border: 2px solid #ddd;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.player-btn.active {
    background: #e8f4fd;
    border-color: #667eea;
    font-weight: bold;
}

.player-inputs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.filter-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.filter-group label {
    font-weight: 600;
    color: #495057;
}

select,
input[type="text"] {
    padding: 10px 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color .3s ease;
    text-align: right;
    min-width: 200px;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* --- SWIPING SCREEN --- */
.swipe-deck {
    position: relative;
    width: 90%;
    max-width: 350px;
    height: 450px;
    margin: 20px auto;
}

/* In style.css, DELETE all old .name-card styles and REPLACE with this */

.name-card {
    background: #fefefe;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #ddd;
    
    position: absolute;
    width: 100%;
    height: 100%;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 30px;
    
    /* This transition is for the snap-back and fly-off animations */
    transition: transform 0.25s ease-in-out, opacity 0.25s ease-in-out;
    
    transform-origin: 50% 150%;
    cursor: grab;
    user-select: none;
    will-change: transform, opacity; /* Performance hint for browsers */
}

/* This creates the STACKED EFFECT */
.name-card:nth-last-child(2) {
    transform: translateY(-15px) scale(0.95);
    z-index: -1;
}

.name-card:nth-last-child(3) {
    transform: translateY(-30px) scale(0.90);
    z-index: -2;
}

/* --- Interaction States --- */
.name-card.dragging {
    transition: none; /* Disable transition while actively dragging */
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.name-card.swiped-left {
    transform: translateX(-150%) rotate(-60deg) !important;
    opacity: 0;
}
.name-card.swiped-right {
    transform: translateX(150%) rotate(60deg) !important;
    opacity: 0;
}

/* --- Card Content Styling --- */
.name-card h2 {
    font-family: 'Cairo', sans-serif;
    font-size: 3rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.name-card .latin-name {
    font-size: 1.2rem;
    font-weight: 500;
    color: #888; /* A muted grey to be less prominent than the origin */
    margin-bottom: 20px;
    font-style: normal;
}

.name-card .origin {
    font-size: 1rem;
    font-weight: 400;
    color: #7f8c8d;
    margin-bottom: 15px;
    font-style: italic;
}

.name-card .meaning {
    font-size: 1.1rem;
    line-height: 1.7;
    color: #34495e;
}

.card-placeholder {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #6c757d;
}

.swipe-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

.control-btn {
    background: #fff;
    border: 2px solid #ccc;
    color: #555;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn:hover {
    background: #f1f1f1;
    border-color: #aaa;
    transform: scale(1.1);
}

/* --- RANKING SCREEN --- */
.ranking-arena {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 20px;
}

.vs-card {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    width: 45%;
    min-height: 150px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 2rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
}

.vs-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,.05);
}

.vs-separator {
    font-size: 1.5rem;
    color: #777;
    font-weight: bold;
}

#ranking-progress {
    text-align: center;
    color: #6c757d;
    margin-top: 20px;
    font-style: italic;
}

/* --- RESULTS SCREEN --- */
#results-subtitle {
    text-align: center;
}

#final-list-container ul {
    list-style: none;
    padding: 0;
}

#final-list-container li {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 10px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 500px;
}

.final-name {
    font-weight: bold;
    font-size: 1.2rem;
}

.final-score {
    background: #667eea;
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

/* --- MODAL --- */
.modal {
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fefefe;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
}

.close-btn {
    color: #aaa;
    position: absolute;
    left: 15px;
    top: 5px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-btn:hover {
    color: black;
}

.letter-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    justify-content: center;
    max-width: 400px;
    padding: 10px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
}

.letter-filter-container label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.swipe-stats {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    margin-top: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    color: #fff;
    font-weight: bold;
    border-radius: 8px;
}

.stat-item {
    text-align: center;
}

.stat-item span {
    display: block;
    font-size: 1.5rem;
}

.letter-filter-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    width: 100%;
    justify-content: center;
}

.filter-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.filter-btn:hover {
    background-color: #e0e0e0;
}

#liked-list-ul {
    list-style-type: none;
    padding: 0;
    margin-top: 20px;
}

#liked-list-ul li {
    padding: 10px;
    border-bottom: 1px solid #ddd;
    font-size: 1.1rem;
}

#liked-list-ul li:last-child {
    border-bottom: none;
}

/* --- LOADER SPINNER --- */
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- RESPONSIVE DESIGN --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .header h1 {
        font-size: 2rem;
    }
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    .vs-card {
        font-size: 1.5rem;
    }
}


/* --- Clean & Modern Setup Screen Header --- */

.setup-header {
    padding: 20px 10px;
    background: none; /* Remove the gradient from the header itself */
    color: #333; /* Change text color to be readable on the white page background */
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px; /* Adjust the space between elements */
}

.header-text {
    text-align: center;
    /* We'll re-style the h1 and p for better contrast */
}

.setup-header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: #2c3e50; /* A strong, dark color for the title */
}

.setup-header p {
    font-size: 1rem;
    color: #555; /* A softer color for the subtitle */
    opacity: 1; /* Override the default header opacity */
}

.header-baby-photo {
    width: 100px; /* A good base size */
    height: auto; /* Maintain the aspect ratio */
    border-radius: 8px; /* Softly rounded corners, not a circle */
    object-fit: cover;
    /* NO BORDER, NO SHADOW */
}


/* --- Responsive Design to keep images on mobile --- */
@media (max-width: 600px) {
    .header-baby-photo {
        width: 100px; /* Make images a bit smaller on mobile */
    }

    .setup-header h1 {
        font-size: 1.8rem; /* Adjust font size for smaller screens */
    }
    
    .setup-header p {
        font-size: 0.9rem;
    }
}

.creator-credit {
    text-align: center;
    padding: 20px 30px;
    margin: 20px auto 0 auto;
    max-width: 500px;
    background-color: #f8f9fa;
    border-radius: 8px;
    line-height: 1.8;
}

.creator-credit p {
    color: #6c757d;
    margin: 0;
}

.creator-credit strong {
    color: #343a40;
}

.creator-credit a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
}

.creator-credit a:hover {
    text-decoration: underline;
}



