/* ===== Interactive Quizzes page ===== */

.quiz-hero {
    padding: 64px 0 0;
    background:
        radial-gradient(circle at 7% 15%, rgba(243,111,0,.10), transparent 25%),
        radial-gradient(circle at 96% 30%, rgba(109,93,252,.10), transparent 28%),
        linear-gradient(#fff, #fafbff);
    border-bottom: 1px solid var(--border);
}

.quiz-title {
    font-size: clamp(36px, 5vw, 56px);
    letter-spacing: -2px;
}

.quiz-title strong {
    display: inline;
}

.quiz-intro {
    margin-top: 16px;
    max-width: 640px;
    color: var(--muted);
    font-size: 17px;
}

.quiz-tabs {
    display: flex;
    gap: 6px;
    margin-top: 36px;
    overflow-x: auto;
}

.quiz-tabs [role="tab"] {
    appearance: none;
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    padding: 13px 20px;
    border-radius: 12px 12px 0 0;
    font: inherit;
    font-size: 14px;
    font-weight: 750;
    color: var(--muted);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    top: 1px;
}

.quiz-tabs [role="tab"]:hover { color: var(--text); }

.quiz-tabs [role="tab"][aria-selected="true"] {
    background: var(--light);
    border-color: var(--border);
    color: var(--orange);
}

.quiz-tabs [role="tab"]:focus-visible,
.quiz-body button:focus-visible,
.cw-cell input:focus-visible {
    outline: 3px solid rgba(243,111,0,.45);
    outline-offset: 2px;
}

.quiz-body {
    padding: 44px 0 90px;
    background: var(--light);
}

.exam-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 28px;
}

.exam-label {
    color: var(--orange);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
}

.exam-head h2 {
    margin-top: 6px;
    font-size: clamp(26px, 3.4vw, 36px);
    line-height: 1.1;
    letter-spacing: -1.2px;
}

.exam-head p {
    margin-top: 8px;
    color: var(--muted);
    max-width: 620px;
    font-size: 14px;
}

.exam-meta {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.exam-meta div {
    min-width: 96px;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.exam-meta small {
    display: block;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 700;
}

.exam-meta b {
    font-size: 19px;
    font-variant-numeric: tabular-nums;
}

.exam-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.quiz-body .btn { cursor: pointer; font-family: inherit; }
.quiz-body .btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ----- Crossword ----- */

.cw-layout {
    display: grid;
    grid-template-columns: minmax(0, 520px) 1fr;
    gap: 34px;
    align-items: start;
}

.cw-board-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}

.cw-active-clue {
    min-height: 46px;
    padding: 11px 14px;
    margin-bottom: 14px;
    background: #fff4ea;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 650;
    color: var(--text);
}

.cw-active-clue b { color: var(--orange); margin-right: 6px; }

.cw-grid {
    display: grid;
    gap: 2px;
    background: transparent;
    user-select: none;
}

.cw-cell {
    position: relative;
    aspect-ratio: 1;
}

.cw-cell.block { background: transparent; }

.cw-cell input {
    display: block;
    min-width: 0;
    width: 100%;
    height: 100%;
    border: 1.5px solid #cfd5df;
    border-radius: 5px;
    background: white;
    text-align: center;
    text-transform: uppercase;
    font: inherit;
    font-weight: 800;
    font-size: clamp(13px, 2.6vw, 20px);
    color: var(--text);
    padding: 8px 0 0;
    caret-color: transparent;
    cursor: pointer;
}

.cw-cell .num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: clamp(7px, 1.4vw, 10px);
    font-weight: 700;
    color: var(--muted);
    pointer-events: none;
    line-height: 1;
}

