/* Version 1.2 */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* --- Welcome Screen --- */
.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 50%, #ffcc80 100%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
}

.welcome-screen.hidden {
    display: none !important;
}

.welcome-tile {
    width: 120px;
    height: 140px;
    background: linear-gradient(135deg, #ffd93d, #ffb74d);
    border: 5px solid #ff6b6b;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Fredoka', sans-serif;
    font-size: 5rem;
    font-weight: 700;
    color: #4a3520;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    animation: tileFloat 3s ease-in-out infinite;
}

@keyframes tileFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #e65100;
    margin: 10px 0 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.welcome-subtitle {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.1rem;
    color: #bf7830;
    margin: 0;
    font-weight: 500;
}

.welcome-btn {
    background: linear-gradient(135deg, #4CAF50, #66BB6A);
    color: white;
    border: none;
    padding: 18px 50px;
    font-size: 1.8rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
    position: relative;
    /* For absolute positioning of hint button */
}

.welcome-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.6);
}

.welcome-btn:active {
    transform: scale(0.97);
}

/* Manual Hint Button - Fixed Bottom Right */
#manual-hint-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    top: auto;

    background-color: #fffde7;
    color: #fbc02d;
    border: 3px solid #fff59d;
    font-size: 2rem;
    width: 70px;
    /* Larger for easy access */
    height: 70px;
    border-radius: 50%;

    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    /* Ensure on top */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s, visibility 0.3s;
}

.hint-btn-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.5) !important;
    /* Override other transforms */
    pointer-events: none;
}

#manual-hint-btn:hover {
    background-color: #fff9c4;
    transform: scale(1.1) rotate(10deg);
    border-color: #ffee58;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#manual-hint-btn:active {
    transform: scale(0.95);
}


@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 400;
    src: url('../assets/fonts/Fredoka-Regular.ttf') format('truetype');
    font-display: swap;
}

@font-face {
    font-family: 'Fredoka';
    font-style: normal;
    font-weight: 600;
    src: url('../assets/fonts/Fredoka-SemiBold.ttf') format('truetype');
    font-display: swap;
}

:root {
    --primary-color: #FFB74D;
    --secondary-color: #4DB6AC;
    --highlight-color: #4CAF50;
    /* Green for success/save */
    --text-color: #333;
    --bg-color: #f0f0f0;
}

body {
    font-family: 'Fredoka', sans-serif;
    background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 50%, #ffcc80 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}

.game-container {
    text-align: center;
    background-color: white;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    max-width: 95%;
    /* Use more width on mobile/tablet */
    width: 650px;
    /* Slightly wider for long words */
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* --- HEADER --- */
.header-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    /* Left - Center - Right */
    align-items: center;
    margin-bottom: 0.5rem;
    position: relative;
}

/* Center Column (Title) */
.title {
    grid-column: 2;
    color: #e65100;
    font-size: 1.8rem;
    margin: 0;
    white-space: nowrap;
    z-index: 1;
}

/* Left Column (Buttons) */
.header-left {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* Right Column (Toggle) */
.header-right {
    justify-self: end;
    z-index: 2;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s;
    padding: 10px;
    border-radius: 50%;
    float: left;
}

.icon-btn:hover {
    background-color: #f0f0f0;
    transform: scale(1.1);
}

/* --- STAGE (Emoji & Nav) --- */
.emoji-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    /* Prevent jumpiness */
}

.emoji {
    font-size: 8rem;
    animation: bounce 2s infinite;
}

.nav-btn {
    background: none;
    border: none;
    font-size: 3rem;
    cursor: pointer;
    color: #4ecdc4;
    transition: transform 0.2s, color 0.2s;
    padding: 0 10px;
    /* Absolute positioning for clean separation */
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

#prev-btn {
    left: 0;
}

#next-word-btn {
    right: 0;
}

.nav-btn:hover {
    color: #ff6b6b;
    transform: scale(1.2);
}



