/* ===================================
   🚀 Space Adventure Dictionary Theme
   Modern, Kid-Friendly Design (Age 11)
   =================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&family=Concert+One&display=swap');

/* CSS Custom Properties */
:root {
    /* Colors - Cosmic Palette */
    --primary: #00D4FF;
    --primary-glow: rgba(0, 212, 255, 0.5);
    --secondary: #FF6B9D;
    --secondary-glow: rgba(255, 107, 157, 0.5);
    --accent: #FFE66D;
    --accent-glow: rgba(255, 230, 109, 0.5);
    --success: #00F5A0;
    --success-dark: #00C480;
    --error: #FF6B6B;
    --error-dark: #E84545;

    /* Background Gradient */
    --bg-start: #0F0C29;
    --bg-mid: #302B63;
    --bg-end: #24243E;

    /* Card & UI */
    --card-bg: rgba(255, 255, 255, 0.08);
    --card-border: rgba(255, 255, 255, 0.15);
    --input-bg: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);

    /* Typography */
    --font-heading: 'Concert One', cursive;
    --font-body: 'Poppins', sans-serif;

    /* Sizing */
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 30px;
    --radius-full: 50%;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-mid) 50%, var(--bg-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* Animated Star Background */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Floating Blobs */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: var(--primary);
    top: -100px;
    right: -100px;
    animation: float-blob 20s ease-in-out infinite;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: var(--secondary);
    bottom: -50px;
    left: -100px;
    animation: float-blob 25s ease-in-out infinite reverse;
}

.blob-3 {
    width: 200px;
    height: 200px;
    background: var(--accent);
    top: 50%;
    left: 50%;
    animation: float-blob 15s ease-in-out infinite 5s;
}

@keyframes float-blob {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(50px, -30px) scale(1.1);
    }

    50% {
        transform: translate(-20px, 40px) scale(0.9);
    }

    75% {
        transform: translate(-40px, -20px) scale(1.05);
    }
}

/* App Container */
.app-container {
    width: 95%;
    max-width: 480px;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    position: relative;
    z-index: 1;
    box-shadow:
        0 25px 45px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    text-shadow: none;
    animation: glow-text 3s ease-in-out infinite;
}

@keyframes glow-text {

    0%,
    100% {
        filter: drop-shadow(0 0 20px var(--primary-glow));
    }

    50% {
        filter: drop-shadow(0 0 30px var(--secondary-glow));
    }
}

header p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Views */
.view {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.view.hidden {
    display: none;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
}

.view.active {
    display: block;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Control Groups */
.control-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent);
    letter-spacing: 1px;
}

/* Form Elements */
select,
input[type="text"] {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--input-bg);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

select:hover,
input[type="text"]:hover {
    background: rgba(255, 255, 255, 0.15);
}

select:focus,
input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    background: rgba(255, 255, 255, 0.12);
}

select option {
    background: #2c2a53;
    color: var(--text-primary);
    padding: 10px;
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Dropdown option hover/selected states */
select option:hover,
select option:checked {
    background: #3a3870 !important;
    color: var(--text-primary);
}

/* Buttons */
button {
    width: 100%;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 1.3rem;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    margin-bottom: 1rem;
}

button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

button:hover::before {
    left: 100%;
}

button:active {
    transform: scale(0.98);
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #0099CC 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(0, 212, 255, 0.4);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 212, 255, 0.5);
}

.primary-btn:disabled {
    background: linear-gradient(135deg, #3a3a5a 0%, #2a2a4a 100%);
    box-shadow: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: not-allowed;
}

.secondary-btn {
    background: linear-gradient(135deg, var(--secondary) 0%, #E5508C 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.4);
}

.secondary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 107, 157, 0.5);
}

.action-btn {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-dark) 100%);
    color: #0a3025;
    font-weight: 700;
    box-shadow: 0 12px 35px rgba(0, 245, 160, 0.5);
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(0, 245, 160, 0.5);
}

.icon-btn {
    width: auto;
    padding: 0.75rem 1rem;
    margin: 0;
    background: linear-gradient(135deg, var(--error) 0%, var(--error-dark) 100%);
    color: white;
    font-size: 1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--input-bg);
    border-radius: 20px;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--primary), var(--secondary));
    background-size: 200% 100%;
    animation: gradient-move 2s linear infinite;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 20px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    filter: blur(3px);
}

