/* Adelynn's Jungle Memory Safari - Clean Rebuild */
/* Product of Bradley Virtual Solutions, LLC */

:root {
    --jungle-green: #2d5016;
    --jungle-light: #4a7c23;
    --jungle-bright: #6ba644;
    --jungle-yellow: #ffd700;
    --jungle-orange: #ff8c00;
    --jungle-pink: #ff69b4;
    --jungle-blue: #87ceeb;
    --jungle-dark: #1a3009;
    --white: #ffffff;
    --black: #000000;
    --border-radius: 12px;
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, 
        var(--jungle-green) 0%, 
        var(--jungle-light) 50%, 
        var(--jungle-bright) 100%);
    min-height: 100vh;
    color: var(--white);
    overflow-x: hidden;
    
    /* iOS Touch Optimizations */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    
    /* iOS Safe Area Support */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

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

.game-title {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--jungle-yellow);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.game-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
}

.stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    border: 2px solid var(--jungle-yellow);
}

.stat-label {
    font-weight: bold;
    color: var(--jungle-yellow);
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--white);
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.difficulty-selector label {
    font-weight: bold;
    color: var(--jungle-yellow);
}

.difficulty-selector select {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    border: 2px solid var(--jungle-yellow);
    background: var(--white);
    color: var(--jungle-dark);
    font-weight: bold;
}

.sound-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sound-controls label {
    font-size: 1.2rem;
    color: var(--jungle-yellow);
}

.sound-controls input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--jungle-yellow);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.btn-primary {
    background: var(--jungle-yellow);
    color: var(--jungle-dark);
}

