/* Põhiasetus */
.snowman-svg {
    width: 100%;
    height: auto;
    max-height: 350px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
    /* Eemaldatud transition transform, sest nüüd pöörame sisemist gruppi */
}

.snowman-part {
    transition: all 0.5s ease;
    transform-origin: center;
    transform-box: fill-box;
}

/* Sulamise efektid */
.melted {
    /* See klass on nüüd üldine, spetsiifilised animatsioonid allpool */
    pointer-events: none;
}

/* Kukkumine ja mahajäämine (kõvad osad) */
.fall-and-stay {
    animation: fallToGroundStay 1s forwards cubic-bezier(0.6, 0.04, 0.98, 0.335);
    pointer-events: none;
}

@keyframes fallToGroundStay {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    20% {
        transform: translate(0, 20px) rotate(10deg);
    }
    100% {
        /* Kukub piisavalt alla, et jõuda maapinnale */
        transform: translate(0, 280px) rotate(90deg);
        /* Ei muuda opacity-t 0-ks, vaid jääb nähtavaks */
    }
}

/* Sulamine (lumepallid) */
.melt-away {
    animation: meltDown 1.5s forwards ease-in-out;
    pointer-events: none;
}

@keyframes meltDown {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.2, 0.5) translateY(20px);
    }
}

/* Lääpavajumine - keha grupp */
.snowman-leaning {
    transform: rotate(-5deg) translateX(-5px);
    transition: transform 1s ease;
    transform-origin: bottom center;
    transform-box: fill-box;
}

.snowman-dying {
    transform: rotate(-10deg) translateX(-10px);
    filter: blur(1px);
    transition: all 1s ease;
    transform-origin: bottom center;
    transform-box: fill-box;
}

/* Kuju deformeerumine */
.distorted {
    transform: scale(1.1, 0.9);
}

.puddle {
    transition: all 0.5s ease;
    transform-origin: center bottom;
}

/* Sõna kuvamine */
.word-display {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px 16px;
    min-height: 60px;
    padding: 10px;
    width: 100%;
}

.word-group {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
}

.word-spacer {
    width: 12px;
    flex-shrink: 0;
}

.letter-slot {
    width: 35px;
    height: 45px;
    border-bottom: 3px solid #333;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    color: #333;
    transition: all 0.3s ease;
    /* Klipib tähe "pop" animatsiooni ülevoolu, et ei tekiks hetkelisi kerimisribasid */
    overflow: hidden;
}

.letter-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Suurus: keskmine (13-20 tähte) */
.word-group.size-md { gap: 4px; }
.word-spacer.size-md { width: 10px; }
.letter-slot.size-md {
    width: 28px;
    height: 38px;
    font-size: 20px;
    border-bottom-width: 2px;
}

/* Suurus: väike (21-30 tähte) */
.word-group.size-sm { gap: 3px; }
.word-spacer.size-sm { width: 8px; }
.letter-slot.size-sm {
    width: 24px;
    height: 32px;
    font-size: 16px;
    border-bottom-width: 2px;
}

/* Suurus: väga väike (31+ tähte) */
.word-group.size-xs { gap: 2px; }
.word-spacer.size-xs { width: 6px; }
.letter-slot.size-xs {
    width: 20px;
    height: 28px;
    font-size: 14px;
    border-bottom-width: 2px;
}

.letter-slot.revealed .letter-inner {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); }
}

/* Klaviatuur */
.keyboard {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    max-width: 600px;
    margin: 0 auto;
}

.key-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #dbdbdb;
    border-radius: 4px;
    background-color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #363636;
}

.key-btn:hover:not(:disabled) {
    background-color: #f5f5f5;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.key-btn:active:not(:disabled) {
    transform: translateY(0);
}

.key-btn.correct {
    background-color: #48c774;
    border-color: #48c774;
    color: white;
}

.key-btn.wrong {
    background-color: #f14668;
    border-color: #f14668;
    color: white;
    opacity: 0.5;
}

.key-btn:disabled {
    cursor: not-allowed;
    pointer-events: none;
}

/* Vihje */
.hint-blurred {
    filter: blur(5px);
    cursor: pointer;
    user-select: none;
    transition: filter 0.3s ease;
}

.hint-blurred:hover {
    filter: blur(3px);
}

.hint-revealed {
    filter: blur(0);
    cursor: default;
}

.hint-box {
    cursor: pointer;
}

/* Elud */
.life-heart {
    font-size: 20px;
    margin: 0 2px;
    display: inline-block;
    transition: all 0.3s;
}

.life-heart.lost {
    opacity: 0.2;
    transform: scale(0.8);
    filter: grayscale(100%);
}

/* Result modal */
#result-modal .modal-card {
    border-radius: 8px;
    overflow: hidden;
}

.result-icon {
    font-size: 48px;
}

.result-icon.win {
    color: #48c774;
}

.result-icon.lose {
    color: #f14668;
}

#player-name-field hr {
    background-color: var(--border-color, #ededed);
    height: 1px;
}

#player-name-field .field.has-addons {
    justify-content: center;
}

#player-name-field .control.is-expanded {
    max-width: 260px;
}

