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

body {
    font-family: 'Poppins', 'Arial', sans-serif;
    background: radial-gradient(circle at top, #8c6eff 0%, #4427ff 45%, #1d1d50 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #222;
}

.container {
    width: 100%;
    max-width: 1300px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    padding: 25px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.2);
} 

/* Header */
.header {
    grid-column: 1 / -1;
    text-align: center;
    padding: 32px;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border-radius: 24px;
    color: white;
    box-shadow: 0 20px 50px rgba(79, 70, 229, 0.2);
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 12px;
    text-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
    margin-bottom: 24px;
}

.header-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.12);
    padding: 12px 18px;
    border-radius: 14px;
    min-width: 110px;
}

.stat .label {
    font-size: 0.8em;
    opacity: 0.85;
    margin-bottom: 6px;
    color: #e0e7ff;
}

.stat .value {
    font-size: 2em;
    font-weight: bold;
    color: #ffffff;
}

.game-selector {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
    padding: 24px;
    border-radius: 24px;
    border: 1px solid rgba(79, 70, 229, 0.12);
    box-shadow: 0 18px 32px rgba(79, 70, 229, 0.08);
}

.game-selector h2 {
    margin-bottom: 22px;
    color: #3730a3;
    font-size: 1.7em;
}

.game-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

.game-card {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 20px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 150px;
    position: relative;
    overflow: hidden;
}

.game-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(255,255,255,0.18), transparent 45%);
    opacity: 0;
    transition: opacity 0.25s;
}

.game-card:hover::before,
.game-card.active::before {
    opacity: 1;
}

.game-card:hover,
.game-card.active {
    transform: translateY(-5px);
    box-shadow: 0 25px 60px rgba(79, 70, 229, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

.game-card h3 {
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #222;
}

.game-card p {
    font-size: 0.95em;
    color: #555;
    line-height: 1.4;
}

.game-intro,
.color-word,
.target-number,
.math-problem,
#simonHint {
    font-size: 1.2em;
    padding: 10px;
    margin-bottom: 15px;
    color: #333;
}

.reaction-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.reaction-box {
    width: 180px;
    height: 180px;
    border-radius: 20px;
    background: #f44336;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.3em;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.reaction-box.ready {
    background: #4caf50;
}

.mole-grid,
.memory-grid,
.number-grid,
.math-buttons,
.color-buttons,
.simon-board {
    display: grid;
    gap: 10px;
}

.mole-grid {
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
    height: 100%;
}

.mole-hole {
    background: #f5f5f5;
    border-radius: 18px;
    border: 2px solid #ccc;
    position: relative;
    transition: transform 0.2s;
}

.mole-hole.mole {
    background: #795548;
    transform: translateY(-6px);
}

.memory-grid {
    grid-template-columns: repeat(4, 1fr);
}

.memory-card {
    background: #fff;
    border: 2px solid #667eea;
    border-radius: 12px;
    height: 90px;
    font-size: 1.8em;
    cursor: pointer;
}

.balloon {
    position: absolute;
    width: 60px;
    height: 90px;
    font-size: 2rem;
    pointer-events: auto;
}

.color-match,
.number-sprint,
.math-flash {
    width: 100%;
}

.color-buttons,
.number-grid,
.math-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.color-option,
.number-option,
.math-option {
    min-height: 50px;
}

.target-number,
.math-problem,
#simonHint {
    text-align: center;
}

.simon-board {
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    justify-items: center;
    align-items: center;
    height: 100%;
}

.simon-pad {
    width: 140px;
    height: 140px;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    transition: filter 0.2s, transform 0.2s;
}

.simon-pad:hover,
.simon-pad.active-simon {
    transform: scale(1.05);
}

.simon-green {
    background: #4caf50;
}

.simon-red {
    background: #f44336;
}

.simon-yellow {
    background: #ffeb3b;
}

.simon-blue {
    background: #2196f3;
}

#simonHint {
    margin-top: 20px;
    color: #555;
}

#sprintButton {
    width: 140px;
    height: 60px;
    position: absolute;
}

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

.stat .label {
    font-size: 0.8em;
    opacity: 0.9;
    margin-bottom: 5px;
}

.stat .value {
    font-size: 1.8em;
    font-weight: bold;
}