.btn-primary:hover {
    background: var(--jungle-orange);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Game Board */
.game-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.game-board {
    display: grid;
    gap: 15px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    border: 3px solid var(--jungle-yellow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.game-board.easy {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
}

.game-board.medium {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
}

.game-board.hard {
    grid-template-columns: repeat(5, 1fr);
    max-width: 1000px;
}

.game-board.expert {
    grid-template-columns: repeat(6, 1fr);
    max-width: 1200px;
}

.game-board.legendary {
    grid-template-columns: repeat(10, 1fr);
    max-width: 1400px;
}

/* Cards */
.card {
    width: 130px;
    height: 170px;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease;
    
    /* iOS Touch Optimizations */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
    
    /* Prevent zoom on double tap */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.card:hover {
    transform: scale(1.05);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.card-front {
    background: white;
    color: var(--jungle-dark);
    transform: rotateY(180deg);
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.card-back {
    background: linear-gradient(135deg, 
        var(--jungle-green) 0%, 
        var(--jungle-light) 50%, 
        var(--jungle-bright) 100%);
    color: var(--white);
    transform: rotateY(0deg);
}

.animal-image {
    width: 125px;
    height: 125px;
    object-fit: contain;
    border-radius: 0;
    background: white;
    border: none;
    margin-bottom: 2px;
}

.animal-name {
    font-size: 0.5rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.0;
    color: var(--jungle-dark);
    margin: 0;
    padding: 0 1px;
}

.animal-emoji {
    font-size: 3rem !important;
    display: block;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.card-pattern {
    font-size: 3rem;
    color: var(--jungle-yellow);
}

/* Game Message */
.game-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.game-message.hidden {
    display: none;
}

.message-content {
    background: var(--white);
    color: var(--jungle-dark);
    padding: 40px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    border: 3px solid var(--jungle-yellow);
}

.message-content h2 {
    color: var(--jungle-green);
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.message-content p {
    margin-bottom: 30px;
    font-size: 1.1rem;
    line-height: 1.5;
}

/* Achievement Popup */
.achievement-popup {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: 3px solid #ff8c00;
    border-radius: var(--border-radius);
    padding: 15px;
    max-width: 300px;
    z-index: 1001;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    animation: achievementSlideIn 0.6s ease-out;
    transform: translateX(0);
}

@keyframes achievementSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.achievement-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement-icon {
    font-size: 2rem;
    animation: achievementBounce 0.6s ease-out;
}

@keyframes achievementBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.achievement-text h3 {
    margin: 0 0 5px 0;
    color: #2d5016;
    font-size: 1.1rem;
    font-weight: bold;
}

.achievement-text p {
    margin: 0;
    color: #4a7c23;
    font-size: 0.9rem;
    line-height: 1.3;
}

/* Educational Fact Display */
.animal-fact-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, var(--jungle-green), var(--jungle-light));
    border: 3px solid var(--jungle-yellow);
    border-radius: var(--border-radius);
    padding: 20px;
    max-width: 400px;
    width: 90%;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: factSlideIn 0.5s ease-out;
}

@keyframes factSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.fact-content {
    text-align: center;
    color: var(--white);
}

.fact-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border-bottom: 2px solid var(--jungle-yellow);
    padding-bottom: 10px;
}

.fact-emoji {
    font-size: 2.5rem;
    margin-right: 10px;
}

.fact-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--jungle-yellow);
    margin: 0;
    flex: 1;
}

.fact-close {
    background: var(--jungle-orange);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.fact-close:hover {
    background: var(--jungle-pink);
}

.fact-text {
    font-size: 1.1rem;
    line-height: 1.4;
    margin: 15px 0;
    text-align: left;
}

.fact-category {
    font-size: 0.9rem;
    color: var(--jungle-yellow);
    font-style: italic;
    margin-top: 10px;
    text-align: center;
}

/* Statistics Modal */
.stats-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.stats-modal.hidden {
    display: none;
}

.stats-content {
    background: linear-gradient(135deg, var(--jungle-green), var(--jungle-light));
    border: 3px solid var(--jungle-yellow);
    border-radius: var(--border-radius);
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--white);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--jungle-yellow);
    padding-bottom: 10px;
}

.stats-header h2 {
    margin: 0;
    color: var(--jungle-yellow);
    font-size: 1.8rem;
}

.stats-close {
    background: var(--jungle-orange);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.stats-close:hover {
    background: var(--jungle-pink);
}

.stats-section {
    margin-bottom: 25px;
}

.stats-section h3 {
    color: var(--jungle-yellow);
    margin-bottom: 15px;
    font-size: 1.3rem;
    border-bottom: 1px solid var(--jungle-bright);
    padding-bottom: 5px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--jungle-bright);
}

.stat-label {
    font-weight: bold;
    color: var(--jungle-yellow);
}

.stat-value {
    color: var(--white);
    font-weight: bold;
    font-size: 1.1rem;
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.achievement-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    border: 2px solid var(--jungle-bright);
    text-align: center;
    transition: transform 0.3s ease;
}

.achievement-item.unlocked {
    border-color: var(--jungle-yellow);
    background: rgba(255, 215, 0, 0.1);
}

.achievement-item:hover {
    transform: translateY(-2px);
}

.achievement-item .achievement-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.achievement-item h4 {
    margin: 0 0 5px 0;
    color: var(--jungle-yellow);
    font-size: 1.1rem;
}

.achievement-item p {
    margin: 0;
    color: var(--white);
    font-size: 0.9rem;
    opacity: 0.8;
}

.achievement-item.unlocked p {
    opacity: 1;
}

/* Responsive Design */

/* Large Tablets and Small Laptops */
@media (max-width: 1024px) {
    .game-container {
        max-width: 100%;
        padding: 15px;
    }
    
    .game-board.legendary {
        max-width: 1000px;
        grid-template-columns: repeat(8, 1fr);
    }
    
    .game-board.expert {
        max-width: 900px;
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Tablets (iPad, iPad Air, iPad Pro) */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }
    
    .game-stats {
        gap: 15px;
    }
    
    .stat {
        padding: 8px 15px;
    }
    
    .game-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .card {
        width: 100px;
        height: 140px;
    }
    
    .animal-image {
        width: 98px;
        height: 98px;
    }
    
    .animal-name {
        font-size: 0.8rem;
    }
    
    .card-pattern {
        font-size: 2.5rem;
    }
}

/* iPhone XS Max and similar large phones */
@media (max-width: 414px) {
    .game-container {
        padding: 8px;
        max-width: 100%;
    }
    
    .game-title {
        font-size: 1.7rem;
    }
    
    .card {
        width: 60px;
        height: 85px;
    }
    
    .animal-image {
        width: 58px;
        height: 58px;
    }
    
    .animal-name {
        font-size: 0.65rem;
        padding: 2px;
    }
    
    .card-pattern {
        font-size: 1.9rem;
    }
    
    .game-board {
        gap: 6px;
        padding: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure grid layouts fit on iPhone XS Max */
    .game-board.hard {
        max-width: 100%;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.expert {
        max-width: 100%;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.legendary {
        max-width: 100%;
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Small Phones (iPhone SE, iPhone 12 mini, etc.) */
@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .card {
        width: 65px;
        height: 95px;
    }
    
    .animal-image {
        width: 63px;
        height: 63px;
    }
    
    .animal-name {
        font-size: 0.6rem;
        padding: 2px;
    }
    
    .card-pattern {
        font-size: 1.8rem;
    }
    
    .game-board {
        gap: 8px;
        padding: 12px;
    }
    
    /* Ensure grid layouts fit on small screens */
    .game-board.hard {
        max-width: 400px;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.expert {
        max-width: 400px;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.legendary {
        max-width: 400px;
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Extra Small Phones (iPhone 5/5S/SE) */
@media (max-width: 375px) {
    .game-container {
        padding: 8px;
    }
    
    .game-title {
        font-size: 1.6rem;
    }
    
    .card {
        width: 60px;
        height: 85px;
    }
    
    .animal-image {
        width: 58px;
        height: 58px;
    }
    
    .animal-name {
        font-size: 0.55rem;
        padding: 1px;
    }
    
    .game-board {
        gap: 6px;
        padding: 8px;
    }
    
    .game-stats {
        gap: 10px;
    }
    
    .stat {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    /* Ensure grid layouts fit on small screens */
    .game-board.hard {
        max-width: 350px;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.expert {
        max-width: 350px;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.legendary {
        max-width: 350px;
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Landscape Orientation for Phones */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        padding: 5px;
    }
    
    .game-header {
        margin-bottom: 15px;
    }
    
    .game-ti