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

:root {
    --bg-dark: #0a0a0e;
    --bg-darker: #050508;
    --container-bg: rgba(12, 12, 18, 0.96);
    --text-color: #e0e0e8;
    --text-secondary: #9898a8;
    --gold: #f0b030;
    --gold-light: #ffc850;
    --ruby: #dd2244;
    --emerald: #22dd66;
    --sapphire: #3388ee;
    --amethyst: #aa44dd;
    --topaz: #f0a010;
    --diamond: #e8e8ff;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #0c0c12 0%, #060608 60%, #040406 100%);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 10px;
    overflow: hidden;
}

/* Radial golden glow from above (spotlight effect) */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 120%;
    height: 60%;
    background: radial-gradient(ellipse at center, rgba(240, 176, 48, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.game-container {
    background: var(--container-bg);
    border-radius: 16px;
    padding: 12px 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 600px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: none;
    position: relative;
    z-index: 1;
}

.game-container::-webkit-scrollbar {
    display: none;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.header h1 {
    color: #fff;
    font-size: 1.8rem;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 2px 4px rgba(0, 0, 0, 0.8);
    flex: 1;
    letter-spacing: 3px;
    font-weight: 900;
}

/* Hamburger Button */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 3px;
    background: #888;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger:hover span {
    background: #fff;
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Slide Menu */
.slide-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 280px;
    height: 100%;
    background: rgba(10, 10, 16, 0.98);
    box-shadow: 5px 0 20px rgba(0, 0, 0, 0.6);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}

.slide-menu.active {
    left: 0;
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.menu-header h2 {
    color: #fff;
    font-size: 1.4rem;
}

.close-menu {
    background: none;
    border: none;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
    line-height: 1;
}

.close-menu:hover {
    color: var(--ruby);
}

.menu-content {
    padding: 20px;
}

.menu-section {
    margin-bottom: 25px;
}

.menu-section h3 {
    color: var(--sapphire);
    font-size: 1rem;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-home-link {
    display: block;
    padding: 12px 16px;
    background: linear-gradient(145deg, var(--sapphire), #2266cc);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
}

.menu-home-link:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(51, 136, 238, 0.3);
}

.menu-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.menu-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--sapphire);
}

/* New Game Button */
#newGameBtn {
    background: linear-gradient(145deg, var(--emerald), #1ab855);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    box-shadow: 0 3px 0 #168a40, 0 4px 10px rgba(0, 0, 0, 0.3);
}

#newGameBtn:hover {
    filter: brightness(1.15);
    transform: scale(1.05);
}

/* Hangman Area */
.hangman-area {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    /* min-height: 0; */
    /* max-height: 280px; */
    margin-top: 40px;
    background:
        radial-gradient(ellipse 50% 45% at 50% 8%, rgba(255, 200, 60, 0.18) 0%, transparent 55%),
        radial-gradient(ellipse 30% 25% at 50% 5%, rgba(255, 220, 100, 0.1) 0%, transparent 40%),
        linear-gradient(180deg, #08080c 0%, #040406 100%);
    border-radius: 12px;
    padding: 5px 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}

#hangman {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
}

.body-part {
    stroke-width: 6;
    fill: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.body-part.visible {
    opacity: 1;
}

/* Jewel-colored body parts */
#head { stroke: var(--emerald); stroke-width: 3; }
#head.visible {
    fill: var(--emerald);
    filter: drop-shadow(0 0 10px rgba(34, 221, 102, 0.7));
}

#body { stroke: var(--amethyst); }
#body.visible { filter: drop-shadow(0 0 8px rgba(170, 68, 221, 0.6)); }

#leftArm, #rightArm { stroke: var(--sapphire); }
#leftArm.visible, #rightArm.visible { filter: drop-shadow(0 0 8px rgba(51, 136, 238, 0.6)); }

#leftLeg, #rightLeg { stroke: var(--ruby); }
#leftLeg.visible, #rightLeg.visible { filter: drop-shadow(0 0 8px rgba(221, 34, 68, 0.6)); }

#leftHand, #rightHand { stroke: var(--topaz); stroke-width: 2; }
#leftHand.visible, #rightHand.visible { fill: var(--topaz); filter: drop-shadow(0 0 8px rgba(240, 160, 16, 0.6)); }

#leftFoot, #rightFoot { stroke: var(--diamond); stroke-width: 2; }
#leftFoot.visible, #rightFoot.visible { fill: var(--diamond); filter: drop-shadow(0 0 8px rgba(232, 232, 255, 0.6)); }

/* Word Display - dynamic sizing */
.word-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px 8px;
    margin: 8px 0;
    padding: 0 15px;
    min-height: 40px;
}

.word-group {
    display: inline-flex;
    gap: var(--letter-gap, 3px);
    white-space: nowrap;
}

.letter-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--letter-size, 28px);
    height: calc(var(--letter-size, 28px) * 1.2);
    font-size: calc(var(--letter-size, 28px) * 0.7);
    font-weight: bold;
    color: var(--text-color);
    border-bottom: 3px solid rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
}

/* Hint Section */
.hint-section {
    margin: 4px 0 6px 0;
    flex-shrink: 0;
}

#hintBtn {
    background: linear-gradient(145deg, var(--amethyst), #8833bb);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 0 #662299, 0 4px 10px rgba(0, 0, 0, 0.3);
}

#hintBtn:hover {
    transform: scale(1.05);
    filter: brightness(1.15);
}

