
:root {
    --md3-primary: #6750A4;
    --md3-on-primary: #FFFFFF;
    --md3-surface: #FFFBFE;
    --md3-on-surface: #1C1B1F;
    --md3-secondary: #625B71;
    --md3-outline: #79747E;
    --md3-surface-variant: #E7E0EC;
    --md3-elevation-1: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.10);
    --md3-elevation-2: 0 2px 6px rgba(0,0,0,0.10), 0 6px 10px rgba(0,0,0,0.08);
    --radius: 12px;
}

html, body {
    min-height: 100%;
    margin: 0;
    background: var(--md3-surface);
    color: var(--md3-on-surface);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    line-height: 1.5;
}
body { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.2px;
}

.subtitle {
    color: #4A4458;
    font-size: 0.95rem;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.06s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--md3-primary);
    color: var(--md3-on-primary);
    box-shadow: var(--md3-elevation-1);
}

.actions-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
}
.actions-left,
.actions-right { display: flex; gap: 10px; flex-wrap: wrap; }

/* Trophy outside card */
.card { position: relative; }
.award-trophy {
    position: absolute;
    right: -28px;
    top: 50%;
    transform: translateY(-50%);
    color: #6A5CB3;
    background: transparent;
    font-size: 28px;
}

.btn-tonal {
    background: var(--md3-surface-variant);
    color: #1D192B;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 860px) {
    .layout { grid-template-columns: 1fr; }
}

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--md3-elevation-1);
    border: 1px solid #E8E0F0;
}

.panel {
    padding: 16px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.panel h2 {
    font-size: 1.1rem;
    margin: 0 0 12px 0;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #F6EDFF;
    color: #1D192B;
    border-radius: 28px;
    padding: 10px 14px;
    font-weight: 600;
    border: 1px solid var(--md3-outline);
    box-shadow: var(--md3-elevation-1);
    user-select: none;
}

/* Selected word chip (click-to-select) */
.chip.selected {
    outline: 3px solid var(--md3-primary);
    box-shadow: var(--md3-elevation-2);
    background: #ECE3FF;
}

.chip[draggable="true"] { cursor: grab; }
.chip.dragging { opacity: 0.6; }

.chip .handle {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--md3-primary);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.9);
    flex: none;
}

.targets { display: flex; flex-wrap: wrap; gap: 12px; }

.target {
    position: relative;
    padding: 8px 10px 8px 10px;
    background: #FFFBFE;
    border-radius: var(--radius);
    border: 1px dashed var(--md3-outline);
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Flowing bubble sizing */
.chips .chip { flex: 0 1 auto; }
.targets .target { flex: 0 1 auto; max-width: 100%; }

/* Preserve full-width rows for other challenge types placed in .chips */
.chips .image-row,
.chips .gender-row { flex: 1 1 100%; width: 100%; }

/* Compact targets on narrow screens */
@media (max-width: 560px) {
    .targets { gap: 10px; }
}

.target:hover { box-shadow: var(--md3-elevation-1); }

.target-label { color: #4A4458; font-size: 0.92rem; max-width: 36ch; word-break: break-word; }
.target-dropzone { min-width: 24px; min-height: 24px; display: inline-flex; align-items: center; }

.target.accept { background: #F0EDFF; border-color: var(--md3-primary); }
.target.filled { border-style: solid; background: white; }
.target.correct { outline: 2px solid #0F9D58; background: #E6F4EA; }
.target.incorrect { outline: 2px solid #B3261E; }

.score {
    margin-top: 12px;
    color: #4A4458;
    font-weight: 600;
}

.footer-note {
    margin-top: 18px;
    color: #4A4458;
    font-size: 0.9rem;
}

body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial; }
.gender-row { display: grid; grid-template-columns: auto auto 1fr; gap: 10px; align-items: center; background: transparent; border: none; border-radius: 0; padding: 0; }
.gender-btn { background: var(--md3-surface-variant); color: #1D192B; padding: 8px 14px; font-size: 1rem; min-width: 64px; height: 40px; border-radius: 999px; box-shadow: var(--md3-elevation-2); }
.gender-btn.correct { background: #E6F4EA; color: #0D652D; }
.gender-btn.incorrect { background: #FCE8E6; color: #A50E0E; }
.gender-btn.disabled { opacity: 0.7; }
.noun-label { font-weight: 600; color: #1D192B; }
.noun-check { margin-left: 8px; font-weight: 700; }
#btn-continue.is-disabled { opacity: 0.5; cursor: not-allowed; }
.image-row { display: grid; grid-template-rows: auto auto; gap: 10px; }
.image-bottom { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; }
.image-thumb { width: 160px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--md3-outline); }
.image-input { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--md3-outline); font-size: 1rem; }
.answer-mark { font-weight: 700; }
.answer-mark.ok { color: #0D652D; }
.answer-mark.bad { color: #A50E0E; }
.correct-answer { color: #4A4458; font-size: 0.95rem; }

/* Completion modal */
.completion-modal {
    position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.4); z-index: 9999;
}
.completion-card {
    background: white; border-radius: 16px; padding: 20px; max-width: 420px; width: 92%;
    box-shadow: var(--md3-elevation-2); text-align: center; border: 1px solid #E8E0F0;
}
.completion-card img { max-width: 100%; height: auto; }
.completion-actions { margin-top: 16px; display: flex; justify-content: center; }