/* 1️⃣ Load the font INSIDE the iframe */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* 2️⃣ Base typography for all H5P content */
html,
body,
.h5p-content {
    font-size: 16px;
    line-height: 1.5;
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    color: #1E3D6B;
}

/* 3️⃣ Force inner elements (H5P likes to override things) */
.h5p-content p,
.h5p-content li,
.h5p-content div:not(.joubel-tip-container):not(.joubel-tip-container *):not(.h5p-tooltip),
.h5p-content span:not(.joubel-tip-container *) {
    font-family: "Poppins", system-ui, sans-serif !important;
    color: #1E3D6B !important;
}

.h5peditor .ui-dialog .h5p-joubelui-button,
.h5peditor .h5p-joubelui-button,
.h5p-joubelui-button {
    font-size: 1em;
    line-height: 1.2;
    margin: 0.5em 0.5em 1em;
    padding: 0.5em 1.25em;
    border-radius: 2em;
    background: #1E3D6B;
    color: #ffffff;
    cursor: pointer;
    border: none;
    box-shadow: none;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    display: inline-block;
    text-align: center;
    text-shadow: none;
    text-decoration: none;
    vertical-align: baseline;
}



.h5p-content button {
    font-family: "Poppins", system-ui, sans-serif !important;
    color: #ffffff !important;
}

.h5p-blanks .h5p-text-input {
    font-family: 'Poppins';
    font-size: 14px;
    border-radius: 0.5em;
    border: 1px solid #a0a0a0;
    padding: 0.1875em 1em 0.1875em 0.5em;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    width: 6em;
}

.h5p-content {
    position: relative;
    background: #fefefe;
    border: 0px;
    border-bottom: none;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
}

.h5p-question-introduction {
    margin: 0em 0 10px 0 !important;
    font-size: 18px;
    font-family: 'Poppins', sans-serif;
    color: #1E3D6B;
    line-height: 1.6;
    font-weight: 600;
}

.h5p-question-content {
    margin: 0em !important;
}

.h5p-drag-text .joubel-tip-container {
    top: -1.1em;
    right: -0.6em;
    position: absolute;
    z-index: 4;
    font-size: 0.9em;
    color: #1E3D6B !important;

}



.h5p-drag-text [aria-grabbed] {
    border-radius: 0.5em;
    border: 1px solid #1E3D6B;
    background-color: #F7F6F4;
    color: #1E3D6B;
    padding: 0.2em 0.5em;
    box-shadow: none;

}

/* Drop zone - base styling */
.h5p-drag-text [aria-dropeffect] {
    border-radius: 0.5em;
    border: 1px solid #1E3D6B;
    background-color: #FFFFFF;
}

/* ============================================
   DRAG TEXT - AUTO-EXPANDING DROP ZONES
   ============================================ */

/* Drop zone container - allow expansion */
.h5p-drag-text .h5p-drag-dropzone-container,
.h5p-drag-text .ui-droppable {
    width: auto !important;
    min-width: 4em !important;
    max-width: none !important;
    display: inline-block !important;
    height: auto !important;
    min-height: 1.5em !important;
    padding: 0.2em 0.4em !important;
    vertical-align: middle !important;
}

/* Droppable area styling */
.h5p-drag-text span.ui-droppable {
    width: auto !important;
    min-width: 4em !important;
}

/* Dropped word inside drop zone */
.h5p-drag-text .h5p-drag-dropped,
.h5p-drag-text .ui-droppable .h5p-drag-draggable {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: unset !important;
    position: relative !important;
    display: inline-block !important;
    width: auto !important;
    max-width: none !important;
}

/* Draggable words - ensure they don't get cut */
.h5p-drag-text .h5p-drag-draggable-words .ui-draggable,
.h5p-drag-text span.ui-draggable {
    white-space: nowrap !important;
    overflow: visible !important;
}

/* Text container - allow wrapping but not truncation */
.h5p-drag-text .h5p-drag-text-inner {
    overflow: visible !important;
}

/* Ensure the parent container allows content to expand */
.h5p-drag-text p,
.h5p-drag-text .h5p-drag-text-container {
    overflow: visible !important;
}

