/* ===== CSS Variables & Reset ===== */
:root {
    --primary-color: #6C63FF;
    --secondary-color: #FF6B9D;
    --accent-color: #FFD93D;
    --success-color: #6BCB77;
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #2D3748;
    --text-secondary: #718096;
    --shadow-soft: 0 10px 40px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.4);
    --border-radius: 20px;
    --border-radius-lg: 30px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Nunito', 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    touch-action: manipulation;
}

/* ===== App Container ===== */
.app-container {
    width: 100%;
    max-width: 800px;
    height: 100%;
    max-height: 1000px;
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ===== Header ===== */
.header {
    padding: 15px 20px;
    text-align: center;
    background: linear-gradient(135deg, #FFE5EC 0%, #E8F4FF 100%);
    border-bottom: 3px solid rgba(108, 99, 255, 0.2);
}

.title {
    font-size: 1.8rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {

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

    50% {
        transform: scale(1.02);
    }
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--success-color), var(--accent-color));
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* ===== Navigation Tabs ===== */
.nav-tabs {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.5);
    justify-content: center;
}

.nav-tab {
    flex: 1;
    max-width: 150px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-tab:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    transform: scale(1.05);
}

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

.tab-text {
    font-size: 0.9rem;
    font-weight: 700;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 15px;
    overflow: hidden;
}

/* ===== Character Display ===== */
.character-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.current-character {
    font-size: 4rem;
    font-weight: 800;
    color: var(--primary-color);
    text-shadow: 3px 3px 0 rgba(108, 99, 255, 0.2);
    animation: characterPop 0.5s ease;
    min-width: 100px;
    text-align: center;
}

@keyframes characterPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

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

.nav-arrow {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-color), #FFB347);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 217, 61, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-arrow:hover {
    transform: scale(1.1);
}

.nav-arrow:active {
    transform: scale(0.95);
}

/* ===== Canvas Container ===== */
.canvas-container {
    flex: 1;
    position: relative;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 4px dashed rgba(108, 99, 255, 0.3);
    min-height: 250px;
}

.guide-canvas,
.tracing-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.guide-canvas {
    z-index: 1;
    pointer-events: none;
}

.tracing-canvas {
    z-index: 2;
}

/* ===== Action Buttons ===== */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn {
    padding: 15px 25px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.clear-btn {
    background: linear-gradient(135deg, #FF6B6B, #EE5A5A);
    color: white;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

.check-btn {
    background: linear-gradient(135deg, var(--success-color), #4CAF50);
    color: white;
    box-shadow: 0 5px 20px rgba(107, 203, 119, 0.4);
}

.hint-btn {
    background: linear-gradient(135deg, var(--accent-color), #FFB347);
    color: var(--text-primary);
    box-shadow: 0 5px 20px rgba(255, 217, 61, 0.4);
}

.action-btn:hover {
    transform: translateY(-3px) scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

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

/* ===== Character Picker ===== */
.character-picker {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(108, 99, 255, 0.1);
    border-radius: var(--border-radius);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    /* Show scrollbar on desktop for better UX */
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(0, 0, 0, 0.1);
}

.character-picker::-webkit-scrollbar {
    height: 6px;
}

.character-picker::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.character-picker::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.picker-item {
    min-width: 45px;
    height: 45px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: white;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.picker-item:hover {
    transform: scale(1.1);
    background: var(--primary-color);
    color: white;
}

.picker-item.active {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    transform: scale(1.1);
}

.picker-item.completed {
    background: var(--success-color);
    color: white;
}

/* ===== Mascot ===== */
.mascot {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.mascot-body {
    font-size: 3rem;
    animation: mascotBounce 1s ease-in-out infinite;
}

@keyframes mascotBounce {

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

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

.speech-bubble {
    background: white;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    max-width: 150px;
    text-align: center;
    position: relative;
    margin-bottom: 10px;
    /* Auto-hide transition */
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: white transparent transparent;
}

/* ===== Celebration Overlay ===== */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.celebration.hidden {
    opacity: 0;
    pointer-events: none;
}

.celebration-text {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    text-shadow: 3px 3px 10px rgba(0, 0, 0, 0.3);
    animation: celebrationPop 0.5s ease forwards;
}

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

    50% {
        transform: scale(1.3);
    }

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

.stars-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.star {
    position: absolute;
    font-size: 2rem;
    animation: starFall 1.5s ease-out forwards;
}

@keyframes starFall {
    0% {
        opacity: 1;
        transform: translateY(-50px) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(720deg);
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 600px) {
    .title {
        font-size: 1.4rem;
    }

    .nav-tab {
        padding: 10px 15px;
    }

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

    .tab-text {
        font-size: 0.75rem;
    }

    .current-character {
        font-size: 3rem;
    }

    .nav-arrow {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .action-btn {
        padding: 12px 18px;
        font-size: 0.9rem;
    }

    .mascot {
        display: none;
    }

    .picker-item {
        min-width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (min-width: 768px) {
    .app-container {
        padding: 10px;
    }

    .canvas-container {
        min-height: 350px;
    }

    .current-character {
        font-size: 5rem;
    }
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Animations ===== */
@keyframes shake {

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

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes pulse {

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

    50% {
        transform: scale(1.1);
    }
}

.pulse {
    animation: pulse 0.5s ease;
}