/* Fixed font reference - version 1.1 */
@font-face {
    font-family: 'ThisCafe';
    src: url('./fonts/this_cafe.ttf') format('truetype');
}

* {
    box-sizing: border-box;
}

/* 🌐 Language Selector */
#language-selector {
    position: fixed;
    top: 10px;
    right: 15px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.95);
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#language-selector label {
    font-size: 0.95rem;
    font-weight: bold;
    color: #333;
    margin: 0;
    cursor: pointer;
}

#language-selector select {
    padding: 6px 10px;
    font-size: 0.9rem;
    border: 2px solid #009688;
    border-radius: 6px;
    background-color: white;
    color: #333;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

#language-selector select:hover {
    border-color: #00796b;
}

#language-selector select:focus {
    outline: none;
    border-color: #004d40;
    box-shadow: 0 0 5px rgba(0, 150, 136, 0.3);
}

body {
    font-family: 'This Cafe', sans-serif;
    background: linear-gradient(rgba(249, 249, 249, 0.95), rgba(249, 249, 249, 0.95)), 
                url('./images/background.jpg') center/cover no-repeat fixed;
    text-align: center;
    margin: 0;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

h1 {
    font-size: 2.5rem;
    margin-top: 15px;
    margin-bottom: 5px;
    color: #222;
    text-shadow: 1px 1px 2px #999;
    letter-spacing: 1px;
    text-align: center;
}

h2 {
    font-size: 1.4rem;
    margin-top: 0;
    margin-bottom: 15px;
    color: #444;
    text-shadow: 0.5px 0.5px 1px #bbb;
    text-align: center;
}

.controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
}

button {
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background-color: #009688;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

/* 🎮 Special styling for mode toggle */
#interactive-toggle {
    background-color: #4caf50;
    font-weight: bold;
}

/* 🎮 Mode selection buttons */
#play-mode-btn, #solver-mode-btn {
    font-size: 1.1rem;
    padding: 12px 20px;
    font-weight: bold;
    margin: 0 5px;
}

#play-mode-btn {
    background-color: #4caf50;
}

#solver-mode-btn {
    background-color: #2196f3;
}

button:hover {
    background-color: #2196f3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 🎯 Difficulty buttons */
.difficulty-btn {
    margin: 3px;
    padding: 12px 16px;
    font-size: 0.9rem;
    border-radius: 10px;
    min-width: 100px;
    transition: all 0.3s ease;
}

.difficulty-btn:hover {
    transform: scale(1.05);
}

#easy-btn { background-color: #4caf50; }
#easy-btn:hover { background-color: #45a049; }

#medium-btn { background-color: #ff9800; }
#medium-btn:hover { background-color: #f57c00; }

#hard-btn { background-color: #f44336; }
#hard-btn:hover { background-color: #d32f2f; }

#time-trial-btn { background-color: #9c27b0; }
#time-trial-btn:hover { background-color: #7b1fa2; }

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ❓ Tutorial button styling */
#tutorial-btn {
    background-color: #673ab7 !important;
    font-size: 0.9rem !important;
    padding: 10px 14px !important;
    border-radius: 8px !important;
    margin: 0 !important;
    color: white !important;
}

#tutorial-btn:hover {
    background-color: #5e35b1 !important;
}

#puzzle-board {
    display: grid;
    gap: 8px;
    margin-bottom: 20px;
    width: 100%;
    max-width: 350px;
    grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
    padding: 0 10px;
}

.tile {
    background-color: #fffbf0;
    border: 2px solid #ccc;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    width: 100%;
    transition: background 0.3s ease, transform 0.2s;
    -moz-appearance: textfield; /* Firefox: remove number arrows */
    cursor: pointer; /* 🎮 Show it's clickable */
}

/* 🎮 Interactive hover effect */
.tile:hover {
    background-color: #e8f5e8;
    transform: scale(1.05);
    border-color: #4caf50;
}

/* 🎮 Clickable tile effect */
.tile.clickable {
    background-color: #f0f8ff;
    border-color: #2196f3;
    animation: pulse 1.5s infinite;
}

/* 🎯 Moveable tiles with arrows */
.tile.moveable {
    background-color: #e8f5e8 !important;
    border-color: #4caf50 !important;
    cursor: pointer !important;
    animation: breathe 2s ease-in-out infinite;
}

/* 🌬️ Breathing animation for moveable tiles */
@keyframes breathe {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
    }
}

/* 🏹 Arrow indicators */
.arrow-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    font-size: 0.8rem;
    color: #4caf50;
    font-weight: bold;
    pointer-events: none;
    text-shadow: 0 0 2px white;
}

/* 💡 Hint highlight - Enhanced animations */
.tile.hint-highlight {
    background-color: #fff3e0 !important;
    border-color: #ff9800 !important;
    animation: hintGlow 1s ease-in-out infinite alternate;
}

