/* Pair-Fect Nutrition - Memory Card Matching Game Styles */

@font-face {
    font-family: 'ImpactLike';
    src: local('Impact'), local('Arial Black'), sans-serif;
    font-weight: 900;
}

@font-face {
    font-family: 'Enfanutra';
    src: url('../assets/fonts/Enfanutra-Black.otf') format('opentype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -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;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    /*background: #000000;*/
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
}

.game-wrapper {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.fullscreen-toggle {
    position: fixed;
    top: 0%;
    right: 0%;
    width: 12%;
    height: 6%;
    z-index: 100;
}

.screensaver-toggle {
    position: fixed;
    top: 0%;
    left: 0%;
    width: 12%;
    height: 6%;
    z-index: 100;
}

.game-container {
    position: relative;
    flex: 0 0 auto;
    width: 452px;
    height: 804px;
    transform-origin: center center;
    will-change: transform;
    /*background: linear-gradient(180deg, #1e40af 0%, #1e3a8a 40%, #0f172a 100%);
    border: 8px solid #1e40af;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), inset 0 0 30px rgba(59, 130, 246, 0.3);*/
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    /*background: linear-gradient(180deg, #93c5fd 0%, #bfdbfe 50%, #dbeafe 100%);*/
    justify-content: flex-start;
}

.screen.active {
    display: flex;
}

.screen-header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
    min-height: 60px;
}

.enfamama-logo {
    max-width: 120px;
    max-height: 50px;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

/* Welcome Screen */
#welcomeScreen {
    overflow: hidden;
}

.welcome-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

#welcomeScreen > :not(.welcome-video) {
    position: relative;
    z-index: 1;
}

.title-container {
    width: 100%;
    text-align: center;
    margin: 15px 0;
}

.game-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fbbf24;
    text-shadow:
        3px 3px 0 #1e40af,
        -2px -2px 0 #ffffff,
        2px -2px 0 #ffffff,
        -2px 2px 0 #ffffff,
        0 4px 6px rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    line-height: 1.1;
    font-family: 'Arial Black', Impact, sans-serif;
}

.welcome-message {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 12px 15px;
    margin: 10px 0;
    width: 90%;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid #fbbf24;
}

.welcome-message p {
    color: #1e40af;
    font-size: 0.85rem;
    font-weight: 600;
    margin: 4px 0;
    line-height: 1.3;
}

.decorative-cards {
    position: relative;
    width: 100%;
    height: 150px;
    margin: 15px 0;
    flex: 1;
    max-height: 200px;
}

.decor-card {
    position: absolute;
    width: 80px;
    height: 110px;
    /*background: linear-gradient(135deg, #f9a8d4 0%, #ec4899 100%);*/
    border-radius: 10px;
    /*border: 2px solid white;*/
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.decor-card img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    /*object-fit: cover; */
}

.decor-1 {
    top: 10px;
    left: 10%;
    transform: rotate(-15deg);
    z-index: 1;
}

.decor-2 {
    top: 20px;
    left: 35%;
    transform: rotate(0deg);
    z-index: 2;
}

.decor-3 {
    top: 10px;
    right: 10%;
    transform: rotate(15deg);
    z-index: 1;
}

.startBtn {
    position: absolute !important;
    width: 33.6%;
    height: 6%;
    left: 33%;
    bottom: 9.5%;
}

/* Preparation Screen */

/* Gameplay Screen */
#gameplayScreen {
    overflow: hidden;
}

.gameplay-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

#gameplayScreen > .screen-header,
#gameplayScreen > .game-info,
#gameplayScreen > .game-grid {
    position: relative;
    z-index: 1;
}

#gameplayScreen > .sound-toggle {
    z-index: 2;
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 95%;
    margin: 10px 0;
    gap: 10px;
}