/* ============================================
   SINGLE CHOICE SET
   ============================================ */

/* Main container */
.h5p-sc-set {
    background: #fefefe;
    border-radius: 1em;
    padding: 1.5em;
    box-shadow: 0 2px 12px rgba(30, 61, 107, 0.08);
}

/* Question */
.h5p-sc-question {
    font-size: 20px !important;
    font-weight: 500 !important;
    color: #1E3D6B !important;
    margin-bottom: 1.5em !important;
    text-align: center;
}

.h5p-sc-question p {
    margin: 0 !important;
    color: #1E3D6B !important;
    line-height: 1.5;
}

/* Alternatives list */
.h5p-sc-alternatives {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex;
    flex-direction: column;
    gap: 0.75em;
}

/* Individual alternative */
.h5p-sc-alternative {
    background: #F7F6F4;
    border: 2px solid transparent;
    border-radius: 0.75em;
    padding: 1em 1.25em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.h5p-sc-alternative:hover {
    background: #eeedeb;
    border-color: #1E3D6B;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 61, 107, 0.12);
}

.h5p-sc-alternative:focus {
    outline: none;
    border-color: #1E3D6B;
    box-shadow: 0 0 0 3px rgba(30, 61, 107, 0.2);
}

/* Alternative label */
.h5p-sc-label {
    flex: 1;
    font-size: 16px;
    font-weight: 400;
    z-index: 1;
}

.h5p-sc-label p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Progress bar (hidden or minimal) */
.h5p-sc-progressbar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    background: rgba(30, 61, 107, 0.1);
    z-index: 0;
    transition: width 0.3s ease;
}

/* Status icon */
.h5p-sc-status {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-left: 1em;
    flex-shrink: 0;
    z-index: 1;
}

/* Correct answer state */
.h5p-sc-alternative.h5p-sc-is-correct.h5p-sc-selected,
.h5p-sc-alternative.h5p-sc-is-correct[aria-checked="true"] {
    background: #d4edda !important;
    border-color: #28a745 !important;
}

.h5p-sc-alternative.h5p-sc-is-correct.h5p-sc-selected .h5p-sc-status,
.h5p-sc-alternative.h5p-sc-is-correct[aria-checked="true"] .h5p-sc-status {
    background: #28a745;
}

.h5p-sc-alternative.h5p-sc-is-correct.h5p-sc-selected .h5p-sc-status::after,
.h5p-sc-alternative.h5p-sc-is-correct[aria-checked="true"] .h5p-sc-status::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Wrong answer state */
.h5p-sc-alternative.h5p-sc-is-wrong.h5p-sc-selected,
.h5p-sc-alternative.h5p-sc-is-wrong[aria-checked="true"] {
    background: #f8d7da !important;
    border-color: #dc3545 !important;
}

.h5p-sc-alternative.h5p-sc-is-wrong.h5p-sc-selected .h5p-sc-status,
.h5p-sc-alternative.h5p-sc-is-wrong[aria-checked="true"] .h5p-sc-status {
    background: #dc3545;
}

.h5p-sc-alternative.h5p-sc-is-wrong.h5p-sc-selected .h5p-sc-status::after,
.h5p-sc-alternative.h5p-sc-is-wrong[aria-checked="true"] .h5p-sc-status::after {
    content: '✕';
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Show correct answer highlight */
.h5p-sc-alternative.h5p-sc-is-correct.h5p-sc-reveal {
    background: #d4edda !important;
    border-color: #28a745 !important;
}

/* Results slide */
.h5p-sc-set-results {
    text-align: center;
    padding: 1.5em 1em;
}

.h5p-sc-result-container {
    background: #fff;
    border-radius: 1em;
    padding: 1.5em;
    max-width: 320px;
    margin: 0 auto;
    box-shadow: 0 2px 12px rgba(30, 61, 107, 0.08);
}

.h5p-sc-feedback-container {
    margin-bottom: 1em;
}

.h5p-sc-feedback-container:focus {
    outline: none;
}

/* Feedback message */
.h5p-question-feedback {
    margin-bottom: 1em !important;
}

.h5p-question-feedback-container {
    background: transparent;
}

.h5p-question-feedback-content {
    font-size: 16px;
    font-weight: 500;
    color: #1E3D6B;
    text-align: center;
}

.h5p-question-feedback-content-text {
    display: block;
}

/* Score bar - simplified */
.h5p-question-scorebar {
    margin: 0 !important;
}

.h5p-question-scorebar-container {
    padding: 0;
}

.h5p-joubelui-score-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    background: transparent !important;
    padding: 0 !important;
}

