/* ========================================
   Phrasal Verbs Lab - Multiple Choice
   Travel & Navigation Theme
   &copy; Cool English 2026
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --slate-50:  #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;

    --teal-50:   #f0fdfa;
    --teal-100:  #ccfbf1;
    --teal-200:  #99f6e4;
    --teal-300:  #5eead4;
    --teal-400:  #2dd4bf;
    --teal-500:  #14b8a6;
    --teal-600:  #0d9488;
    --teal-700:  #0f766e;

    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;

    --red-50:  #fff1f2;
    --red-100: #fee2e2;
    --red-400: #f87171;
    --red-500: #ef4444;
    --red-600: #dc2626;

    --amber-400: #fbbf24;
    --amber-500: #f59e0b;

    --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl:  0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    --shadow-2xl: 0 25px 50px -12px rgba(0,0,0,0.25);
}

/* Desktop: locked viewport — no scroll */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdfa 50%, #e0f2fe 100%);
    background-attachment: fixed;
    color: var(--slate-800);
}

.app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========================================
   Header
   ======================================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(90deg, #FF6B35, #F59E0B, #22C55E, #06B6D4, #8B5CF6, #EC4899) 1;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.875rem;
    background: var(--slate-100);
    color: var(--slate-600);
    text-decoration: none;
    transition: all 0.3s ease;
    border: 2px solid var(--slate-200);
    flex-shrink: 0;
}

.back-btn:hover {
    background: var(--teal-500);
    border-color: var(--teal-500);
    color: white;
    transform: translateX(-3px);
}

.logo {
    width: 3rem;
    height: 3rem;
    border-radius: 0.875rem;
    background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-lg);
    flex-shrink: 0;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.main-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--slate-800);
}

.theme-badge {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Nav Buttons */
.header-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.875rem;
    background: white;
    color: var(--slate-600);
    border: 3px solid var(--slate-300);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.header-nav-btn:hover:not(:disabled) {
    background: var(--teal-500);
    border-color: var(--teal-500);
    color: white;
    transform: scale(1.08);
}

.header-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Score */
.score-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
    padding: 0.5rem 1.25rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.score-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.score-count {
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
}

/* Progress */
.progress-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    padding: 0.75rem 1.25rem;
    border-radius: 1.25rem;
    border: 2px solid var(--teal-200);
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
}

.progress-dots {
    display: flex;
    gap: 0.4rem;
}

.progress-dot {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--slate-300);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-dot:hover  { transform: scale(1.2); background: var(--slate-400); }
.progress-dot.active { background: linear-gradient(135deg, var(--teal-400), var(--teal-600)); transform: scale(1.3); box-shadow: 0 0 8px rgba(20,184,166,0.5); }
.progress-dot.correct   { background: linear-gradient(135deg, var(--emerald-400), var(--emerald-500)); }
.progress-dot.incorrect { background: linear-gradient(135deg, var(--red-400), var(--red-500)); }

.progress-count {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--teal-600);
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    flex: 1;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.game-container {
    flex: 1;
    display: flex;
    gap: 1.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 1.5rem;
    padding: 1.25rem;
    box-shadow: var(--shadow-xl);
    border: 3px solid var(--teal-200);
    min-height: 0;
    overflow: hidden;
}

/* Left — image + sentence */
.question-section {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    min-height: 0;
    overflow: hidden;
}

.image-wrapper {
    flex: 1;
    min-height: 0;
    border-radius: 1.25rem;
    overflow: hidden;
    background: linear-gradient(135deg, var(--teal-100), var(--emerald-100));
    border: 4px solid var(--teal-300);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-wrapper img[src=""] { display: none; }

/* Sentence box */
.sentence-box {
    background: linear-gradient(135deg, var(--slate-50), var(--slate-100));
    border-radius: 1rem;
    padding: 1rem 1.5rem;
    border: 3px solid var(--slate-200);
    position: relative;
    flex-shrink: 0;
}

.sentence-box::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 8px; height: 100%;
    background: linear-gradient(180deg, var(--teal-400), var(--teal-600));
    border-radius: 4px 0 0 4px;
}

/* Inline feedback badge */
.inline-feedback {
    position: absolute;
    top: -1rem;
    right: 1rem;
}