/* --- GAME AREA (Slots & Tiles) --- */
.game-area-row {
    /* Removed the weird side-by-side flex layout */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 2rem;
}

.word-row-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.word-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    /* Allow wrapping for long words */
    max-width: 100%;
}



.letter-box {
    width: 60px;
    height: 80px;
    border: 3px solid #4ecdc4;
    border-radius: 12px;
    font-size: 2.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    background-color: #f7fff7;
    transition: transform 0.2s, background-color 0.2s;
    user-select: none;
}

.letter-box.filled {
    background-color: #ffe66d;
    transform: scale(1.05);
    border-color: #ff6b6b;
}

.letter-box.active {
    border-color: #ff6b6b;
    box-shadow: 0 0 10px #ff6b6b;
}

.message {
    font-size: 2rem;
    color: #4ecdc4;
    margin-bottom: 1rem;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hidden {
    display: none !important;
}

.next-btn {
    background-color: #ff6b6b;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka', sans-serif;
    transition: transform 0.2s, background-color 0.2s;
}

.next-btn:hover {
    background-color: #ff5252;
    transform: scale(1.05);
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    overflow-x: hidden;
}

@media (max-width: 600px) {
    .modal-content {
        padding: 1.5rem 1rem;
        max-height: 95vh;
        overflow-y: auto;
    }

    .close-btn {
        font-size: 3rem;
        top: 5px;
        right: 10px;
        padding: 10px;
        line-height: 0.8;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .modal-content {
        height: 95vh;
        display: flex;
        flex-direction: column;
        padding: 10px;
    }

    .tabs {
        margin-bottom: 10px;
    }

    .close-btn {
        top: 0;
        right: 5px;
    }
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
}

.close-btn:hover {
    color: #ff6b6b;
}

/* Settings Title */
.settings-title {
    margin-bottom: 20px;
}

/* Settings Groups */
.settings-group {
    margin-bottom: 20px;
    /* padding: 12px; */
}

.settings-group-header {
    font-size: 0.85rem;
    font-weight: 700;
    color: #bf360c;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    padding-left: 4px;
}

/* Styled Setting Card */
.setting-card {
    background: #fff3e0;
    padding: 14px 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #ffe0b2;
}

.setting-card:last-child {
    margin-bottom: 0;
}

.setting-card-column {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-info span,
.setting-info>label {
    font-weight: 600;
    color: #e65100;
    font-size: 1rem;
}

.setting-info small {
    display: block;
    color: #bf7830;
    font-weight: normal;
    font-size: 0.78rem;
    line-height: 1.3;
}

.setting-card .switch {
    transform: scale(0.9);
    flex-shrink: 0;
}

.setting-select {
    width: 100%;
    height: 48px;
    /* Improved touch target */
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ffcc80;
    font-size: 1rem;
    background: white;
    font-family: inherit;
}


/* Full Width Button */
.full-width-btn {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    font-size: 1.1rem;
    border-radius: 12px;
}

/* Backup Section */
.backup-section {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    margin-top: 20px;
    overflow: hidden;
}

.backup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-weight: 700;
    color: #616161;
    cursor: pointer;
    list-style: none;
}

.backup-header::-webkit-details-marker {
    display: none;
}

.backup-chevron {
    font-size: 0.8rem;
    transition: transform 0.3s;
}

details.backup-section[open] .backup-chevron {
    transform: rotate(180deg);
}

.backup-content {
    padding: 0 16px 16px;
}

.backup-description {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 12px;
}

.backup-actions {
    margin-bottom: 10px;
}

.backup-btn {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: inherit;
    transition: background 0.2s;
}

.backup-btn:hover {
    background: #f0f0f0;
}

.backup-btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    margin-top: 8px;
}

.backup-btn-primary:hover {
    background: #f57c00;
}

.backup-textarea {
    width: 100%;
    height: 60px;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.8rem;
    resize: vertical;
    box-sizing: border-box;
}

.backup-import {
    width: 100%;
}

/* Sticker Status */
.sticker-status {
    text-align: center;
    margin: 5px;
    font-size: 0.8rem;
    color: #666;
}

/* Tab Spacer */
.tab-spacer {
    height: 50px;
}







@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* --- STICKER BOOK --- */
.sticker-book-content {
    max-width: 800px;
    width: 95%;
    height: 95vh;
    /* Fixed height to allow scrolling inside */
    max-height: 800px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.sticker-grid {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 10px;
}


/* --- BUTTONS --- */
button,
.nav-btn,
.action-btn,
.backup-btn,
.install-btn,
.welcome-btn {
    font-family: 'Fredoka', sans-serif !important;
    font-weight: 600;
    transition: transform 0.1s, background-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
    border: none;
}

button:active,
.nav-btn:active,
.action-btn:active,
.backup-btn:active {
    transform: scale(0.95);
}

/* Chunky Buttons */
.next-btn,
.welcome-btn,
.add-btn {
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}

.next-btn:active,
.welcome-btn:active,
.add-btn:active {
    box-shadow: 0 0 0 rgba(0, 0, 0, 0.2);
    transform: translateY(4px);
}

/* Reset Tiles Button - Better Visibility */
#reset-tiles-btn {
    font-size: 1.5rem;
    padding: 12px;
    background: #FFECB3;
    border: 2px solid #FFC107;
    border-radius: 50%;
    margin-left: 15px;
    align-self: center;
    color: #e65100;
    box-shadow: 0 4px 0 #FFA000;
    display: flex;
    /* Ensure centering */
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
}

#reset-tiles-btn:hover {
    background: #FFE082;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #FFA000;
}

