/* ============================================
   STAR MATCH - GAME STYLES
   ============================================ */

:root {
    --space-dark: #0a0a1a;
    --space-purple: #1a1a3a;
    --accent-teal: #2dd4bf;
    --accent-teal-dark: #0d9488;
    --accent-gold: #ffd166;
    --font-main: 'Nunito', sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background: radial-gradient(
        ellipse at 50% 50%,
        #0f3d3e 0%,
        #1a3a3a 30%,
        var(--space-dark) 70%,
        #050510 100%
    );
}

/* Background Canvas */
#game-bg {
    position: fixed;
    bottom: 20px;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

/* Game Container */
.game-container {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 30px;
    background: rgba(10, 10, 30, 0.7);
    border-bottom: 2px solid rgba(45, 212, 191, 0.3);
    position: relative;
}

.title-box {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.stats-box {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 25px;
}

.title-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 2px;
}

.title-text {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    font-weight: 900;
    color: white;
    text-shadow: 0 0 10px rgba(45, 212, 191, 0.5);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 1px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: white;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 500px;
    width: 100%;
}

/* Individual Card */
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    perspective: 1000px;
    user-select: none;
    -webkit-user-select: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
}

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

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

.card.matched .card-front {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(255, 209, 102, 0.4);
}

/* Card faces */
.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Back of card (what you see before flipping) */
.card-back {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.2), rgba(13, 148, 136, 0.3));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.card-back::before {
    content: '?';
    font-size: 2.5rem;
    font-weight: 900;
    color: rgba(255, 255, 255, 0.4);
    text-shadow: 0 0 10px rgba(45, 212, 191, 0.3);
}

.card:hover .card-back {
    border-color: rgba(45, 212, 191, 0.5);
    box-shadow: 0 0 20px rgba(45, 212, 191, 0.2);
}

/* Front of card (the icon) */
.card-front {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
    transform: rotateY(180deg);
}

.card-front img {
    width: 70%;
    height: 70%;
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

/* Disable clicking on matched or flipping cards */
.card.flipping {
    pointer-events: none;
}

.card.matched {
    pointer-events: none;
    animation: matchPulse 0.5s ease-out;
}

@keyframes matchPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Message */
.message {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 20;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message.show {
    opacity: 1;
}

/* Overlays */
.overlay {
    position: fixed;
    bottom: 20px;
    inset: 0;
    background: rgba(5, 5, 16, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    max-width: 500px;
    max-height: 92vh;
    overflow-y: auto;
}

.overlay-planet {
    width: 100px;
    height: 100px;
    margin-bottom: 20px;
    animation: float 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px rgba(45, 212, 191, 0.4));
}

.overlay h1 {
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--accent-teal);
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(45, 212, 191, 0.3);
}

.overlay p {
    font-size: 1.2rem;
    color: white;
    margin-bottom: 10px;
    line-height: 1.5;
}

.game-desc {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto 20px;
}

.choose-label {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-top: 15px;
    letter-spacing: 1px;
}

.difficulty-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 18px 28px;
    border-radius: 16px;
    border: 2px solid;
    font-family: var(--font-main);
    font-size: 1.2rem;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 140px;
    color: white;
    background: transparent;
}

.diff-btn span {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.8;
    display: block;
    margin-top: 2px;
}

.diff-btn:hover {
    transform: scale(1.08);
}

/* Easy: Soft Teal */
.diff-easy {
    border-color: #5eead4;
    background: rgba(94, 234, 212, 0.15);
    box-shadow: 0 0 15px rgba(94, 234, 212, 0.2);
}

.diff-easy:hover {
    background: rgba(94, 234, 212, 0.3);
    box-shadow: 0 0 25px rgba(94, 234, 212, 0.4);
}

/* Medium: Bright Teal */
.diff-medium {
    border-color: #2dd4bf;
    background: rgba(45, 212, 191, 0.15);
    box-shadow: 0 0 15px rgba(45, 212, 191, 0.2);
}

.diff-medium:hover {
    background: rgba(45, 212, 191, 0.3);
    box-shadow: 0 0 25px rgba(45, 212, 191, 0.4);
}

/* Hard: Deep Teal */
.diff-hard {
    border-color: #14b8a6;
    background: rgba(20, 184, 166, 0.15);
    box-shadow: 0 0 15px rgba(20, 184, 166, 0.2);
}

.diff-hard:hover {
    background: rgba(20, 184, 166, 0.3);
    box-shadow: 0 0 25px rgba(20, 184, 166, 0.4);
}

.launch-btn {
    display: inline-block;
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.3rem;
    font-weight: 900;
    font-family: var(--font-main);
    color: var(--space-dark);
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-teal-dark));
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(45, 212, 191, 0.4);
    transition: all 0.3s ease;
}

.launch-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(45, 212, 191, 0.6);
}

.home-btn {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-decoration: none;
    border: 2px solid var(--accent-gold);
    border-radius: 50px;
    transition: all 0.3s ease;
}

.home-btn:hover {
    background: var(--accent-gold);
    color: var(--space-dark);
}

/* Win Screen */
.win-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.win-stars img {
    width: 40px;
    height: 40px;
    animation: starSpin 1s ease-in-out infinite alternate;
}

.win-stars img:nth-child(2) { animation-delay: 0.1s; }
.win-stars img:nth-child(3) { animation-delay: 0.2s; }
.win-stars img:nth-child(4) { animation-delay: 0.3s; }
.win-stars img:nth-child(5) { animation-delay: 0.4s; }

@keyframes starSpin {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.2) rotate(15deg); }
}

.final-stats {
    font-size: 1.3rem;
    color: var(--accent-gold);
    margin: 15px 0;
    font-weight: 700;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Responsive */
@media (max-width: 600px) {
    .game-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 15px;
    }

    .title-box {
        text-align: center;
    }

    .stats-box {
        position: static;
        transform: none;
        order: -1;
        gap: 15px;
    }

    .card-grid {
        gap: 10px;
        max-width: 360px;
    }

    .card-back::before {
        font-size: 1.8rem;
    }

    .difficulty-buttons {
        gap: 8px;
    }

    .diff-btn {
        padding: 14px 18px;
        font-size: 1rem;
        min-width: 120px;
    }
}

/* ============================================
   EXIT BUTTON — Bottom Right Corner
   ============================================ */
.exit-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 50;
    padding: 8px 16px;
    border-radius: 24px;
    background: rgba(10, 10, 30, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.15);
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.exit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
    .exit-btn {
        bottom: 12px;
        right: 12px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .card-grid {
        gap: 6px;
        max-width: 280px;
    }

    .card-back::before {
        font-size: 1.5rem;
    }

    .title-box {
        font-size: 1.2rem;
    }

    .stats-box {
        font-size: 0.85rem;
    }
}



/* Short landscape screens (Nest Hub, landscape phones, small tablets) */
@media (max-width: 1050px) {
    .game-header {
        flex-direction: column;
        gap: 6px;
        padding: 12px 18px;
    }

    .stats-box {
        position: static;
        transform: none;
        order: -1;
        justify-content: center;
    }

    .stat {
        align-items: center;
    }

    .title-text {
        font-size: clamp(1.35rem, 4vw, 2.25rem);
        line-height: 1.15;
    }
}

@media (max-height: 640px) {
    .game-container {
        padding: 8px;
    }

    .game-header {
        padding: 8px 14px;
        margin-bottom: 8px;
    }

    .message {
        margin-bottom: 6px;
        min-height: 22px;
        font-size: 0.95rem;
    }
}