.got-it-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, var(--emerald-400), var(--emerald-600));
    color: white;
    font-size: 1rem;
    font-weight: 700;
    padding: 0.35rem 0.85rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-md);
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0%   { transform: scale(0.7); opacity: 0; }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1);   opacity: 1; }
}

.sentence-text {
    font-size: clamp(1.5rem, 2.5vw, 2.75rem);
    font-weight: 600;
    color: var(--slate-700);
    line-height: 1.5;
}

/* Blank */
.blank {
    display: inline-block;
    min-width: 220px;
    padding: 0.2rem 1.25rem;
    background: linear-gradient(135deg, var(--teal-100), var(--emerald-100));
    border: 3px dashed var(--teal-400);
    border-radius: 0.75rem;
    color: var(--teal-600);
    font-weight: 800;
    text-align: center;
    transition: all 0.3s ease;
}

.blank.filled {
    border-style: solid;
    animation: popIn 0.3s ease;
}

.blank.correct {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
    border-color: var(--teal-600);
    color: white;
}

/* Shake animation when wrong answer clicked */
.blank.shake {
    animation: blankShake 0.45s ease;
}

@keyframes blankShake {
    0%,  100% { transform: translateX(0); }
    20%  { transform: translateX(-8px); }
    40%  { transform: translateX(8px); }
    60%  { transform: translateX(-5px); }
    80%  { transform: translateX(5px); }
}

@keyframes popIn {
    0%   { transform: scale(0.85); }
    55%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Right — options */
.options-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    overflow: hidden;
}

.options-label {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--slate-600);
    text-align: center;
    flex-shrink: 0;
}

.options-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 0.5rem;
    min-height: 0;
}

/* ========================================
   Option Buttons
   ======================================== */
.option-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 3px solid var(--slate-200);
    border-radius: 0.875rem;
    font-size: clamp(1.5rem, 2.8vw, 3.5rem);
    font-weight: 900;
    color: var(--slate-700);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    padding: 0.4rem 0.5rem;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.option-btn span {
    position: relative;
    z-index: 1;
    line-height: 1.2;
    text-align: center;
}

.option-btn:hover:not(:disabled) {
    border-color: var(--teal-400);
    border-width: 3px;
    background: var(--teal-50);
    color: var(--teal-700);
    transform: scale(1.03);
    box-shadow: var(--shadow-lg), 0 0 0 3px rgba(20,184,166,0.15);
}

.option-btn:active:not(:disabled) {
    transform: scale(0.97);
}

/* CORRECT — full teal fill, white text */
.option-btn.correct {
    background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
    border-color: var(--teal-600);
    border-width: 3px;
    color: white;
    box-shadow: var(--shadow-lg), 0 0 20px rgba(20,184,166,0.4);
    animation: correctPop 0.35s ease;
}

/* INCORRECT — light pink tint, red text, red border (NOT full fill) */
.option-btn.incorrect {
    background: var(--red-50);
    border-color: var(--red-400);
    border-width: 3px;
    color: var(--red-500);
    box-shadow: var(--shadow-md);
    animation: incorrectShake 0.4s ease;
}

/* Other options dim elegantly after question is answered */
.option-btn.disabled-other {
    opacity: 0.35;
    transform: scale(0.98);
    filter: grayscale(20%);
}

.option-btn:disabled { cursor: not-allowed; }

@keyframes correctPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