#reset-tiles-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #FFA000;
}

/* --- HINT SYSTEM --- */
@keyframes hint-pulse {

    0%,
    100% {
        box-shadow: 0 0 10px 5px rgba(255, 215, 0, 0.6);
        transform: scale(1);
        background-color: #fff9c4;
        /* Pale yellow bg */
        border-color: #ffd700;
    }

    50% {
        box-shadow: 0 0 25px 10px rgba(255, 215, 0, 0.9);
        transform: scale(1.1);
        background-color: #fff59d;
        /* Stronger yellow */
        border-color: #ffca28;
    }
}

.hint-active {
    animation: hint-pulse 1s infinite !important;
    z-index: 100;
    position: relative;
    border: 3px solid #ffca28 !important;
}

/* Keyboard Mode Ghost Letter */
.letter-box.hint-active::after {
    content: attr(data-hint);
    position: absolute;
    color: rgba(0, 0, 0, 0.4);
    font-size: 2.5rem;
    font-weight: bold;
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: fadeIn 0.5s;
}



.tab-pane ::-webkit-scrollbar,
.sticker-grid::-webkit-scrollbar {
    width: 4px;
}

.tab-pane::-webkit-scrollbar-track,
.sticker-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.tab-pane::-webkit-scrollbar-thumb,
.sticker-grid::-webkit-scrollbar-thumb {
    background: #ffcc80;
    border-radius: 4px;
}

/* Level Sections */
.level-section {
    margin-bottom: 20px;
}

/* Level Headers */
.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.level-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.level-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e65100;
    margin: 0;
}

.level-badge {
    background: #fff3e0;
    color: #ef6c00;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid #ffe0b2;
    white-space: nowrap;
}

/* Progress Bar Redesign */
.level-progress-wrapper {
    margin-bottom: 20px;
}

.level-progress-track {
    height: 14px;
    background: #f0f0f0;
    border-radius: 7px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.level-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    border-radius: 7px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

/* Shine effect on bar */
.level-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.3) 50%,
            rgba(255, 255, 255, 0) 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.level-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.85rem;
    color: #888;
    font-weight: 600;
    padding: 0 2px;
}

.level-current {
    color: #333;
    font-weight: 700;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
}

.sticker-item {
    background: #fff;
    border-radius: 15px;
    padding: 10px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid #eee;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    aspect-ratio: 1/1.2;
}