.timer-display, .progress-display {
    background: rgba(30, 64, 175, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid #fbbf24;
    flex: 1;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.timer-label, .progress-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 2px;
}

.timer-value {
    position: absolute;
    bottom: 12.1% !important;
    font-size: 1.2rem;
    font-weight: 800;
    font-family: 'Enfanutra', 'Courier New', monospace;
    left: 52% !important;
    color: #ffffff;
    -webkit-text-stroke: 1px #2A3B7F;
    text-shadow:
        -1.5px -1.5px 0 #2A3B7F,
        1.5px -1.5px 0 #2A3B7F,
        -1.5px 1.5px 0 #2A3B7F,
        1.5px 1.5px 0 #2A3B7F;
    animation: timerFadeIn 1s ease-in;
}

@keyframes timerFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* .timer-value, .progress-value {
    font-size: 1.2rem;
    font-weight: 900;
    font-family: 'Courier New', monospace;
}

.timer-value.warning-yellow {
    color: #fbbf24;
    animation: pulse 1s ease-in-out infinite;
}

.timer-value.warning-red {
    color: #ef4444;
    animation: pulse 0.5s ease-in-out infinite;
} */

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    width: 92%;
    margin: auto 0;
    align-content: center;
    margin-top: 53%;
}

.game-card {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4.5;
    cursor: pointer;
    perspective: 1000px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-card.disabled {
    cursor: not-allowed;
    pointer-events: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.4s ease;
    transform-style: preserve-3d;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    backface-visibility: hidden;
    border-radius: 10px;
    /*border: 2px solid white;*/
    /*box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);*/
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.card-front {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    transform: translate(-50%, -50%) rotateY(180deg);
    padding: 4px;
}

.card-front.maternal-health {
    background: linear-gradient(135deg, #93c5fd 0%, #3b82f6 100%);
}

.card-front.lactation-nutrition {
    background: linear-gradient(135deg, #86efac 0%, #22c55e 100%);
}

.card-front.mental-performance {
    background: linear-gradient(135deg, #fda4af 0%, #f43f5e 100%);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.game-card.matched .card-face {
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.8);
    animation: glow 1s ease-in-out;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 12px rgba(251, 191, 36, 0.8); }
    50% { box-shadow: 0 0 20px rgba(251, 191, 36, 1); }
}

.sound-toggle {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(30, 64, 175, 0.9);
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Screensaver Screen */
#screensaverScreen {
    overflow: hidden;
    padding: 0;
    cursor: pointer;
}

.screensaver-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

/* Result Screens */
#winScreen {
    overflow: hidden;
}

.win-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

#winScreen > .screen-header,
#winScreen > .result-content,
#winScreen > .result-buttons {
    position: relative;
    z-index: 1;
}

.lose-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    pointer-events: none;
}

#loseScreen > .screen-header,
#loseScreen > .result-content,
#loseScreen > .result-buttons {
    position: relative;
    z-index: 1;
}

.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 90%;
    text-align: center;
}

.result-title {
    font-size: 2.2rem;
    font-weight: 900;
    font-family: 'Arial Black', Impact, sans-serif;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.win-title {
    color: #fbbf24;
    text-shadow:
        3px 3px 0 #1e40af,
        -2px -2px 0 #ffffff,
        2px -2px 0 #ffffff,
        -2px 2px 0 #ffffff,
        0 4px 6px rgba(0, 0, 0, 0.5);
}

.lose-title {
    color: #ef4444;
    text-shadow:
        3px 3px 0 #1e40af,
        -2px -2px 0 #ffffff,
        2px -2px 0 #ffffff,
        -2px 2px 0 #ffffff,
        0 4px 6px rgba(0, 0, 0, 0.5);
}

.result-message {
    color: #1e40af;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid #fbbf24;
}

.result-stats {
    background: rgba(30, 64, 175, 0.9);
    color: white;
    padding: 15px;
    border-radius: 10px;
    border: 2px solid #fbbf24;
    margin-bottom: 20px;
    width: 100%;
}

.result-stats p {
    margin: 5px 0;
    font-size: 0.9rem;
    font-weight: 600;
}

.result-stats span {
    color: #fbbf24;
    font-weight: 900;
}

.confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 12px;
    background: #fbbf24;
    animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
    to {
        transform: translateY(900px) rotate(720deg);
    }
}

.result-button {
    position: absolute;
    bottom: 30.2% !important;
    left: 26% !important;
    width: 48% !important;
    height: 8% !important;
}

/* The game uses a fixed 450x800 (9:16) design canvas that is scaled
   proportionally to fit any viewport via JavaScript (see fitGameToViewport). */