.h5p-joubelui-score-bar-visuals {
    display: none;
}

/* Simple numeric score */
.h5p-joubelui-score-numeric {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.15em;
    font-size: 28px;
    font-weight: 600;
    color: #1E3D6B;
}

.h5p-joubelui-score-number {
    font-variant-numeric: tabular-nums;
}

.h5p-joubelui-score-number-counter {
    font-size: 36px;
    color: #1E3D6B;
}

.h5p-joubelui-score-number-separator {
    color: #a0a0a0;
    font-weight: 400;
    font-size: 24px;
}

.h5p-joubelui-score-max {
    color: #666;
}

/* Button container */
.h5p-sc-button-container {
    margin-top: 1em;
}

.h5p-question-buttons {
    display: flex;
    gap: 0.5em;
    justify-content: center;
}

.h5p-question-buttons.has-scorebar {
    margin-top: 0;
}

/* Prevent button truncation on mobile - show full text */
.h5p-joubelui-button.truncated {
    width: auto !important;
    height: auto !important;
    padding: 0.5em 1.25em !important;
    border-radius: 2em !important;
    min-width: unset !important;
}

/* Ensure button text is visible */
.h5p-joubelui-button.truncated .h5p-joubelui-button-text,
.h5p-joubelui-button.truncated span {
    display: inline !important;
    visibility: visible !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    clip: unset !important;
    overflow: visible !important;
}

/* Remove icon pseudo-elements for truncated buttons */
.h5p-question-try-again.truncated::before,
.h5p-question-show-solution.truncated::before,
.h5p-question-check-answer.truncated::before {
    content: none !important;
}

/* Stack buttons vertically on very small screens if needed */
@media screen and (max-width: 400px) {
    .h5p-question-buttons {
        flex-direction: column !important;
        gap: 0.5em !important;
    }

    .h5p-joubelui-button.truncated {
        width: 100% !important;
        text-align: center !important;
    }
}

/* Hide complex tooltips on touch devices */
.h5p-joubelui-button[data-tooltip] {
    position: relative;
}

