/* TWIN SNAKES — page chrome + HUD. Game is always cinematic dark; --ts-accent honors site theme. */

:root {
    --ts-accent: #00FF00;
    --ts-twin: #FF2D95;
    --ts-gold: #ffd75e;
    --ts-dim: rgba(255, 255, 255, 0.55);
    --ts-mono: 'JetBrains Mono', 'Courier New', Courier, monospace;
    --sa-top: env(safe-area-inset-top, 0px);
    --sa-bottom: env(safe-area-inset-bottom, 0px);
    --sa-left: env(safe-area-inset-left, 0px);
    --sa-right: env(safe-area-inset-right, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    background: #000;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: var(--ts-mono);
    color: #fff;
}

#game-root { position: fixed; inset: 0; width: 100vw; height: 100dvh; }

#ts-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- Nav buttons (logged-in users only) ---------- */
.nav-buttons { display: none; }
html.ts-authed .nav-buttons { display: block; }
html.no-game .nav-buttons { display: none; }

.back-button, .home-button {
    position: fixed;
    z-index: 60;
    top: calc(12px + var(--sa-top));
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--ts-accent);
    color: var(--ts-accent);
    font-family: var(--ts-mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.3s ease;
}
.back-button { right: calc(12px + var(--sa-right)); }
.home-button { left: calc(12px + var(--sa-left)); }
.back-button:hover, .home-button:hover { background: rgba(255, 255, 255, 0.08); }
/* fade chrome while playing */
body.ts-playing .back-button, body.ts-playing .home-button { opacity: 0.15; pointer-events: none; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 40; }

.loss-panel {
    position: absolute;
    top: calc(10px + var(--sa-top));
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 6px 8px;
    text-shadow: 0 0 8px currentColor;
}
#loss-left { left: calc(12px + var(--sa-left)); color: var(--ts-accent); }
#loss-right { right: calc(12px + var(--sa-right)); color: var(--ts-twin); text-align: right; align-items: flex-end; }
.loss-label b, .loss-label span { font-weight: 700; }
.loss-panel canvas { opacity: 0.95; width: 120px; height: 36px; }

.loss-sub {
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: none;
}

#soul-wrap {
    position: absolute;
    top: calc(14px + var(--sa-top));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}
.soul-cap {
    font-size: 0.56rem;
    letter-spacing: 0.1em;
    text-shadow: 0 1px 3px #000;
}
.soul-cap-l { color: var(--ts-accent); }
.soul-cap-r { color: var(--ts-twin); }

#soul-bar {
    position: relative;
    width: min(34vw, 260px);
    height: 6px;
    display: flex;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.5);
}
#soul-player { background: var(--ts-accent); box-shadow: 0 0 8px var(--ts-accent); transition: width 0.4s ease; }
#soul-latent { background: rgba(255, 255, 255, 0.15); transition: width 0.4s ease; }
#soul-twin { background: var(--ts-twin); box-shadow: 0 0 8px var(--ts-twin); transition: width 0.4s ease; }
#soul-tick {
    position: absolute; top: -3px; bottom: -3px; left: 80%; width: 1px;
    background: var(--ts-gold);
}
#soul-tick-label {
    position: absolute;
    top: 9px;
    left: 80%;
    transform: translateX(-50%);
    font-size: 0.5rem;
    letter-spacing: 0.06em;
    color: var(--ts-gold);
    opacity: 0.7;
    white-space: nowrap;
    text-shadow: 0 1px 3px #000;
}

#epoch-bar {
    position: absolute;
    top: calc(36px + var(--sa-top));
    left: 50%;
    transform: translateX(-50%);
    width: min(34vw, 260px);
    height: 2px;
    background: rgba(255, 255, 255, 0.12);
}
#epoch-fill {
    height: 100%;
    width: 0%;
    background: var(--ts-accent);
    opacity: 0.8;
}
#epoch-bar.urgent #epoch-fill {
    background: var(--ts-gold);
    animation: twinPulse 0.5s ease-in-out infinite alternate;
}

