:root {
    --primary: #9d4edd; /* Cosmic Purple */
    --secondary: #00bbf9; /* Bright Cyan */
    --accent: #fee440; /* Star Yellow */
    --bg-light: #f3e8ff; /* Very light purple background */
    --card-bg: #ffffff;
    --text-dark: #240046;
    --bot-bubble: #e0b1cb;
    --puzzle-border: #f15bb5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-light) 0%, #e0fbfc 100%);
    color: var(--text-dark);
    overflow-x: hidden;
}

h1, h2, h3, .logo {
    font-family: 'Fredoka One', cursive;
}

/* --- ANIMATIONS --- */
@keyframes float-space {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes pulse-star {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- HEADER --- */
header {
    background: linear-gradient(135deg, #7b2cbf 0%, #5390d9 100%);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 5px solid var(--accent);
}

.logo {
    font-size: 2.2rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 2px 2px #3c096c;
}

.logo i {
    animation: pulse-star 3s infinite ease-in-out;
    color: var(--accent);
}

nav a {
    text-decoration: none;
    color: #fff;
    font-weight: 800;
    margin-left: 25px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    padding: 8px 16px;
    border-radius: 20px;
}

nav a:hover, nav a.active {
    background-color: var(--accent);
    color: var(--text-dark);
    box-shadow: 0 4px 10px rgba(254, 228, 64, 0.4);
}

/* --- HERO SECTION --- */
.hero {
    text-align: center;
    padding: 70px 20px;
    position: relative;
}

.hero::before {
    content: '✨';
    position: absolute;
    top: 20%;
    left: 20%;
    font-size: 2rem;
    animation: pulse-star 2s infinite;
}

.hero::after {
    content: '🌟';
    position: absolute;
    top: 30%;
    right: 20%;
    font-size: 2.5rem;
    animation: pulse-star 3s infinite 1s;
}

.hero h1 {
    font-size: 3.8rem;
    color: var(--primary);
    margin-bottom: 15px;
    text-shadow: 2px 2px #fff;
}

.hero p {
    font-size: 1.4rem;
    max-width: 650px;
    margin: 0 auto 25px;
    font-weight: 700;
}

.space-mascot {
    font-size: 6rem;
    color: var(--secondary);
    animation: float-space 4s ease-in-out infinite;
    margin-bottom: 15px;
    display: inline-block;
    filter: drop-shadow(4px 4px 0px #fff);
}

/* --- MAIN CONTENT LAYOUT --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

section {
    margin-bottom: 60px;
    scroll-margin-top: 100px;
}

.section-title {
    text-align: center;
    font-size: 2.8rem;
    color: var(--primary);
    margin-bottom: 40px;
    text-shadow: 2px 2px #fff;
}

/* --- PUZZLES SECTION --- */
.puzzles-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.puzzle-card {
    background: white;
    border-radius: 30px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    border: 4px solid var(--secondary);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.puzzle-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 100px;
    height: 100px;
    background: var(--bg-light);
    border-radius: 50%;
    z-index: 0;
}

.puzzle-card > * { position: relative; z-index: 1; }

.puzzle-display {
    background: #fdfaf6;
    border-radius: 20px;
    padding: 20px;
    margin: 15px 0;
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--text-dark);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--puzzle-border);
}

/* --- GAMES SECTION --- */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.game-card {
    background: linear-gradient(180deg, #ffffff 0%, #f4f1de 100%);
    border-radius: 25px;
    padding: 25px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
    text-align: center;
    border: 4px solid transparent;
    transition: transform 0.3s, border-color 0.3s;
}

.game-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent);
}

.game-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.game-box {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-top: 15px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid #eee;
}

.game-question {
    font-size: 1.8rem; 
    font-weight: 800; 
    color: var(--primary);
}

.game-input {
    width: 110px;
    padding: 10px;
    font-size: 1.3rem;
    text-align: center;
    border: 3px solid var(--secondary);
    border-radius: 12px;
    margin: 10px 0;
    font-weight: bold;
}

.game-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 20px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 4px 0px #5a189a;
}

.game-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.game-feedback { margin-top: 10px; font-weight: 800; font-size: 1.1rem; }

/* --- ABOUT & FEATURES --- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    text-align: center;
}

.feature-item {
    background: #fff;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.04);
    border-bottom: 5px solid var(--secondary);
}

.feature-item i {
    font-size: 3rem;
    color: var(--puzzle-border);
    margin-bottom: 15px;
}

/* --- CHATBOT WIDGET --- */
.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
}

.chat-button {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    border: none;
    font-size: 2.2rem;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 187, 249, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s;
}

.chat-button:hover { transform: scale(1.1) rotate(10deg); }

.chat-window {
    position: absolute;
    bottom: 90px;
    right: 0;
    width: 360px;
    height: 480px;
    background: white;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 4px solid var(--secondary);
}

.chat-header {
    background: var(--secondary);
    color: white;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8fbff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 700;
}

.msg-bot { background: var(--bot-bubble); align-self: flex-start; border-top-left-radius: 0; color: var(--text-dark); }
.msg-user { background: var(--primary); color: white; align-self: flex-end; border-top-right-radius: 0; }

.chat-footer {
    padding: 15px;
    display: flex;
    gap: 10px;
    background: #fff;
    border-top: 1px solid #eee;
}

.chat-input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 1rem;
}

.chat-send {
    background: var(--secondary);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

/* --- FOOTER --- */
footer {
    background: linear-gradient(135deg, #10002b 0%, #240046 100%);
    color: white;
    padding: 50px 20px 30px;
    text-align: center;
    margin-top: 80px;
    border-top: 8px solid var(--accent);
}

.footer-content { max-width: 800px; margin: 0 auto; }
.footer-logo { font-size: 2.2rem; margin-bottom: 15px; color: var(--secondary); font-family: 'Fredoka One', cursive;}
.footer-contacts { display: flex; justify-content: center; gap: 30px; margin: 25px 0; flex-wrap: wrap; }

.footer-contacts a {
    color: var(--text-dark);
    text-decoration: none;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    padding: 12px 25px;
    border-radius: 20px;
    transition: 0.3s;
}

.footer-contacts a:hover { background: #fff; transform: translateY(-3px); }
.footer-bottom { font-size: 1rem; color: #9d4edd; margin-top: 25px; font-weight: 700; }