/* ── New difficulty effects ─────────────────────── */
@keyframes reveal-pokemon {
    from {
        filter: brightness(0);
    }

    to {
        filter: brightness(1);
    }
}

.fx-reveal {
    animation: reveal-pokemon var(--reveal-duration, 6s) linear forwards;
}

/* Free input box */
.answer-input-box {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
}

.answer-input-box.hidden {
    display: none;
}

.answer-input-box input {
    flex: 1;
    padding: 11px 14px;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 800;
    font-family: var(--font-body, Arial);
    background: white;
    color: #1a1a2e;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    min-height: 50px;
    box-shadow: 0 5px 0 var(--border);
}

.answer-input-box input:focus {
    border-color: var(--primary, #1a3a9e);
    box-shadow: 0 4px 0 var(--primary, #1a3a9e);
}

.answer-input-box button {
    padding: 11px 20px;
    background: var(--primary, #1a3a9e);
    color: white;
    border: 3px solid #0d2270;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #0d2270;
    min-height: 48px;
    transition: transform var(--t), box-shadow var(--t), background var(--t);
}

.answer-input-box button:hover:not(:disabled) {
    background: #2a4abe;
    transform: translateY(3px);
    box-shadow: 0 1px 0 #0d2270;
}

.answer-input-box.answer-correct input,
.answer-input-box.answer-correct button {
    background: var(--green, #6ddb8b) !important;
    border-color: var(--green-dark, #2d8a4a) !important;
    color: #1a4a1a !important;
    box-shadow: 0 4px 0 var(--green-dark, #2d8a4a) !important;
}

.answer-input-box.answer-wrong input,
.answer-input-box.answer-wrong button {
    background: #ff6b6b !important;
    border-color: #c62828 !important;
    color: white !important;
    box-shadow: 0 4px 0 #c62828 !important;
}

/* ── Answer animations ──────────────────────────── */
@keyframes answer-shake {
    0% {
        transform: translateX(0) rotate(0deg);
    }

    15% {
        transform: translateX(-8px) rotate(-2deg);
    }

    30% {
        transform: translateX(7px) rotate(2deg);
    }

    45% {
        transform: translateX(-6px) rotate(-1deg);
    }

    60% {
        transform: translateX(5px) rotate(1deg);
    }

    75% {
        transform: translateX(-3px) rotate(0deg);
    }

    100% {
        transform: translateX(0) rotate(0deg);
    }
}

@keyframes answer-bounce {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.18);
    }

    55% {
        transform: scale(0.93);
    }

    75% {
        transform: scale(1.07);
    }

    90% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }
}

.answer-shake {
    animation: answer-shake 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.answer-bounce {
    animation: answer-bounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.opponent-score {
    font-size: 0.8rem;
    color: #999;
    font-weight: 600;
    margin-top: -4px;
}

.hint-box {
    display: none;
}


/* ── Pokémon battle arena ────────────────────────── */
.image-box {
    background: linear-gradient(180deg,
            #daeaf5 0%,
            #eaf3f8 40%,
            #f5f0e8 80%,
            #e8e0d0 100%);
    border-radius: 18px;
    padding: 14px;
    min-height: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s, box-shadow 0.3s, border-color 0.3s;
    border: 3px solid rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.06), 0 3px 12px rgba(0, 0, 0, 0.08);
}

/* Ellipse shadow on the arena floor (like Gen IV-VI battles) */
.image-box::after {
    content: '';
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 14px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.13) 0%, transparent 80%);
    border-radius: 50%;
    pointer-events: none;
}

.image-box.shiny-encounter {
    background: linear-gradient(135deg, #fff8e1, #fff3c4, #fff8e1);
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 0 40px rgba(255, 215, 0, 0.2);
    animation: shinyPulse 1.5s ease-in-out infinite;
}

@keyframes shinyPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), 0 0 40px rgba(255, 215, 0, 0.2);
    }

    50% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.4);
    }
}

