/* CSS Variables */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-shadow: 0 20px 60px rgba(99, 102, 241, 0.3);
    --letter-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    background: var(--bg-gradient);
    background-attachment: fixed;
    overflow-x: hidden;
    color: #fff;
}

/* Back to Portfolio */
.back-home {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    z-index: 100;
    transition: var(--transition);
}

.back-home:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

/* Game Wrapper */
.game-wrapper {
    max-width: 500px;
    margin: 0 auto;
    padding: 80px 20px 40px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title-icon {
    animation: bounce 2s infinite;
}

.title-icon:last-child {
    animation-delay: 0.5s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 5px;
    font-weight: 600;
}

/* Score Bar */
.score-bar {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 15px 20px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

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

.score-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.score-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.streak-item {
    position: relative;
}

.streak-item.active {
    animation: pulse 0.5s ease-in-out;
}

.streak-item.hot {
    animation: fire-glow 0.5s ease-in-out infinite alternate;
}

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

@keyframes fire-glow {
    0% { text-shadow: 0 0 10px #f59e0b; }
    100% { text-shadow: 0 0 30px #f59e0b, 0 0 50px #f59e0b; }
}

/* Game Card */
.game-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    padding: 30px 25px;
    box-shadow: var(--card-shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 25px;
    color: #333;
}

/* Progress */
.level-progress {
    text-align: center;
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}

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

.progress-text {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 600;
}

/* Word Area */
.word-area {
    text-align: center;
    padding: 20px 0;
}

.hint-emoji {
    font-size: 4rem;
    margin-bottom: 10px;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.1));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-5px) rotate(5deg); }
    75% { transform: translateY(-5px) rotate(-5deg); }
}

.hint-text {
    font-size: 1.2rem;
    color: #6b7280;
    margin-bottom: 25px;
    font-weight: 600;
}

/* Word Slots */
.word-slots {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
    min-height: 70px;
}

