/* ==========================================
   AI Prompt Learning Game - Styles
   A fun, kid-friendly design
   ========================================== */

/* CSS Variables */
:root {
    /* Colors - Vibrant & Playful */
    --primary: #6C63FF;
    --primary-dark: #5A52E0;
    --primary-light: #8B85FF;
    --secondary: #FF6B9D;
    --accent: #00D9A6;
    --warning: #FFB84D;
    --success: #4ADE80;
    --error: #FF6B6B;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6C63FF 0%, #A855F7 100%);
    --gradient-success: linear-gradient(135deg, #4ADE80 0%, #00D9A6 100%);
    --gradient-fail: linear-gradient(135deg, #FF6B9D 0%, #FF6B6B 100%);
    --gradient-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);

    /* Neutral */
    --bg-dark: #0f0f1a;
    --bg-card: rgba(255, 255, 255, 0.08);
    --bg-card-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.5);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;
    --radius-full: 50%;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.4);

    /* Fonts */
    --font-primary: 'Fredoka', sans-serif;
    --font-secondary: 'Comic Neue', cursive;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

/* Page Background (Static) */
body {
    background: #0f0f1a;
    /* Static dark background */
}

/* Animated Background (Now inside container) */
.bg-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: var(--radius-lg);
}

.stars,
.stars2,
.stars3 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-repeat: repeat;
}

.stars {
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Ccircle fill='%23ffffff' cx='50' cy='50' r='1'/%3E%3Ccircle fill='%23ffffff' cx='150' cy='100' r='1.5'/%3E%3Ccircle fill='%23ffffff' cx='250' cy='150' r='1'/%3E%3Ccircle fill='%23ffffff' cx='350' cy='50' r='2'/%3E%3Ccircle fill='%23ffffff' cx='100' cy='250' r='1'/%3E%3Ccircle fill='%23ffffff' cx='200' cy='300' r='1.5'/%3E%3Ccircle fill='%23ffffff' cx='300' cy='350' r='1'/%3E%3Ccircle fill='%23ffffff' cx='50' cy='350' r='2'/%3E%3C/svg%3E");
    animation: animStar 100s linear infinite;
    opacity: 0.5;
}

.stars2 {
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' viewBox='0 0 300 300'%3E%3Ccircle fill='%236C63FF' cx='75' cy='75' r='2'/%3E%3Ccircle fill='%23FF6B9D' cx='175' cy='225' r='2'/%3E%3Ccircle fill='%2300D9A6' cx='275' cy='125' r='2'/%3E%3C/svg%3E");
    animation: animStar 150s linear infinite;
    opacity: 0.3;
}

.stars3 {
    background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Ccircle fill='%23FFB84D' cx='100' cy='100' r='3'/%3E%3C/svg%3E");
    animation: animStar 200s linear infinite;
    opacity: 0.4;
}

@keyframes animStar {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-100%);
    }
}

/* Container - Full Screen Vertical & Wider */
.container {
    width: min(100vw - 20px, 600px);
    height: calc(100vh - 20px);
    aspect-ratio: auto;
    margin: 0 auto;
    padding: var(--spacing-xl);
    /* Increased padding */
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    /* Gradient inside box */
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    scrollbar-width: none;
    position: relative;
    /* For absolute positioning of background */
}

/* Ensure content sits above background */
.header,
.screen,
.modal {
    z-index: 1;
    position: relative;
}

/* Hide scrollbar for Chrome/Safari/Opera */
.container::-webkit-scrollbar {
    display: none;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-xs) 0;
    margin-bottom: var(--spacing-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo-icon {
    font-size: 1.8rem;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.user-stats {
    display: flex;
    gap: var(--spacing-md);
}

.stat-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-card);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-icon {
    font-size: 1.2rem;
}

.stat-value {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Screens */
.screen {
    display: none;
    flex: 1;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Welcome Screen */
.welcome-content {
    text-align: center;
    padding: var(--spacing-xl);
}

.mascot {
    font-size: 4rem;
    animation: float 3s ease-in-out infinite;
    margin-bottom: var(--spacing-md);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-15px) rotate(5deg);
    }

    75% {
        transform: translateY(-15px) rotate(-5deg);
    }
}

.welcome-content h2 {
    font-size: 1.3rem;
    margin-bottom: var(--spacing-sm);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-text {
    font-size: 1.2rem;
    /* Larger text */
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto var(--spacing-xl);
    font-family: var(--font-secondary);
    line-height: 1.8;
}

/* Difficulty Selector */
.difficulty-selector {
    margin-bottom: var(--spacing-md);
}

.difficulty-selector h3 {
    font-size: 1rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-secondary);
}

.difficulty-buttons {
    display: flex;
    gap: var(--spacing-md);
    justify-content: center;
    flex-wrap: wrap;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 146px;
    backdrop-filter: blur(10px);
}

.difficulty-btn:hover {
    background: var(--bg-card-hover);
    transform: translateY(-5px);
}

.difficulty-btn.selected {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.difficulty-btn.easy.selected {
    border-color: var(--success);
}

.difficulty-btn.medium.selected {
    border-color: var(--warning);
}

.difficulty-btn.hard.selected {
    border-color: var(--secondary);
}

.diff-icon {
    font-size: 1.5rem;
}

.diff-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.diff-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    margin-top: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-2xl);
    padding: 1rem 2.5rem;
    /* Larger padding */
    border: none;
    border-radius: var(--radius-xl);
    font-family: var(--font-primary);
    font-size: 1.25rem;
    /* Larger font */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--primary);
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-start {
    font-size: 1.4rem;
    padding: var(--spacing-lg) var(--spacing-2xl);
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.level-badge {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: var(--bg-card);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-xl);
    font-weight: 500;
}

