.tst-app {
    --tst-bg: #f5f7fb;
    --tst-surface: #ffffff;
    --tst-text: #111827;
    --tst-muted: #667085;
    --tst-border: #dfe3ea;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px;
    border-radius: 18px;
    background: var(--tst-bg);
    color: var(--tst-text);
    box-sizing: border-box;
    font-family: inherit;
}

.tst-app * { box-sizing: border-box; }

/* Thin header */
.tst-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    margin-bottom: 8px;
}

.tst-title-wrap { min-width: 0; }
.tst-title {
    margin: 0 0 1px;
    font-size: clamp(18px, 3vw, 24px);
    line-height: 1.1;
}
.tst-subtitle {
    margin: 0;
    color: var(--tst-muted);
    font-size: 11px;
    line-height: 1.25;
}

.tst-actions { display: flex; gap: 6px; }
.tst-btn {
    appearance: none;
    border: 1px solid var(--tst-border);
    background: var(--tst-surface);
    color: var(--tst-text);
    min-height: 34px;
    padding: 6px 11px;
    border-radius: 9px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.tst-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    margin-bottom: 7px;
}
.tst-stat {
    background: var(--tst-surface);
    border: 1px solid var(--tst-border);
    border-radius: 10px;
    padding: 7px 9px;
}
.tst-stat-label {
    display: block;
    color: var(--tst-muted);
    font-size: 10px;
    line-height: 1.1;
    margin-bottom: 1px;
}
.tst-stat strong { font-size: 16px; line-height: 1; }

.tst-color-key {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 12px;
    margin: 0 0 7px;
    font-size: 11px;
    color: var(--tst-muted);
}
.tst-color-key span { display: inline-flex; align-items: center; gap: 5px; }
.tst-color-key i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tst-key-color);
    display: inline-block;
}

.tst-stage-wrap {
    position: relative;
    width: 100%;
    height: min(72vh, 760px);
    min-height: 430px;
    overflow: hidden;
    border: 2px solid var(--tst-border);
    border-radius: 14px;
    background: #fff;
}

.tst-stage {
    display: block;
    width: 100%;
    height: 100%;
    background: #fff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    cursor: crosshair;
}

.tst-stage-hint {
    pointer-events: none;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    text-align: center;
    color: #667085;
    padding: 24px;
}
.tst-stage-hint strong { color: #1f2937; font-size: 19px; }
.tst-stage-hint span { font-size: 12px; }
.tst-stage-hint.is-hidden { opacity: 0; visibility: hidden; }

/* Fullscreen and exit controls live inside the testing area. */
.tst-stage-icon {
    position: absolute;
    z-index: 20;
    top: 10px;
    right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(17, 24, 39, .14);
    border-radius: 10px;
    background: rgba(255, 255, 255, .92);
    color: #111827;
    font: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .10);
    -webkit-tap-highlight-color: transparent;
}
.tst-stage-icon:active { transform: scale(.96); }
.tst-exit-icon {
    font-size: 30px;
    font-weight: 300;
}

/* Native Fullscreen API + CSS fallback for browsers that don't support it. */
.tst-app:fullscreen,
.tst-app.tst-fallback-fullscreen {
    max-width: none;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: #fff;
}

.tst-app:fullscreen .tst-toolbar,
.tst-app:fullscreen .tst-stats,
.tst-app:fullscreen .tst-color-key,
.tst-app.tst-fallback-fullscreen .tst-toolbar,
.tst-app.tst-fallback-fullscreen .tst-stats,
.tst-app.tst-fallback-fullscreen .tst-color-key {
    display: none !important;
}

.tst-app:fullscreen .tst-stage-wrap,
.tst-app.tst-fallback-fullscreen .tst-stage-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
}

.tst-app:fullscreen .tst-stage-icon,
.tst-app.tst-fallback-fullscreen .tst-stage-icon {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
}

.tst-app.tst-fallback-fullscreen {
    position: fixed;
    z-index: 2147483646;
    inset: 0;
}

html.tst-lock-scroll,
body.tst-lock-scroll {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

@media (max-width: 700px) {
    .tst-app { padding: 8px; border-radius: 14px; }
    .tst-toolbar { min-height: 36px; margin-bottom: 6px; }
    .tst-title { font-size: 18px; }
    .tst-subtitle { font-size: 10px; }
    .tst-btn { min-height: 31px; padding: 5px 9px; }
    .tst-stats { gap: 5px; margin-bottom: 5px; }
    .tst-stat { padding: 6px 7px; }
    .tst-stat-label { font-size: 9px; }
    .tst-stat strong { font-size: 15px; }
    .tst-color-key { gap: 4px 9px; margin-bottom: 5px; font-size: 10px; }
    .tst-stage-wrap { min-height: 62vh; height: 68vh; border-radius: 12px; }
    .tst-stage-icon { width: 36px; height: 36px; top: 8px; right: 8px; }
}

.tst-stage-icon[hidden] { display: none !important; }
