/* Final design layer: loader, form controls, action buttons, guest navigation, icons. */

/* ---------- Loader (crawlable prerender stays in the DOM but is visually hidden) ---------- */
#app > .seo-prerender {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    border: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

.app-loading {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.loading-logo-wrap {
    display: grid;
    place-items: center;
    width: 112px;
    height: 112px;
    border-radius: 34px;
    background: rgba(255, 255, 255, .78);
    box-shadow: 0 22px 50px rgba(83, 61, 164, .2), inset 0 1px 0 #fff;
    animation: nsm-loader-glow 2.6s ease-in-out infinite;
}

.loading-logo { width: 78px; height: 78px; object-fit: contain; }

@keyframes nsm-loader-glow {
    0%, 100% { box-shadow: 0 22px 50px rgba(83, 61, 164, .2), 0 0 0 0 rgba(121, 85, 239, .22); }
    50% { box-shadow: 0 26px 56px rgba(83, 61, 164, .26), 0 0 0 16px rgba(121, 85, 239, 0); }
}

:root[data-theme="dark"] .app-loading {
    background: radial-gradient(circle at 50% 35%, #342a4d 0, #221c31 52%, #17131f 100%);
    color: #f4eeff;
}

:root[data-theme="dark"] .app-loading span { color: #c1b7d6; }
:root[data-theme="dark"] .loading-logo-wrap { background: rgba(255, 255, 255, .08); box-shadow: 0 22px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .12); }
:root[data-theme="dark"] .loading-progress { background: #3a3150; }

/* ---------- Checkboxes, radios, switches ---------- */
input[type="checkbox"],
input[type="radio"] {
    -webkit-appearance: none;
    appearance: none;
    display: inline-grid;
    flex: 0 0 auto;
    place-content: center;
    width: 21px;
    height: 21px;
    margin: 0;
    border: 1.5px solid #cdc3e6;
    background: #fff;
    cursor: pointer;
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

input[type="checkbox"] { border-radius: 7px; }
input[type="radio"] { border-radius: 50%; }

input[type="checkbox"]::before,
input[type="radio"]::before {
    content: "";
    transform: scale(0);
    transition: transform .22s cubic-bezier(.34, 1.56, .64, 1);
    background: #fff;
}

input[type="checkbox"]::before {
    width: 11px;
    height: 11px;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%);
}

input[type="radio"]::before {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover { border-color: #8f6cf2; box-shadow: 0 0 0 4px rgba(112, 72, 232, .1); }

input[type="checkbox"]:checked,
input[type="radio"]:checked {
    border-color: transparent;
    background: linear-gradient(135deg, #8461f2, #5f3bd2);
    box-shadow: 0 5px 12px rgba(93, 60, 208, .3);
}

input[type="checkbox"]:checked::before,
input[type="radio"]:checked::before { transform: scale(1); }

input[type="checkbox"]:active,
input[type="radio"]:active { transform: scale(.9); }

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(112, 72, 232, .28); }

input[type="checkbox"]:disabled,
input[type="radio"]:disabled { opacity: .5; cursor: not-allowed; }

.filter-checkbox,
.filter-radio {
    gap: 11px;
    padding: 0 10px;
    cursor: pointer;
    user-select: none;
}

.filter-checkbox span,
.filter-radio span { transition: color .16s ease; }

.filter-checkbox:has(input:checked) span,
.filter-radio:has(input:checked) span { color: #4f2fc0; font-weight: 750; }

.filter-toggle input[type="checkbox"] {
    width: 42px;
    height: 24px;
    border-radius: 999px;
    place-content: center start;
    padding: 0 3px;
}

.filter-toggle input[type="checkbox"]::before {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    clip-path: none;
    transform: translateX(0) scale(1);
    box-shadow: 0 2px 5px rgba(37, 24, 87, .26);
    transition: transform .24s cubic-bezier(.34, 1.4, .64, 1), background-color .18s ease;
}

.filter-toggle input[type="checkbox"]:not(:checked)::before { background: #b9afd0; }
.filter-toggle input[type="checkbox"]:checked::before { transform: translateX(18px) scale(1); }

:root[data-theme="dark"] input[type="checkbox"],
:root[data-theme="dark"] input[type="radio"] { border-color: #5d5178; background: #2a2438; }

:root[data-theme="dark"] input[type="checkbox"]:checked,
:root[data-theme="dark"] input[type="radio"]:checked {
    border-color: transparent;
    background: linear-gradient(135deg, #9a82f7, #7552e6);
    box-shadow: 0 5px 14px rgba(0, 0, 0, .35);
}

:root[data-theme="dark"] input[type="checkbox"]:hover,
:root[data-theme="dark"] input[type="radio"]:hover { border-color: #a58cff; box-shadow: 0 0 0 4px rgba(165, 140, 255, .14); }

:root[data-theme="dark"] .filter-checkbox:has(input:checked) span,
:root[data-theme="dark"] .filter-radio:has(input:checked) span { color: #e2d8ff; }

:root[data-theme="dark"] .filter-toggle input[type="checkbox"]:not(:checked)::before { background: #81769a; }

:root[data-theme="dark"] .filter-checkbox:hover,
:root[data-theme="dark"] .filter-radio:hover { background: rgba(165, 140, 255, .1); }

/* ---------- Select ---------- */
select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235a3fc4' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 15px;
    cursor: pointer;
}

:root[data-theme="dark"] select {
    background-color: #2a2438;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cdbfff' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    border-color: #4a405e;
    color: #f0e9ff;
}

:root[data-theme="dark"] select option { background: #2a2438; color: #f0e9ff; }

/* ---------- Action buttons ---------- */
.card-action,
.subject-exercise-card .card-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    margin-top: 6px;
    padding: 0 18px;
    border: 1px solid rgba(112, 72, 232, .2);
    border-radius: 13px;
    background: linear-gradient(180deg, #f7f3ff, #efe9ff);
    color: #5431c7;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .01em;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease;
}

.card-action > span { display: inline-block; transition: transform .22s cubic-bezier(.34, 1.56, .64, 1); }

.card-action:hover,
.card-action:focus-visible {
    border-color: transparent;
    background: linear-gradient(135deg, #7d59f0, #5c38d0);
    color: #fff;
    box-shadow: 0 12px 24px rgba(93, 60, 208, .3);
    transform: translateY(-1px);
}

.card-action:hover > span,
.card-action:focus-visible > span { transform: translateX(4px); }
.card-action:active { transform: translateY(0) scale(.98); }

:root[data-theme="dark"] .card-action,
:root[data-theme="dark"] .subject-exercise-card .card-action {
    border-color: #5b4b7b;
    background: linear-gradient(180deg, #3a3053, #322a48);
    color: #e0d4ff;
}

:root[data-theme="dark"] .card-action:hover,
:root[data-theme="dark"] .card-action:focus-visible {
    border-color: transparent;
    background: linear-gradient(135deg, #9077f5, #7452e4);
    color: #fff;
    box-shadow: 0 12px 26px rgba(0, 0, 0, .4);
}

/* Hover must never swallow the label colour. */
.button { transition: transform .18s ease, box-shadow .2s ease, background .2s ease, color .2s ease, border-color .2s ease; }
.button:active:not(:disabled) { transform: scale(.98); }
.button-primary,
.button-primary:hover,
.button-primary:focus-visible,
.button-primary:active { color: #fff; }

.button-secondary:hover:not(:disabled),
.button-ghost:hover:not(:disabled) { background: #e8e0ff; color: #4526ad; border-color: #cfc0f8; }

:root[data-theme="dark"] .button-secondary:hover:not(:disabled),
:root[data-theme="dark"] .button-ghost:hover:not(:disabled) { background: #3b3152; color: #f6f0ff; border-color: #6a5a92; }

/* ---------- Game icons ---------- */
.game-icon .glyph-icon { width: 56%; height: 56%; }
.subject-card-icon .glyph-icon { width: 54%; height: 54%; }
.practice-target .game-icon .glyph-icon,
.recent-row .game-icon .glyph-icon { width: 54%; height: 54%; }
.glyph-icon { display: block; flex: none; }
.lessons-banner-link .glyph-icon { width: 20px; height: 20px; }

/* ---------- Guest navigation ---------- */
.main-nav.is-guest { justify-content: flex-start; }

.nav-guest {
    display: grid;
    gap: 10px;
    padding: 8px 4px;
}

.nav-guest p {
    margin: 0 0 6px;
    color: #6f6882;
    font-size: 13px;
    line-height: 1.6;
}

.nav-guest .button { width: 100%; justify-content: center; min-height: 44px; }
.main-nav .nav-guest .button-primary { color: #fff; }
.main-nav .nav-guest .button-secondary { color: #5431c7; }
.main-nav .nav-guest .button-secondary:hover { color: #4526ad; background: #e8e0ff; }
:root[data-theme="dark"] .main-nav .nav-guest .button-secondary { color: #e4dcf2; }

/* ===== Auth pages without sidebar ===== */
.app-shell.app-shell-auth { display: block; }
.app-shell-auth .app-main { display: grid; min-height: 100dvh; place-items: center; padding: 32px 16px; }
.app-shell-auth .page-container { width: 100%; max-width: 520px; }

/* ===== Achievements spacing ===== */
.achievement-page { display: grid; gap: 20px; }
.achievement-page > * { margin: 0; }
.achievement-collection { padding-top: 4px; }
.achievement-overview { margin-bottom: 4px; }

/* ===== Home insights aligned with subject grid ===== */
.home-insights { width: 100%; box-sizing: border-box; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.home-insights > * { min-width: 0; }
@media (max-width: 1100px) { .home-insights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .home-insights { grid-template-columns: 1fr; } }

/* Progress card: light theme variant */
:root:not([data-theme="dark"]) .home-progress-card {
    border-color: #ddd2fb;
    background: radial-gradient(circle at 90% 4%, rgba(170, 130, 255, .28), transparent 40%), linear-gradient(125deg, #f6f1ff, #e9defd);
    color: #2b1768;
}
:root:not([data-theme="dark"]) .home-progress-label { color: #6a42d6; }
:root:not([data-theme="dark"]) .home-progress-copy > span { color: #5d5280; }
:root:not([data-theme="dark"]) .home-progress-track { background: rgba(98, 62, 200, .15); }

/* ===== Profile username edit ===== */
.profile-hero { min-width: 0; }
.name-inline-edit { display: grid; width: 100%; max-width: 320px; margin: 12px auto 0; gap: 10px; box-sizing: border-box; }
.name-inline-edit input { width: 100%; min-width: 0; box-sizing: border-box; text-align: center; }
.name-edit-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.name-edit-actions .button { width: 100%; justify-content: center; }
:root[data-theme="dark"] .name-inline-edit input { background: #241d36; border-color: #3d3358; color: #f1ecfb; }

/* ===== 2FA panel ===== */
.twofa-panel { display: grid; gap: 14px; margin-top: 18px; padding: 18px; border-radius: 18px; text-align: left; }
.twofa-head { display: flex; align-items: center; gap: 12px; }
.twofa-shield { display: grid; flex: 0 0 40px; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: rgba(124, 58, 237, .14); font-size: 20px; }
.twofa-head-copy { flex: 1; min-width: 0; }
.twofa-head-copy h3 { margin: 0; font-size: 15px; }
.twofa-head-copy p { margin: 2px 0 0; font-size: 12px; opacity: .7; }
.twofa-badge { flex: 0 0 auto; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.twofa-badge.is-on { background: rgba(16, 185, 129, .16); color: #0f8a62; }
.twofa-badge.is-off { background: rgba(124, 58, 237, .12); color: #6b46d8; }
.twofa-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.twofa-row .twofa-input { flex: 1 1 160px; min-width: 0; width: auto; }
.twofa-fields { display: grid; gap: 8px; }
.twofa-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.twofa-actions .button { flex: 1 1 140px; justify-content: center; }
.twofa-setup { display: grid; gap: 12px; justify-items: center; text-align: center; }
.twofa-qr { padding: 12px; border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(60, 30, 140, .15); }
.twofa-setup .twofa-row { width: 100%; }
.twofa-code { text-align: center; letter-spacing: .3em; font-weight: 800; }
.twofa-manual code { display: block; margin-top: 6px; word-break: break-all; font-size: 12px; }
.twofa-codes ul { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin: 10px 0; padding: 0; list-style: none; }
.twofa-codes li { padding: 8px; border-radius: 10px; background: rgba(124, 58, 237, .1); font-family: ui-monospace, monospace; font-size: 13px; text-align: center; }
.button-danger { border: 1px solid rgba(220, 38, 38, .35); background: rgba(220, 38, 38, .08); color: #c42626; font-weight: 700; }
.button-danger:hover { background: #dc2626; color: #fff; }
:root[data-theme="dark"] .twofa-qr { background: #fff; }
:root[data-theme="dark"] .twofa-badge.is-on { color: #5eead4; }
:root[data-theme="dark"] .twofa-badge.is-off { color: #cdbcff; }
:root[data-theme="dark"] .button-danger { color: #fca5a5; }

/* ===== Tournament podium ===== */
.podium-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; max-width: 760px; margin: 8px auto 0; }
.podium-card { min-height: 0; padding: 18px 10px 0; overflow: visible; border: 0; background: none; box-shadow: none; animation: podiumRise .8s cubic-bezier(.2, .9, .3, 1) both; }
.podium-1 { animation-delay: .25s; }
.podium-2 { animation-delay: .05s; }
.podium-3 { animation-delay: .45s; }
.podium-avatar { position: relative; width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 50%; font-size: 36px; border: 3px solid var(--medal); box-shadow: 0 0 0 4px color-mix(in srgb, var(--medal) 25%, transparent), 0 10px 26px color-mix(in srgb, var(--medal) 45%, transparent); }
.podium-1 { --medal: #f5b82e; --step-h: 120px; }
.podium-2 { --medal: #aab4c8; --step-h: 88px; }
.podium-3 { --medal: #d08a52; --step-h: 64px; }
.podium-1 .podium-avatar { width: 88px; height: 88px; font-size: 44px; animation: podiumGlow 2.4s ease-in-out infinite; }
.podium-crown { position: absolute; top: -14px; font-size: 28px; animation: crownBob 2.4s ease-in-out infinite; filter: drop-shadow(0 4px 6px rgba(245, 184, 46, .5)); }
.podium-card .podium-name { display: block; max-width: 100%; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.podium-card .podium-score { display: block; margin-bottom: 10px; font-weight: 700; }
.podium-step { display: grid; width: 100%; height: var(--step-h); place-items: center; border-radius: 16px 16px 0 0; background: linear-gradient(180deg, color-mix(in srgb, var(--medal) 85%, #fff), color-mix(in srgb, var(--medal) 55%, #3b2a7a)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .45); transform-origin: bottom; animation: stepGrow .8s cubic-bezier(.2, .9, .3, 1) both; }
.podium-step span { color: #fff; font-size: 34px; font-weight: 900; text-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
.tournament-row { transition: transform .2s ease, box-shadow .2s ease; animation: rowIn .4s ease both; }
.tournament-row:hover { transform: translateX(3px); }
:root[data-theme="dark"] .podium-card .podium-score { color: #b9aed6; }
:root[data-theme="dark"] .tournament-table-card { background: #1d172b; border-color: #35294d; }
:root[data-theme="dark"] .tournament-row { background: #261e38; border-color: #35294d; }
:root[data-theme="dark"] .tournament-row.is-self { background: #3a2c63; border-color: #7a5ceb; }
:root[data-theme="dark"] .tournament-rank, :root[data-theme="dark"] .tournament-score { color: #d8ccff; }
@keyframes podiumRise { from { opacity: 0; transform: translateY(36px); } to { opacity: 1; transform: none; } }
@keyframes stepGrow { from { transform: scaleY(.1); } to { transform: scaleY(1); } }
@keyframes podiumGlow { 50% { box-shadow: 0 0 0 7px rgba(245, 184, 46, .22), 0 12px 34px rgba(245, 184, 46, .6); } }
@keyframes crownBob { 50% { transform: translateY(-4px) rotate(-4deg); } }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .podium-card, .podium-step, .podium-avatar, .podium-crown, .tournament-row { animation: none !important; } }
:root[data-theme="dark"] .main-nav .nav-guest .button-secondary:hover { color: #f6f0ff; background: #3b3152; }

:root[data-theme="dark"] .nav-guest p { color: #beb4d0; }

/* Dark theme: gameplay surfaces */
:root[data-theme="dark"] .game-header,
:root[data-theme="dark"] .game-panel,
:root[data-theme="dark"] .game-progress,
:root[data-theme="dark"] .accent-word-wrap {
  background: linear-gradient(180deg, rgba(34, 28, 58, .94), rgba(22, 18, 40, .94)) !important;
  border: 1px solid rgba(160, 140, 255, .22) !important;
  color: #f3f0ff !important;
  box-shadow: 0 18px 44px rgba(0, 0, 0, .38) !important;
}
:root[data-theme="dark"] .game-header h1,
:root[data-theme="dark"] .game-title h1,
:root[data-theme="dark"] .game-title .eyebrow { color: #f6f3ff !important; -webkit-text-fill-color: currentColor !important; }
:root[data-theme="dark"] .game-title .eyebrow { color: #b8a6ff !important; }
:root[data-theme="dark"] .math-problem,
:root[data-theme="dark"] .prompt-word,
:root[data-theme="dark"] .word-card,
:root[data-theme="dark"] .pattern-sequence,
:root[data-theme="dark"] .geometry-stage {
  background: linear-gradient(135deg, rgba(124, 92, 255, .28), rgba(70, 50, 150, .22)) !important;
  border: 1px solid rgba(160, 140, 255, .28);
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}
:root[data-theme="dark"] .back-button {
  background: rgba(255, 255, 255, .08) !important;
  color: #f3f0ff !important;
  border: 1px solid rgba(255, 255, 255, .14);
}
:root[data-theme="dark"] .answer-area input {
  background: rgba(10, 8, 24, .6) !important;
  color: #fff !important;
  border-color: rgba(160, 140, 255, .35) !important;
}
:root[data-theme="dark"] .answer-area input::placeholder { color: #a79ccf; }
:root[data-theme="dark"] .hint-inline-button,
:root[data-theme="dark"] .speak-button {
  background: rgba(255, 255, 255, .08) !important;
  border: 1px solid rgba(255, 255, 255, .14) !important;
}
:root[data-theme="dark"] kbd { background: rgba(255, 255, 255, .1); color: #f3f0ff; border-color: rgba(255, 255, 255, .2); }
:root[data-theme="dark"] .prompt-hint,
:root[data-theme="dark"] .keyboard-hint { color: #b9b0dc; }
:root[data-theme="dark"] .tip-card { background: rgba(255, 190, 90, .1); border-color: rgba(255, 190, 90, .25); color: #ffd9a0; }
:root[data-theme="dark"] .tip-card p { color: #e7c496; }

/* ===== Round 3 polish ===== */
/* Light sidebar */
:root:not([data-theme="dark"]) .site-header { background: linear-gradient(180deg, #ffffff, #f7f3ff 70%, #f1ebff); border-color: #e6def8; box-shadow: 0 16px 40px rgba(94, 63, 190, .10); }
:root:not([data-theme="dark"]) .main-nav .nav-action { color: #5a5274; }
:root:not([data-theme="dark"]) .main-nav .nav-icon { color: #7c5ce6; stroke: currentColor; fill: none; }
:root:not([data-theme="dark"]) .main-nav .nav-action:hover { background: rgba(124, 92, 230, .10); color: #5b3cc4; }
:root:not([data-theme="dark"]) .main-nav .nav-action.active { background: linear-gradient(135deg, #ede6ff, #e1d6ff); color: #5b3cc4; box-shadow: inset 0 0 0 1px rgba(124, 92, 230, .25); }

/* Profile settings: full-width children */
.profile-controls-card .profile-settings > * { grid-column: 1 / -1; }
.profile-controls-card .profile-settings .profile-class-block { grid-column: 1 / -1; }
.profile-controls-card .twofa-panel { width: 100%; box-sizing: border-box; margin-top: 8px; }
.profile-danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 8px; padding: 14px 16px; border: 1px dashed rgba(220, 38, 38, .35); border-radius: 16px; }
.profile-danger-zone div { display: grid; gap: 2px; min-width: 0; }
.profile-danger-zone small { opacity: .7; font-size: 12px; }
.profile-controls-card .profile-danger-zone .profile-reset-main { width: auto; flex: 0 0 auto; margin: 0; }
@media (max-width: 560px) { .profile-danger-zone { flex-direction: column; align-items: stretch; } .profile-controls-card .profile-danger-zone .profile-reset-main { width: 100%; } }

/* QR: no double frame */
.twofa-qr { width: fit-content; padding: 0; background: none; box-shadow: none; }
.twofa-qr .qr-frame { margin: 0; }

/* Podium glow per medal */
.podium-avatar, .podium-1 .podium-avatar { animation: medalGlow 2.6s ease-in-out infinite; }
@keyframes medalGlow {
    0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--medal) 30%, transparent), 0 0 14px 2px color-mix(in srgb, var(--medal) 45%, transparent); }
    50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--medal) 20%, transparent), 0 0 30px 8px color-mix(in srgb, var(--medal) 70%, transparent); }
}
.podium-card .podium-avatar[class*="avatar-bg-"] { border-color: var(--medal); }

/* Level missing XP */
.level-missing { display: block; margin-top: 2px; color: #7c5ce6; font-size: 12px; font-style: normal; font-weight: 800; }
:root[data-theme="dark"] .level-missing { color: #c4b0ff; }

/* ===== Round 4: icons, level cards, media search ===== */
.fx-icon { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em; overflow: visible; }
.stat-icon .fx-icon, .achievement-overview-icon .fx-icon { width: 24px; height: 24px; vertical-align: middle; }
.fx-energy { filter: drop-shadow(0 0 4px rgba(255, 190, 40, .65)); animation: fxZap 2.6s ease-in-out infinite; transform-origin: center; }
@keyframes fxZap {
    0%, 55%, 100% { transform: scale(1); filter: drop-shadow(0 0 3px rgba(255, 190, 40, .5)); }
    60% { transform: scale(1.18) rotate(-6deg); filter: drop-shadow(0 0 10px rgba(255, 220, 80, 1)) brightness(1.25); }
    66% { transform: scale(.96); }
    72% { transform: scale(1.1) rotate(4deg); filter: drop-shadow(0 0 8px rgba(255, 220, 80, .9)); }
}
.fx-flame { filter: drop-shadow(0 0 4px rgba(255, 110, 30, .6)); }
.fx-flame-body { transform-origin: 50% 100%; animation: fxFlicker 1.1s ease-in-out infinite alternate; }
.fx-flame-core { transform-origin: 50% 100%; animation: fxFlicker 0.8s ease-in-out infinite alternate-reverse; }
@keyframes fxFlicker {
    0% { transform: scale(1, 1) skewX(0); }
    35% { transform: scale(.95, 1.07) skewX(-2deg); }
    70% { transform: scale(1.04, .96) skewX(2deg); }
    100% { transform: scale(.97, 1.05) skewX(-1deg); }
}
@media (prefers-reduced-motion: reduce) { .fx-energy, .fx-flame-body, .fx-flame-core { animation: none; } }

/* Level cards */
.levels-list { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.level-color-mint { --lv: #34d399; } .level-color-blue { --lv: #3b82f6; } .level-color-violet { --lv: #8b5cf6; }
.level-color-gold { --lv: #f5b82e; } .level-color-orange { --lv: #fb923c; } .level-color-plum { --lv: #c026d3; }
.level-color-pink { --lv: #ec4899; } .level-color-cyan { --lv: #22d3ee; } .level-color-rainbow { --lv: #a855f7; }
.levels-list .level-row {
    position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; padding: 14px; min-width: 0;
    border: 1px solid color-mix(in srgb, var(--lv, #8b5cf6) 35%, transparent); border-radius: 18px;
    background: linear-gradient(145deg, color-mix(in srgb, var(--lv, #8b5cf6) 16%, #fff), color-mix(in srgb, var(--lv, #8b5cf6) 6%, #fff));
    box-shadow: 0 6px 18px color-mix(in srgb, var(--lv, #8b5cf6) 18%, transparent);
    transition: transform .2s ease, box-shadow .2s ease;
}
.levels-list .level-row::after { content: ""; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .45) 50%, transparent 60%); transform: translateX(-120%); }
.levels-list .level-row:hover { transform: translateY(-2px); }
.levels-list .level-row:hover::after { transform: translateX(120%); transition: transform .7s ease; }
.levels-list .level-row.current { border-width: 2px; border-color: var(--lv, #8b5cf6); animation: lvPulse 2.4s ease-in-out infinite; }
@keyframes lvPulse { 50% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--lv, #8b5cf6) 22%, transparent), 0 10px 28px color-mix(in srgb, var(--lv, #8b5cf6) 45%, transparent); } }
.levels-list .level-row .level-badge { flex: 0 0 auto; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 24px; background: linear-gradient(145deg, color-mix(in srgb, var(--lv, #8b5cf6) 70%, #fff), var(--lv, #8b5cf6)); box-shadow: 0 6px 14px color-mix(in srgb, var(--lv, #8b5cf6) 45%, transparent); }
.levels-list .level-row.level-color-rainbow .level-badge { background: linear-gradient(135deg, #f43f5e, #f59e0b, #22c55e, #3b82f6, #a855f7); }
.levels-list .level-row strong { display: block; font-size: 13px; }
.levels-list .level-row small { display: flex; align-items: center; gap: 4px; }
.levels-list .level-current { padding: 3px 8px; border-radius: 999px; background: var(--lv, #8b5cf6); color: #fff; font-size: 10px; font-weight: 900; }
:root[data-theme="dark"] .levels-list .level-row { background: linear-gradient(145deg, color-mix(in srgb, var(--lv, #8b5cf6) 28%, #1e1830), #1e1830); border-color: color-mix(in srgb, var(--lv, #8b5cf6) 55%, transparent); }
:root[data-theme="dark"] .levels-list .level-row.current { background: linear-gradient(145deg, color-mix(in srgb, var(--lv, #8b5cf6) 38%, #1e1830), #231b3a); }
:root[data-theme="dark"] .levels-list .level-row::after { background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, .12) 50%, transparent 60%); }
@media (max-width: 560px) { .levels-list { grid-template-columns: 1fr; } }

/* Media search dark */
:root[data-theme="dark"] .media-search { background: #241d38; border-color: #3f3560; }
:root[data-theme="dark"] .media-search input { background: transparent !important; box-shadow: none !important; border: 0 !important; color: #f1ecfb; }
.media-search input, .media-search input:focus { background: transparent !important; box-shadow: none !important; border: 0 !important; outline: 0; }
.media-search:focus-within { border-color: #7a5ceb; box-shadow: 0 0 0 3px rgba(122, 92, 235, .2); }

/* ===== Round 5 ===== */
/* Autofill / inputs (no yellow) */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus, input:-webkit-autofill:active {
    -webkit-text-fill-color: #2b1f4d; caret-color: #2b1f4d;
    -webkit-box-shadow: 0 0 0 1000px #f4efff inset !important; box-shadow: 0 0 0 1000px #f4efff inset !important;
    transition: background-color 9999s ease-in-out 0s;
}
:root[data-theme="dark"] input:-webkit-autofill, :root[data-theme="dark"] input:-webkit-autofill:hover, :root[data-theme="dark"] input:-webkit-autofill:focus {
    -webkit-text-fill-color: #f1ecfb; caret-color: #f1ecfb;
    -webkit-box-shadow: 0 0 0 1000px #251d3b inset !important; box-shadow: 0 0 0 1000px #251d3b inset !important;
}

/* Levels: single column */
.levels-list { grid-template-columns: 1fr !important; gap: 9px; }
.levels-list .level-row { padding: 12px 14px; }
.levels-list .level-row > div { flex: 1; min-width: 0; }
.levels-list .level-row strong { white-space: normal; }
.levels-list .level-row small { display: flex; align-items: center; gap: 5px; white-space: nowrap; }

/* Danger zone stronger */
.profile-danger-zone { border: 2px dashed #e5334b; background: rgba(229, 51, 75, .06); }
:root[data-theme="dark"] .profile-danger-zone { border-color: #ff5a70; background: rgba(255, 90, 112, .08); }

/* Coin icon */
.fx-coin { filter: drop-shadow(0 0 3px rgba(255, 190, 40, .55)); animation: fxCoinSpin 3.2s ease-in-out infinite; transform-origin: center; }
.stat-icon .fx-coin { width: 24px; height: 24px; vertical-align: middle; }
@keyframes fxCoinSpin { 0%, 70%, 100% { transform: rotateY(0); } 85% { transform: rotateY(180deg) scale(1.1); } }
a:hover .fx-coin, .stat-card:hover .fx-coin, .sidebar-account-link:hover .fx-coin { animation-duration: .9s; }
@media (prefers-reduced-motion: reduce) { .fx-coin { animation: none; } }

/* Skeleton loaders */
.loading-skeleton { display: grid; gap: 14px; width: 100%; padding: 8px 0; }
.loading-skeleton .loader { display: none; }
.loading-skeleton p { margin: 0; color: #8a82a3; font-size: 12px; }
.sk { display: block; border-radius: 12px; background: linear-gradient(100deg, #e9e3f7 30%, #f6f2ff 50%, #e9e3f7 70%); background-size: 200% 100%; animation: skShimmer 1.3s linear infinite; }
.sk-title { width: 42%; height: 30px; } .sk-line { width: 72%; height: 14px; } .sk-line.short { width: 48%; }
.sk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 6px; }
.sk-card { height: 120px; border-radius: 20px; }
@media (max-width: 640px) { .sk-grid { grid-template-columns: 1fr; } }
:root[data-theme="dark"] .sk { background: linear-gradient(100deg, #231c36 30%, #30264a 50%, #231c36 70%); background-size: 200% 100%; }
@keyframes skShimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
