/* ========================================
   CSS RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --teal: #4ECDC4;
    --coral: #FF6B9D;
    --yellow: #FFE66D;
    --purple: #9B59B6;
    --green: #2ECC71;
    --orange: #FF8C42;
    --blue: #3498DB;
    --red: #E74C3C;

    /* Background */
    --bg-start: #2c2c2c;
    --bg-end: #4a4a4a;

    /* UI */
    --card-bg: #FFFFFF;
    --text-dark: #2C3E50;
    --text-light: #FFFFFF;
    --shadow: rgba(0, 0, 0, 0.15);
    --shadow-strong: rgba(0, 0, 0, 0.25);
}

body {
    font-family: 'Nunito', sans-serif;
    background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
    min-height: 100vh;
    color: var(--text-dark);
    overflow-x: hidden;
}

h1, h2, h3, .game-title {
    font-family: 'Fredoka One', cursive;
}

/* ========================================
   SCREEN MANAGEMENT
   ======================================== */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   MENU SCREEN
   ======================================== */
.menu-header {
    text-align: center;
    padding: 30px 0;
}

.game-logo {
    font-size: 2.8rem;
    color: var(--text-light);
    text-shadow: 3px 3px 0 var(--coral), 6px 6px 0 rgba(0,0,0,0.1);
    margin-bottom: 10px;
}

.tagline {
    font-size: 1.3rem;
    color: var(--yellow);
    font-weight: 700;
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 90%;
    margin: 0 auto;
    padding: 20px;
}

@media (min-width: 600px) {
    .game-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 900px) {
    .game-grid {
        grid-template-columns: repeat(8, 1fr);
    }
    .game-logo {
        font-size: 3.5rem;
    }
}

.game-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 20px var(--shadow);
    border: 3px solid transparent;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 40px var(--shadow-strong);
}

.game-card:active {
    transform: translateY(-2px) scale(0.98);
}

.game-card .icon {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

.game-card .name {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.game-card .difficulty {
    font-size: 0.9rem;
    color: var(--orange);
}

.game-card[data-color="teal"] { border-color: var(--teal); }
.game-card[data-color="coral"] { border-color: var(--coral); }
.game-card[data-color="yellow"] { border-color: var(--yellow); }
.game-card[data-color="purple"] { border-color: var(--purple); }
.game-card[data-color="green"] { border-color: var(--green); }
.game-card[data-color="orange"] { border-color: var(--orange); }
.game-card[data-color="blue"] { border-color: var(--blue); }
.game-card[data-color="red"] { border-color: var(--red); }

/* ========================================
   INSTRUCTIONS MODAL
   ======================================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 25px;
    max-width: 450px;
    width: 100%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalPop 0.3s ease;
}

@keyframes modalPop {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    background: linear-gradient(135deg, var(--teal), var(--blue));
    padding: 25px;
    border-radius: 25px 25px 0 0;
    text-align: center;
    color: var(--text-light);
    flex-shrink: 0;
}

.modal-header .icon {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 10px;
}

.modal-header h2 {
    font-size: 1.8rem;
    margin-bottom: 5px;
}

.modal-header .difficulty {
    font-size: 1.2rem;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.modal-body h3 {
    color: var(--purple);
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.modal-body ol, .modal-body ul {
    margin-left: 20px;
    margin-bottom: 20px;
}

.modal-body li {
    margin-bottom: 10px;
    font-size: 1.05rem;
    line-height: 1.4;
}

.modal-body .tip {
    background: #FFF9E6;
    border-left: 4px solid var(--yellow);
    padding: 12px 15px;
    border-radius: 0 10px 10px 0;
    margin-bottom: 15px;
}

.modal-footer {
    padding: 20px 25px 25px;
    text-align: center;
    flex-shrink: 0;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--green), var(--teal));
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--coral), var(--orange));
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
}

.btn-small {
    font-size: 1rem;
    padding: 10px 25px;
}

/* ========================================
   GAME SCREEN
   ======================================== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 800px;
    margin: 0 auto 20px;
    padding: 0 10px;
}

.game-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-btn {
    background: var(--card-bg);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--shadow);
    transition: transform 0.2s ease;
}

.back-btn:hover {
    transform: scale(1.1);
}

.help-btn {
    background: var(--card-bg);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--purple);
    cursor: pointer;
    box-shadow: 0 4px 15px var(--shadow);
    transition: transform 0.2s ease;
}

.help-btn:hover {
    transform: scale(1.1);
}

.game-screen-title {
    color: var(--text-light);
    font-size: 1.8rem;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}

.game-info {
    background: var(--card-bg);
    padding: 8px 20px;
    border-radius: 25px;
    font-weight: 700;
    box-shadow: 0 4px 15px var(--shadow);
}

.game-container {
    background: var(--card-bg);
    border-radius: 25px;
    max-width: 800px;
    margin: 0 auto;
    padding: 30px;
    box-shadow: 0 10px 40px var(--shadow);
    min-height: 400px;
}

/* ========================================
   VICTORY OVERLAY
   ======================================== */
.victory-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.victory-overlay.active {
    display: flex;
}

.victory-content {
    text-align: center;
    color: var(--text-light);
    animation: victoryBounce 0.5s ease;
}

@keyframes victoryBounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.victory-content .trophy {
    font-size: 6rem;
    animation: spin 1s ease;
}

@keyframes spin {
    from { transform: rotate(-10deg); }
    to { transform: rotate(10deg); }
}

.victory-content h2 {
    font-size: 3rem;
    margin: 20px 0;
    text-shadow: 3px 3px 0 var(--coral);
}

.victory-content p {
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.confetti {
    position: fixed;
    width: 15px;
    height: 15px;
    border-radius: 3px;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ========================================
   NAME SCREEN
   ======================================== */
.name-screen-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    text-align: center;
}

.name-form {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.name-label {
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    color: var(--text-light);
}

.name-input {
    font-family: 'Nunito', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    padding: 15px 30px;
    border: 3px solid var(--teal);
    border-radius: 50px;
    text-align: center;
    width: 280px;
    outline: none;
    transition: border-color 0.2s;
}

.name-input:focus {
    border-color: var(--coral);
}

/* ========================================
   FAVOURITES BAR & HEARTS
   ======================================== */
.favourites-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 10px 20px;
    max-width: 90%;
    margin: 0 auto 5px;
}

.fav-filter-btn {
    font-family: 'Fredoka One', cursive;
    font-size: 1rem;
    padding: 8px 22px;
    border: 3px solid var(--coral);
    background: white;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--coral);
}

.fav-filter-btn.active {
    background: var(--coral);
    color: white;
}

.fav-filter-btn:hover:not(.active) {
    background: #ffe0ea;
}

.fav-user-label {
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 600;
}

.fav-heart {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.4rem;
    color: #ccc;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    z-index: 2;
    line-height: 1;
}

.fav-heart:hover {
    transform: scale(1.3);
}

.fav-heart-active {
    color: #FF6B9D;
}

.game-card {
    position: relative;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-center { text-align: center; }
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.hidden { display: none !important; }

/* ========================================
   ANIMATION UTILITIES
   ======================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ========================================
   MODE BUTTONS (shared across games)
   ======================================== */
.mode-btn {
    padding: 10px 20px;
    border: 3px solid var(--purple);
    background: white;
    border-radius: 25px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn.active {
    background: var(--purple);
    color: white;
}

.mode-btn:hover:not(.active) {
    background: #f0e6f6;
}