@keyframes incorrectShake {
    0%,  100% { transform: translateX(0); }
    20%  { transform: translateX(-6px) rotate(-0.5deg); }
    40%  { transform: translateX(6px)  rotate(0.5deg); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
}

/* ========================================
   Completion Overlay (final results only)
   ======================================== */
.completion-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.completion-overlay.visible {
    display: flex;
    opacity: 1;
}

.completion-content {
    background: white;
    border-radius: 2rem;
    padding: 3rem 4rem;
    text-align: center;
    box-shadow: var(--shadow-2xl);
    max-width: 90%;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0%   { transform: scale(0.5); opacity: 0; }
    55%  { transform: scale(1.05); }
    100% { transform: scale(1);   opacity: 1; }
}

.results-emoji      { font-size: 5rem;   margin-bottom: 1rem; }
.results-title      { font-size: 2.5rem; font-weight: 900; color: var(--slate-800); margin-bottom: 0.75rem; }
.results-score      { font-size: 4rem;   font-weight: 900; color: var(--teal-600);  margin-bottom: 0.5rem; }
.results-percentage { font-size: 2rem;   font-weight: 700; color: var(--slate-500); margin-bottom: 0.75rem; }
.results-message    { font-size: 1.5rem; font-weight: 600; color: var(--slate-600); margin-bottom: 2rem; }

.results-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.retry-btn, .home-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    border-radius: 1rem;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.retry-btn {
    background: linear-gradient(135deg, var(--teal-400), var(--teal-600));
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
}

.retry-btn:hover { transform: scale(1.05); box-shadow: var(--shadow-xl); }

.home-btn {
    background: white;
    color: var(--slate-700);
    border: 3px solid var(--slate-300);
}

.home-btn:hover {
    border-color: var(--teal-400);
    color: var(--teal-600);
    transform: scale(1.05);
}

/* ========================================
   Footer
   ======================================== */
.footer {
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.95);
    border-top: 2px solid var(--teal-200);
    text-align: center;
    flex-shrink: 0;
}

.footer p {
    font-size: 1rem;
    color: var(--slate-500);
    font-weight: 600;
}

/* ========================================
   Responsive — 1200px
   ======================================== */
@media (max-width: 1200px) {
    .option-btn { font-size: clamp(1.35rem, 2.4vw, 3rem); }
    .sentence-text { font-size: clamp(1.4rem, 2.2vw, 2.5rem); }
}

/* ========================================
   Responsive — 1024px (tablet landscape)
   ======================================== */
@media (max-width: 1024px) {
    .main-content { padding: 0.75rem 1rem; }

    .game-container {
        flex-direction: column;
        gap: 1rem;
        overflow-y: auto;
    }

    .question-section { flex: none; gap: 0.75rem; }
    .options-section  { flex: none; }

    .image-wrapper {
        flex: none;
        height: 220px;
    }

    .options-grid {
        grid-template-columns: repeat(5, 1fr);
        grid-template-rows: repeat(2, 1fr);
        min-height: 100px;
    }

    .option-btn { font-size: clamp(1.25rem, 2vw, 2.25rem); }
}

/* ========================================
   Responsive — 768px (mobile)
   Mobile: unlock scroll so full layout is reachable
   ======================================== */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow: auto;
    }

    .app {
        height: auto;
        min-height: 100dvh;
        overflow: visible;
    }

    .main-content {
        flex: none;
        overflow: visible;
        padding: 0.625rem;
    }

    .game-container {
        flex: none;
        flex-direction: column;
        overflow: visible;
        gap: 0.75rem;
        padding: 1rem;
        border-width: 2px;
        border-radius: 1.25rem;
    }

    .header {
        flex-wrap: nowrap;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }

    .header-left { flex: 1; min-width: 0; gap: 0.5rem; }
    .header-right { flex-shrink: 0; gap: 0.5rem; }

    .logo { display: none; }
    .main-title { font-size: 1.25rem; }
    .theme-badge { display: none; }

    .header-nav-btn {
        width: 2.5rem; height: 2.5rem;
        border-radius: 0.625rem;
        border-width: 2px;
    }

    .score-container { padding: 0.4rem 0.875rem; }
    .score-count { font-size: 1.25rem; }

    .progress-container { padding: 0.5rem 0.875rem; }
    .progress-dots { display: none; }
    .progress-count { font-size: 1.125rem; }

    .question-section { flex: none; gap: 0.625rem; }
    .image-wrapper { flex: none; height: 200px; border-width: 3px; }

    .sentence-box { padding: 0.875rem 1rem 0.875rem 1.25rem; border-width: 2px; }
    .sentence-box::before { width: 6px; }
    .sentence-text { font-size: 1.5rem; }
    .blank { min-width: 130px; font-size: 1.1rem; padding: 0.2rem 0.75rem; border-width: 2px; }

    .options-section { flex: none; gap: 0.5rem; }
    .options-label { font-size: 1.2rem; }

    .options-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(5, auto);
        gap: 0.5rem;
        min-height: 0;
    }

    .option-btn {
        font-size: 1.75rem;
        padding: 0.875rem 0.5rem;
        border-radius: 0.875rem;
        border-width: 2px;
    }

    .completion-content { padding: 2rem; border-radius: 1.5rem; }
    .results-title { font-size: 2rem; }
    .results-score { font-size: 3rem; }
}

