:root {
    /* PREMIUM NINDŽA PALETA */
    --pozadina: #FAF8F1;       
    --koza: #aabb00;           
    --osnova-oklopa: #693C0F;  
    --heks-centar: #BC8F4D;    
    --heks-spolja: #E2DCC8;    
    --tekst: #39311D;          
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--pozadina);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Roboto', sans-serif;
    color: var(--tekst);
    
    /* Zabrana selektovanja teksta na celom sajtu za glatko iskustvo */
    -webkit-user-select: none; 
    -moz-user-select: none;    
    -ms-user-select: none;     
    user-select: none;         
    
    /* Dozvoljava skrol gore/dole, ali UBIJA bilo kakvo zumiranje! */
    touch-action: pan-x pan-y;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

/* --- GLAVNA NAVIGACIJA --- */
.game-nav {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    margin-bottom: 20px;
}

.nav-btn {
    text-decoration: none;
    padding: 8px 25px;
    border-radius: 20px;
    border: 2px solid var(--koza);
    color: var(--tekst);
    font-weight: bold;
    font-size: 1.1rem;
    transition: all 0.2s ease;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}

.nav-btn.active {
    background: var(--koza);
    color: white;
    box-shadow: 0 4px 10px rgba(170, 187, 0, 0.3);
}

@media (hover: hover) {
    .nav-btn:not(.active):hover {
        background: var(--heks-spolja);
        transform: translateY(-2px);
    }
}
.nav-btn:not(.active):active { background: var(--heks-spolja); transform: translateY(0); }

/* --- ZAGLAVLJE I HELP DUGME --- */
.game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
    width: 100%;
}

.game-header h1 {
    font-size: 2.5rem;
    color: var(--osnova-oklopa);
    text-transform: uppercase;
    margin-bottom: 0;
    letter-spacing: 2px;
}

.help-btn {
    background: transparent;
    border: 2px solid var(--osnova-oklopa) !important;
    color: var(--osnova-oklopa) !important;
    border-radius: 50% !important;
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem !important;
    font-weight: bold !important;
    padding: 0 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
    .help-btn:hover {
        background: var(--osnova-oklopa) !important;
        color: var(--pozadina) !important;
    }
}

/* --- STATISTIKA --- */
.score-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px; 
    width: 100%;
    margin-bottom: 15px;
    font-weight: bold;
}
.stat-box { 
    background: white; 
    padding: 5px 15px; 
    border-radius: 15px; 
    box-shadow: 0 4px 10px rgba(105, 60, 15, 0.05);
    border: 1px solid rgba(105, 60, 15, 0.1); 
    white-space: nowrap; 
    text-align: center;
    font-size: 1rem; 
}

/* --- UNOS (Podržava i reči i matematičke jednačine) --- */
.input-display {
    min-height: 50px;
    width: 100%;
    text-align: center;
    font-size: 2.2rem;
    font-weight: bold;
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    color: var(--osnova-oklopa);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}
.cursor { color: var(--heks-centar); animation: blink 1s step-end infinite; margin-left: 2px; }
@keyframes blink { 50% { opacity: 0; } }

/* --- KORNJAČA VIZUAL --- */
.kornjaca-kontejner {
    position: relative;
    width: 340px;
    height: 380px;
    margin-bottom: 25px;
}

.glava {
    position: absolute; top: 0; left: 135px;
    width: 70px; height: 85px; background: var(--koza);
    border-radius: 50% 50% 40% 40%; z-index: 1;
}

.glava::after {
    content: ''; position: absolute; top: 35px; left: 8px; right: 8px; height: 12px;
    border-bottom: 1px solid rgba(57, 49, 29, 0.4); border-radius: 50% / 0 0 100% 100%; 
    opacity: 0.6; box-shadow: 0 5px 0 0 rgba(57, 49, 29, 0.3);
}

.peraje { position: absolute; background: var(--koza); border-radius: 50%; z-index: 1; }
.prednje-levo { top: 60px; left: 15px; width: 100px; height: 50px; transform: rotate(-40deg); }
.prednje-desno { top: 60px; right: 15px; width: 100px; height: 50px; transform: rotate(40deg); }
.zadnje-levo { bottom: 50px; left: 45px; width: 75px; height: 45px; transform: rotate(-60deg); }
.zadnje-desno { bottom: 50px; right: 45px; width: 75px; height: 45px; transform: rotate(60deg); }