#image,
#dailyImage,
#timerImage,
#trainingImage {
    max-width: 100%;
    height: 160px;
    object-fit: contain;
    transition: filter 0.3s, opacity 0.3s;
    will-change: filter;
    contain: layout style paint;
}

#choices,
#timerChoices,
#trainingChoices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    /* reserve stable height: 2 rows × 52px + 1 gap */
    min-height: 112px;
}

#choices button,
#timerChoices button,
#trainingChoices button {
    background: white;
    border: 3px solid var(--border);
    color: #1a1a2e;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 800;
    font-family: var(--font-body, Arial);
    box-shadow: 0 5px 0 var(--border);
    padding: 11px 8px;
    align-items: center;
    text-align: center;
    justify-content: center;
    flex-direction: row;
    letter-spacing: 0;
    text-transform: none;
    min-height: 52px;
    transition: transform var(--t), box-shadow var(--t), background var(--t);
    will-change: transform;
    transform-origin: center;
    word-break: break-word;
    hyphens: auto;
}

/* ── Mode label & score display ────────────────── */
.mode-label {
    font-family: var(--font-pixel, monospace);
    font-size: 0.55rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    line-height: 1.6;
    margin: -4px 0;
}

#score,
#timerScore {
    font-family: var(--font-pixel, monospace);
    font-size: 0.75rem;
    font-weight: 900;
    color: var(--red);
    letter-spacing: 1px;
    margin: 2px 0;
}

#timerLabel,
#globalTimerLabel {
    font-family: var(--font-pixel, monospace);
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin: 2px 0 8px;
}

#choices button:hover:not(:disabled),
#timerChoices button:hover:not(:disabled),
#trainingChoices button:hover:not(:disabled) {
    background: #f5f5f5;
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--border);
}

@media (max-width: 400px) {
    #choices[style*="1fr 1fr 1fr"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

.correct {
    background: var(--green) !important;
    border-color: var(--green-dark) !important;
    color: var(--green-bg) !important;
    box-shadow: 0 4px 0 var(--green-dark) !important;
}

.wrong {
    background: #ff6b6b !important;
    border-color: var(--red-dark) !important;
    color: white !important;
    box-shadow: 0 4px 0 var(--red-dark) !important;
}

/* ── Pokémon HP bar ──────────────────────────────── */
#timerBar,
#globalTimerBar {
    width: 100%;
    height: 16px;
    background: #1a1a2e;
    border-radius: 6px;
    border: 2px solid #111;
    padding: 2px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(255, 255, 255, 0.08);
    position: relative;
}

/* HP label above bar */
#timerBar::before,
#globalTimerBar::before {
    content: 'HP';
    position: absolute;
    top: -18px;
    left: 0;
    font-family: var(--font-pixel, monospace);
    font-size: 0.45rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    pointer-events: none;
}

#timerFill,
#globalTimerFill {
    height: 100%;
    width: 100%;
    background: var(--hp-high);
    transition: width 1s linear, background 0.3s;
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(84, 196, 58, 0.5);
}

@media (max-width: 850px) {
    .image-box {
        min-height: 150px;
        padding: 10px;
    }

    #image,
    #dailyImage,
    #timerImage,
    #trainingImage {
        height: 140px;
    }

    #choices,
    #timerChoices,
    #trainingChoices {
        gap: 6px;
    }

    #choices button,
    #timerChoices button,
    #trainingChoices button {
        padding: 10px 6px;
        font-size: 0.82rem;
        min-height: 48px;
    }
}

@media (max-width: 380px) {
    .image-box {
        min-height: 120px;
        padding: 8px;
    }

    #image,
    #dailyImage,
    #timerImage,
    #trainingImage {
        height: 110px;
    }


    #choices {
        grid-template-columns: 1fr 1fr !important;
    }

    #choices button,
    #timerChoices button,
    #trainingChoices button {
        font-size: 0.75rem;
        padding: 8px 4px;
        min-height: 44px;
    }
}

.training-gen-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.train-gen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 3px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: bold;
    color: #1a1a1a;
    box-shadow: 0 4px 0 var(--border);
    cursor: pointer;
    transition: transform var(--t), box-shadow var(--t), background var(--t);
}