.sticker-item:hover {
    transform: translateY(-5px) scale(1.03);
    border-color: var(--primary-color);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.sticker-item.locked {
    opacity: 0.6;
    filter: grayscale(100%);
    cursor: default;
    background: #f9f9f9;
    border-style: dashed;
}

.sticker-item.locked:hover {
    transform: none;
    border-color: #ddd;
    box-shadow: none;
}

.sticker-item.sticker-custom {
    border-color: #ffcc80;
    position: relative;
}

.sticker-item.sticker-custom::after {
    content: '⭐';
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.7rem;
    line-height: 1;
}

.sticker-emoji {
    font-size: 3.5rem;
    margin-bottom: 5px;
    line-height: 1;
}

.sticker-word {
    font-size: 0.9rem;
    font-weight: 700;
    color: #444;
    text-align: center;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 5px;
}

.sticker-item.locked .sticker-emoji {
    filter: blur(8px);
    opacity: 0.5;
}

/* Golden Glow for Unlocked */
.sticker-item:not(.locked) {
    border-color: gold;
    background: linear-gradient(135deg, #fff 0%, #fffdf0 100%);
}



/* New Sticker Popup */
.new-sticker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    cursor: pointer;
    animation: fadeIn 0.3s ease-out;
}

.new-sticker-overlay.fade-out {
    animation: fadeOut 0.5s ease-out forwards;
}

.new-sticker-popup {
    background: linear-gradient(135deg, #fff9c4 0%, #fff176 30%, #ffffff 100%);
    border-radius: 25px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 80px rgba(255, 215, 0, 0.4);
    border: 3px solid gold;
    animation: stickerBounceIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.new-sticker-badge {
    position: absolute;
    top: -15px;
    right: -10px;
    background: #ff5252;
    color: white;
    font-size: 0.9rem;
    font-weight: 800;
    padding: 4px 14px;
    border-radius: 20px;
    transform: rotate(12deg);
    box-shadow: 0 4px 10px rgba(255, 82, 82, 0.4);
    letter-spacing: 1px;
}

.new-sticker-emoji {
    font-size: 6rem;
    margin: 10px 0;
    animation: stickerPulse 1.5s ease-in-out infinite;
}

.new-sticker-word {
    font-size: 2rem;
    font-weight: 700;
    color: #e65100;
    margin-bottom: 5px;
    letter-spacing: 3px;
}

.new-sticker-subtitle {
    font-size: 1.1rem;
    color: #888;
    font-weight: 600;
}

@keyframes stickerBounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3) rotate(-10deg);
    }

    50% {
        transform: scale(1.1) rotate(3deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes stickerPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* Custom Words & Emoji Picker */
.settings-content {
    max-width: 500px;
    width: 95%;
    padding: 20px;
    height: 95vh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-x: hidden;
}

.tabs {
    display: flex;
    background: #f0f0f0;
    padding: 5px;
    border-radius: 25px;
    margin-bottom: 20px;
    border-bottom: none;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px 10px;
    /* Min height 44px */
    font-size: 0.9rem;
    font-weight: 700;
    color: #888;
    cursor: pointer;
    border-radius: 20px;
    transition: all 0.2s ease;
    text-align: center;
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
}

.tab-pane {
    display: none;
    flex: 1;
    overflow-y: auto;
    flex-direction: column;
}

.tab-pane.active {
    display: flex;
}


.add-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    height: 45px;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
}


.add-btn:active {
    transform: scale(0.95);
}



/* Emoji Picker Styles */
.emoji-picker {
    border: 1px solid #ccc;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    margin-top: 5px;
    z-index: 10;
    margin-top: 5px;
    z-index: 10;
    overflow: hidden;
    width: 100%;
    margin-bottom: 15px;
    /* Add space below when open */
    position: relative;
    /* Keep it in flow */
}

.emoji-picker.hidden {
    display: none !important;
}

.custom-words-container {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}



.emoji-search {
    width: 100%;
    padding: 10px;
    border: none;
    border-bottom: 1px solid #eee;
    background: #fdfdfd;
    font-size: 0.9rem;
}

.emoji-categories {
    display: flex;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
}

.category-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
}

.category-btn.active {
    opacity: 1;
    background: white;
    border-bottom: 3px solid var(--primary-color);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 5px;
    padding: 10px;
    height: 150px;
    /* Fixed height scroll */
    overflow-y: auto;
}

.emoji-option {
    font-size: 1.6rem;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.1s;
}

.emoji-option:hover {
    background: #f0f0f0;
}

.list-title {
    margin: 5px 0 10px;
    color: #444;
}

/* --- Custom Words UI --- */

.add-word-card {
    background: #fdfdfd;
    border-radius: 16px;
    padding: 20px;
    border: 2px solid #eee;
    margin-bottom: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
}

.add-word-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.input-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-wrapper label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #666;
    margin-left: 5px;
}

