/* ===========================
   Kids Brain Game - Main Styles
   Mobile-First Responsive Design
   =========================== */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ===========================
   Open Dashboard Button
   =========================== */

.kbg-button-wrapper {
    margin: 20px auto;
    max-width: 1200px;
}

.kbg-open-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 20px 40px;
    border-radius: 50px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.kbg-open-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.6);
}

.kbg-open-btn:active {
    transform: translateY(-1px);
}

#kbg-dashboard-container {
    margin-top: 20px;
    animation: slideDown 0.5s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kbg-game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    min-height: 500px;
}

/* ===========================
   Header Section
   =========================== */

.kbg-game-header {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
    gap: 15px;
}

.kbg-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kbg-brain-icon {
    font-size: 2.5em;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.kbg-logo h2 {
    margin: 0;
    color: #667eea;
    font-size: 1.8em;
    font-weight: bold;
}

.kbg-score-panel {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.kbg-score {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.2em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.kbg-stars {
    font-size: 1.5em;
    animation: starshine 1.5s ease-in-out infinite;
}

@keyframes starshine {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ===========================
   Game Menu
   =========================== */

.kbg-game-menu {
    background: white;
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
}

.kbg-game-menu h3 {
    color: #667eea;
    font-size: 2em;
    margin: 0 0 30px 0;
    font-weight: bold;
}

.kbg-game-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.kbg-game-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    border: none;
    border-radius: 15px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.kbg-game-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.kbg-game-btn:active {
    transform: translateY(-2px);
}

.kbg-game-btn:nth-child(1) {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.kbg-game-btn:nth-child(2) {
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
}

.kbg-game-btn:nth-child(3) {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.kbg-game-btn:nth-child(4) {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.kbg-game-btn:nth-child(5) {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.kbg-btn-icon {
    font-size: 3em;
}

.kbg-btn-text {
    color: white;
    font-weight: bold;
    font-size: 1.2em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===========================
   Game Area
   =========================== */

.kbg-game-area {
    background: white;
    border-radius: 15px;
    padding: 20px;
    min-height: 400px;
}

.kbg-game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.kbg-back-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.kbg-back-btn:hover {
    background: #5568d3;
    transform: scale(1.05);
}

.kbg-timer {
    background: #f093fb;
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 1.1em;
}

/* ===========================
   Memory Game
   =========================== */

.kbg-memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.kbg-memory-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    position: relative;
}

.kbg-memory-card:hover {
    transform: scale(1.05);
}

.kbg-memory-card.flipped {
    background: white;
}

.kbg-memory-card.matched {
    background: #4ade80;
    animation: bounce 0.5s ease;
}

.kbg-memory-card .card-front,
.kbg-memory-card .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    border-radius: 15px;
}

.kbg-memory-card .card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.kbg-memory-card .card-back {
    background: white;
}

/* ===========================
   Color Sequence Game
   =========================== */

.kbg-color-sequence {
    text-align: center;
}

.kbg-sequence-display {
    margin: 30px auto;
    max-width: 600px;
}

.kbg-sequence-message {
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 20px;
    font-weight: bold;
}

.kbg-color-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 400px;
    margin: 0 auto;
}

.kbg-color-button {
    aspect-ratio: 1;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    font-size: 1.5em;
}

.kbg-color-button:hover {
    transform: scale(1.05);
}

.kbg-color-button:active {
    transform: scale(0.95);
}

.kbg-color-button.active {
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
}

/* ===========================
   Math Challenge
   =========================== */

.kbg-math-challenge {
    text-align: center;
    padding: 30px;
}

.kbg-math-question {
    font-size: 3em;
    color: #667eea;
    margin: 30px 0;
    font-weight: bold;
}

.kbg-math-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 400px;
    margin: 0 auto;
}

.kbg-math-option {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 30px;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.kbg-math-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.kbg-math-option.correct {
    background: #4ade80;
    animation: bounce 0.5s ease;
}

.kbg-math-option.wrong {
    background: #ef4444;
    animation: shake 0.5s ease;
}

/* ===========================
   Pattern Recognition
   =========================== */

.kbg-pattern-game {
    text-align: center;
    padding: 20px;
}

.kbg-pattern-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.kbg-pattern-item {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.kbg-pattern-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 40px;
}

.kbg-pattern-option {
    width: 100px;
    height: 100px;
    border: 3px solid transparent;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3em;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.kbg-pattern-option:hover {
    transform: scale(1.1);
    border-color: #667eea;
}

/* ===========================
   Shape Sorting Game
   =========================== */

.kbg-shape-sorting {
    padding: 20px;
}

.kbg-sorting-instruction {
    text-align: center;
    font-size: 1.5em;
    color: #667eea;
    margin-bottom: 30px;
    font-weight: bold;
}

.kbg-shape-containers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kbg-shape-container {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 20px;
    min-height: 150px;
    background: #f0f0f0;
    text-align: center;
}

.kbg-container-label {
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.kbg-draggable-shapes {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    padding: 20px;
    background: white;
    border-radius: 15px;
}

.kbg-draggable-shape {
    width: 80px;
    height: 80px;
    cursor: move;
    transition: all 0.3s ease;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.kbg-draggable-shape:hover {
    transform: scale(1.1);
}

/* ===========================
   Celebration Modal
   =========================== */

.kbg-celebration {
    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;
    animation: fadeIn 0.3s ease;
}

.kbg-celebration-content {
    background: white;
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    animation: scaleIn 0.5s ease;
}

.kbg-celebration-emoji {
    font-size: 5em;
    animation: bounce 0.5s ease infinite;
}

.kbg-celebration-content h2 {
    color: #667eea;
    font-size: 2.5em;
    margin: 20px 0;
}

.kbg-celebration-message {
    font-size: 1.3em;
    color: #666;
    margin: 20px 0;
}

.kbg-play-again-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 1.3em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
}

.kbg-play-again-btn:hover {
    transform: scale(1.05);
}

/* ===========================
   Animations
   =========================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.5); }
    to { transform: scale(1); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* ===========================
   Responsive Design
   =========================== */

@media (max-width: 768px) {
    .kbg-game-container {
        padding: 10px;
    }
    
    .kbg-open-btn {
        font-size: 1.2em;
        padding: 15px 30px;
    }
    
    .kbg-logo h2 {
        font-size: 1.3em;
    }
    
    .kbg-brain-icon {
        font-size: 2em;
    }
    
    .kbg-score {
        font-size: 1em;
        padding: 8px 15px;
    }
    
    .kbg-game-menu h3 {
        font-size: 1.5em;
    }
    
    .kbg-game-buttons {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .kbg-memory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    .kbg-memory-card {
        font-size: 2em;
    }
    
    .kbg-math-question {
        font-size: 2em;
    }
    
    .kbg-math-options {
        grid-template-columns: 1fr;
    }
    
    .kbg-celebration-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .kbg-celebration-emoji {
        font-size: 3em;
    }
    
    .kbg-celebration-content h2 {
        font-size: 1.8em;
    }
}

@media (max-width: 480px) {
    .kbg-memory-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .kbg-color-grid {
        max-width: 300px;
    }
    
    .kbg-pattern-item {
        width: 60px;
        height: 60px;
        font-size: 2em;
    }
    
    .kbg-pattern-option {
        width: 80px;
        height: 80px;
        font-size: 2.5em;
    }
}

/* ===========================
   Utility Classes
   =========================== */

.kbg-hidden {
    display: none !important;
}

.kbg-fade-in {
    animation: fadeIn 0.5s ease;
}

.kbg-slide-in {
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
