:root {
    --primary-color: #4a90e2;
    --bg-color: #f0f2f5;
    --text-color: #333;
    --cube-bg: #ffffff;
    --cube-shadow: #d1d9e6;
    --cube-depth: #bdc3c7;
    --correct-color: #4caf50;
    --misplaced-color: #ffc107;
    --wrong-color: #f44336;
    --drag-over-color: #e3f2fd;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%234a90e2' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px; /* Added more vertical padding for desktop */
    color: var(--text-color);
}

#game-container {
    width: 100%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 25px;
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 20px;
    user-select: none;
    -webkit-user-select: none;
    border: 4px solid #fff;
}

#game-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
    margin-bottom: 5px;
}

#game-logo {
    width: 45px;
    height: 45px;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1));
}

#game-title {
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary-color), #2c5282);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#category-display {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#level-indicator {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
    color: var(--text-color);
}

#category-name {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--primary-color);
    text-wrap: balance; /* Prevents single words on a new line */
    line-height: 1.2;
}

#level-progress {
    text-align: right;
    width: 150px;
}

#progress-text, #score-display {
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
}

#score-display {
    color: var(--primary-color);
}

#progress-bar-container {
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #64b5f6);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#icon-container {
    display: flex;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle, #ffffff 0%, #f8f9fa 100%);
    border-radius: 15px;
    min-height: 180px;
    align-items: center;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.02);
    position: relative;
}

#hint-btn, #skip-btn {
    position: absolute;
    bottom: 10px;
    padding: 8px 15px;
    background: #fff;
    border: none;
    border-radius: 20px;
    box-shadow: 0 4px 0 #ddd, 0 6px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s;
}

#hint-btn { right: 10px; }
#skip-btn { left: 10px; }

#hint-btn:active, #skip-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #ddd, 0 3px 5px rgba(0,0,0,0.1);
}

#hint-btn:disabled, #skip-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

#current-icon {
    max-width: 160px;
    max-height: 160px;
    object-fit: contain;
    filter: drop-shadow(0 5px 15px rgba(0,0,0,0.1));
}

#answer-container {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap; /* Prevent wrapping to next line */
    min-height: 70px;
    padding: 10px;
    width: 100%;
}

.answer-slot {
    flex: 0 1 48px; /* Allow shrinking but max width 48px */
    aspect-ratio: 1 / 1;
    height: auto;
    border: 3px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.6rem;
    font-weight: 800;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0; /* Required for flex-shrink */
}

.answer-slot.drag-over {
    border-color: var(--primary-color);
    background-color: var(--drag-over-color);
    transform: scale(1.1) translateY(-5px);
    border-style: dashed;
}

.answer-slot.selected {
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 15px rgba(74, 144, 226, 0.3);
    border-width: 4px;
    transform: translateY(-2px);
}

/* Volumetric (3D) Look for filled slots and cubes */
.answer-slot.filled, .letter-cube {
    background: var(--cube-bg);
    border: none;
    box-shadow: 
        0 4px 0 var(--cube-depth),
        0 8px 15px rgba(0,0,0,0.1);
    transform: translateY(-4px) rotate(var(--rand-rot, 0deg));
    font-size: clamp(1rem, 5vw, 1.6rem); /* Responsive font size */
}

.answer-slot.filled {
    cursor: pointer;
    color: white;
}

/* Feedback Colors */
.answer-slot.status-correct {
    background: var(--correct-color);
    box-shadow: 0 4px 0 #388e3c, 0 8px 15px rgba(76, 175, 80, 0.3);
}

.answer-slot.status-misplaced {
    background: var(--misplaced-color);
    box-shadow: 0 4px 0 #f57f17, 0 8px 15px rgba(255, 193, 7, 0.3);
}

.answer-slot.status-wrong {
    background: var(--wrong-color);
    box-shadow: 0 4px 0 #c62828, 0 8px 15px rgba(244, 67, 54, 0.3);
}

.answer-slot.is-hint {
    opacity: 0.6;
    border-style: solid;
    background: #fdfdfd;
    color: #aaa;
    pointer-events: none;
    box-shadow: 0 2px 0 #eee;
    transform: none;
}