.train-gen-btn:hover {
    background: #f5f5f5;
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--border);
}

.train-gen-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.train-gen-all {
    background: #e8f5e9;
    border-color: #4caf50;
    box-shadow: 0 4px 0 #388e3c;
}

.train-gen-all:hover {
    background: #c8e6c9;
}

.train-gen-label {
    flex-shrink: 0;
    min-width: 60px;
    text-align: left;
}

.train-gen-starters {
    display: flex;
    gap: 4px;
}

.train-gen-starters img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

@keyframes pokemonAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(8px);
    }

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

.pokemon-appearing {
    animation: pokemonAppear 0.35s ease-out forwards;
}

.timer-bar-outer {
    width: 100%;
    height: 16px;
    background: #1a1a2e;
    border-radius: 6px;
    border: 2px solid #111;
    padding: 2px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.timer-bar-fill {
    height: 100%;
    width: 100%;
    background: var(--hp-high);
    transition: width 1s linear, background 0.3s;
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(84, 196, 58, 0.5);
}

.timer-label-text {
    font-family: var(--font-pixel, monospace);
    font-size: 0.55rem;
    color: var(--text-muted);
    margin: 6px 0 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.inverse-pokemon-name {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary, #1a3a9e);
    margin: 8px 0 4px;
    text-align: center;
}

.inverse-hint {
    font-size: 0.8rem;
    color: #999;
    margin: 0 0 12px;
    text-align: center;
}

.inverse-choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
}

.inverse-choice-btn {
    background: #f0f0f0;
    border: 3px solid var(--border, #ddd);
    border-radius: var(--radius, 14px);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.inverse-choice-btn:hover:not(:disabled) {
    background: #e8e8e8;
    transform: translateY(2px);
}

.inverse-choice-btn.correct {
    border-color: #4caf50 !important;
    background: #e8f5e9 !important;
}

.inverse-choice-btn.wrong {
    border-color: #f44336 !important;
    background: #ffebee !important;
}

.inverse-shadow-img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    pointer-events: none;
    transition: filter 0.4s ease;
}

.sound-game-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

.sound-play-btn {
    font-size: 3rem;
    background: var(--primary, #1a3a9e);
    color: white;
    border: none;
    border-radius: 50%;
    width: 90px;
    height: 90px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 16px rgba(26, 58, 158, 0.3);
}

.sound-play-btn:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(26, 58, 158, 0.4);
}

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

.sound-hint {
    font-size: 0.8rem;
    color: #999;
    margin: 0;
}

.sound-reveal {
    text-align: center;
    min-height: 1.4em;
    margin: 4px 0;
}

.sound-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

.sound-choices button {
    background: white;
    border: 3px solid var(--border, #ddd);
    color: #1a1a1a;
    border-radius: var(--radius, 14px);
    font-size: 0.85rem;
    font-weight: bold;
    box-shadow: 0 4px 0 var(--border, #ddd);
    padding: 11px 8px;
    text-align: center;
    min-height: 48px;
    cursor: pointer;
    transition: transform var(--t, 0.1s), box-shadow var(--t, 0.1s), background var(--t, 0.1s);
    word-break: break-word;
}

.sound-choices button:hover:not(:disabled) {
    background: #f5f5f5;
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--border, #ddd);
}

.sound-choices button.correct {
    background: var(--green, #6ddb8b) !important;
    border-color: #2d8a4a !important;
    color: #1a4a1a !important;
    box-shadow: 0 4px 0 #2d8a4a !important;
}

.sound-choices button.wrong {
    background: #ff6b6b !important;
    border-color: #c62828 !important;
    color: white !important;
    box-shadow: 0 4px 0 #c62828 !important;
}

@media (max-width: 380px) {
    .inverse-shadow-img {
        width: 70px;
        height: 70px;
    }

    .inverse-choice-btn {
        min-height: 80px;
    }

    .sound-play-btn {
        width: 72px;
        height: 72px;
        font-size: 2.4rem;
    }
}