#epoch-chip {
    position: absolute;
    top: calc(42px + var(--sa-top));
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.1em;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 10px;
    text-shadow: 0 1px 3px #000;
}

/* one line that always answers "what do I do right now" */
#objective-strip {
    position: absolute;
    top: 16%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    font-size: 0.78rem;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.92);
    background: rgba(0, 0, 0, 0.6);
    border-left: 2px solid var(--ts-accent);
    padding: 4px 14px;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
#objective-strip.fading { opacity: 0; }

/* status chips: dash cooldown, starve countdown, powerup buffs — radial timers */
#status-chips {
    position: absolute;
    bottom: calc(150px + var(--sa-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    pointer-events: none;
}
.chip {
    --chip-c: var(--ts-accent);
    --sweep: 0;
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    background: rgba(0, 0, 0, 0.62);
    border: 1px solid var(--chip-c);
    color: var(--chip-c);
}
.chip::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: conic-gradient(var(--chip-c) calc(var(--sweep) * 360deg), transparent 0);
    opacity: 0.22;
    pointer-events: none;
}
.chip .chip-glyph { font-size: 0.86rem; font-weight: 700; line-height: 1; text-shadow: 0 0 8px currentColor; z-index: 1; }
.chip .chip-label { font-size: 0.5rem; letter-spacing: 0.04em; opacity: 0.85; z-index: 1; white-space: nowrap; }
.chip.urgent { animation: twinPulse 0.4s ease-in-out infinite alternate; }

/* the twin's buffs, small, under its loss panel — seeing them IS counterplay */
#twin-chips { display: flex; gap: 4px; justify-content: flex-end; }
#twin-chips .chip { width: 26px; height: 26px; }
#twin-chips .chip .chip-glyph { font-size: 0.6rem; }
#twin-chips .chip .chip-label { display: none; }

/* directional damage flash: rotated edge gradient, 400ms */
#damage-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 43;
    opacity: 0;
    --dmg-ang: 0deg;
    --dmg-c: rgba(255, 45, 149, 0.45);
    background: linear-gradient(var(--dmg-ang), var(--dmg-c), transparent 38%);
}
#damage-vignette.hit { animation: dmgFlash 0.45s ease-out; }
@keyframes dmgFlash { from { opacity: 1; } to { opacity: 0; } }

/* floating soul deltas beside the bar */
.soul-delta {
    position: absolute;
    top: calc(30px + var(--sa-top));
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    pointer-events: none;
    z-index: 47;
    text-shadow: 0 0 8px currentColor, 0 1px 3px #000;
    animation: deltaRise 1.1s ease-out forwards;
}
@keyframes deltaRise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-16px); opacity: 0; } }

#ticker {
    position: absolute;
    bottom: calc(12px + var(--sa-bottom));
    left: calc(12px + var(--sa-left));
    font-size: 0.8rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    max-width: 78vw;
    overflow: hidden;
}
#ticker .tk-line {
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 8px;
    display: inline-block;
    margin-top: 2px;
    text-shadow: 0 1px 3px #000;
}
#ticker .tk-line { opacity: 0.7; transition: opacity 1s ease; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
#ticker .tk-line.fading { opacity: 0; }
/* one rule: anything that changes your numbers gets color; pure flavor stays dim */
#ticker .tk-line.gold { opacity: 0.95; color: var(--ts-gold); }
#ticker .tk-line.twin { opacity: 0.95; color: var(--ts-twin); }
#ticker .tk-line.accent { opacity: 0.95; color: var(--ts-accent); }