#letter-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px;
    justify-content: center;
    align-content: center;
    min-height: 200px;
    transition: background-color 0.3s;
    perspective: 1000px;
}

#letter-pool.drag-over {
    background-color: var(--drag-over-color);
    border-radius: 15px;
}

.letter-cube {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: grab;
    user-select: none;
    text-transform: uppercase;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s, opacity 0.3s;
    background: var(--cube-bg);
    box-shadow: 
        0 5px 0 var(--cube-depth), 
        0 10px 20px rgba(0,0,0,0.1);
    transform: 
        rotate(var(--rand-rot, 0deg)) 
        translate(var(--rand-x, 0px), var(--rand-y, 0px));
    position: relative;
    z-index: 1;
}

.letter-cube:hover {
    z-index: 10;
    transform: 
        translateY(-8px) 
        rotate(calc(var(--rand-rot, 0deg) * 1.5)) 
        scale(1.1);
    box-shadow: 0 12px 0 var(--cube-depth), 0 15px 30px rgba(0,0,0,0.15);
}

.letter-cube:active {
    transform: translateY(0) rotate(0deg) scale(0.95);
    box-shadow: 0 2px 0 var(--cube-depth), 0 4px 8px rgba(0,0,0,0.1);
    cursor: grabbing;
}

.letter-cube.dragging {
    opacity: 0.3;
    transform: scale(0.8);
}

.dragging-ghost {
    opacity: 0.9;
    pointer-events: none;
    transition: none !important;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4) !important;
    z-index: 2000;
}

.letter-cube.used {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.5);
}

.letter-cube.confirmed-wrong {
    background: #ffebee;
    color: var(--wrong-color);
    box-shadow: 0 4px 0 #ef9a9a;
    opacity: 0.6;
}

.letter-cube.confirmed-misplaced {
    background: var(--misplaced-color);
    color: white;
    box-shadow: 0 4px 0 #f57f17;
}

.letter-cube.confirmed-correct {
    background: var(--correct-color);
    color: white;
    box-shadow: 0 4px 0 #388e3c;
}

/* Modal Improvements */
#message-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

#message-content {
    background: white;
    padding: 35px;
    border-radius: 35px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2);
    text-align: center;
    width: 90%;
    max-width: 420px;
    border: 6px solid var(--primary-color);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#message-container.hidden {
    opacity: 0;
    pointer-events: none;
}

#message-container.hidden #message-content {
    transform: scale(0.7) translateY(40px);
}

#message-text {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 10px;
}

#message-details {
    margin-bottom: 25px;
    color: #666;
    line-height: 1.5;
}

#message-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 25px;
    border: none;
    border-radius: 18px;
    font-size: 1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 0 #3a76bb;
}

.modal-btn.secondary {
    background: #edf2f7;
    color: #4a5568;
    box-shadow: 0 4px 0 #cbd5e0;
}

.modal-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.modal-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}


footer {
    margin-top: 10px;
    text-align: center;
    font-size: 0.8rem;
    color: #888;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 500px) {
    body {
        background: #fff;
        align-items: flex-start;
        padding: 0; /* Reset body padding for mobile */
    }
    
    #game-container {
        max-width: 100%;
        border-radius: 0;
        box-shadow: none;
        border: none;
        min-height: 100vh;
        padding: 15px;
        gap: 15px;
        justify-content: space-between; /* Spread content and push footer down */
    }

    #icon-container {
        min-height: 150px;
        padding: 10px;
    }

    #current-icon {
        max-width: 140px;
        max-height: 140px;
    }

    .letter-cube {
        width: 48px;
        height: 48px;
        font-size: 1.2rem;
        border-radius: 12px;
    }

    .answer-slot {
        flex: 0 1 42px;
        font-size: 1.4rem;
        border-radius: 12px;
    }

    #message-content {
        padding: 25px;
        border-radius: 25px;
    }

    #message-text {
        font-size: 1.8rem;
    }
}