/* ========================================
   Responsive — 480px
   ======================================== */
@media (max-width: 480px) {
    .header { padding: 0.5rem; gap: 0.375rem; }
    .main-title { font-size: 1.125rem; }
    .header-nav-btn { width: 2.25rem; height: 2.25rem; }
    .score-count { font-size: 1.125rem; }
    .progress-count { font-size: 1rem; }

    .main-content { padding: 0.375rem; }

    .game-container { padding: 0.75rem; gap: 0.5rem; }
    .image-wrapper { height: 170px; }
    .sentence-text { font-size: 1.25rem; }
    .blank { min-width: 110px; font-size: 1rem; }

    .options-label { font-size: 1.1rem; }
    .option-btn { font-size: 1.5rem; padding: 0.75rem 0.4rem; }

    .results-emoji { font-size: 4rem; }
    .results-title { font-size: 1.75rem; }
    .results-score { font-size: 2.5rem; }
}

/* ========================================
   V4 RESPONSIVE CLIP/SCROLL SAFETY PATCH
   Same principle as Definitions V4:
   shrink first, then scroll the real content area instead of clipping.
   This patch is intentionally last so it wins the cascade.
   ======================================== */
@media (min-width: 900px) {
    html,
    body,
    .app {
        height: 100dvh;
        overflow: hidden;
    }

    .main-content {
        min-height: 0;
        overflow: hidden;
    }

    .game-container {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
        overscroll-behavior: contain;
    }

    .question-section,
    .options-section {
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        scrollbar-gutter: stable;
    }

    .sentence-box,
    .options-label,
    .footer {
        flex-shrink: 0;
    }
}

/* Medium teacher-laptop/projector heights, including responsive test panes around 1058px tall. */
@media (min-width: 900px) and (max-height: 1100px) {
    .header {
        padding-top: clamp(0.45rem, 0.8vh, 0.75rem);
        padding-bottom: clamp(0.45rem, 0.8vh, 0.75rem);
    }

    .main-content {
        padding-top: clamp(0.45rem, 0.9vh, 0.85rem);
        padding-bottom: clamp(0.45rem, 0.9vh, 0.85rem);
    }

    .game-container {
        padding: clamp(0.8rem, 1.35vh, 1.15rem);
        gap: clamp(0.85rem, 1.5vw, 1.35rem);
    }

    .question-section,
    .options-section {
        gap: clamp(0.5rem, 0.9vh, 0.75rem);
    }

    .sentence-box {
        padding: clamp(0.75rem, 1.2vh, 1rem) clamp(1rem, 1.8vw, 1.4rem);
    }

    .sentence-text {
        font-size: clamp(1.45rem, 3vh, 2.2rem);
        line-height: 1.22;
    }

    .blank {
        font-size: clamp(1.15rem, 2.2vh, 1.5rem);
        min-width: clamp(120px, 12vw, 170px);
    }

    .options-label {
        font-size: clamp(1.25rem, 2.6vh, 1.75rem);
    }

    .options-grid {
        gap: clamp(0.35rem, 0.7vh, 0.5rem);
    }

    .option-btn {
        font-size: clamp(1.45rem, 3.3vh, 2.35rem);
        padding-top: clamp(0.6rem, 1.1vh, 0.85rem);
        padding-bottom: clamp(0.6rem, 1.1vh, 0.85rem);
        line-height: 1;
    }
}

@media (min-width: 900px) and (max-height: 820px) {
    .main-content {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .sentence-text {
        font-size: 1.45rem;
    }

    .option-btn {
        font-size: 1.5rem;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }

    .footer {
        padding-top: 0.25rem;
        padding-bottom: 0.25rem;
    }
}

@media (min-width: 900px) and (max-height: 720px) {
    .game-container {
        padding: 0.65rem;
    }

    .sentence-text {
        font-size: 1.25rem;
    }

    .option-btn {
        font-size: 1.3rem;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }
}