/* ---------- Diegetic overlays ---------- */
#aim-ring, #clip-ring {
    position: absolute;
    z-index: 45;
    pointer-events: none;
    transform: translate(-50%, -50%);
}
#aim-ring { width: 84px; height: 84px; }
#aim-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#aim-ring .ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.15); stroke-width: 3; }
#aim-ring .ring-fg {
    fill: none; stroke: var(--ts-gold); stroke-width: 3;
    stroke-dasharray: 176; stroke-dashoffset: 0;
    filter: drop-shadow(0 0 4px var(--ts-gold));
}

#clip-ring { width: 140px; height: 140px; }
#clip-ring svg { width: 100%; height: 100%; }
#clip-ring .clipring {
    fill: none; stroke: var(--ts-twin); stroke-width: 2.5;
    filter: drop-shadow(0 0 6px var(--ts-twin));
}
#clip-ring .clip-label {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    font-size: 0.66rem; letter-spacing: 0.25em; color: #fff;
    text-shadow: 0 0 8px var(--ts-twin);
}

#chevron {
    position: absolute;
    z-index: 44;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    color: var(--ts-twin);
    text-shadow: 0 0 8px var(--ts-twin);
}
#chevron .chev-arrow { font-size: 1.2rem; line-height: 1; }
#chevron .chev-text {
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.6);
    padding: 1px 6px;
}

#twin-warning {
    position: absolute;
    top: calc(70px + var(--sa-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 46;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.35em;
    color: #fff;
    background: rgba(60, 0, 30, 0.7);
    border: 1px solid var(--ts-twin);
    padding: 4px 16px;
    text-shadow: 0 0 12px var(--ts-twin);
    animation: twinPulse 0.7s ease-in-out infinite alternate;
    pointer-events: none;
    text-align: center;
}
#twin-warning .tw-sub {
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: none;
    margin-top: 2px;
}
#chevron.urgent { animation: twinPulse 0.4s ease-in-out infinite alternate; }
@keyframes twinPulse { from { opacity: 0.55; } to { opacity: 1; } }

/* DESCENT banner: live dive state + predicted outcome, always readable */
#dive-banner {
    position: absolute;
    top: 22%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 46;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    padding: 6px 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid currentColor;
    pointer-events: none;
    white-space: nowrap;
    font-family: var(--ts-mono);
}
#dive-banner.db-good { color: var(--ts-gold); text-shadow: 0 0 14px var(--ts-gold); }
#dive-banner.db-bad { color: #ff5555; text-shadow: 0 0 14px #ff5555; }
#dive-banner.db-orbit { color: #dfe8ff; text-shadow: 0 0 12px #dfe8ff; }
#dive-banner.db-committed { color: var(--ts-accent); text-shadow: 0 0 14px var(--ts-accent); }

#toasts {
    position: absolute;
    bottom: calc(64px + var(--sa-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 46;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}
.ts-toast {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #fff;
    background: rgba(0, 0, 0, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.35);
    padding: 0.45rem 1rem;
    text-shadow: 0 0 8px currentColor, 0 1px 3px #000;
    animation: toastIn 0.25s ease;
    white-space: nowrap;
}
.ts-toast.gold { color: var(--ts-gold); border-color: var(--ts-gold); }
.ts-toast.twin { color: var(--ts-twin); border-color: var(--ts-twin); }
.ts-toast.accent { color: var(--ts-accent); border-color: var(--ts-accent); }
.ts-toast.fading { opacity: 0; transition: opacity 0.8s ease; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Title screen ---------- */
#title-screen {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.9rem;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.72) 100%);
    padding: calc(20px + var(--sa-top)) 20px calc(20px + var(--sa-bottom));
    transition: opacity 0.6s ease;
}
#title-screen.fading { opacity: 0; pointer-events: none; }

.ts-logo {
    font-size: clamp(1.8rem, 7vw, 3.4rem);
    font-weight: 700;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    color: #fff;
    text-shadow: 0 0 18px var(--ts-accent), 0 0 60px var(--ts-accent);
    white-space: nowrap;
    animation: logoBreathe 6s ease-in-out infinite;
}
@keyframes logoBreathe {
    0%, 100% { text-shadow: 0 0 18px var(--ts-accent), 0 0 60px var(--ts-accent); }
    50% { text-shadow: 0 0 26px #fff, 0 0 80px var(--ts-accent); }
}
@media (prefers-reduced-motion: reduce) { .ts-logo { animation: none; } }
body.ts-reduced .ts-logo { animation: none; }

#tut-skip {
    position: absolute;
    right: calc(14px + var(--sa-right));
    bottom: calc(52px + var(--sa-bottom));
    z-index: 47;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    pointer-events: auto;
}
.ts-tagline { font-size: 0.7rem; letter-spacing: 0.2em; color: var(--ts-dim); }

.ts-menu { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 1.2rem; align-items: flex-start; }
.ts-cmd {
    background: none;
    border: none;
    font-family: var(--ts-mono);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: var(--ts-accent);
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.0);
    transition: text-shadow 0.2s ease, transform 0.15s ease;
}
.ts-cmd:hover, .ts-cmd:focus-visible { text-shadow: 0 0 10px var(--ts-accent); transform: translateX(4px); outline: none; }