.rep {
    position: absolute; bottom: 20px; left: 155px; width: 0; height: 0;
    border-left: 15px solid transparent; border-right: 15px solid transparent;
    border-top: 45px solid var(--koza); z-index: 1;
}

.podloga-oklopa {
    position: absolute; top: 45px; left: 20px; width: 300px; height: 295px; background: var(--osnova-oklopa);
    border-radius: 50% 50% 45% 45%; z-index: 2; box-shadow: 0 10px 30px rgba(57, 49, 29, 0.2);
}

/* --- HEKSAGONI --- */
.heks-mreza { position: absolute; top: 58px; left: 25px; width: 290px; height: 270px; z-index: 3; }

.heks {
    position: absolute; width: 96px; height: 82px;
    display: flex; justify-content: center; align-items: center;
    font-size: 2.2rem; font-weight: bold;
    
    /* DODATO ZA STARE TELEFONE (Samsung S8, stari iPhone) */
    -webkit-clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);

    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    cursor: pointer; transition: 0.1s;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.heks:active { transform: scale(0.9); }

.heks-centar { 
    background: var(--heks-centar); color: white; 
    top: 94px; left: 97px; font-size: 2.8rem; 
}
#meta-broj { cursor: default; } 
#meta-broj:active { transform: scale(1); }

.heks-spolja { 
    background: var(--heks-spolja); color: var(--tekst); opacity: 1; transition: all 0.2s; 
}

/* Isključen broj (Samo za Kornjobroj) */
.heks-disabled {
    background: #c5c1b5; color: #8c8981; pointer-events: none; transform: scale(0.95);
}

.poz-1 { top: 8px; left: 97px; } .poz-2 { top: 51px; left: 172px; }
.poz-3 { top: 137px; left: 172px; } .poz-4 { top: 180px; left: 97px; }
.poz-5 { top: 137px; left: 22px; } .poz-6 { top: 51px; left: 22px; }

/* --- MATEMATIČKE KONTROLE (Kornjobroj) --- */
.math-controls { display: flex; gap: 8px; margin-bottom: 20px; justify-content: center; width: 100%; }
.math-btn {
    width: 45px; height: 45px; padding: 0; border-radius: 10px; font-size: 1.4rem;
    background: var(--heks-spolja); border: 2px solid var(--osnova-oklopa); font-weight: bold;
}
.math-op { background: var(--heks-centar); color: white; }

/* --- KONTROLE --- */
.controls { display: flex; gap: 15px; }

button {
    padding: 12px 25px; border-radius: 25px; border: 2px solid var(--koza); background: white; 
    cursor: pointer; font-weight: bold; font-size: 1rem; letter-spacing: 0.8px; color: var(--tekst);
    transition: all 0.2s ease; box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    -webkit-tap-highlight-color: transparent; touch-action: manipulation; 
}

/* Centriranje SVG ikonica na dugmićima */
#btn-delete, #btn-shuffle, #btn-reset {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) {
    button:hover { background: var(--heks-spolja); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
}
button:active { background: var(--heks-spolja); transform: translateY(0); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }

/* ============================================================== */
/* === LEBDEĆI TOOLTIP DIZAJN ZA PORUKE U BOJI OKLOPA KORNJAČE ===*/
/* ============================================================== */
.messages { 
    position: fixed;
    top: 25vh; /* Pozicionirano iznad oklopa kornjače za OBE igre */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--osnova-oklopa); /* Braon boja kao osnova oklopa */
    color: #ffffff !important; /* Beli tekst zbog kontrasta */
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 1rem;
    z-index: 1000;
    opacity: 0; /* Sakriveno po defaultu */
    pointer-events: none; /* Da klikovi prolaze kroz njega ako ga slucajno pipnu */
    transition: opacity 0.3s ease; /* Meka animacija pojavljivanja */
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    white-space: nowrap; /* Da tekst uvek stane u jedan red */
}

/* Klasa koja ga pali iz JavaScripta */
.messages.show {
    opacity: 1;
}