/* Fullscreen mode adjustments */
body.fullscreen .navbar {
    display: none !important;
}

body.fullscreen .section {
    padding: 1rem !important;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

body.fullscreen .container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

body.fullscreen #game-view {
    height: 100%;
}

body.fullscreen .columns {
    height: 100%;
    align-items: center;
}

/* Kompaktne vaade tavarežiimis ka */
#game-view .box {
    padding: 1rem;
}

#game-view .level {
    margin-bottom: 1rem !important;
}

/* ========================================
   TUME REŽIIM (Dark Mode)
   ======================================== */

/* Sõna kuvamine - tähtede slotid */
[data-theme="dark"] .letter-slot {
    border-bottom-color: #a1a1aa;
    color: #e4e4e7;
}

/* Klaviatuuri nupud */
[data-theme="dark"] .key-btn {
    background-color: #2a3a5a;
    border-color: #3f3f46;
    color: #e4e4e7;
}

[data-theme="dark"] .key-btn:hover:not(:disabled) {
    background-color: #3a4a6a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

[data-theme="dark"] .key-btn.correct {
    background-color: #22c55e;
    border-color: #22c55e;
    color: white;
}

[data-theme="dark"] .key-btn.wrong {
    background-color: #ef4444;
    border-color: #ef4444;
    color: white;
    opacity: 0.5;
}

/* Vihje kast */
[data-theme="dark"] .hint-box {
    background-color: var(--bg-card);
}

[data-theme="dark"] #hint-text {
    color: #e4e4e7;
}

/* Lumememme kast */
[data-theme="dark"] .snowman-box {
    background-color: var(--bg-card);
}

/* Kategooria tekst */
[data-theme="dark"] #game-category {
    color: #e4e4e7;
}

[data-theme="dark"] .heading {
    color: #a1a1aa;
}

/* Mängu kastid */
[data-theme="dark"] .word-box,
[data-theme="dark"] .keyboard-box {
    background-color: var(--bg-card);
}

[data-theme="dark"] #result-modal #correct-word {
    color: #22d3ee !important;
}

/* Modaali päis tumedas režiimis */
[data-theme="dark"] #result-modal .modal-card-head.has-background-success-light {
    background-color: rgba(34, 197, 94, 0.2) !important;
}

[data-theme="dark"] #result-modal .modal-card-head.has-background-danger-light {
    background-color: rgba(239, 68, 68, 0.2) !important;
}

[data-theme="dark"] #result-modal .modal-card-title {
    color: #e4e4e7;
}

/* Tabid tumedas režiimis */
[data-theme="dark"] .tabs.is-boxed a {
    border-color: #3f3f46;
    color: #a1a1aa;
}

[data-theme="dark"] .tabs.is-boxed li.is-active a {
    background-color: var(--bg-card);
    border-color: #3f3f46;
    border-bottom-color: transparent;
    color: #e4e4e7;
}

/* Sõnakogude ja jagatud mängude elemendid */
[data-theme="dark"] .wl-item {
    background-color: var(--bg-card);
}

[data-theme="dark"] #results-modal .box {
    background-color: var(--bg-card);
    border-left-color: #3298dc;
}

/* Modaalide nuppude vahe */
.modal .modal-card-foot {
    gap: 0.75rem;
}

/* Tabid */
.tabs.is-boxed {
    margin-bottom: 0 !important;
}

.tabs.is-boxed + .tab-content {
    border-top: none;
}

/* Sõnakogu redigeerija */
.wl-item-row {
    margin-bottom: 0.25rem !important;
}

.wl-item-row .input.is-small {
    font-size: 0.85rem;
}

/* Jagatud mängude tabel */
.sg-results-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Tulemuste modaali kokkuvõte */
#results-modal .box {
    border-left: 3px solid var(--accent-color, #3298dc);
}

#results-modal .heading {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .word-display {
        gap: 8px 12px;
    }

    .word-group { gap: 4px; }

    .letter-slot {
        width: 25px;
        height: 35px;
        font-size: 20px;
    }

    .letter-slot.size-md {
        width: 22px;
        height: 30px;
        font-size: 16px;
    }

    .letter-slot.size-sm {
        width: 20px;
        height: 28px;
        font-size: 14px;
    }

    .letter-slot.size-xs {
        width: 18px;
        height: 24px;
        font-size: 12px;
    }

    .key-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .snowman-svg {
        max-height: 200px;
    }

    /* Seadistusvaate nupud üksteise alla */
    #setup-view .field.is-grouped {
        flex-direction: column;
    }
    #setup-view .field.is-grouped .control.is-expanded {
        width: 100%;
    }
    #setup-view .field.is-grouped .button.is-medium {
        font-size: 0.95rem;
    }

    /* Modaal mobiilil */
    #result-modal .modal-card {
        max-width: 95%;
        margin: 0 auto;
    }

    .result-icon {
        font-size: 36px;
    }

    /* Tabid mobiilil */
    .tabs.is-boxed span:not(.icon) {
        font-size: 0.85rem;
    }

    /* Jagatud mängude tabel */
    #shared-games-tab .table td,
    #shared-games-tab .table th {
        font-size: 0.85rem;
        padding: 0.4em 0.5em;
    }
}