#howPanel {
    max-width: min(78vw, 520px);
    font-size: 0.68rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.65);
    padding: 0.9rem 1.1rem;
    max-height: 42dvh;
    overflow-y: auto;
}
#howPanel b { color: var(--ts-accent); }
#howPanel p + p { margin-top: 0.45rem; }

.ts-seed, .ts-best { font-size: 0.58rem; letter-spacing: 0.12em; color: rgba(255, 255, 255, 0.35); }
.ts-best { color: var(--ts-gold); }
.ts-dim { color: rgba(255, 255, 255, 0.35); font-size: 0.8em; }

/* ---------- End screen ---------- */
#end-screen {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    background: rgba(0, 0, 0, 0.6);
    padding: calc(20px + var(--sa-top)) 20px calc(20px + var(--sa-bottom));
    animation: endIn 1.2s ease;
}
@keyframes endIn { from { opacity: 0; } to { opacity: 1; } }

.end-title {
    font-size: clamp(1.2rem, 5vw, 2rem);
    font-weight: 700;
    letter-spacing: 0.22em;
    text-indent: 0.22em;
}
.end-title.win { color: var(--ts-gold); text-shadow: 0 0 20px var(--ts-gold); }
.end-title.lose { color: var(--ts-twin); text-shadow: 0 0 20px var(--ts-twin); }
.end-sub { font-size: 0.72rem; color: var(--ts-dim); letter-spacing: 0.1em; text-align: center; line-height: 1.7; }

.end-stats {
    font-size: 0.64rem;
    line-height: 1.9;
    color: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.6);
    padding: 0.8rem 1.4rem;
    letter-spacing: 0.05em;
}
.end-stats .st-k { color: var(--ts-dim); }
.end-stats .st-v { color: #fff; float: right; margin-left: 2rem; }

.end-actions { display: flex; gap: 1.4rem; margin-top: 0.6rem; }

/* ---------- Pause ---------- */
#pause-overlay {
    position: absolute;
    inset: 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: rgba(0, 0, 0, 0.72);
    font-size: 1rem;
    letter-spacing: 0.3em;
}
#pause-overlay .pause-sub { font-size: 0.6rem; letter-spacing: 0.15em; color: var(--ts-dim); }

/* ---------- Debug ---------- */
#debug-overlay {
    position: absolute;
    bottom: calc(12px + var(--sa-bottom));
    right: calc(12px + var(--sa-right));
    z-index: 70;
    font-size: 0.58rem;
    line-height: 1.5;
    color: #0ff;
    background: rgba(0, 0, 0, 0.65);
    padding: 0.4rem 0.6rem;
    pointer-events: none;
    white-space: pre;
}