#hintBtn:disabled {
    background: linear-gradient(145deg, #2a2a30, #1a1a20);
    color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: none;
}

#playAgainBtn {
    background: linear-gradient(145deg, var(--emerald), #1ab855);
    color: #fff;
    border: none;
    padding: 10px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 3px 0 #168a40, 0 4px 10px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
}

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

.hint-text {
    margin-top: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.9), rgba(15, 15, 22, 0.9));
    border: 1px solid rgba(170, 68, 221, 0.3);
    border-radius: 10px;
    color: #ddb0ff;
    font-size: 1rem;
    font-style: italic;
    display: none;
    animation: fadeInHint 0.3s ease;
}

.hint-text.visible {
    display: block;
}

@keyframes fadeInHint {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 40px;
    margin-bottom: 40px;
    padding-top: 6px;
    flex-shrink: 0;
}

/* Colorful 3D block keys */
.key {
    width: 36px;
    height: 42px;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Color variants for scattered block effect */
.key.key-red {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    box-shadow: 0 4px 0 #962d22, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.key.key-green {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    box-shadow: 0 4px 0 #1e8449, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.key.key-orange {
    background: linear-gradient(145deg, #f39c12, #e67e22);
    box-shadow: 0 4px 0 #c06808, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.key.key-blue {
    background: linear-gradient(145deg, #3498db, #2980b9);
    box-shadow: 0 4px 0 #1f6591, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.key.key-purple {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    box-shadow: 0 4px 0 #6c3483, 0 6px 10px rgba(0, 0, 0, 0.3);
}

.key:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.key:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 1px 0 currentColor, 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key:disabled {
    cursor: not-allowed;
    transform: none;
}

.key.correct {
    background: linear-gradient(145deg, #2ecc71, #27ae60) !important;
    box-shadow: 0 4px 0 #1e8449, 0 0 12px rgba(46, 204, 113, 0.4) !important;
    animation: correctPulse 0.3s ease;
}

.key.incorrect {
    background: linear-gradient(145deg, #1a1a22, #101018) !important;
    box-shadow: 0 2px 0 #08080c, 0 3px 6px rgba(0, 0, 0, 0.3) !important;
    opacity: 0.4;
    color: #555;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Slight random rotations applied via JS classes */
/* .key.tilt-1 { transform: rotate(-2deg); }
.key.tilt-2 { transform: rotate(1.5deg); }
.key.tilt-3 { transform: rotate(-1deg); }
.key.tilt-4 { transform: rotate(2deg); }
.key.tilt-5 { transform: rotate(0deg); }

.key:hover:not(:disabled).tilt-1,
.key:hover:not(:disabled).tilt-2,
.key:hover:not(:disabled).tilt-3,
.key:hover:not(:disabled).tilt-4,
.key:hover:not(:disabled).tilt-5 {
    transform: translateY(-2px) rotate(0deg);
} */

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: rgba(12, 12, 18, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 35px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: slideIn 0.4s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content.win {
    border: 4px solid var(--emerald);
}

.modal-content.win h2 {
    color: var(--emerald);
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-content.win::before {
    content: "\1F389";
    font-size: 3.5rem;
    display: block;
    margin-bottom: 10px;
    animation: bounce 0.5s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.modal-content.lose {
    border: 4px solid var(--ruby);
}

.modal-content.lose h2 {
    color: var(--ruby);
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-content.lose::before {
    content: "\1F480";
    font-size: 3.5rem;
    display: block;
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 10px 0;
}

.word-reveal {
    font-size: 1rem;
    margin: 15px 0;
}

.word-reveal span {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #fff;
}

.modal-content button {
    background: linear-gradient(145deg, var(--emerald), #1ab855);
    color: #fff;
    border: none;
    padding: 12px 35px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 3px 0 #168a40, 0 4px 10px rgba(0, 0, 0, 0.3);
}

.modal-content button:hover {
    transform: scale(1.05);
    filter: brightness(1.15);
}

/* How to Play Modal */
.modal-content.how-to-play {
    border-color: rgba(255, 255, 255, 0.15);
}

.modal-content.how-to-play h2 {
    color: #fff;
    font-size: 1.6rem;
    margin-bottom: 15px;
}

.how-to-play-body {
    text-align: left;
    margin-bottom: 10px;
}

.how-to-play-body p {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: left;
}

.how-to-play-body ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.how-to-play-body li {
    color: var(--text-secondary);
    font-size: 0.95rem;
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.how-to-play-body li::before {
    content: '\2022';
    color: var(--emerald);
    position: absolute;
    left: 4px;
}

.how-to-play-body li strong {
    color: #fff;
}

/* Responsive */
@media (max-width: 500px) {
    body {
        padding: 0;
    }

    .game-container {
        padding: 10px 12px;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .header h1 {
        font-size: 1.3rem;
    }

    .key {
        width: 28px;
        height: 34px;
        font-size: 0.8rem;
    }

    .keyboard {
        gap: 6px;
    }

    #newGameBtn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* .hangman-area {
        padding: 8px;
    } */

    #hintBtn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    .hint-text {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
}

@media (max-height: 700px) {
    /* .hangman-area {
        padding: 2px 8px;
        max-height: 220px;
    } */

    .header {
        margin-bottom: 3px;
    }

    .word-display {
        margin: 5px 0;
    }

    .hint-section {
        margin: 2px 0 4px 0;
    }

    #hintBtn {
        padding: 6px 14px;
        font-size: 0.8rem;
    }

    .keyboard {
        padding-top: 4px;
    }
}