.cw-cell.in-word input { background: #fff4ea; border-color: #ffc796; }
.cw-cell.current input { background: #ffe1c7; border-color: var(--orange); }
.cw-cell.wrong input { background: #fdecec; border-color: #e5484d; color: #c62a2f; }
.cw-cell.right input { background: #e9fbf5; border-color: var(--green); color: #127a5b; }
.cw-cell.revealed input { color: #c62a2f; }

.cw-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

.cw-clues {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.cw-clues h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    margin-bottom: 10px;
}

.cw-clues ol { list-style: none; display: grid; gap: 6px; }

.cw-clues li button {
    width: 100%;
    display: flex;
    gap: 10px;
    text-align: left;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: white;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.cw-clues li button:hover { border-color: #ffc796; }
.cw-clues li button b { color: var(--orange); min-width: 18px; }
.cw-clues li button.active { background: #fff4ea; border-color: var(--orange); }
.cw-clues li button.done { color: var(--muted); }
.cw-clues li button.done span { text-decoration: line-through; text-decoration-color: #c9ced8; }
.cw-clues li button.correct { border-color: var(--green); background: #f1fcf8; }
.cw-clues li button.incorrect { border-color: #f2b8ba; background: #fff6f6; }

/* ----- Spin the wheel ----- */

.sw-layout {
    display: grid;
    grid-template-columns: minmax(0, 440px) 1fr;
    gap: 40px;
    align-items: center;
}

.sw-wheel-wrap {
    position: relative;
    width: 100%;
    max-width: 440px;
    aspect-ratio: 1;
    margin: auto;
}

.sw-rotor {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-shadow: var(--shadow), 0 0 0 10px white, 0 0 0 11px var(--border);
    transition: transform 4.2s cubic-bezier(.12,.72,.12,1);
}

/* Topic wheel (at rest) and NXTROI wheel (shown only while spinning) */
#sw-wheel,
.sw-brand {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.sw-brand {
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s ease;
}

.sw-rotor.spinning .sw-brand { opacity: 1; transition-duration: .2s; }

.sw-pointer {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 17px solid transparent;
    border-right: 17px solid transparent;
    border-top: 32px solid var(--dark);
    z-index: 2;
    filter: drop-shadow(0 4px 6px rgba(16,24,39,.25));
}

.sw-spin {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 5px solid white;
    background: var(--dark);
    color: white;
    font: inherit;
    font-weight: 800;
    font-size: clamp(12px, 2.4vw, 16px);
    letter-spacing: 1px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(16,24,39,.3);
    transition: background .2s, transform .2s;
}

.sw-spin:hover:not(:disabled) { background: var(--orange); }
.sw-spin:disabled { cursor: not-allowed; background: #4b5563; }

.sw-question {
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 26px;
    min-height: 340px;
}

.sw-placeholder b { font-size: 22px; }
.sw-placeholder p { margin-top: 6px; color: var(--muted); }

.sw-topics {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
}

.sw-topics li {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 650;
}

.sw-topics i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.sw-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    border-radius: 999px;
    color: white;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .6px;
    text-transform: uppercase;
}

.sw-q-text {
    margin-top: 14px;
    font-size: 18px;
    font-weight: 750;
    line-height: 1.4;
}

.sw-q-text code,
.sw-options code,
.sw-explain code,
.review-list code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: .92em;
    background: #f2f4f8;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 5px;
}

.sw-q-code {
    margin-top: 12px;
    padding: 14px 16px;
    background: var(--dark);
    color: #e6edf7;
    border-radius: 10px;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre;
    overflow-x: auto;
}

.sw-options {
    display: grid;
    gap: 9px;
    margin-top: 18px;
}

.sw-options button {
    display: flex;
    gap: 12px;
    align-items: center;
    text-align: left;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 11px;
    background: white;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.sw-options button:hover:not(:disabled) { border-color: var(--orange); background: #fffaf6; }
.sw-options button:disabled { cursor: default; }

.sw-options button > span:first-child {
    flex: none;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 7px;
    background: var(--light);
    font-weight: 800;
    font-size: 12px;
}

.sw-options button.correct { border-color: var(--green); background: #effbf6; }
.sw-options button.correct > span:first-child { background: var(--green); color: white; }
.sw-options button.incorrect { border-color: #e5484d; background: #fff4f4; }
.sw-options button.incorrect > span:first-child { background: #e5484d; color: white; }

.sw-explain {
    margin-top: 16px;
    padding: 13px 15px;
    border-radius: 11px;
    font-size: 13.5px;
    background: var(--light);
}

.sw-explain.good { background: #effbf6; }
.sw-explain.bad { background: #fff4f4; }
.sw-explain b { display: block; margin-bottom: 3px; }

.sw-next { margin-top: 16px; }

/* ----- Results ----- */

.result-card {
    margin-top: 30px;
    padding: 30px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.result-top {
    display: flex;
    align-items: center;
    gap: 26px;
    flex-wrap: wrap;
}

.result-ring {
    --pct: 0;
    --ring: var(--green);
    width: 116px;
    height: 116px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--ring) calc(var(--pct) * 1%), #eef0f4 0);
    flex: none;
}

.result-ring span {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: white;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 800;
}

.result-top h3 { font-size: 24px; letter-spacing: -.6px; }
.result-top p { color: var(--muted); margin-top: 4px; }

.result-badge {
    display: inline-block;
    margin-top: 10px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .6px;
}

.result-badge.pass { background: #e9fbf5; color: #127a5b; }
.result-badge.fail { background: #fdecec; color: #c62a2f; }

.result-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 24px;
}

.result-breakdown div {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
}

.result-breakdown b { display: block; font-size: 18px; }

.review-list {
    list-style: none;
    display: grid;
    gap: 8px;
    margin-top: 22px;
}

.review-list li {
    padding: 12px 14px;
    border-left: 4px solid var(--green);
    background: var(--light);
    border-radius: 0 10px 10px 0;
    font-size: 13.5px;
}

.review-list li.miss { border-left-color: #e5484d; }
.review-list li small { display: block; color: var(--muted); margin-top: 2px; }

.result-card .exam-actions { margin-top: 24px; }

.noscript-msg {
    padding: 18px;
    background: #fff4ea;
    border-radius: 12px;
    margin-bottom: 20px;
}

@media (max-width: 960px) {
    .cw-layout, .sw-layout { grid-template-columns: 1fr; }
    .cw-board-wrap { max-width: 560px; }
}

@media (max-width: 640px) {
    .exam-head { flex-direction: column; align-items: flex-start; }
    .cw-clues { grid-template-columns: 1fr; }
    .cw-board-wrap { padding: 12px; }
    .cw-grid { gap: 1px; }
    .cw-cell input { border-radius: 3px; padding-top: 5px; }
    .sw-question { padding: 20px; min-height: 0; }
    .result-card { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    .sw-rotor { transition-duration: .01s; }
    .sw-brand { display: none; }
}

/* ===== Entry form, timer, participants ===== */

.quiz-hero-links { margin-top: 14px; font-size: 14px; font-weight: 700; }
.quiz-hero-links a { color: var(--orange); }
.quiz-hero-links a:hover { text-decoration: underline; }

.quiz-gate {
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
}

.gate-info {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.gate-info div {
    padding: 12px 14px;
    background: var(--light);
    border-radius: 12px;
}

[hidden] { display: none !important; }

.participants th,
.results-table th {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 700;
}

.gate-info small {
    display: block;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    font-weight: 700;
}

.gate-info b { font-size: 17px; }
.quiz-id { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; color: var(--orange-dark); letter-spacing: -.3px; }

.gate-status {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: 10px;
    background: #eef6ff;
    color: #1d4ed8;
    font-size: 13.5px;
    font-weight: 600;
}
.gate-status.closed { background: #fdecec; color: #b42318; }

.entry-form {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 16px;
}

.entry-form h3,
.entry-form .form-error,
.entry-form .form-foot { grid-column: 1 / -1; }
.entry-form h3 { font-size: 17px; }

.field { display: grid; gap: 5px; align-content: start; }
.field label { font-size: 13px; font-weight: 700; }
.field label span { color: var(--orange); }

.field input {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid #cfd5df;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: white;
}
.field input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,111,0,.15); }
.field input[aria-invalid="true"] { border-color: #e5484d; }
.field-error { color: #c62a2f; font-size: 12px; min-height: 0; }
.field-error:empty { display: none; }

.form-error { color: #c62a2f; font-size: 13.5px; font-weight: 600; }
.form-error:empty { display: none; }

.form-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.form-foot small { color: var(--muted); font-size: 12.5px; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.exam-meta .timer.warn { border-color: #f5a3a5; background: #fff4f4; }
.exam-meta .timer.warn b { color: #c62a2f; }

.cw-clues li button small { color: var(--muted); }
.sw-options button.chosen { border-color: var(--orange); background: #fffaf6; }

.rank-line { color: var(--text) !important; font-weight: 700; }
.no-attempts { align-self: center; color: var(--muted); font-size: 13px; }

.participants {
    margin-top: 30px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
}

.participants-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.participants-head h3 { font-size: 18px; }
.participants-head h3 span { color: var(--muted); font-weight: 600; font-size: 14px; }
.participants-head > div { display: flex; gap: 8px; }

.btn-sm { padding: 8px 13px; font-size: 12px; }

.table-wrap { overflow-x: auto; }

.participants table,
.results-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.participants th,
.participants td,
.results-table th,
.results-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.participants tr.me td,
.results-table tr.me td { background: #fff7f0; }

.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
td.empty { text-align: center; color: var(--muted); padding: 22px; white-space: normal; }

.you {
    margin-left: 7px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--orange);
    color: white;
    font-size: 10px;
    font-weight: 800;
    vertical-align: 1px;
}

.pill {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.pill.ok { background: #e9fbf5; color: #127a5b; }
.pill.live { background: #fff1e6; color: var(--orange-dark); }
.pill.muted { background: #f0f2f5; color: var(--muted); }

@media (max-width: 760px) {
    .entry-form { grid-template-columns: 1fr; }
    .gate-info { grid-template-columns: 1fr 1fr; }
    .gate-info div:first-child { grid-column: 1 / -1; }
    .quiz-gate, .participants { padding: 18px; }
}

/* ===== Results page ===== */

.results-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 28px 0 34px;
}
.results-controls label { font-size: 13px; font-weight: 700; }
.results-controls select {
    padding: 9px 12px;
    border: 1.5px solid #cfd5df;
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    background: white;
    min-width: 220px;
}
.results-controls small { color: var(--muted); font-size: 12px; }

.results-grid { display: grid; gap: 26px; }

.results-table {
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
}

.results-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.results-head h2 { font-size: 24px; letter-spacing: -.6px; margin-top: 2px; }

.winner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: 14px;
    background: linear-gradient(135deg, #fff4e5, #fffaf3);
    border: 1px solid #ffd8a8;
}
.winner .trophy { font-size: 30px; line-height: 1; }
.winner small { display: block; font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--orange-dark); }
.winner b { display: block; font-size: 18px; }
.winner span { color: var(--muted); font-size: 13px; }

.rank {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #f0f2f5;
    font-weight: 800;
    font-size: 12px;
}
.rank.r1 { background: #f5b301; color: white; }
.rank.r2 { background: #a8b0bd; color: white; }
.rank.r3 { background: #c77c3a; color: white; }
.results-table tr.first td { font-weight: 600; }
.results-table td .pill { margin-left: 6px; }
.results-grid > * { min-width: 0; }

.participants-head > div { align-items: center; flex-wrap: wrap; }
.p-updated { color: var(--muted); font-size: 12px; }
.field-count { color: var(--muted); font-size: 11.5px; }

/* Mobile number: country + dial code + digits */
.phone-group {
    display: flex;
    align-items: stretch;
    border: 1.5px solid #cfd5df;
    border-radius: 10px;
    background: white;
    overflow: hidden;
}
.phone-group:focus-within { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,111,0,.15); }
.phone-group select {
    max-width: 46%;
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--light);
    padding: 0 8px;
    font: inherit;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.phone-group select:focus { outline: none; background: #fff4ea; }
.phone-group .dial {
    display: flex;
    align-items: center;
    padding: 0 2px 0 10px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
}
.phone-group input,
.field .phone-group input {
    flex: 1;
    min-width: 0;
    border: 0;
    border-radius: 0;
    padding-left: 2px;
    box-shadow: none !important;
    letter-spacing: .5px;
}
.field .phone-group input:focus { box-shadow: none; }
.field:has(input[aria-invalid="true"]) .phone-group { border-color: #e5484d; }

.quiz-off {
    padding: 34px 26px;
    text-align: center;
    background: white;
    border: 1px solid var(--border);
    border-radius: 18px;
}
.quiz-off b { font-size: 20px; }
.quiz-off p { margin-top: 6px; color: var(--muted); }
.quiz-off a { color: var(--orange); font-weight: 700; }

/* ===== Memory Flip ===== */
.mf-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin-bottom: 12px; }
.mf-hint { margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); min-height: 21px; flex: 1 1 260px; }
.mf-mini { font-size: 13px; font-weight: 800; color: var(--dark); background: #fff7f0; border: 1px solid #ffd0a8; border-radius: 999px; padding: 5px 12px; white-space: pre; font-variant-numeric: tabular-nums; }
.mf-mini:empty { display: none; }
/* Sized by JS to fit the screen: columns and card height come from layout() */
.quiz-play .mf-board.mf-sized { grid-template-columns: repeat(var(--mf-cols, 4), minmax(0, 1fr)); gap: 10px; margin: 0 auto; }
.mf-board.mf-sized .mf-card { aspect-ratio: auto; height: var(--mf-h, 140px); min-width: 0; }
/* Hidden copy of a card, used only to measure how much room a definition needs */
.mf-probe { position: absolute !important; left: -9999px; top: 0; visibility: hidden; pointer-events: none; height: auto !important; aspect-ratio: auto !important; }
.mf-probe .mf-face { position: relative; inset: auto; display: block; transform: none; box-shadow: none; }
.mf-probe .mf-txt { font-size: 11px !important; }
/* Timer / score boxes share the width on small phones instead of pushing the page wider */
@media (max-width: 480px) {
    .exam-meta { width: 100%; }
    .exam-meta div { flex: 1 1 0; min-width: 0; padding: 8px 10px; }
}
.mf-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    perspective: 1200px;
}
.mf-board.mf-many { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.mf-card {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    border-radius: 16px;
    text-align: center;
}
.mf-card:focus-visible { outline: 3px solid rgba(243,111,0,.5); outline-offset: 3px; }
.mf-inner {
    position: absolute; inset: 0; display: block;
    transform-style: preserve-3d;
    transition: transform .45s cubic-bezier(.2,.7,.2,1);
    border-radius: 16px;
}
.mf-card.up .mf-inner, .mf-card.done .mf-inner { transform: rotateY(180deg); }
.mf-face {
    position: absolute; inset: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: 16px;
    display: grid; place-items: center;
    padding: 12px;
}
.mf-back {
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.14), transparent 40%),
        linear-gradient(135deg, var(--dark), #24314a);
    box-shadow: 0 10px 24px rgba(16,24,39,.18);
    transition: transform .2s, box-shadow .2s;
}
.mf-back svg { width: 34%; max-width: 64px; }
.mf-card:hover:not(.up):not(.done) .mf-back { transform: translateY(-2px); box-shadow: 0 16px 30px rgba(16,24,39,.25); }
.mf-card.loading .mf-back { opacity: .75; }
.mf-card.loading .mf-back svg { animation: mf-pulse .8s ease-in-out infinite; }
@keyframes mf-pulse { 50% { transform: scale(.9); opacity: .6; } }
.mf-front {
    transform: rotateY(180deg);
    background: white;
    border: 2px solid var(--border);
    box-shadow: var(--shadow);
    padding-top: 26px;
}
.mf-tag { position: absolute; top: 8px; left: 10px; font-size: 9.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; }
.mf-txt { display: block; }
.mf-term .mf-front { border-color: #ffd0a8; }
.mf-term .mf-tag { color: var(--orange-dark); }
.mf-term .mf-txt { font-size: clamp(16px, 2.3vw, 22px); font-weight: 800; }
.mf-def .mf-front { border-color: #d6d1ff; }
.mf-def .mf-tag { color: var(--purple); }
.mf-def .mf-txt { font-size: clamp(11px, 1.3vw, 13.5px); font-weight: 600; color: #344054; line-height: 1.32; }
.mf-card.done .mf-front { border-color: var(--green); background: #f0fcf7; }
.mf-card.done .mf-tag { color: #127a5b; }
.mf-card.done { cursor: default; }
.mf-card.miss .mf-front { border-color: #e5484d; background: #fff4f4; }

@media (max-width: 680px) {
    .mf-board, .mf-board.mf-many { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .mf-card { aspect-ratio: 1 / 1; }
    .mf-face { padding: 10px; }
    .mf-front { padding-top: 26px; }
    .mf-def .mf-txt { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { .mf-inner { transition-duration: .01s; } }

/* Three tabs on small screens: share the width instead of scrolling off-screen */
@media (max-width: 640px) {
    .quiz-tabs { gap: 4px; overflow: visible; }
    .quiz-tabs [role="tab"] {
        flex: 1 1 0;
        min-width: 0;
        white-space: normal;
        padding: 10px 6px;
        font-size: 12.5px;
        line-height: 1.25;
        text-align: center;
    }
}