.tile.hint-pulse {
    animation: hintPulse 0.8s ease-in-out infinite alternate;
}

.tile.hint-glow {
    animation: hintGlow 1s ease-in-out infinite alternate;
}

/* Combined animation for ultimate attention */
.tile.hint-highlight.hint-pulse.hint-glow {
    background-color: #fff3e0 !important;
    border-color: #ff4444 !important;
    animation: hintCombined 0.6s ease-in-out infinite alternate;
}

@keyframes hintGlow {
    from { box-shadow: 0 0 5px #ff9800; }
    to { box-shadow: 0 0 15px #ff9800, 0 0 25px #ff9800; }
}

@keyframes hintPulse {
    from { 
        transform: scale(1);
        background-color: #fff3e0;
    }
    to { 
        transform: scale(1.05);
        background-color: #ffeb3b;
    }
}

@keyframes hintCombined {
    from { 
        transform: scale(1);
        background-color: #fff3e0;
        box-shadow: 0 0 5px #ff4444;
        border-color: #ff4444;
    }
    to { 
        transform: scale(1.1);
        background-color: #ffeb3b;
        box-shadow: 0 0 20px #ff4444, 0 0 30px #ff4444;
        border-color: #ff0000;
    }
}

@keyframes hintArrowPulse {
    from { 
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.8;
    }
    to { 
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }
}

/* 💡 Hint button styling */
#hint-btn {
    background-color: #ff9800;
}

#hint-btn:hover {
    background-color: #f57c00;
}

@keyframes hintPop {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(33, 150, 243, 0); }
    100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); }
}

/* ⌨️ Keyboard hint animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Chrome/Safari: remove number arrows */
.tile::-webkit-outer-spin-button,
.tile::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tile:focus {
    outline: 2px solid #009688;
    background-color: #e0f7fa;
}

/* ❌ Invalid input styling */
.tile.invalid {
    background-color: #ffebee !important;
    border-color: #f44336 !important;
    animation: shake 0.5s ease-in-out;
}

/* 🎯 Next moveable tiles - Shows which tiles CAN move next (with smooth pulse) */
.tile.next-moveable {
    background-color: #fff9c4 !important;
    border-color: #f57f17 !important;
    animation: nextMoveablePulse 0.8s ease-in-out infinite;
    position: relative;
}

/* Arrow indicator showing direction of movement */
.move-arrow {
    position: absolute;
    font-size: 1.2rem;
    font-weight: bold;
    color: #f57f17;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 249, 196, 0.9);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.8);
    z-index: 10;
    animation: arrowPulse 0.8s ease-in-out infinite;
}

@keyframes nextMoveablePulse {
    0% {
        background-color: #fff9c4;
        box-shadow: 0 0 5px rgba(245, 127, 23, 0.6);
        transform: scale(1);
    }
    50% {
        background-color: #ffeb3b;
        box-shadow: 0 0 15px rgba(245, 127, 23, 0.9);
        transform: scale(1.02);
    }
    100% {
        background-color: #fff9c4;
        box-shadow: 0 0 5px rgba(245, 127, 23, 0.6);
        transform: scale(1);
    }
}

@keyframes arrowPulse {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.15);
    }
    100% {
        opacity: 0.7;
        transform: scale(1);
    }
}


/* Arrows for PREVIOUS and NEXT */
#prev-btn::before {
    content: "← ";
}
#next-btn::after {
    content: " →";
}

#brain-loader {
    display: none;
    margin: 20px auto;
    width: 60px;
}

#move-counter {
    margin-top: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #444;
}

#step-counter {
    display: none;
    font-size: 1.2rem;
    font-weight: bold;
    color: #444;
    margin-top: 15px;
}

/* 🎉 Puzzle Solved Popup */
#solved-popup {
    display: none;
    position: fixed;
    top: 25%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff9c4;
    color: #222;
    padding: 15px 30px;
    border: 2px solid #fbc02d;
    border-radius: 12px;
    font-size: 1.6rem;
    font-weight: bold;
    box-shadow: 0 0 25px 8px rgba(255, 235, 59, 0.6);
    animation: glow 1.5s ease-in-out forwards;
    z-index: 9999;
}

@keyframes glow {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.8); }
    40%  { opacity: 1; transform: translateX(-50%) scale(1.05); }
    100% { opacity: 0; transform: translateX(-50%) scale(1); }
}

/* Mobile & Tablet Optimization */
@media (max-width: 768px) {
    h1 {
        font-size: 2.4rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    button {
        font-size: 1rem;
        padding: 10px 16px;
    }

    .tile {
        font-size: 1.4rem;
    }

    .controls {
        gap: 8px;
        margin-bottom: 25px;
    }
}