/* Ads */
.ad-banner {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
    min-height: 100px;
}

.top-ad {
    grid-column: 1 / -1;
    order: -1;
}

.ad-sidebar {
    grid-row: 3;
    grid-column: 1;
    display: flex;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px;
    min-width: 300px;
    height: fit-content;
}

.bottom-ad {
    grid-column: 1 / -1;
    order: 1;
}

/* Game Wrapper */
.game-wrapper {
    width: 100%;
    min-height: 650px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px 0;
}

.game-board {
    width: 100%;
    max-width: 1100px;
    min-height: 620px;
    height: auto;
    background: linear-gradient(180deg, #f5faf4 0%, #e4f4e8 45%, #d7efe0 100%);
    border-radius: 28px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 4px 18px rgba(0, 0, 0, 0.08), 0 18px 45px rgba(33, 150, 83, 0.12);
    border: 4px solid #4caf50;
}

/* Tiles */
.tile {
    position: absolute;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #ff6b6b, #ff8e72);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 1.5em;
    user-select: none;
    transition: transform 0.1s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.tile:hover {
    transform: scale(1.1);
}

.tile.gold {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    font-size: 2em;
}

.tile.purple {
    background: linear-gradient(135deg, #9c27b0, #bb86fc);
}

.tile.blue {
    background: linear-gradient(135deg, #2196f3, #64b5f6);
}

.tile.active:active {
    transform: scale(0.9);
}

/* Game States */
.game-state {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

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

.modal {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #667eea;
}

.modal p {
    font-size: 1.1em;
    margin-bottom: 10px;
    color: #666;
}

.rules {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    line-height: 1.8;
}

.final-score {
    font-size: 1.5em;
    margin: 20px 0;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 10px;
}

.final-score p {
    margin: 10px 0;
}

.new-record {
    font-size: 1.2em;
    color: #ffc107;
    font-weight: bold;
    animation: pulse 0.5s infinite;
}

.new-record.hidden {
    display: none;
}

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

/* Buttons */
.buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn {
    padding: 12px 30px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #4caf50;
    color: white;
}

.btn-secondary:hover {
    background: #45a049;
    transform: translateY(-2px);
}

/* Video Ad Modal */
.video-ad-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.video-ad-modal.hidden {
    display: none;
}

.video-ad-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

.mock-video {
    background: #000;
    color: #fff;
    padding: 60px 40px;
    border-radius: 10px;
    margin: 20px 0;
    font-size: 1.2em;
}

/* Floating Points */
.float-points {
    position: absolute;
    font-weight: bold;
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    color: #ffc107;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

@keyframes floatUp {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.8);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .ad-sidebar {
        grid-column: 1;
        grid-row: auto;
        min-width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .game-wrapper {
        grid-column: 1;
    }

    .header h1 {
        font-size: 2em;
    }

    .header-stats {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        border-radius: 10px;
    }

    .header {
        padding: 15px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .header-stats {
        gap: 15px;
    }

    .stat .value {
        font-size: 1.4em;
    }

    .game-board {
        height: 400px;
    }

    .tile {
        width: 50px;
        height: 50px;
        font-size: 1.2em;
    }

    .tile.gold {
        font-size: 1.5em;
    }

    .modal {
        padding: 30px 20px;
        max-width: 90%;
    }

    .modal h2 {
        font-size: 1.6em;
    }

    .btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }

    .ad-banner {
        min-height: 80px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 8px;
    }

    .header {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.5em;
        margin-bottom: 10px;
    }

    .header-stats {
        gap: 10px;
        font-size: 0.9em;
    }

    .stat .value {
        font-size: 1.2em;
    }

    .game-board {
        height: 300px;
    }

    .tile {
        width: 45px;
        height: 45px;
        font-size: 1em;
    }

    .game-state {
        padding: 10px;
    }

    .modal {
        padding: 20px;
    }

    .modal h2 {
        font-size: 1.3em;
    }

    .rules {
        font-size: 0.9em;
        padding: 10px;
    }

    .buttons {
        gap: 5px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.8em;
    }
}

/* Animations */
@keyframes tileAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes tileDisappear {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

.tile {
    animation: tileAppear 0.3s ease-out;
}

.tile.removing {
    animation: tileDisappear 0.2s ease-out forwards;
}