/* --- LISTA PRONAĐENIH REČI (Slovo) --- */
.found-words-container { width: 100%; max-width: 400px; margin-top: 10px; text-align: center; }
.found-words-container h3 { color: var(--osnova-oklopa); margin-bottom: 10px; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1.5px; }
.words-list {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; min-height: 80px; 
    padding: 20px; background: #ffffff; border-radius: 15px; border: 2px dashed var(--heks-spolja);
    box-shadow: inset 0 4px 10px rgba(105, 60, 15, 0.05);
}
.empty-message { color: #a0aab5; font-style: italic; margin: auto; font-weight: normal; }
.word-tag {
    background: var(--heks-spolja); color: var(--tekst); padding: 6px 14px; border-radius: 20px; 
    font-size: 0.95rem; font-weight: bold; letter-spacing: 0.5px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.word-tag.pangram { background: var(--heks-centar); color: var(--tekst); border: 2px solid var(--osnova-oklopa); box-shadow: 0 0 10px rgba(188, 143, 77, 0.4); }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* --- DUGME ZA DELJENJE (SHARE) --- */
.share-btn {
    background-color: var(--heks-centar); color: white; border: 2px solid var(--osnova-oklopa);
    padding: 10px 20px; font-weight: bold; font-size: 1.1rem; border-radius: 20px; margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(188, 143, 77, 0.4); animation: popIn 0.3s ease forwards; cursor: pointer;
}
@media (hover: hover) { .share-btn:hover { background-color: var(--osnova-oklopa); color: var(--pozadina); transform: translateY(-2px) scale(1.05); } }

/* --- ISKAČUĆI PROZOR (MODAL) ZA PRAVILA --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(105, 60, 15, 0.7); 
    display: flex; justify-content: center; align-items: center; z-index: 100; opacity: 0; pointer-events: none; 
    transition: opacity 0.3s ease; backdrop-filter: blur(5px);
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--pozadina); padding: 30px; border-radius: 20px; width: 90%; max-width: 400px; position: relative; transform: translateY(-30px); transition: transform 0.3s ease; box-shadow: 0 15px 40px rgba(0,0,0,0.3); }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-content h2 { color: var(--osnova-oklopa); margin-bottom: 20px; text-align: center; letter-spacing: 1.5px; }
.modal-content ul { list-style-type: none; }
.modal-content li { margin-bottom: 12px; padding-left: 25px; position: relative; line-height: 1.5; font-size: 1.05rem; color: var(--tekst); }
.modal-content li::before { content: '🐢'; position: absolute; left: 0; top: 0; font-size: 0.9rem; }
.close-btn { position: absolute; top: 15px; right: 15px; background: none !important; border: none !important; font-size: 2.2rem !important; color: var(--heks-centar) !important; padding: 0 !important; line-height: 1 !important; width: auto !important; height: auto !important; cursor: pointer; transition: all 0.2s ease; }
@media (hover: hover) { .close-btn:hover { color: var(--osnova-oklopa) !important; transform: scale(1.2) !important; } }

/* =========================================
   === PRILAGOĐAVANJE ZA MOBILNE TELEFONE ===
   ========================================= */
@media (max-width: 400px) {
    .kornjaca-kontejner { transform: scale(0.85); margin-bottom: 5px; }
    .game-header h1 { font-size: 2rem; letter-spacing: 1px; }
    .input-display { font-size: 1.8rem; margin-bottom: 10px; }
    .controls { gap: 8px; }
    button { padding: 10px 15px; font-size: 0.9rem; letter-spacing: 0.5px;}
    .found-words-container { max-width: 90vw; }
    .math-btn { width: 40px; height: 40px; font-size: 1.2rem; }
    
    /* Na mobilnim vraćamo prirodnu širinu, uz dozvolu za skupljanje */
    .score-container { 
        gap: 10px; 
        justify-content: center; 
    }
    .stat-box {
        flex: 0 1 auto; /* Prati širinu teksta, ali se skuplja ako zatreba */
        min-width: 0;
        padding: 5px 12px; 
        font-size: 11px; 
        letter-spacing: -0.2px; 
        overflow: hidden; 
        text-overflow: ellipsis; 
    }
}

@media (max-width: 330px) {
    .kornjaca-kontejner { transform: scale(0.75); }
    /* Dodatno stiskanje za mikroskopske ekrane */
    .stat-box { font-size: 10px; padding: 5px 8px; }
}

/* --- STILOVI ZA KLIKABILNU JEDNAČINU SA KURSOROM (KORNJOBROJ) --- */
.display-item {
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    padding: 0 2px; /* Lakši prostor za hvatanje prstom */
}

@media (hover: hover) {
    .display-item:hover {
        color: var(--koza); /* Zelena boja da ukaže na to da može da se klikne */
        transform: scale(1.1);
    }
}

.display-item:active {
    color: var(--koza);
    transform: scale(0.9);
}

/* Izmena: Uklanjamo onaj stari fiksni HTML kursor jer ga JS crta dinamički */
#equation-display > .cursor:last-child {
    display: none;
}