.input-wrapper input {
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 1.1rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-wrapper input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.emoji-input-wrapper {
    flex: 0 0 100px;
    /* Fixed width for emoji input */
}

.emoji-input-row {
    display: flex;
    gap: 5px;
}

.emoji-text-input {
    width: 50px !important;
    text-align: center;
}

.emoji-picker-toggle {
    background: #eee;
    border: none;
    border-radius: 10px;
    font-size: 1.5rem;
    cursor: pointer;
    width: 45px;
    height: 48px;
    /* Match input height roughly */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.emoji-picker-toggle:hover {
    background: #ddd;
}

.feedback-message {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: 600;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.feedback-message.success {
    background-color: #d4edda;
    color: #155724;
}

.feedback-message.error {
    background-color: #f8d7da;
    color: #721c24;
}

.feedback-message.info {
    background-color: #cce5ff;
    color: #004085;
}


.custom-words-list {
    list-style: none;
    padding: 0;
    max-height: 250px;
    overflow-y: auto;
}

.custom-word-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: white;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    gap: 8px;
    flex-wrap: nowrap;
    overflow-x: auto;
    min-width: 0;
}

.custom-word-item>span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

.custom-word-item>div {
    flex-shrink: 0;
}

.empty-state {
    text-align: center;
    color: #888;
    padding: 30px;
    background: #f9f9f9;
    border-radius: 12px;
    font-style: italic;
    margin-top: 10px;
}

.tile-pool {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    /* Important for long words! */
    min-height: 80px;
    width: 100%;
}

.tile {
    width: 60px;
    height: 80px;
    background-color: #ffd93d;
    border: 3px solid #ff6b6b;
    border-radius: 10px;
    font-size: 3rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tile:hover {
    transform: scale(1.1) translateY(-5px);
    background-color: #ffc107;
}

.tile.used {
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #aaa;
    pointer-events: none;
    opacity: 0.5;
    transform: scale(0.9);
    box-shadow: none;
}

/* Update letter-box for tile mode */
.letter-box.tile-mode {
    cursor: pointer;
}

.letter-box.tile-mode:hover {
    background-color: #ffe66d;
}

.letter-box.empty-slot {
    border-style: dashed;
    background-color: #fafafa;
}

/* Toggle Switch Styling */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 5px 10px;
    border-radius: 20px;
    border: 1px solid #eee;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    /* Wider */
    height: 34px;
    /* Taller */
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    /* Larger knob */
    width: 26px;
    /* Larger knob */
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #4ecdc4;
}

input:focus+.slider {
    box-shadow: 0 0 1px #4ecdc4;
}

input:checked+.slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- RESPONSIVE DESIGN --- */

/* Tablet & Smaller Laptops */
@media (max-width: 900px) {
    .game-container {
        width: 95%;
        padding: 1.5rem;
    }

    .emoji {
        font-size: 6rem;
    }

    .letter-box,
    .tile {
        width: 50px;
        height: 70px;
        font-size: 2.5rem;
    }
}

/* Mobile Devices - App Layout */
@media (max-width: 600px) {
    body {
        overscroll-behavior-y: none;
        height: 100dvh;
        width: 100%;
        position: fixed;
        overflow: hidden;
        background: linear-gradient(135deg, #fff8e1 0%, #ffe0b2 50%, #ffcc80 100%);
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        display: flex;
        flex-direction: column;
    }

    .game-container {
        padding: 5px 10px 20px;
        width: 100%;
        height: 100%;
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        /* Don't space out! Pack to top */
        gap: 2vh;
        /* Use relative spacing */
        overflow-y: auto;
        /* Enable scrolling for content */
        -webkit-overflow-scrolling: touch;
        align-items: center;
    }

    /* 1. Header */
    .header-controls {
        width: 100%;
        display: grid;
        grid-template-areas:
            "left right";
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 20px;
        flex: 0 0 auto;
        padding-top: 5px;
    }

    .title {
        display: none;
    }

    .header-left {
        grid-area: left;
        justify-self: start;
    }

    .header-right {
        grid-area: right;
        justify-self: end;
    }

    .toggle-container {
        transform: scale(0.8);
        margin: 0;
        transform-origin: right center;
    }

    #settings-btn {
        font-size: 1.3rem;
        padding: 5px;
    }

    /* 2. Stage: Emoji & Navigation */
    .emoji-container {
        flex: 0 1 auto;
        /* Don't grow aggressively */
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
        min-height: 100px;
    }

    .emoji {
        font-size: 5rem;
        max-height: 20vh;
        /* Strict limit */
        width: auto;
        object-fit: contain;
    }

    .nav-btn {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        font-size: 3rem;
        padding: 15px;
        z-index: 20;
        opacity: 0.8;
        /* Make visible by default on mobile */
        background: rgba(255, 255, 255, 0.5);
        /* Semi-transparent background */
        border-radius: 50%;
    }

    #prev-btn {
        left: 0;
    }

    #next-word-btn {
        right: 0;
    }

    .nav-btn:hover {
        opacity: 1;
    }

    /* 3. Game Area: Slots */
    .game-area-row {
        flex: 0 0 auto;
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
        align-items: center;
        margin-bottom: 0;
    }

    .word-row-container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .word-container {
        display: flex;
        justify-content: center;
        gap: 4px;
    }

    .letter-box,
    .tile {
        width: 42px;
        height: 56px;
        font-size: 1.6rem;
        border-radius: 8px;
        border-width: 2px;
    }

    #reset-tiles-btn {
        position: static;
        margin: 0;
        background: #f0f0f0;
        box-shadow: none;
        font-size: 1rem;
        padding: 8px;
    }

    /* 4. Footer: Tile Pool */
    .tile-pool {
        flex: 0 0 auto;
        min-height: 80px;
        background: transparent;
        border-radius: 15px 15px 0 0;
        padding: 10px 0;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 100%;
    }

    .next-btn {
        position: static;
        transform: none;
        margin-top: 10px;
        margin-bottom: 30px;
        font-size: 1.5rem;
        padding: 15px 40px;
        z-index: 1000;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%);
        border: 4px solid white;
        animation: pulseBtn 2s infinite;
        width: auto;
        white-space: nowrap;
        align-self: center;
    }

    @keyframes pulseBtn {
        0% {
            transform: scale(1);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }

        50% {
            transform: scale(1.05);
            box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
        }

        100% {
            transform: scale(1);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        }
    }

    /* Hide Next Button normally, maybe show it differently on mobile? */
    /* Actually: Let's put the Next button inside the header or fixed */

    .celebration-creature {
        font-size: 6rem;
    }
}