/* ---------- Fallback (unsupported browser) ---------- */
#fallback-overlay { display: none; }
html.no-game #fallback-overlay {
    display: flex;
    position: absolute;
    inset: 0;
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: #000;
    text-align: center;
}
html.no-game #fallback-overlay img {
    width: min(50vw, 224px);
    height: auto;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
html.no-game #ts-canvas, html.no-game #title-screen, html.no-game #hud { display: none; }
.fb-title { font-size: 1.1rem; letter-spacing: 0.3em; text-indent: 0.3em; color: var(--ts-accent); text-shadow: 0 0 14px var(--ts-accent); }
.fb-text { font-size: 0.68rem; line-height: 1.8; color: var(--ts-dim); }

/* ---------- Touch UI ---------- */
/* JS-gated (.tui-on on body): (pointer:coarse) at boot, a touch mid-session, or ?touchui=1.
   Desktop mouse players never see it. */
#touch-ui { display: none; --tui-scale: 1; }
body.tui-on #touch-ui { display: block; position: absolute; inset: 0; pointer-events: none; z-index: 48; }
#touch-ui > * { transition: opacity 0.35s ease; }
#touch-ui:not(.tui-play) #tui-stick,
#touch-ui:not(.tui-play) #tui-commit,
#touch-ui:not(.tui-play) #tui-dash { opacity: 0; pointer-events: none; }
#touch-ui.tui-idle .tui-btn:not(.tui-sys) { opacity: 0.35; }

#tui-stick {
    position: absolute;
    width: calc(clamp(96px, 30vw, 132px) * var(--tui-scale));
    height: calc(clamp(96px, 30vw, 132px) * var(--tui-scale));
    transform: translate(-50%, -50%);
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    opacity: 0;
    pointer-events: none;
}
#tui-stick.live { opacity: 1; }
#tui-knob {
    position: absolute;
    left: 50%; top: 50%;
    width: 42%; height: 42%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--ts-accent);
    opacity: 0.85;
    box-shadow: 0 0 12px var(--ts-accent);
}

.tui-btn {
    position: absolute;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    border-radius: 50%;
    border: 1.5px solid var(--ts-accent);
    background: rgba(0, 0, 0, 0.5);
    color: var(--ts-accent);
    font-family: var(--ts-mono);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    transition: transform 0.08s ease, opacity 0.35s ease, border-color 0.2s ease, color 0.2s ease;
}
.tui-btn.pressed { transform: scale(0.94); background: rgba(255, 255, 255, 0.10); }
.tui-btn .tui-glyph { font-size: 1.1rem; font-weight: 700; line-height: 1; text-shadow: 0 0 8px currentColor; }
.tui-btn .tui-label { font-size: 0.5rem; letter-spacing: 0.1em; opacity: 0.8; }

#tui-commit {
    width: calc(clamp(72px, 22vw, 92px) * var(--tui-scale));
    height: calc(clamp(72px, 22vw, 92px) * var(--tui-scale));
    right: calc(20px + var(--sa-right));
    bottom: calc(88px + var(--sa-bottom));
    opacity: 0.25;
}
#tui-commit svg { position: absolute; inset: -2px; transform: rotate(-90deg); }
#tui-commit .tui-ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 3; }
#tui-commit .tui-ring { fill: none; stroke: currentColor; stroke-width: 3; stroke-dasharray: 176; stroke-dashoffset: 176; }
#touch-ui[data-mode="aim"] #tui-commit { opacity: 1; border-color: var(--ts-gold); color: var(--ts-gold); }
#touch-ui[data-mode="incoming"] #tui-commit {
    opacity: 1; border-color: var(--ts-twin); color: var(--ts-twin);
    animation: twinPulse 0.4s ease-in-out infinite alternate;
}
#touch-ui[data-mode="committed"] #tui-commit { opacity: 0.15; }

