/* ===================================================================
   /mouse-test

   Every lit part is driven by mouse-test.js from real events: .is-down
   while a physical button is held (by MouseEvent.button), .is-tested once
   it has been seen, and the wheel ridges move by the real wheel deltaY.
   Scoped under .mt.
   =================================================================== */

.mt {
    --mt-accent: #3d8bff;
    --mt-accent-2: #22d3ee;
    --mt-ok: #22c55e;
    --mt-warn: #f59e0b;
    --mt-ink: #10162b;
    --mt-muted: #5b6275;
    --mt-line: #e4e7ef;

    margin: 18px auto 24px;
    padding: 0;
    max-width: 1100px;
    border-radius: 28px;
    background: #fff;
    border: 1px solid var(--mt-line);
    box-shadow: 0 30px 60px -32px rgb(16 22 43 / 45%);
    overflow: hidden;
    text-align: left;
    color: var(--mt-ink);
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.mt *, .mt *::before, .mt *::after { box-sizing: border-box; }
.mt button { font: inherit; }
.mt svg { display: block; }
.mt :where(p, ul, dl, dd) { margin: 0; }

.mt-visually-hidden {
    position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */

.mt-topbar {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
    padding: 12px 20px;
    background: linear-gradient(180deg, #151b33, #10162b);
    color: #cdd5ee;
}
.mt-detected { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; }
.mt-detected svg { width: 18px; height: 18px; color: var(--mt-accent-2); flex: none; }
.mt-actions { display: flex; gap: 8px; }

.mt-btn {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: 38px; padding: 0 14px; border-radius: 12px; cursor: pointer;
    border: 1px solid var(--mt-line); background: #fff; color: var(--mt-ink); font-weight: 600; font-size: .88rem;
    transition: background-color .15s ease, transform .1s ease, color .15s ease;
}
.mt-btn svg { width: 17px; height: 17px; }
.mt-btn:active { transform: translateY(1px); }
.mt-btn--ghost { background: rgb(255 255 255 / 8%); border-color: rgb(255 255 255 / 14%); color: #dfe5f7; }
.mt-btn--ghost:hover { background: rgb(255 255 255 / 16%); color: #fff; }
.mt-btn:focus-visible { outline: 3px solid var(--mt-accent-2); outline-offset: 2px; }
#mtSound[aria-pressed="false"] { color: #8f9bbd; }
#mtSound[aria-pressed="false"] .mt-sound-waves { opacity: 0; }

.mt-touch {
    margin: 0; padding: 12px 20px; background: #fff7e6; border-bottom: 1px solid #fde2a7;
    color: #7a4b00; font-size: .92rem; font-weight: 500;
}
.mt-touch a { color: #7a4b00; font-weight: 700; }

/* ---------- stage ---------- */

.mt-stage {
    display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: clamp(16px, 3vw, 36px); align-items: stretch;
    padding: clamp(20px, 3.5vw, 40px);
    background:
        radial-gradient(50% 60% at 18% 100%, rgb(61 139 255 / 26%), transparent 70%),
        radial-gradient(40% 50% at 80% 0%, rgb(34 211 238 / 10%), transparent 70%),
        linear-gradient(180deg, #10162b 0%, #1a2142 100%);
    /* The test area: no selecting text with a held button, no autoscroll cursor. */
    user-select: none; -webkit-user-select: none;
}

.mt-mouse-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.mt-mouse { width: 100%; max-width: 240px; height: auto; filter: drop-shadow(0 26px 26px rgb(0 0 0 / 45%)); overflow: visible; }

.mt-part { cursor: pointer; transition: transform .07s ease; transform-box: view-box; }
.mt-face { fill: url(#mtShell); stroke: #0b0e1a; stroke-width: 1.5; transition: fill .12s ease; }
.mt-label { font: 700 15px/1 "Poppins", system-ui, sans-serif; fill: #8f9bbd; text-anchor: middle; pointer-events: none; transition: fill .12s ease; }
.mt-side-label { font: 700 8px/1 "Poppins", system-ui, sans-serif; fill: #8f9bbd; text-anchor: middle; letter-spacing: .06em; pointer-events: none; }
.mt-ridges rect { fill: #6b76a0; }

/* tested: a green tint that stays */
.mt-part.is-tested .mt-face { fill: #1f5a46; }
.mt-part.is-tested .mt-label { fill: #86efac; }
.mt-wheel.is-tested .mt-face { fill: #1f5a46; }

/* held: sinks and glows */
.mt-main.is-down { transform: translateY(2px); }
.mt-side.is-down { transform: translateX(2px); }
.mt-wheel.is-down { transform: translateY(1.5px); }
.mt-part.is-down .mt-face { fill: var(--mt-accent); filter: drop-shadow(0 0 10px rgb(61 139 255 / 90%)); }
.mt-part.is-down .mt-label, .mt-part.is-down .mt-side-label { fill: #fff; }
.mt-wheel.is-down .mt-ridges rect { fill: #cfe3ff; }

.mt-arrow { fill: #3a4163; transition: fill .25s ease, opacity .25s ease; opacity: .7; }
.mt-arrow.is-on { fill: var(--mt-accent-2); opacity: 1; filter: drop-shadow(0 0 6px var(--mt-accent-2)); transition: none; }
.mt-arrow.is-tested { fill: #22a06b; opacity: .9; }
.mt-arrow.is-tested.is-on { fill: var(--mt-accent-2); }

.mt-led { fill: #3a4163; transition: fill .3s ease; }
.mt.is-active .mt-led { fill: var(--mt-accent-2); filter: drop-shadow(0 0 5px var(--mt-accent-2)); transition: none; }
.mt.is-complete .mt-led { fill: #34f5a6; filter: drop-shadow(0 0 5px #34f5a6); }

.mt-last {
    min-height: 32px; padding: 5px 14px; border-radius: 999px;
    background: rgb(255 255 255 / 8%); color: #e8ecfb; font-size: .85rem; font-weight: 600; white-space: nowrap;
}
.mt-last:empty { visibility: hidden; }
.mt-last.is-pop { animation: mt-pop .25s ease; }
@keyframes mt-pop { 40% { transform: scale(1.08); background: rgb(61 139 255 / 35%); } }

/* ---------- pad ---------- */

.mt-pad-wrap { display: flex; min-width: 0; }
.mt-pad {
    position: relative; flex: 1; min-height: 320px; border-radius: 22px; overflow: hidden;
    background:
        linear-gradient(rgb(255 255 255 / 4%) 1px, transparent 1px) 0 0 / 28px 28px,
        linear-gradient(90deg, rgb(255 255 255 / 4%) 1px, transparent 1px) 0 0 / 28px 28px,
        radial-gradient(80% 90% at 50% 40%, #1f2850, #121833);
    border: 1px solid rgb(255 255 255 / 10%);
    box-shadow: inset 0 2px 14px rgb(0 0 0 / 35%);
    cursor: crosshair; touch-action: none;
}
.mt-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mt-pad-hint {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px; text-align: center;
    background: rgb(16 22 43 / 80%); border: 1px solid rgb(255 255 255 / 12%); color: #fff;
    font-size: .9rem; font-weight: 600; pointer-events: none;
    animation: mt-breathe 2.4s ease-in-out infinite; transition: opacity .3s ease;
}
.mt.has-moved .mt-pad-hint { opacity: 0; animation: none; }
@keyframes mt-breathe { 50% { transform: translate(-50%, calc(-50% - 3px)); } }
.mt-pad-readouts {
    position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; pointer-events: none;
}
.mt-pad-readouts span {
    padding: 4px 10px; border-radius: 999px; background: rgb(16 22 43 / 70%); border: 1px solid rgb(255 255 255 / 10%);
    color: #aeb8d6; font-size: .78rem; font-variant-numeric: tabular-nums;
}
.mt-pad-readouts b { color: #fff; }

/* ---------- panel ---------- */

.mt-panel {
    display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); gap: 18px 24px; align-items: start;
    padding: 22px clamp(16px, 3vw, 32px) 6px;
}

.mt-progress-card {
    display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: center;
    padding: 14px; border-radius: 18px; background: #f6f8fc; border: 1px solid var(--mt-line);
}
.mt-progress { position: relative; width: 56px; height: 56px; }
.mt-progress svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.mt-progress circle { fill: none; stroke-width: 3.4; }
.mt-progress-track { stroke: #e3e7f1; }
.mt-progress-bar { stroke: var(--mt-ok); stroke-linecap: round; stroke-dasharray: 100 100; stroke-dashoffset: calc(100 - var(--p)); transition: stroke-dashoffset .3s ease; }
.mt-progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
.mt-progress-text strong { display: block; font-size: 1.05rem; }
.mt-progress-text span { display: block; font-size: .78rem; color: var(--mt-muted); }

.mt-checks { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.mt-checks li {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 999px; background: #fff; border: 1px solid var(--mt-line);
    font-size: .8rem; font-weight: 600; color: var(--mt-muted);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.mt-checks li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d3d8e4; }
.mt-checks li.is-tested { background: #e8fbef; border-color: #a7e9bf; color: #14532d; }
.mt-checks li.is-tested::before { background: var(--mt-ok); }
.mt-checks li.is-pop { animation: mt-pop-chip .3s ease; }
.mt-checks li.mt-optional { border-style: dashed; }
@keyframes mt-pop-chip { 40% { transform: scale(1.12); } }

.mt-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.mt-stat { min-width: 0; padding: 12px 14px; border-radius: 16px; background: #f6f8fc; border: 1px solid var(--mt-line); }
.mt-stat dt { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--mt-muted); }
.mt-stat dd { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-stat dd small { font-size: .72rem; font-weight: 600; color: var(--mt-muted); }
.mt-stat .mt-sub { font-size: .76rem; font-weight: 500; color: var(--mt-muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.mt-stat--hero { background: linear-gradient(135deg, #eef4ff, #e6fbff); border-color: #cfe0fb; }
.mt-stat--hero { grid-row: span 2; display: flex; flex-direction: column; justify-content: center; }
.mt-stat--hero dd:first-of-type { color: #1d4ed8; font-size: 2.6rem; }

.mt-status {
    margin: 16px clamp(16px, 3vw, 32px) 0; padding: 12px 16px;
    border-radius: 14px; background: #f4f7ff; border: 1px solid #dce6fb;
    font-weight: 600; color: #1d3a7a;
}
.mt.is-complete .mt-status { background: #ecfdf3; border-color: #bbf0cf; color: #14532d; }
.mt-warning {
    margin: 10px clamp(16px, 3vw, 32px) 0; padding: 12px 16px;
    border-radius: 14px; background: #fff7e6; border: 1px solid #fde2a7; color: #7a4b00; font-weight: 600;
}
.mt-note { margin: 12px clamp(16px, 3vw, 32px) 22px; font-size: .86rem; color: var(--mt-muted); }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
    .mt-panel { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .mt { border-radius: 20px; }
    .mt-topbar { padding: 10px 12px; }
    .mt-stage { grid-template-columns: 1fr; padding: 16px; }
    .mt-mouse { max-width: 170px; }
    .mt-pad { min-height: 240px; }
    .mt-stats { grid-template-columns: 1fr 1fr; }
    .mt-stat--hero { grid-row: auto; grid-column: 1 / -1; }
    .mt-stat--hero dd:first-of-type { font-size: 1.8rem; }
    .mt-stat dd { font-size: 1.2rem; }
}
@media (pointer: coarse) {
    .mt-btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    .mt *, .mt *::before, .mt *::after { animation: none !important; transition: none !important; }
}
