/* === GENERAL LAYOUT === */
@import url('https://fonts.googleapis.com/css2?family=Noto+Color+Emoji:wght@400&display=swap');

body {
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    text-align: center;
    margin: 0;
    background-color: #f0f0f0;
    color: #222;
}

.container {
    text-align: center;
    margin-top: 50px;
    position: relative;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.8);
}

.game-container {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    display: inline-block;
    width: 100%;
    max-width: 1200px; /* or your chosen width */
    box-sizing: border-box;
    min-height: 900px;   /* Add this line for minimum height */
    height: 100vh;       /* Or set a fixed height, e.g., 900px */
}

.button-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 6px;
    margin-top: 6px;
    flex-direction: column;
    width: 100%;
    padding: 0;
}

#language-box {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 8px;
}

.lang-btn {
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1.5px solid #b3c6e0;
    background: #f5faff;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.18s, box-shadow 0.18s, transform 0.18s;
    outline: none;
    margin: 2px 0;
}
.lang-btn.active, .lang-btn:focus {
    background: #e0e7ef;
    border-color: #60a5fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.lang-btn .pick-alt-label {
    display: block;
    font-size: 11px;
    color: #555;
    margin-top: 2px;
    text-align: left;
}

.flag-emoji {
    font-size: 1.5em;
    margin-right: 6px;
    vertical-align: middle;
    font-family: 'Noto Color Emoji', 'Segoe UI Emoji', 'Apple Color Emoji', 'Segoe UI Symbol', sans-serif;
    display: inline-block;
    line-height: 1;
    /* Ensure flags render properly on Windows */
    -webkit-font-feature-settings: "liga" 1, "dlig" 1, "emoji" 1;
    font-feature-settings: "liga" 1, "dlig" 1, "emoji" 1;
    /* Force emoji rendering */
    -webkit-text-rendering: optimizeLegibility;
    text-rendering: optimizeLegibility;
    font-variant-emoji: emoji;
}

/* Fallback for systems that don't support flag emojis */
@supports not (font-family: 'Noto Color Emoji') {
    .flag-emoji {
        font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Segoe UI Symbol', sans-serif;
    }
}

/* Additional fallback for Windows systems */
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .flag-emoji {
        font-family: 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
    }
}

/* Force emoji rendering on Windows */
@media screen and (max-width: 9999px) {
    .flag-emoji {
        font-family: 'Noto Color Emoji', 'Segoe UI Emoji', 'Apple Color Emoji', 'Segoe UI Symbol', sans-serif !important;
        font-variant-emoji: emoji;
        -webkit-font-feature-settings: "emoji" 1;
        font-feature-settings: "emoji" 1;
    }
}



/* === BUTTONS === */
button {
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    margin: 5px;
    border-radius: 6px;
    border: 1px solid #b3c6e0;
    background: #f5faff;
    transition: background 0.18s, box-shadow 0.18s;
}
button:active, button:focus {
    background: #e0e7ef;
    outline: none;
}

#start-btn, #stop-btn, #new-game-button {
    min-width: 120px;
}

#instructions-button {
    width: auto;
    font-weight: bold;
    border-radius: 8px;
    background: #e0e7ef;
    border: 1.5px solid #60a5fa;
}

.hide {
    display: none !important;
}

/* === WORD DISPLAY === */
.word-display {
    font-size: 24px;
    margin-top: 20px;
    letter-spacing: 0.1em;
    font-family: 'Consolas', 'Courier New', monospace;
    word-break: break-all;
}

/* === HANGMAN CANVAS === */
#hangman-canvas {
    margin-top: 20px;
    border: 1px solid #ccc;
    background: #fff;
    border-radius: 6px;
}

/* === LETTER KEYPAD === */
.letter-container {
    width: 75%;
    max-width: 700px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
    gap: 0.3em;
    justify-content: center;
    margin: 20px auto;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    padding-bottom: 8px;
    scrollbar-color: #888 #eee;
    scrollbar-width: thin;
}
.letter-container::-webkit-scrollbar {
    height: 8px;
    background: #eee;
}
.letter-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#letter-container button {
    height: 35px;
    width: 100%;
    border-radius: 0.2em;
    background-color: #ffffff;
    cursor: pointer;
    border: 1px solid #b3c6e0;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s;
}

#letter-container button.active {
    background-color: #ffe066;
}

#letter-container button.hyphen-button {
    background-color: #2563eb;
    color: white;
    animation: flash-slow 2s infinite;
}

#letter-container button.guessed {
    background-color: #60a5fa;
    color: white;
}

/* === LOG CONTAINER === */
#log-container {
    background-color: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    padding: 10px;
    margin-top: 20px;
    width: 100%;
    height: 150px;
    overflow-y: auto;
    word-wrap: break-word;
    position: static;
    box-sizing: border-box;
    font-size: 15px;
    border-radius: 0 0 10px 10px;
    margin-left: 0;
    margin-right: 0;
}
#log-container div {
    margin: 5px 0;
    padding: 5px;
    border-radius: 3px;
}

/* Hide scrollbar but allow scrolling */
#log-container::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}
#log-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* === POPUPS === */
.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    width: 80%;
    max-width: 600px;
    padding: 20px;
    animation: popup-fadein 0.7s;
}

.popup-content {
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
}

/* === HINT BOX === */
.hint-box {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    background-color: rgba(255, 255, 255, 0.95);
    border: 2px solid #676767;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    color: #333;
    max-width: 260px;
    z-index: 100;
    text-align: left;
}

/* === LANGUAGE SELECTION POPUP === */
#lang-select-popup {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popup-fadein 0.7s;
}

