/* ===================================
   Family Match Game - Modern Styling
   =================================== */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    min-height: 100vh;
    padding: 20px;
    color: #fff;
}

/* Header Section */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, #e94560, #ff6b6b, #ffa502);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(233, 69, 96, 0.3);
    margin-bottom: 10px;
}

.header .subtitle {
    color: #888;
    font-size: 1rem;
    margin-bottom: 20px;
}

/* Control Buttons */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.btn {
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    color: white;
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(233, 69, 96, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
    padding: 15px 25px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #e94560;
}

/* Game Container */
.memory-game {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

/* Cards Grid */
.cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    flex: 1;
    min-width: 0;
}

@media (max-width: 768px) {
    .cards {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)) !important;
        gap: 10px;
    }
}

@media (max-width: 500px) {
    .cards {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)) !important;
    }
}

/* Card Styling */
.card {
    aspect-ratio: 6 / 7;
    min-width: 0;
    perspective: 1000px;
    cursor: pointer;
    position: relative;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.card-front {
    background: linear-gradient(135deg, #2d2d44 0%, #1a1a2e 100%);
    border: 2px solid rgba(233, 69, 96, 0.3);
    flex-direction: column;
    gap: 5px;
}

.card-front span {
    font-size: 0.9rem;
    color: #e94560;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

.card-front::before {
    content: '?';
    font-size: 2.5rem;
    color: rgba(233, 69, 96, 0.5);
    font-weight: bold;
}

.card-back {
    background: #f8f8f8;
    transform: rotateY(180deg);
    border: 3px solid #e94560;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card.matched .card-inner {
    box-shadow: 0 0 25px rgba(46, 213, 115, 0.5);
}

.card.matched .card-back {
    border-color: #2ed573;
}

.card:hover:not(.flipped):not(.matched) .card-inner {
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4);
}

/* Matched Names Panel */
.matched-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    min-width: 250px;
    max-width: 300px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 80vh;
    overflow-y: auto;
}

.matched-panel h2 {
    font-size: 1.2rem;
    color: #e94560;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(233, 69, 96, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.matched-panel h2::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #2ed573, #7bed9f);
    border-radius: 50%;
    font-size: 0.9rem;
    color: white;
}

.matched-list {
    list-style: none;
}

.matched-list li {
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(46, 213, 115, 0.1);
    border-radius: 10px;
    border-left: 4px solid #2ed573;
    font-size: 0.95rem;
    animation: slideIn 0.3s ease;
    color: #fff;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.empty-message {
    color: #666;
    font-style: italic;
    font-size: 0.9rem;
}

/* Victory Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 40px 50px;
    border-radius: 25px;
    text-align: center;
    max-width: 400px;
    border: 2px solid rgba(233, 69, 96, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.4s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal h2 {
    font-size: 2rem;
    color: #2ed573;
    margin-bottom: 15px;
}

.modal .trophy {
    font-size: 4rem;
    margin-bottom: 15px;
}

.modal p {
    color: #ccc;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.modal .highlight {
    color: #e94560;
    font-weight: 700;
    font-size: 1.3rem;
}

.modal .btn {
    margin-top: 25px;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .memory-game {
        flex-direction: column;
        align-items: center;
    }

    .matched-panel {
        width: 100%;
        max-width: 500px;
        order: 2;
    }

    .cards {
        order: 1;
    }
}

@media (max-width: 400px) {
    .card {
        width: 90px;
        height: 105px;
    }

    .header h1 {
        font-size: 1.8rem;
    }
}

/* ===================================
   Initials Input Modal
   =================================== */
.initials-modal {
    max-width: 350px;
}

.initials-prompt {
    font-size: 1rem;
    color: #aaa;
    margin-bottom: 15px;
}

.initials-input {
    width: 160px;
    padding: 15px 20px;
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(233, 69, 96, 0.5);
    border-radius: 12px;
    color: #fff;
    outline: none;
    transition: all 0.3s ease;
}

.initials-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 8px;
}

.initials-input:focus {
    border-color: #e94560;
    box-shadow: 0 0 20px rgba(233, 69, 96, 0.3);
}

/* ===================================
   Leaderboard Modal
   =================================== */
.leaderboard-modal {
    max-width: 400px;
    padding: 30px 40px;
}

.leaderboard-modal h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #ffa502;
}

.leaderboard-list {
    list-style: none;
    margin-bottom: 25px;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: all 0.2s ease;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-entry .rank {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-weight: 700;
    margin-right: 15px;
    font-size: 0.9rem;
}

.leaderboard-entry.gold .rank {
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    color: #1a1a2e;
}

.leaderboard-entry.silver .rank {
    background: linear-gradient(135deg, #c0c0c0, #a0a0a0);
    color: #1a1a2e;
}

.leaderboard-entry.bronze .rank {
    background: linear-gradient(135deg, #cd7f32, #b87333);
    color: #1a1a2e;
}

.leaderboard-entry .initials {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: #e94560;
    flex: 1;
}

.leaderboard-entry .turns {
    color: #888;
    font-size: 0.9rem;
}

.no-scores {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 30px;
}

/* ===================================
   Family Selection Modal
   =================================== */
.family-select-modal {
    max-width: 500px;
    padding: 40px;
}

.family-select-modal h2 {
    color: #ffa502;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

.family-select-modal p {
    color: #aaa;
    margin-bottom: 25px;
}

.family-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.family-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 18px 25px;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #fff;
    font-family: inherit;
    text-align: left;
}

.family-btn:hover {
    background: rgba(233, 69, 96, 0.15);
    border-color: #e94560;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.25);
}

.family-btn-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e94560, #ff6b6b);
    border-radius: 12px;
    flex-shrink: 0;
}

.family-btn-info {
    flex: 1;
}

.family-btn-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 3px;
}

.family-btn-count {
    font-size: 0.85rem;
    color: #888;
}

/* Accent Button (Change Family) */
.btn-accent {
    background: linear-gradient(135deg, #ffa502, #ff6348);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 165, 2, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 2, 0.45);
}

/* Current Family Label */
.family-label {
    display: inline-block;
    margin-bottom: 10px;
    padding: 6px 16px;
    background: rgba(255, 165, 2, 0.15);
    border: 1px solid rgba(255, 165, 2, 0.3);
    border-radius: 20px;
    font-size: 0.85rem;
    color: #ffa502;
    letter-spacing: 1px;
    text-transform: uppercase;
}