.word-slot {
    width: 55px;
    height: 65px;
    background: linear-gradient(145deg, #f3f4f6, #e5e7eb);
    border: 3px dashed #d1d5db;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    transition: var(--transition);
    cursor: pointer;
}

.word-slot.drag-over {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    transform: scale(1.05);
}

.word-slot.filled {
    border-style: solid;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

.word-slot.correct {
    border-color: var(--success);
    background: linear-gradient(145deg, #d1fae5, #a7f3d0);
    animation: correct-pop 0.5s ease;
}

.word-slot.incorrect {
    border-color: var(--error);
    background: linear-gradient(145deg, #fee2e2, #fecaca);
    animation: shake 0.5s ease;
}

@keyframes correct-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

/* Feedback */
.feedback {
    font-size: 1.1rem;
    font-weight: 700;
    min-height: 30px;
    transition: var(--transition);
}

.feedback.success {
    color: var(--success);
    animation: fade-in 0.3s ease;
}

.feedback.error {
    color: var(--error);
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Letter Bank */
.letter-bank {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 20px;
    background: #f9fafb;
    border-radius: 20px;
    min-height: 100px;
}

.letter-tile {
    width: 50px;
    height: 55px;
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: #fff;
    cursor: grab;
    user-select: none;
    box-shadow: var(--letter-shadow);
    transition: var(--transition);
    text-transform: uppercase;
}

.letter-tile:hover {
    transform: translateY(-5px) rotate(5deg);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

.letter-tile:active,
.letter-tile.dragging {
    cursor: grabbing;
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

.letter-tile.used {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.9);
}

.letter-tile.selected {
    border: 3px solid #f97316;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.5);
}

.letter-tile.hint-reveal {
    animation: hint-glow 1s ease infinite;
}

@keyframes hint-glow {
    0%, 100% { box-shadow: 0 0 10px var(--warning); }
    50% { box-shadow: 0 0 30px var(--warning); }
}

/* Control Buttons */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

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

.hint-btn {
    background: linear-gradient(145deg, #fbbf24, #f59e0b);
    color: #fff;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.hint-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.hint-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.skip-btn {
    background: linear-gradient(145deg, #9ca3af, #6b7280);
    color: #fff;
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
}

.skip-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
}

.reset-btn {
    background: linear-gradient(145deg, #ef4444, #dc2626);
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.reset-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #fff;
    border-radius: 30px;
    padding: 0;
    text-align: center;
    max-width: 400px;
    width: 100%;
    transform: scale(0.8);
    transition: var(--transition);
    color: #333;
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 4rem;
    margin-bottom: 15px;
}

.modal-icon.large {
    font-size: 5rem;
}

.modal-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.modal-subtitle {
    font-size: 1.1rem;
    color: #6b7280;
    margin-bottom: 25px;
}

/* Stars Display */
.stars-display {
    font-size: 2.5rem;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.stars-display .star {
    opacity: 0.2;
    transition: var(--transition);
}

.stars-display .star.earned {
    opacity: 1;
    animation: star-pop 0.5s ease backwards;
}

.stars-display .star.earned:nth-child(1) { animation-delay: 0.2s; }
.stars-display .star.earned:nth-child(2) { animation-delay: 0.4s; }
.stars-display .star.earned:nth-child(3) { animation-delay: 0.6s; }

@keyframes star-pop {
    0% { transform: scale(0) rotate(-180deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Level Stats */
.level-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 25px;
}

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

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

.stat-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

/* Final Stats */
.final-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.final-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f3f4f6;
    border-radius: 15px;
}

.final-stat-label {
    font-weight: 600;
    color: #6b7280;
}

.final-stat-value {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Play Button */
.play-btn {
    background: linear-gradient(145deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 15px 40px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.4);
    transition: var(--transition);
}

.play-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.5);
}

/* How to Play */
.how-to-play {
    background: #f3f4f6;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
}

.how-to-play h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 15px;
    text-align: center;
}

.how-to-play ul {
    list-style: none;
}

.how-to-play li {
    padding: 8px 0;
    font-weight: 600;
    color: #4b5563;
}

/* Sound Toggle */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 100;
    transition: var(--transition);
}

.sound-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

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

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall 3s ease-out forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Category Selection Grid */
.category-screen {
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 40px 30px;
    text-align: center;
}

.back-btn {
    position: absolute;
    top: 15px;
    left: 20px;
    background: #f3f4f6;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 15px;
    background: #fff;
    border: 3px solid;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.category-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.category-card:active {
    transform: scale(0.95);
}

.category-icon {
    font-size: 2.5rem;
    margin-bottom: 8px;
}

.category-name {
    font-family: 'Fredoka', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    text-align: center;
}

/* Responsive */
@media (max-width: 480px) {
    .game-title {
        font-size: 1.8rem;
    }
    
    .letter-tile {
        width: 42px;
        height: 48px;
        font-size: 1.5rem;
    }
    
    .word-slot {
        width: 45px;
        height: 55px;
        font-size: 1.6rem;
    }
    
    .control-btn {
        padding: 10px 15px;
        font-size: 0.85rem;
    }
    
    .hint-emoji {
        font-size: 3rem;
    }
    
    .score-bar {
        padding: 12px 15px;
    }
    
    .score-value {
        font-size: 1.2rem;
    }
    
    .modal-content {
        padding: 30px 20px;
    }
    
    .modal-icon {
        font-size: 3rem;
    }
    
    .modal-title {
        font-size: 1.5rem;
    }
    
    .back-home {
        top: 10px;
        left: 10px;
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .category-card {
        padding: 15px 10px;
    }
    
    .category-icon {
        font-size: 2rem;
    }
    
    .category-name {
        font-size: 0.85rem;
    }
}

/* Touch support for mobile */
@media (hover: none) {
    .letter-tile:hover {
        transform: none;
    }
    
    .letter-tile:active {
        transform: scale(1.1);
    }
}