.lang-popup-content {
    background: linear-gradient(135deg, #f8fafc 60%, #e0e7ef 100%);
    border-radius: 18px;
    padding: 36px 28px 28px 28px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    min-width: 260px;
    max-width: 95vw;
    animation: popup-bouncein 0.7s cubic-bezier(.68,-0.55,.27,1.55);
    border: 2px solid #b3c6e0;
    position: relative;
    overflow: hidden;
}

#lang-select-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}
#lang-select-buttons button {
    font-size: 1.25em;
    padding: 14px 28px;
    border-radius: 10px;
    border: 1.5px solid #b3c6e0;
    background: #f5faff;
    margin: 0 0 6px 0;
    cursor: pointer;
    width: 260px;
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: flex-start;
    transition: background 0.18s, box-shadow 0.18s, transform 0.18s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    font-weight: 500;
    letter-spacing: 0.01em;
    outline: none;
    border-bottom: 3px solid #dbeafe;
    position: relative;
    overflow: hidden;
}
#lang-select-buttons button:hover, #lang-select-buttons button:focus {
    background: #e0e7ef;
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    transform: scale(1.03) translateY(-2px);
    border-color: #60a5fa;
}
#lang-select-buttons button .flag-emoji {
    font-size: 2em;
    filter: drop-shadow(0 1px 2px #b3c6e0);
    margin-right: 10px;
    transition: transform 0.2s;
    font-family: 'Noto Color Emoji', 'Segoe UI Emoji', 'Apple Color Emoji', 'Segoe UI Symbol', sans-serif;
    display: inline-block;
    line-height: 1;
}
#lang-select-buttons button:hover .flag-emoji {
    transform: scale(1.15) rotate(-6deg);
}
#lang-select-popup h2 {
    font-size: 2em;
    margin-bottom: 24px;
    color: #2563eb;
    letter-spacing: 0.01em;
    font-weight: 700;
    text-shadow: 0 2px 8px #e0e7ef;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    animation: popup-title-fadein 1.2s;
}

/* === ANIMATIONS === */
@keyframes popup-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes popup-bouncein {
    0% { transform: scale(0.7) translateY(60px); opacity: 0; }
    60% { transform: scale(1.05) translateY(-8px); opacity: 1; }
    80% { transform: scale(0.98) translateY(2px);}
    100% { transform: scale(1) translateY(0);}
}
@keyframes popup-title-fadein {
    from { opacity: 0; transform: translateY(-30px);}
    to { opacity: 1; transform: translateY(0);}
}
@keyframes flash {
    0%, 100% { background-color: #60a5fa; }
    50% { background-color: #fff; }
}
@keyframes flash-slow {
    0%, 100% { background-color: #60a5fa; }
    50% { background-color: #fff; }
}
.flashing {
    animation: flash 1s infinite;
}
.flashing-slow {
    animation: flash-slow 2s infinite;
}

/* === RESPONSIVE DESIGN === */
@media screen and (max-width: 768px) {
    .game-container {
        padding: 10px 0;
        width: 100%;
        margin: 0;
        transform: scale(0.9);
        border-radius: 0;
        max-width: 100vw;
    }
    .letter-container {
        width: 100%;
        grid-template-columns: repeat(7, 1fr);
        gap: 0.2em;
    }
    #letter-container button {
        height: 30px;
        font-size: 12px;
        padding: 0;
    }
    #hangman-canvas {
        width: 120px;
        height: 120px;
    }
    .word-display {
        font-size: 20px;
        margin-top: 10px;
    }
    #log-container {
        width: 100%;
        height: 120px; /* or 100px/80px as needed */
        font-size: 14px;
        border-radius: 0 0 10px 10px;
        margin-left: 0;
        margin-right: 0;
    }
    button {
        padding: 8px 16px;
        font-size: 14px;
        margin: 3px;
    }
    .popup {
        width: 90%;
        padding: 15px;
    }
    .popup-content {
        font-size: 14px;
    }
    .container {
        margin: 0;
        width: 100%;
    }
    #lang-select-buttons button {
        width: 90vw;
        font-size: 1.1em;
        padding: 12px 10px;
    }
    .lang-popup-content {
        padding: 18px 4vw 18px 4vw;
    }
}

@media screen and (max-width: 480px) {
    body {
        margin: 0;
    }
    .container {
        margin: 0;
        width: 100%;
    }
    .game-container {
        width: 100%;
        transform: scale(0.85);
        transform-origin: top center;
        border-radius: 0;
        margin: 0;
        padding: 10px 0;
        max-width: 100vw;
    }
    .letter-container {
        grid-template-columns: repeat(6, 1fr);
    }
    #letter-container button {
        height: 25px;
        font-size: 11px;
    }
    .word-display {
        font-size: 18px;
    }
    #hangman-canvas {
        width: 100px;
        height: 100px;
    }
    button {
        padding: 6px 12px;
        font-size: 12px;
    }
    #log-container {
        width: 100%;
        height: 120px; /* or 100px/80px as needed */
        font-size: 14px;
        border-radius: 0 0 10px 10px;
        margin-left: 0;
        margin-right: 0;
    }
}

@media screen and (max-width: 320px) {
    .game-container {
        transform: scale(0.8);
        width: 100%;
        margin: 0;
        padding: 10px 0;
    }
    #log-container {
        width: 100%;
        height: 120px; /* or 100px/80px as needed */
        font-size: 14px;
        border-radius: 0 0 10px 10px;
        margin-left: 0;
        margin-right: 0;
    }
}