.question-counter {
    color: var(--text-secondary);
    font-weight: 500;
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Image Section */
.image-section {
    display: flex;
    justify-content: center;
}

.image-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 350px;
    width: 100%;
}

.card-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-align: center;
}

.image-container {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.3);
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
    background: rgba(0, 0, 0, 0.7);
}

.image-loading.hidden {
    display: none;
}

.loader {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Hint Section */
.hint-section {
    display: flex;
    justify-content: center;
}

.hint-bubble {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    background: rgba(255, 184, 77, 0.15);
    border: 1px solid rgba(255, 184, 77, 0.3);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-xl);
    color: var(--warning);
}

.hint-icon {
    font-size: 1.2rem;
}

.hint-text {
    font-size: 0.95rem;
    font-family: var(--font-secondary);
}

/* Prompt Section */
.prompt-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    align-items: center;
}

.prompt-label {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.prompt-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
}

.prompt-input {
    width: 100%;
    padding: var(--spacing-lg);
    padding-bottom: var(--spacing-xl);
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-secondary);
    font-size: 1.1rem;
    resize: none;
    transition: all 0.3s ease;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.2);
}

.prompt-input::placeholder {
    color: var(--text-muted);
}

.char-counter {
    position: absolute;
    bottom: var(--spacing-sm);
    right: var(--spacing-md);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-submit {
    width: 100%;
    max-width: 300px;
}

/* Loading Screen */
.loading-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: var(--spacing-lg);
}

.magic-wand {
    font-size: 5rem;
    animation: wave 1s ease-in-out infinite;
}

@keyframes wave {

    0%,
    100% {
        transform: rotate(-10deg);
    }

    50% {
        transform: rotate(10deg);
    }
}

.loading-bar {
    width: 300px;
    height: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.loading-progress {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-xl);
    animation: loading 2s ease-in-out infinite;
}

@keyframes loading {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

.loading-tip {
    color: var(--text-secondary);
    font-family: var(--font-secondary);
}

/* Result Screen */
.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg) 0;
}

.result-header {
    text-align: center;
}

.result-emoji {
    font-size: 4rem;
    animation: pop 0.5s ease;
}

@keyframes pop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.result-title {
    font-size: 2rem;
    background: var(--gradient-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-title.fail {
    background: var(--gradient-fail);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Comparison Section */
.comparison-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

.comparison-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    text-align: center;
    backdrop-filter: blur(10px);
}

.comparison-card img {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.vs-badge {
    background: var(--gradient-primary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--shadow-md);
}

/* Score Section */
.score-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
}

.score-circle {
    position: relative;
    width: 150px;
    height: 150px;
}

.score-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.score-bg {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 8;
}

.score-fill {
    fill: none;
    stroke: url(#scoreGradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1.5s ease;
}

.score-value {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}

.score-percent {
    font-size: 1rem;
    color: var(--text-secondary);
}

.score-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Feedback Section */
.feedback-section {
    background: var(--bg-card);
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: var(--radius-lg);
    max-width: 400px;
    text-align: center;
}

.feedback-text {
    font-family: var(--font-secondary);
    font-size: 1.1rem;
    color: var(--text-primary);
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-lg);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    text-align: center;
    max-width: 400px;
    animation: modalPop 0.3s ease;
}

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

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.modal-content h3 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* Confetti Canvas */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-md);
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .mascot {
        font-size: 4rem;
    }

    .welcome-content h2 {
        font-size: 1.5rem;
    }

    .difficulty-buttons {
        gap: var(--spacing-sm);
    }

    .difficulty-btn {
        min-width: 100px;
        padding: var(--spacing-md);
    }

    .comparison-card img {
        width: 140px;
        height: 140px;
    }

    .score-circle {
        width: 120px;
        height: 120px;
    }

    .score-value {
        font-size: 2rem;
    }
}

/* Summary Screen */
.summary-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    text-align: center;
}

.summary-emoji {
    font-size: 5rem;
    margin-bottom: var(--spacing-sm);
    animation: bounce 2s infinite;
}

.summary-title {
    font-size: 2.2rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-score-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 350px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.score-stars {
    font-size: 2rem;
    margin-bottom: var(--spacing-lg);
    display: flex;
    justify-content: center;
    gap: var(--spacing-xs);
}

.score-stars span {
    opacity: 0.3;
    transition: all 0.5s ease;
    transform: scale(0.8);
}

.score-stars span.active {
    opacity: 1;
    transform: scale(1.2);
    text-shadow: 0 0 15px rgba(255, 184, 77, 0.5);
}

.final-stats {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.stat-item.vertical {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.stat-divider {
    width: 2px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
}

.stat-num {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.summary-message {
    font-size: 1.2rem;
    color: var(--text-secondary);
    max-width: 400px;
    font-family: var(--font-secondary);
}