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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #073b6e;
    font-family: Arial, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#game-container {
    display: flex;
    flex-direction: column;
    /* Use viewport width but constrain by max-width and keep a fixed aspect ratio */
    width: 100vw;
    max-width: 420px;
    height: auto;
    position: relative;
    margin: 0 auto;
    aspect-ratio: 9 / 16; /* preferred modern browsers */
}

canvas {
    display: block;
    width: 100% !important;
    height: auto !important; /* let the canvas keep its aspect ratio */
}

.input-container {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: 10px;
    position: fixed;
    top: 380px;
    left: 50%;
    transform: translateX(-50%);
    transition: all 0.3s ease;
}

.word-group {
    display: flex;
    gap: 4px;
}

.word-group + .word-group {
    margin-left: 20px;
}

.word-separator {
    width: 20px;
    height: 34px;
}

@media (min-width: 421px) {
    #game-container {
        width: 420px;
    }
    
    .input-container {
        /* left: calc(50% + (100vw - 420px)/6); */
    }
}

/* Fallback for browsers that don't support aspect-ratio: maintain ratio by forcing height via viewport math */
@supports not (aspect-ratio: 1/1) {
    #game-container {
        /* padding hack: height = (DESIGN_HEIGHT / DESIGN_WIDTH) * width */
        height: calc(100vw * 800 / 420);
        max-height: 100vh;
    }
    @media (min-width: 421px) {
        #game-container { height: calc(420px * 800 / 420); }
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

@keyframes blink {
    0%, 50%, 100% { border-color: #27ae60; box-shadow: 0 0 10px rgba(39, 174, 96, 0.5) !important; }
    25%, 75% { border-color: #2ecc71; box-shadow: 0 0 15px rgba(46, 204, 113, 0.8) !important; }
}

.letter-input {
    width: 34px;
    height: 34px;
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #3498db;
    border-radius: 6px;
    background: white;
    text-transform: uppercase;
    outline: none;
    cursor: pointer;
    user-select: none;
    autocomplete: off;
    autocorrect: off;
    autocapitalize: off;
    spellcheck: false;
    transition: all 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .letter-input:hover {
        border-color: #2980b9;
        box-shadow: 0 0 6px rgba(41, 128, 185, 0.4);
    }
}

.letter-input:focus {
    border-color: #2980b9;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.letter-input.error {
    border-color: #e74c3c;
    animation: shake 0.2s ease-in-out;
}

.letter-input.correct {
    border-color: #27ae60 !important;
    background: #e7fff1;
    animation: blink 0.8s ease-in-out;
}

.letter-input.space {
    visibility: hidden;
}

.letter-input.active {
    border-color: #f1c40f !important;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.75) !important;
    background: #fffef2;
    transform: scale(1.05);
}

.letter-input.helper-filled {
    background-color: #f1c40f !important;
    color: #2c3e50 !important;
    border-color: #f39c12 !important;
    font-weight: bold;
}

.helper-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* gap: 80px; */
    /* position: fixed; */
    width: 380px;
    top: 490px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.helper-button {
    width: 40px;
    height: 40px;
    position: relative;
}

/* ========================================================
   INTERACTIVE TUTORIAL OVERLAY & SPOTLIGHT SYSTEM
   ======================================================== */
.tutorial-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    overflow: hidden;
    font-family: 'Baloo 2', Arial, sans-serif;
    pointer-events: none; /* Allows pointer pass-through by default; interactive child elements enable pointer-events */
    opacity: 0;
    transition: opacity 0.35s ease;
}

.tutorial-overlay.active {
    opacity: 1;
}

/* Dark scrim background that dims the non-highlighted areas */
.tutorial-scrim {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto; /* Blocks background clicks during non-typing steps */
}

.tutorial-overlay.allow-interaction .tutorial-scrim {
    pointer-events: none; /* Allows user to tap on-screen keyboard during practice */
}

/* Glowing Spotlight Cut-out Window */
.tutorial-spotlight-box {
    position: absolute;
    border-radius: 14px;
    border: 3px solid #f1c40f;
    box-shadow: 0 0 0 9999px rgba(5, 18, 38, 0.8),
                0 0 25px rgba(241, 196, 15, 0.8),
                inset 0 0 15px rgba(241, 196, 15, 0.25);
    transition: left 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                top 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                width 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                height 0.4s cubic-bezier(0.25, 1, 0.5, 1),
                border-radius 0.4s ease;
    pointer-events: none;
    animation: tutorialGlowPulse 2.4s infinite ease-in-out;
    z-index: 10001;
}

@keyframes tutorialGlowPulse {
    0%, 100% {
        border-color: #f1c40f;
        box-shadow: 0 0 0 9999px rgba(5, 18, 38, 0.8),
                    0 0 20px rgba(241, 196, 15, 0.7),
                    inset 0 0 10px rgba(241, 196, 15, 0.2);
    }
    50% {
        border-color: #ffd700;
        box-shadow: 0 0 0 9999px rgba(5, 18, 38, 0.8),
                    0 0 32px rgba(255, 215, 0, 0.95),
                    inset 0 0 20px rgba(255, 215, 0, 0.4);
    }
}

/* Floating Context Callout Card */
/* Floating Context Callout Card */
.tutorial-callout {
    position: absolute;
    width: calc(100% - 36px);
    max-width: 380px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(160deg, rgba(13, 39, 76, 0.97) 0%, rgba(7, 24, 48, 0.98) 100%);
    border: 2px solid #2980b9;
    border-radius: 18px;
    padding: 16px 18px;
    color: #ffffff;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7), 0 0 16px rgba(41, 128, 185, 0.35);
    z-index: 10002;
    transition: top 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.3s ease;
    pointer-events: auto;
    text-align: center;
    backdrop-filter: blur(6px);
}

.tutorial-callout.typing-mode {
    padding: 10px 14px;
    max-width: 360px;
}

.tutorial-callout.typing-mode .tutorial-title {
    font-size: 17px;
    margin-bottom: 4px;
}

.tutorial-callout.typing-mode .tutorial-text {
    margin-bottom: 0;
    font-size: 13px;
}

.tutorial-step-badge {
    display: inline-block;
    background: rgba(241, 196, 15, 0.15);
    border: 1.5px solid #f1c40f;
    color: #ffd700;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    padding: 2px 14px;
    border-radius: 20px;
    margin-bottom: 6px;
    text-transform: uppercase;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
}

.tutorial-title {
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    line-height: 1.25;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
}

.tutorial-text {
    font-size: 13.5px;
    line-height: 1.5;
    color: #e2e8f0;
    margin-bottom: 14px;
    font-family: Arial, sans-serif;
}

.tutorial-text strong {
    color: #ffd700;
}

.tutorial-btn-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Tutorial Next Button: Styled after authentic game buttons (e.g. ht_play_button.png) */
.tutorial-next-btn {
    background: linear-gradient(180deg, #1e88e5 0%, #1565c0 60%, #0d47a1 100%);
    color: #ffffff;
    border: 2px solid #64b5f6;
    border-bottom: 4px solid #092c68;
    padding: 8px 26px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
    transition: transform 0.1s ease, filter 0.15s ease;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.tutorial-next-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.12);
}

.tutorial-next-btn:active {
    transform: translateY(2px) scale(0.96);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

/* Skip Tutorial Button: Aligned with game header and styled like game buttons */
.tutorial-skip-btn {
    position: absolute;
    top: 46px;
    right: 14px;
    background: linear-gradient(180deg, #1b74e4 0%, #0d47a1 100%);
    border: 2px solid #5dade2;
    border-bottom: 3px solid #092c68;
    color: #ffffff;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    z-index: 10005;
    pointer-events: auto;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease, filter 0.15s ease;
}

.tutorial-skip-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.tutorial-skip-btn:active {
    transform: translateY(2px) scale(0.96);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ========================================================
   TUTORIAL SCRIPTURE MODAL (Matches GameScene Scripture Modal)
   ======================================================== */
.tutorial-scripture-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10015;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    animation: fadeInAllSet 0.25s ease forwards;
}

.tutorial-scripture-card {
    width: calc(100% - 48px);
    max-width: 360px;
    background: #ffffff;
    border: 3px solid #8e44ad;
    border-radius: 18px;
    padding: 26px 20px 20px;
    text-align: center;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    animation: popInCard 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.tutorial-scripture-title {
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
    font-size: 22px;
    font-weight: bold;
    color: #8e44ad;
    margin-bottom: 14px;
}

.tutorial-scripture-verse {
    font-family: Arial, sans-serif;
    font-size: 16px;
    line-height: 1.55;
    color: #2c3e50;
    margin-bottom: 22px;
}

.tutorial-scripture-btn-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Universal Red Close Button image (closebutton.png) */
.tutorial-game-close-btn {
    width: 44px;
    height: 44px;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.tutorial-game-close-btn:hover {
    transform: scale(1.12);
    filter: brightness(1.1);
}

.tutorial-game-close-btn:active {
    transform: scale(0.92);
}

/* ========================================================
   'YOU'RE ALL SET' CELEBRATION OVERLAY
   (Uses congratulation ribbon and official play_button.png)
   ======================================================== */
.tutorial-allset-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    z-index: 10020;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeInAllSet 0.35s ease forwards;
    pointer-events: auto;
}

@keyframes fadeInAllSet {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.tutorial-allset-card {
    width: calc(100% - 44px);
    max-width: 360px;
    background: #ffffff;
    border: 3.5px solid #1c458e;
    border-radius: 22px;
    padding: 20px 20px 22px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85);
    animation: popInCard 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popInCard {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.tutorial-allset-banner {
    width: 82%;
    max-width: 270px;
    height: auto;
    display: block;
    margin: -8px auto 14px;
    user-select: none;
    -webkit-user-drag: none;
}

.tutorial-allset-title {
    font-size: 24px;
    font-weight: 800;
    color: #1c458e;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
}

.tutorial-allset-subtitle {
    font-size: 15px;
    font-weight: 700;
    color: #ef9118;
    margin-bottom: 12px;
    font-family: 'Baloo', 'Baloo 2', Arial, sans-serif;
}

.tutorial-allset-text {
    font-family: Arial, sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    color: #2c3e50;
    margin-bottom: 22px;
}

.tutorial-allset-btn-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Official game Play Button image (play_button.png) */
.tutorial-game-play-btn {
    width: 160px;
    height: auto;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
    animation: pulseGamePlayBtn 1.8s infinite ease-in-out;
}

@keyframes pulseGamePlayBtn {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 6px 14px rgba(46, 204, 113, 0.5));
    }
    50% {
        transform: scale(1.06);
        filter: drop-shadow(0 10px 22px rgba(46, 204, 113, 0.8));
    }
}

.tutorial-game-play-btn:hover {
    transform: scale(1.08);
    filter: brightness(1.1);
}

.tutorial-game-play-btn:active {
    transform: scale(0.95);
}


