* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

.container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.clear-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.clear-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.new-word-button {
    background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(86, 171, 47, 0.4);
}

.new-word-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(86, 171, 47, 0.6);
}

.new-word-button:active {
    transform: translateY(0);
}

.word-display {
    display: none;
    /* Hidden used for internal logic or debug if needed */
}

.level-indicator {
    font-size: 18px;
    font-weight: 600;
    color: #667eea;
}

.canvas-wrapper {
    display: flex;
    background: #f5f1e8;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    /* Parchment texture using CSS */
    background-image:
        repeating-linear-gradient(0deg,
            transparent,
            transparent 2px,
            rgba(139, 119, 101, 0.03) 2px,
            rgba(139, 119, 101, 0.03) 4px),
        repeating-linear-gradient(90deg,
            transparent,
            transparent 2px,
            rgba(139, 119, 101, 0.03) 2px,
            rgba(139, 119, 101, 0.03) 4px);
}

.guides-column {
    width: 60px;
    flex-shrink: 0;
    /* Prevent column from being squashed in portrait */
    background: rgba(255, 255, 255, 0.3);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 0;
    position: relative;
    pointer-events: none;
}

.guide-icon {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    opacity: 0.6;
    filter: grayscale(0.2);
}

#drawingCanvas {
    display: block;
    width: 100%;
    height: 600px;
    cursor: crosshair;
    touch-action: none;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    #drawingCanvas {
        height: min(600px, calc(100vh - 200px));
    }

    .guides-column {
        width: 45px;
    }

    .guide-icon {
        font-size: 18px;
    }

    .controls {
        padding: 12px 20px;
    }

    .clear-button {
        padding: 10px 25px;
        font-size: 14px;
    }

    .level-indicator {
        font-size: 16px;
    }
}

/* iPad specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    #drawingCanvas {
        height: 700px;
    }
}

/* New Controls Layout */
.controls {
    display: flex !important;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.settings-group {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.settings-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.settings-item label {
    font-size: 14px;
    font-weight: bold;
    color: #764ba2;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Setting Buttons */
.setting-val {
    background: #fff;
    border: 2px solid #764ba2;
    color: #764ba2;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    min-width: 80px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.setting-val:active {
    background: #764ba2;
    color: #fff;
    transform: scale(0.95);
}

/* Settings Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.3s;
}

.overlay.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: white;
    padding: 2.5rem;
    border-radius: 25px;
    text-align: center;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.4);
}

#overlayTitle {
    margin-bottom: 2rem;
    color: #2c3e50;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    margin-bottom: 2rem;
}

.option-btn {
    background: #f8f9ff;
    border: 2px solid #b5c1fb;
    color: #333;
    padding: 20px 10px;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:active {
    background: #764ba2;
    border-color: #764ba2;
    color: white;
    transform: scale(0.9);
}

.option-btn.active {
    background: #764ba2;
    color: white;
    border-color: #764ba2;
}

.close-overlay {
    background: #eee;
    border: none;
    color: #666;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
}

.version-tag {
    position: fixed;
    bottom: 10px;
    right: 15px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-family: monospace;
    pointer-events: none;
}

/* Game Progression - Mercurial Thermometer */
.progress-section {
    width: 100%;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.thermometer-container {
    width: 100%;
    max-width: 400px;
    height: 30px;
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 20px;
    /* Room for the bulb */
}

.thermometer-bulb {
    width: 36px;
    height: 36px;
    background: radial-gradient(circle at 30% 30%, #f0f0f0, #adb5bd, #6c757d);
    border: 3px solid #fff;
    border-radius: 50%;
    position: absolute;
    left: 0;
    transform: translate(-50%, 0);
    /* Center on the leading edge */
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset -4px -4px 8px rgba(0, 0, 0, 0.4);
    transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.thermometer-tube {
    flex-grow: 1;
    height: 18px;
    background: rgba(255, 255, 255, 0.4);
    border: 2px solid #fff;
    border-radius: 0 20px 20px 0;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(2px);
}

.thermometer-mercury {
    height: 100%;
    width: 0%;
    /* Dynamic */
    background: linear-gradient(to bottom, #f8f9fa 0%, #ced4da 50%, #adb5bd 100%);
    border-radius: 0 10px 10px 0;
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* Splash Animation */
.thermometer-mercury.splash {
    animation: mercury-splash 0.5s ease-out;
}

@keyframes mercury-splash {
    0% {
        filter: brightness(1) contrast(1);
    }

    50% {
        filter: brightness(1.4) contrast(1.2);
        transform: scaleY(1.1);
    }

    100% {
        filter: brightness(1) contrast(1);
        transform: scaleY(1);
    }
}

/* Metallic Shine / Mercury Highlight */
.thermometer-mercury::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}

.progress-label {
    font-family: 'Segoe UI', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: #4a4a4a;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Re-adjusting mobile spacing for the new section */
@media (max-width: 768px) {
    .progress-section {
        margin-top: 10px;
    }

    .thermometer-container {
        max-width: 280px;
    }
}

.progress-display {
    font-family: 'Segoe UI', sans-serif;
    font-weight: bold;
    color: #2c3e50;
    margin: 0 10px;
    font-size: 1.1rem;
}

/* Modal Overlay */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex !important;
    /* Force flex */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    font-family: sans-serif;
    max-width: 90%;
    width: 400px;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 2rem;
}

.modal-content p {
    font-size: 1.2rem;
    color: #4a4a4a;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

#playAgainBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s;
}

#playAgainBtn:hover {
    transform: scale(1.05);
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#vocabModal {
    /* Using default modal styles (centered, dark overlay) */
    align-items: center !important;
}

#vocabModal .vocab-content {
    border: 5px solid #764ba2;
    padding: 2.5rem;
    width: 600px;
    max-width: 95%;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

#vocabModal h2 {
    font-size: 1.8rem;
    margin-bottom: 0.2rem;
    color: #764ba2;
}

.vocab-target-word {
    font-size: 3.5rem;
    font-weight: 800;
    color: #2c3e50;
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    font-family: 'Segoe UI', sans-serif;
}

.vocab-grid {
    display: flex;
    justify-content: center;
    gap: 25px;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.vocab-option {
    background: #f8f9ff;
    border: 4px solid #b5c1fb;
    border-radius: 20px;
    width: 150px;
    height: 150px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.vocab-option svg,
.vocab-option img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.vocab-option:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.vocab-option.correct {
    border-color: #a8e063;
    background: #e8f5e9;
    transform: scale(1.1);
}

.vocab-option.incorrect {
    border-color: #ff6b6b;
    background: #ffebee;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    50% {
        transform: translateX(10px);
    }

    75% {
        transform: translateX(-10px);
    }
}