/* Landscape Mode (Short screens) */
@media (max-height: 500px) and (orientation: landscape) {
    .game-container {
        padding: 5px;
        flex-direction: row;
        /* Side by side layout */
        justify-content: center;
        align-items: center;
        gap: 10px;
    }

    .header-controls {
        position: absolute;
        top: 5px;
        left: 5px;
        width: auto;
        display: flex;
        gap: 10px;
        z-index: 100;
        background: rgba(255, 255, 255, 0.8);
        padding: 5px;
        border-radius: 10px;
    }

    .title {
        display: none;
    }

    /* Hide title in landscape to save space */
    .toggle-container {
        margin: 0;
    }

    .emoji-container {
        flex: 1;
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .emoji {
        display: block;
        /* Show emoji! */
        max-height: 80vh;
        font-size: 4rem;
    }

    .game-area-row {
        flex: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .word-container {
        margin: 0;
    }

    .tile-pool {
        display: none;
        /* Hide pool if using keyboard, specific adjustment might be needed for tiles */
    }
}

/* --- MAGIC EFFECTS --- */
.magic-sparkle {
    position: fixed;
    font-size: 2rem;
    pointer-events: none;
    z-index: 9999;
    animation: sparklePop 1s ease-out forwards;
}

@keyframes sparklePop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.5);
        opacity: 0;
    }
}