@keyframes gradient-move {
    0% {
        background-position: 0% 0%;
    }

    100% {
        background-position: 200% 0%;
    }
}

.status-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--accent);
    letter-spacing: 1px;
}

/* Question Card */
.card {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.2) 0%, rgba(103, 58, 183, 0.2) 100%);
    padding: 2.5rem 2rem;
    border: 2px solid rgba(156, 39, 176, 0.3);
    border-radius: var(--radius-lg);
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '✨';
    position: absolute;
    top: 10px;
    left: 15px;
    font-size: 1.5rem;
    animation: sparkle 2s ease-in-out infinite;
}

.card::after {
    content: '⭐';
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 1.2rem;
    animation: sparkle 2s ease-in-out infinite 0.5s;
}

@keyframes sparkle {

    0%,
    100% {
        opacity: 0.5;
        transform: scale(1) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: scale(1.2) rotate(15deg);
    }
}

.question-card h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--text-primary);
    text-shadow: 0 0 30px var(--secondary-glow);
    margin: 0;
    word-break: break-word;
}

.feedback-text {
    font-family: var(--font-body);
    font-weight: 600;
    min-height: 1.5em;
    /* Prevent layout jump */
    transition: all 0.3s ease;
}

.feedback-text.top {
    font-size: 1.1rem;
    color: var(--error);
    margin-bottom: 0.5rem;
}

.feedback-text.bottom {
    font-size: 1.2rem;
    color: var(--success);
    margin-top: 0.5rem;
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Evaluation View */
#evaluation-view h2 {
    text-align: center;
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.score-circle {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem auto;
    font-size: 2.5rem;
    font-family: var(--font-heading);
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow:
        0 0 40px var(--primary-glow),
        inset 0 -5px 20px rgba(0, 0, 0, 0.2);
    animation: pulse-glow 2s ease-in-out infinite;
    position: relative;
}

.score-circle::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 40px var(--primary-glow);
    }

    50% {
        box-shadow: 0 0 60px var(--secondary-glow), 0 0 80px var(--primary-glow);
    }
}

#score-message {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
    font-family: var(--font-heading);
    color: var(--success);
}

.mistakes-container {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
}

.mistake-item {
    background: var(--input-bg);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--error);
    transition: transform 0.2s ease;
}

.mistake-item:hover {
    transform: translateX(5px);
}

.mistake-item:last-child {
    margin-bottom: 0;
}

.mistake-item .word {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
    color: var(--secondary);
}

.mistake-item .detail {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.mistake-item .correct {
    color: var(--success);
}

.mistake-item .wrong {
    color: var(--error);
    text-decoration: line-through;
    opacity: 0.8;
}

/* Dictionary View */
.search-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.search-bar input {
    flex: 1;
}

.word-list {
    max-height: 350px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
}

.dict-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--card-border);
    font-weight: 600;
    color: var(--text-primary);
    transition: background 0.2s ease;
}

.dict-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dict-item:last-child {
    border-bottom: none;
}

.dict-item span:first-child {
    color: var(--secondary);
}

.dict-item span:last-child {
    color: var(--primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--secondary), var(--primary));
}

/* Confetti Container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent);
    animation: confetti-fall 3s ease-in-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .app-container {
        padding: 1.5rem;
        margin: 1rem;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .question-card h2 {
        font-size: 2rem;
    }

    button {
        font-size: 1.1rem;
        padding: 0.875rem 1.25rem;
    }

    .score-circle {
        width: 130px;
        height: 130px;
        font-size: 2rem;
    }
}

/* Accessibility - Reduce Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .blob {
        animation: none;
    }

    .star {
        animation: none;
        opacity: 0.5;
    }
}

/* Next Button State */
.next-btn {
    background: linear-gradient(135deg, #FF9966 0%, #FF5E62 100%) !important;
    box-shadow: 0 12px 35px rgba(255, 94, 98, 0.5) !important;
}

.next-btn:hover {
    box-shadow: 0 15px 40px rgba(255, 94, 98, 0.6) !important;
}