#tui-dash {
    --cd: 1;
    width: calc(clamp(56px, 17vw, 72px) * var(--tui-scale));
    height: calc(clamp(56px, 17vw, 72px) * var(--tui-scale));
    right: calc(112px + var(--sa-right));
    bottom: calc(170px + var(--sa-bottom));
    opacity: 0.5;
}
#tui-dash::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: conic-gradient(var(--ts-accent) calc(var(--cd) * 360deg), transparent 0);
    opacity: 0.25;
    pointer-events: none;
}
#tui-dash.ready { opacity: 0.95; }
#tui-dash:not(.ready) { color: rgba(255, 255, 255, 0.45); border-color: rgba(255, 255, 255, 0.3); }

.tui-btn.tui-sys {
    width: 40px; height: 40px;
    border-radius: 8px;
    top: calc(64px + var(--sa-top));
    opacity: 0.45;
    font-size: 0.7rem;
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.8);
}
#tui-pause { right: calc(12px + var(--sa-right)); }
#tui-mute { right: calc(60px + var(--sa-right)); }
#tui-mute.muted { color: var(--ts-twin); text-decoration: line-through; }

/* left-handed mirror */
#touch-ui[data-side="left"] #tui-commit { right: auto; left: calc(20px + var(--sa-left)); }
#touch-ui[data-side="left"] #tui-dash { right: auto; left: calc(112px + var(--sa-left)); }

@media (orientation: landscape) and (pointer: coarse) {
    #tui-commit { bottom: calc(56px + var(--sa-bottom)); right: calc(28px + var(--sa-right)); }
    #tui-dash { bottom: calc(128px + var(--sa-bottom)); right: calc(118px + var(--sa-right)); }
}
@media (pointer: coarse) and (min-width: 900px) {
    #touch-ui { --tui-scale: 1.15; }
    #tui-commit { bottom: calc(136px + var(--sa-bottom)); }
    #tui-dash { bottom: calc(218px + var(--sa-bottom)); }
}

/* ---------- Pause menu + settings ---------- */
.pause-menu { gap: 0.7rem; }
.pm-title { font-size: 1rem; letter-spacing: 0.3em; }
.pm-cmds { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.menu-panel {
    max-width: min(84vw, 460px);
    max-height: 46dvh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.7);
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.set-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
}
.set-label { color: rgba(255, 255, 255, 0.75); white-space: nowrap; }
.ctl-bind { color: var(--ts-accent); text-align: right; }
.set-val {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: var(--ts-accent);
    font-family: var(--ts-mono);
    font-size: 0.68rem;
    padding: 0.15rem 0.7rem;
    min-width: 4.5rem;
    cursor: pointer;
}
.set-row input[type="range"] {
    width: 140px;
    accent-color: var(--ts-accent);
}
.pm-replay { margin-top: 0.3rem; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    #twin-warning { animation: none; }
}
body.ts-reduced #twin-warning,
body.ts-reduced .chip.urgent,
body.ts-reduced #chevron.urgent,
body.ts-reduced #epoch-bar.urgent #epoch-fill,
body.ts-reduced #touch-ui[data-mode="incoming"] #tui-commit { animation: none; }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
    .loss-panel { font-size: 0.68rem; padding: 4px 6px; }
    .loss-panel canvas { width: 84px; height: 26px; }
    /* phones: the center cluster drops BELOW the loss panels — no overlap, ever */
    #soul-wrap { top: calc(96px + var(--sa-top)); }
    #soul-bar { width: 44vw; }
    #epoch-bar { top: calc(118px + var(--sa-top)); width: 44vw; }
    #epoch-chip { top: calc(124px + var(--sa-top)); font-size: 0.64rem; }
    #twin-warning { top: calc(146px + var(--sa-top)); font-size: 0.78rem; }
    #objective-strip {
        top: 22%;
        white-space: normal;
        max-width: 92vw;
        text-align: center;
        font-size: 0.72rem;
    }
    .ts-logo { letter-spacing: 0.18em; text-indent: 0.18em; }
}