/* Tooltip styling */
.h5p-tooltip {
    background: #1E3D6B !important;
    color: #fff !important;
    border-radius: 0.5em !important;
    padding: 0.5em 1em !important;
    font-size: 13px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Hide accessibility announcements visually */
.h5p-sc-a11y {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Animation for slide transitions */
.h5p-sc-slide {
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.h5p-sc-animate {
    transition: transform 0.4s ease;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .h5p-sc-set {
        padding: 1em;
    }

    .h5p-sc-question {
        font-size: 18px !important;
    }

    .h5p-sc-alternative {
        padding: 0.875em 1em;
    }

    .h5p-sc-label {
        font-size: 15px;
    }

    .h5p-question-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .h5p-question-buttons button {
        width: 100%;
        margin: 0.25em 0 !important;
    }
}


.h5p-flashcards.h5p-standalone {
    background-color: #ffffff;
}

/* Navigation buttons (Next/Previous) */
.h5p-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5em 1em;
}

.h5p-button.h5p-next,
.h5p-button.h5p-previous {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    background: #1E3D6B !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    cursor: pointer !important;

    box-shadow: 0 2px 8px rgba(30, 61, 107, 0.3) !important;
    transition: all 0.2s ease !important;
    font-size: 0 !important;
    color: transparent !important;
    overflow: hidden !important;
}

.h5p-button.h5p-next:hover,
.h5p-button.h5p-previous:hover {
    background: #2a5290 !important;
    box-shadow: 0 4px 12px rgba(30, 61, 107, 0.4) !important;
    transform: scale(1.05);
}

.h5p-button.h5p-next:active,
.h5p-button.h5p-previous:active {
    transform: scale(0.98);
}

/* Hide any default icon font content */
.h5p-button.h5p-next::before,
.h5p-button.h5p-previous::before {
    display: none !important;
}

/* Arrow icons using CSS */
.h5p-button.h5p-next::after,
.h5p-button.h5p-previous::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 12px !important;
    height: 12px !important;
    border: none !important;
    border-top: 3px solid #ffffff !important;
    border-right: 3px solid #ffffff !important;
    background: transparent !important;
    box-shadow: none !important;
    display: block !important;
}

.h5p-button.h5p-next::after {
    transform: translate(-65%, -50%) rotate(45deg) !important;
}

.h5p-button.h5p-previous::after {
    transform: translate(-35%, -50%) rotate(-135deg) !important;
}

/* ========================================
   H5P Confirmation Dialog - Mobile Fix
   ======================================== */

.h5p-confirmation-dialog-popup {
    position: fixed !important;
    bottom: 1em !important;
    top: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    max-width: 90vw !important;
    max-height: 80vh !important;
    width: auto !important;
    min-width: 280px !important;
    z-index: 9999 !important;
    box-sizing: border-box !important;
}

@media screen and (max-width: 768px) {
    .h5p-confirmation-dialog-popup {
        width: 90vw !important;
        max-width: 90vw !important;
        min-width: unset !important;
        padding: 1em !important;
        margin: 0 !important;
    }

    .h5p-confirmation-dialog-header {
        padding: 0.75em !important;
    }

    .h5p-confirmation-dialog-header-text {
        font-size: 1.1em !important;
        word-wrap: break-word !important;
    }

    .h5p-confirmation-dialog-body {
        padding: 1em !important;
    }

    .h5p-confirmation-dialog-text {
        font-size: 0.95em !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .h5p-confirmation-dialog-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.5em !important;
        margin-top: 1em !important;
    }

    .h5p-confirmation-dialog-buttons button {
        width: 100% !important;
        padding: 0.75em 1em !important;
        margin: 0 !important;
        font-size: 1em !important;
    }

    .h5p-confirmation-dialog-exit {
        position: absolute !important;
        top: 10px !important;
        right: 15px !important;
        width: 2em !important;
        height: 2em !important;
    }

    .h5p-confirmation-dialog-popup button.h5p-confirmation-dialog-exit::before {
        color: #1E3D6B !important;
    }

}

/* ========================================
   H5P Flashcards - Show Results & Solution Icons
   ======================================== */

/* Show Results Button Container - Simple style matching other buttons */
.h5p-show-results {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5em 1.25em !important;
    background: #1E3D6B !important;
    border-radius: 2em !important;
    margin: 0.5em auto 1em !important;
    border: none !important;
    box-shadow: none !important;
    position: relative !important;
    z-index: 100 !important;
    cursor: pointer !important;
    width: auto !important;
    min-width: fit-content !important;
    text-align: center !important;
    height: auto !important;
    min-height: 2.5em !important;
}

/* Hide the icon for cleaner look */
.h5p-show-results-icon {
    display: none !important;
}

/* Ensure parent container doesn't clip the button */
.h5p-flashcards {
    overflow: visible !important;
}

.h5p-container {
    overflow: visible !important;
}

/* Results Button Labels - match standard button style */
.h5p-show-results-label,
.h5p-show-results-label-mobile {
    background: transparent !important;
    border: none !important;
    color: #ffffff !important;
    font-family: "Poppins", sans-serif !important;
    font-size: 1em !important;
    font-weight: 400 !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    text-shadow: none !important;
    line-height: 1.2 !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
}

/* Force white text color */
.h5p-show-results button,
.h5p-show-results .h5p-show-results-label,
.h5p-show-results .h5p-show-results-label-mobile {
    color: #ffffff !important;
}

.h5p-show-results-label:hover,
.h5p-show-results-label-mobile:hover {
    text-decoration: none !important;
    color: #ffffff !important;
}

/* H5P Mobile class detection (applied by H5P JS) */
.h5p-flashcards.h5p-mobile .h5p-show-results,
.h5p-flashcards .h5p-show-results.h5p-mobile {
    padding: 0.75em 1.5em !important;
    min-height: 3em !important;
    right: 0 !important;
    bottom: 20px !important;
}

.h5p-flashcards.h5p-mobile .h5p-show-results-label,
.h5p-flashcards.h5p-mobile .h5p-show-results-label-mobile,
.h5p-flashcards .h5p-show-results.h5p-mobile .h5p-show-results-label,
.h5p-flashcards .h5p-show-results.h5p-mobile .h5p-show-results-label-mobile {
    font-size: 1.2em !important;
    font-weight: 500 !important;
    color: #ffffff !important;
}

/* Solution overlay styling */
.h5p-solution {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1em !important;
    background: rgba(30, 61, 107, 0.95) !important;
    color: #ffffff !important;
    text-align: center !important;
}

/* Solution Icon */
.solution-icon {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 3em !important;
    height: 3em !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border-radius: 50% !important;
    margin-bottom: 0.75em !important;
}

.h5p-card.h5p-correct .solution-icon::before {
    content: '✓' !important;
    font-size: 1.5em !important;
    color: #4ade80 !important;
}

.h5p-card.h5p-wrong .solution-icon::before {
    content: '✗' !important;
    font-size: 1.5em !important;
    color: #f87171 !important;
}

/* Solution Text */
.solution-text {
    font-family: "Poppins", sans-serif !important;
    font-size: 0.95em !important;
    font-weight: 500 !important;
    color: #ffffff !important;
    line-height: 1.4 !important;
}

/* Feedback Label (Správně!/Nesprávně!) */
.h5p-feedback-label {
    display: inline-block !important;
    padding: 0.25em 0.75em !important;
    border-radius: 1em !important;
    font-family: "Poppins", sans-serif !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
    margin-left: 0.5em !important;
}

.h5p-input.h5p-correct .h5p-feedback-label {
    background: #dcfce7 !important;
    color: #166534 !important;
}

.h5p-input.h5p-wrong .h5p-feedback-label {
    background: #fee2e2 !important;
    color: #991b1b !important;
}

.h5p-flashcards .h5p-results-retry-button {
    display: block;
    margin: 0 auto;
    width: 9em;
    padding: 0.87em;
    color: #adb6c7;
    background: #1E3D6B;
    border: none;
}


/* ========================================
   H5P GUESS ANSWER STYLES
   ======================================== */
.h5p-guess-answer {
    overflow: visible !important;
}

.h5p-guess-answer .solution-text {
    overflow: visible !important;
    max-height: none !important;
    height: auto !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 1em !important;
    margin-top: 0.5em !important;
    border-radius: 0.5em !important;
    font-family: "Poppins", sans-serif !important;
    font-size: 1em !important;
    font-weight: 500 !important;
    color: #ffffff !important;
    line-height: 1.5 !important;
    text-align: center !important;
}

.h5p-guess-answer .solution-text.hidden {
    display: none !important;
}

.h5p-guess-answer .show-solution-button {
    background-color: #1E3D6B !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    margin: 0.5em auto !important;
    display: block !important;
}

.h5p-guess-answer .h5p-guess-answer-title {
    font-family: "Poppins", sans-serif !important;
    color: #1E3D6B !important;
    line-height: 1.5 !important;
}

.h5p-guess-answer .media {
    overflow: visible !important;
}


/* ========================================
   COMPREHENSIVE MOBILE STYLES
   ======================================== */
@media screen and (max-width: 768px) {

    /* Show Results Button - larger on mobile */
    .h5p-show-results {
        padding: 0.75em 1.5em !important;
        min-height: 3em !important;
    }

    .h5p-show-results-label,
    .h5p-show-results-label-mobile {
        font-size: 1.2em !important;
        font-weight: 500 !important;
    }

    /* Flashcard content - better mobile layout */
    .h5p-flashcards .h5p-cardholder {
        padding: 0.5em !important;
    }

    .h5p-flashcards .h5p-imageholder {
        min-height: 200px !important;
    }

    .h5p-flashcards .h5p-imagetext {
        font-size: 1em !important;
        line-height: 1.4 !important;
        padding: 0.5em !important;
    }

    /* Input and check button on mobile */
    .h5p-flashcards .h5p-input {
        flex-wrap: wrap !important;
        gap: 0.5em !important;
    }

    .h5p-flashcards .h5p-textinput {
        width: 100% !important;
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 0.75em !important;
    }

    .h5p-flashcards .h5p-check-button,
    .h5p-flashcards .h5p-icon-button {
        padding: 0.75em 1.25em !important;
        font-size: 1em !important;
    }

    /* Solution text on mobile */
    .solution-text {
        font-size: 1em !important;
        padding: 0.5em !important;
    }

    /* Feedback label on mobile */
    .h5p-feedback-label {
        font-size: 0.9em !important;
        margin-top: 0.5em !important;
        margin-left: 0 !important;
        display: block !important;
    }

    /* Navigation buttons on mobile */
    .h5p-button.h5p-next,
    .h5p-button.h5p-previous {
        width: 44px !important;
        height: 44px !important;
    }

    /* Progress indicator */
    .h5p-progress {
        font-size: 0.9em !important;
        padding: 0.5em !important;
    }

    /* Description text */
    .h5p-description {
        font-size: 0.95em !important;
        line-height: 1.5 !important;
        padding: 0.75em !important;
    }
}

/* ============================================
   Find the Words - Mobile Responsive Fixes
   ============================================ */

/* Scale puzzle grid to fill screen width on mobile */
@media screen and (max-width: 600px) {
    .h5p-find-the-words {
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: visible !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .h5p-find-the-words .h5p-play-area {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 5px !important;
    }

    /* CRITICAL: Break the table layout on mobile */
    .h5p-find-the-words .game-container {
        display: block !important;
        width: 100% !important;
    }

    /* Stack puzzle on top */
    .h5p-find-the-words .puzzle-inline,
    .h5p-find-the-words .puzzle-container {
        display: block !important;
        width: 100% !important;
        text-align: center;
    }

    /* Stack vocabulary below - MUST come after puzzle */
    .h5p-find-the-words .vocabulary-inline-container {
        display: block !important;
        width: 100% !important;
        margin-top: 1em;
        height: auto !important;
    }

    .h5p-find-the-words .vocabulary-block-container {
        width: 100% !important;
        text-align: center;
        display: block !important;
    }

    .h5p-find-the-words .vocabulary-block-container li,
    .h5p-find-the-words .vocabulary-container li {
        display: inline-block !important;
        margin: 5px 10px !important;
    }

    /* Center vocabulary list */
    .h5p-find-the-words .vocabulary-container {
        width: 100% !important;
        text-align: center !important;
        background-color: #f5f5f5;
        padding: 10px 0 !important;
    }

    .h5p-find-the-words .vocabulary-container ul {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        padding: 10px !important;
        margin: 0 !important;
    }

    /* Task description */
    .h5p-find-the-words .h5p-task-description,
    .h5p-find-the-words .h5p-question-introduction {
        font-size: 1em !important;
        padding: 8px !important;
        text-align: center;
    }

    /* Footer and buttons */
    .h5p-find-the-words .footer-container {
        padding: 8px 4px !important;
        width: 100% !important;
        clear: both;
    }

    .h5p-find-the-words .time-status,
    .h5p-find-the-words .counter-status {
        font-size: 0.9em !important;
    }
}

/* Slightly smaller screens - no scaling needed, grid fits */
@media screen and (max-width: 480px) {
    .h5p-find-the-words .vocabulary-container .word {
        font-size: 0.9em !important;
    }
}


.h5p-sort-paragraphs .h5p-sort-paragraphs-button {
    align-items: center;
    background-color: #5271ff;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 1.15em 1.15em;
    border: 2px solid rgba(0, 0, 0, 0);
    border-radius: .3em;
    box-shadow: 0 .1em 0 rgba(0, 0, 0, .3);
    color: #1a73d9;
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    height: 2.75em;
    justify-content: center;
    min-height: 42px;
    min-width: 42px;
    padding: 0;
    width: 2.75em;
}

.h5p-question-buttons.h5p-question-visible {
    display: inline-block;
    width: calc(100% - 1.5em);
    margin-left: 1em;
    margin-right: 0.5em;
    margin-bottom: 20px;
    margin-top: 20px;
}