/* --- CELEBRATION ANIMATIONS --- */
.celebration-creature {
    position: fixed;
    font-size: 15rem;
    z-index: 2000;
    pointer-events: none;
    animation: flyAcross 4s linear forwards;
    bottom: -20vh;
    left: -20vw;
}

@media (max-width: 600px) {
    .celebration-creature {
        font-size: 8rem;
    }
}

@keyframes flyAcross {
    0% {
        transform: translate(0, 0) rotate(0deg);
        left: -10vw;
        bottom: -10vh;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        transform: translate(120vw, -120vh) rotate(20deg);
        left: 0;
        bottom: 0;
        opacity: 1;
    }
}



/* --- About Section (Details Accordion) --- */


.about-section {
    padding: 5px 16px 16px;
    text-align: left;
    color: #555;
}

.about-section p {
    margin-bottom: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
    color: #666;
}

.about-section h4 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: #e65100;
    font-size: 1rem;
    font-weight: 700;
}

.tech-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.tech-list li {
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    margin-bottom: 6px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    color: #555;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.about-footer {
    margin-top: 20px;
    border-top: 1px solid rgba(255, 224, 178, 0.5);
    padding-top: 15px;
}

.love-note {
    font-weight: 700;
    color: #e65100;
    font-size: 1rem;
}

.version-note {
    font-size: 0.8rem;
    color: #bf7830;
    margin-top: 5px;
}

/* PWA Install Card */
.install-card {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    margin-bottom: 20px;
    display: flex;
    /* Ensure flex for alignment */
    justify-content: space-between;
    align-items: center;
}

.install-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 8px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: transform 0.1s;
}

.install-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #388E3C;
}


/* Update Notification Toast */
.update-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideUp 0.3s ease-out;
}

.update-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.reload-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.85rem;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Sticker Book Medals */
.level-medals {
    display: flex;
    gap: 5px;
}

.medal {
    font-size: 1.5rem;
    filter: grayscale(100%);
    opacity: 0.2;
    transition: all 0.3s ease;
}

.medal.unlocked {
    filter: none;
    opacity: 1;
    transform: scale(1.1);
}

/* Modal Actions */
.modal-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 25px;
}

/* Danger Button (Red) */
.danger-btn {
    background-color: #ff5252;
    color: white;
    box-shadow: 0 4px 0 #d32f2f;
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
}

.danger-btn:hover {
    background-color: #ff1744;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #d32f2f;
}

.danger-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #d32f2f;
}

/* Cancel Button (Gray) */
.cancel-btn {
    background-color: #e0e0e0;
    color: #333;
    box-shadow: 0 4px 0 #9e9e9e;
    padding: 12px 24px;
    font-size: 1.1rem;
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
}

.cancel-btn:hover {
    background-color: #d5d5d5;
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #9e9e9e;
}

.cancel-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #9e9e9e;
}