/* =================================================================================
 * KEYSTONE — loading, countdown, Odyssey overlays, in-game notices
 * ---------------------------------------------------------------------------------
 * Surfaces that appear between and around play. Same language as the menus
 * (keystone.css, docs/MENU_UI_OVERHAUL_2026-10.md); no backdrop blur — every one of
 * these sits over a live game scene.
 * ============================================================================== */

/* ---- Cinematic loading: the cover's type is the boot loading screen's (cinematic-loading.css);
   only a name without lettering artwork takes the Keystone display face. ---------------- */
#cinematic-loading-overlay span.cinematic-loading__wordmark {
    font-family: var(--sb-font-display);
    font-weight: 800;
    letter-spacing: 0.02em;
}

/* ---- Countdown: a ring of light per count over the void; the spectrum walks down the
   count, GO is coral (cinematic-loading-overlay.js sets the colours and opens each ring
   with a transform/opacity animation; nothing here repaints). ------------------------- */
.cinematic-countdown {
    --cd-size: min(46vh, 330px);
}

.cinematic-countdown__plate {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--cd-size);
    min-width: 220px;
    height: var(--cd-size);
    min-height: 220px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
}

.cinematic-countdown__text {
    position: relative;
    z-index: 1;
    font: 800 clamp(108px, 14vw, 156px) / 1 var(--sb-font-display);
    letter-spacing: 0.02em;
    text-align: center;
    user-select: none;
}

.cinematic-countdown[data-count='go'] .cinematic-countdown__text {
    font-size: clamp(88px, 11vw, 128px);
    letter-spacing: 0.06em;
}

/* ==================================================================================
 * Odyssey sheets: level complete (#odyssey-results-modal), level failed
 * (#odyssey-failure-modal). Built by src/ui/odyssey/keystone-sheet.js.
 * ================================================================================ */
.sb-ody-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background:
        radial-gradient(70% 60% at 50% 40%, rgba(var(--sb-ody-rgb, var(--sb-gold-rgb)), 0.08), transparent 70%),
        rgba(5, 4, 14, 0.74);
    color: var(--sb-text);
    font-family: var(--sb-font-text);
    animation: sb-fade-in 0.3s ease-out both;
}

/* The results and failure sheets' own layout, figures, stars and leaderboard column:
   odyssey-outcome.css (loaded after this file). */

.sb-ody-sheet {
    position: relative;
    width: min(500px, 100%);
    animation: sb-rise-in 0.48s var(--sb-ease-lock) both;
}

.sb-ody-sheet__panel {
    position: relative;
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    padding: clamp(28px, 5vh, 40px) clamp(24px, 5vw, 40px) clamp(24px, 4vh, 34px);
    border-radius: var(--sb-r-xl);
    border: 1px solid var(--sb-line);
    background:
        radial-gradient(90% 70% at 100% 0%, rgba(var(--sb-ody-rgb, var(--sb-gold-rgb)), 0.14), transparent 62%),
        linear-gradient(180deg, rgb(27, 23, 60) 0%, rgb(12, 10, 30) 100%);
    box-shadow: inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.07), 0 40px 100px rgba(0, 0, 0, 0.5);
    text-align: left;
}

.sb-ody-modal .sb-ody-eyebrow {
    --sb-accent-rgb: var(--sb-ody-rgb, var(--sb-gold-rgb));
}

.sb-ody-title {
    margin: 16px 0 10px;
    font: 700 clamp(1.6rem, 3.2vw, 2.15rem) / 1.1 var(--sb-font-display);
    letter-spacing: -0.005em;
    color: var(--sb-text);
    text-wrap: balance;
}

.sb-ody-lede {
    margin: 0 0 22px;
    color: var(--sb-text-muted);
    font: 500 1rem / 1.55 var(--sb-font-text);
}

/* A charm's icon on the sheets and the map: a box the shared icon stage draws into (live, the
   same icon as the HUD tray's), its glyph showing until the first frame and without a GPU. */
.charm-sprite {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    vertical-align: -7px;
    flex: 0 0 auto;
}

.charm-sprite__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* The glyph is drawn by CSS, so a charm's name reads clean in the text around it. */
.charm-sprite__glyph {
    color: var(--sb-lavender);
    font-size: 14px;
    line-height: 1;
}

.charm-sprite__glyph::before {
    content: '◆';
}

.charm-sprite[data-charm-icon='live'] .charm-sprite__glyph {
    visibility: hidden;
}

.charm-sprite[data-charm='tide'] .charm-sprite__glyph { color: var(--sb-aqua); }
.charm-sprite[data-charm='long-breath'] .charm-sprite__glyph { color: var(--sb-gold); }
.charm-sprite[data-charm='hearth'] .charm-sprite__glyph { color: var(--sb-coral); }

.sb-ody-note {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0 22px;
    padding: 12px 14px;
    border-radius: var(--sb-r-sm);
    border: 1px solid var(--sb-line);
    background: rgba(var(--sb-cream-rgb), 0.03);
    color: var(--sb-text-muted);
    font: 500 0.8125rem / 1.5 var(--sb-font-text);
}

.sb-ody-note strong {
    color: var(--sb-text);
    font: 600 0.6875rem / 1.4 var(--sb-font-display);
    letter-spacing: 0.08em;
}

/* The charm guide (#odyssey-charm-guide) has its own stylesheet: odyssey-charms.css. */

.sb-ody-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.sb-ody-actions .sb-btn--primary {
    min-width: 168px;
}

@media (max-width: 480px) {
    .sb-ody-actions .sb-btn {
        flex: 1 1 100%;
    }
}

/* ---- Goal complete: a quiet banner in the top band while play continues -------------
   One line in the play rail's band above the well's mouth, exactly as tall as the rail's
   tray (the queue starts 10px under that band), centred over the well and clear of the
   rail's corner and its mirror: it never covers the next-piece queue or the well, however
   long the lap. Text sizes are capped so very large text cannot push it down into the queue
   (the HUD's goal section carries the same news at the reader's size). */
#goal-complete-overlay.sb-goal-banner {
    position: fixed;
    top: max(var(--sb-play-inset), env(safe-area-inset-top));
    left: 50%;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
    height: var(--sb-play-tray);
    max-width: calc(100vw - 2 * (var(--sb-play-inset) + 3 * var(--sb-play-tile) + 24px));
    padding: 0 8px 0 9px;
    border-radius: var(--sb-r-md);
    border: 1px solid rgba(var(--sb-mint-rgb), 0.32);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.94), rgba(12, 10, 30, 0.95));
    box-shadow:
        0 12px 34px rgba(0, 0, 0, 0.4),
        0 0 26px rgba(var(--sb-mint-rgb), 0.08),
        inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.07);
    color: var(--sb-text);
    white-space: nowrap;
    transform: translateX(-50%);
    animation: sb-goal-in 0.5s var(--sb-ease-lock) both;
    pointer-events: none;
}

#goal-complete-overlay .sb-goal-banner__mark {
    display: grid;
    flex: none;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(var(--sb-mint-rgb), 0.5);
    background: rgba(var(--sb-mint-rgb), 0.14);
    color: var(--sb-mint);
    box-shadow: 0 0 14px rgba(var(--sb-mint-rgb), 0.22);
}

#goal-complete-overlay .sb-goal-banner__mark svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#goal-complete-overlay .sb-goal-banner__text {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

#goal-complete-overlay .goal-complete-title {
    flex: none;
    margin: 0;
    font: 700 min(0.9375rem, 15px) / 1.2 var(--sb-font-display);
    letter-spacing: 0.02em;
    color: var(--sb-text);
}

#goal-complete-overlay .goal-complete-subtitle {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font: 500 min(0.8125rem, 13px) / 1.3 var(--sb-font-text);
    color: var(--sb-text-muted);
    text-overflow: ellipsis;
}

#goal-complete-overlay .goal-complete-hint {
    display: flex;
    flex: none;
    align-items: center;
    gap: 7px;
    height: 26px;
    margin: 0 0 0 2px;
    padding-left: 12px;
    border-left: 1px solid var(--sb-line);
    font: 600 min(0.75rem, 12px) / 1 var(--sb-font-text);
    color: var(--sb-text-muted);
}

#goal-complete-overlay .sb-kbd {
    font-size: min(0.6875rem, 11px);
}

#goal-complete-overlay .sb-kbd[data-pad] {
    font-size: min(0.625rem, 10px);
}

/* No spare controller button to finish on: the click and Enter remain (odyssey-showcase-input.js). */
#goal-complete-overlay .sb-kbd[hidden] {
    display: none;
}

@keyframes sb-goal-in {
    from { opacity: 0; transform: translate(-50%, -14px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes sb-goal-drop {
    from { opacity: 0; transform: translateY(-14px); }
    to { opacity: 1; transform: none; }
}

/* A phone's band is narrow: the tick goes, "Goal complete" and Finish stay. */
@media (max-width: 480px) {
    #goal-complete-overlay .sb-goal-banner__mark {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sb-ody-modal,
    .sb-ody-sheet,
    #goal-complete-overlay.sb-goal-banner {
        animation: none;
    }
}

/* ---- Odyssey navigator (#odyssey-level-select): its own sheet, odyssey-navigator.css,
   loaded after this one. --------------------------------------------------------------- */

/* ==================================================================================
 * Odyssey board view (#odyssey-board-overlay): the header, the chapter arrival card and
 * the orb panel over the world map have their own stylesheet, odyssey-map.css (loaded
 * after this one). Shell: src/ui/odyssey/BoardInfoOverlay.js.
 * ================================================================================ */

@media (prefers-reduced-motion: reduce) {
    #odyssey-level-select.odyssey-level-select {
        animation: none;
    }
}

/* ==================================================================================
 * Odyssey in-game HUD (#odyssey-hud, src/ui/odyssey/OdysseyHUD.js): Keystone type and
 * no backdrop blur — the panel is opaque already and sits over the live world all level.
 * Layout and sizing stay with odyssey-aaa.css.
 * ================================================================================ */
#odyssey-hud.odyssey-hud {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-color: var(--sb-line-strong);
    background:
        radial-gradient(100% 58% at 50% -18%, rgba(var(--sb-gold-rgb), 0.1), transparent 62%),
        linear-gradient(180deg, rgba(27, 23, 60, 0.93), rgba(12, 10, 30, 0.95));
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.06);
    color: var(--sb-text);
    font-family: var(--sb-font-text);
}

#odyssey-hud .chapter-label,
#odyssey-hud .hud-label,
#odyssey-hud .level-badge {
    font-family: var(--sb-font-display);
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

#odyssey-hud .chapter-label {
    color: rgba(var(--sb-gold-rgb), 0.9);
}

#odyssey-hud .level-name,
#odyssey-hud .progress-value,
#odyssey-hud .time-value {
    font-family: var(--sb-font-display);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--sb-text);
}

#odyssey-hud .level-badge {
    border-radius: 7px;
}

#odyssey-hud .objective-text {
    font-family: var(--sb-font-text);
    font-weight: 700;
    color: var(--sb-aqua);
}

#odyssey-hud .star-row,
#odyssey-hud .bonus-item,
#odyssey-hud .finish-hint {
    font-family: var(--sb-font-text);
    font-weight: 600;
}

/* A thin tile-cornered bar. The fill stays in flow: serenity-hub.css has an unscoped
   absolute .progress-fill that otherwise stretches it to the whole section. */
#odyssey-hud .progress-track {
    position: relative;
    height: 6px;
    margin: 7px 0 1px;
    border-radius: 3px;
    background: rgba(var(--sb-cream-rgb), 0.08);
    box-shadow: none;
}

#odyssey-hud .progress-fill {
    position: relative;
    top: auto;
    height: 100%;
    border-radius: inherit;
    background: var(--sb-spectrum);
    box-shadow: none;
}

#odyssey-hud .progress-fill.is-complete,
#odyssey-hud.is-victory-lap .progress-fill {
    background: linear-gradient(90deg, var(--sb-gold), #ffe9b8, var(--sb-gold));
    background-size: 200% 100%;
    box-shadow: 0 0 12px rgba(var(--sb-gold-rgb), 0.45);
}

#odyssey-hud .finish-hint {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-top-color: var(--sb-line);
    color: var(--sb-text-muted);
}

#odyssey-hud .finish-hint.is-visible {
    display: flex;
}

/* Orb levels: readable objective ledger, a folded guide, and the live duel opponent. */
#odyssey-hud.odyssey-hud::before {
    display: none;
}

#odyssey-hud .hud-section {
    border-bottom-color: var(--sb-line);
}

/* The column is read whole beside the well, never scrolled: close-set sections, and on a
   window too short for them the whole column drawn smaller (src/ui/odyssey/odyssey-hud-fit.js
   sets --ody-hud-fit; the stage rules below apply it). */
#odyssey-hud.odyssey-hud {
    overflow: hidden;
    padding: 13px 16px 11px;
}

#odyssey-hud .hud-section {
    margin-bottom: 7px;
    padding-bottom: 6px;
}

/* A window too short even for the smallest legible column scrolls by wheel or touch, without
   a scrollbar. */
#odyssey-hud[data-fit='scroll'] {
    overflow-y: auto;
    scrollbar-width: none;
}

#odyssey-hud[data-fit='scroll']::-webkit-scrollbar {
    display: none;
}

#odyssey-hud .header-section {
    text-align: left;
}

/* The chapter and the orb's number share one line over the orb's name. */
#odyssey-hud .header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#odyssey-hud .hud-label,
#odyssey-hud .chapter-label {
    font-size: 10px;
    line-height: 1.5;
    color: var(--sb-text-muted);
    letter-spacing: 0.12em;
}

#odyssey-hud .chapter-label {
    color: var(--sb-gold);
}

#odyssey-hud .level-name {
    margin-top: 3px;
    font-size: 15px;
    line-height: 1.3;
    text-align: left;
    text-shadow: none;
}

#odyssey-hud .level-badge {
    margin-top: 0;
    padding: 2px 8px;
    border-color: var(--sb-line-strong);
    background: var(--sb-surface-raised);
    color: var(--sb-text-muted);
    font-size: 10px;
    letter-spacing: 0.08em;
}

#odyssey-hud .objective-text {
    margin: 3px 0 2px;
    font-size: 13.5px;
    line-height: 1.4;
}

#odyssey-hud .hud-level-rules {
    margin: 4px 0 0;
    font-size: 11px;
    line-height: 1.4;
}

#odyssey-hud .progress-value {
    margin-top: 2px;
    font-size: 22px;
    line-height: 1.2;
    text-align: left;
    text-shadow: none;
}

#odyssey-hud .time-value {
    font-size: 18px;
    line-height: 1.2;
    text-shadow: none;
}

#odyssey-hud .hud-tide {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.3;
    color: var(--sb-text-muted);
}

#odyssey-hud .hud-tide.is-warning {
    color: var(--sb-warning);
}

#odyssey-hud .time-value.is-warning {
    color: var(--sb-warning);
}

#odyssey-hud .time-value.is-danger {
    color: var(--sb-danger);
}

#odyssey-hud .star-row,
#odyssey-hud .bonus-item {
    color: var(--sb-text-muted);
    font-size: 11.5px;
    line-height: 1.4;
    opacity: 1;
    align-items: flex-start;
}

#odyssey-hud .stars-list,
#odyssey-hud .bonuses-list {
    gap: 3px;
    margin-top: 4px;
}

#odyssey-hud .star-icon {
    flex: none;
    margin-top: 1px;
}

#odyssey-hud .bonus-checkbox {
    width: 13px;
    height: 13px;
    margin-top: 1px;
    border-width: 1.5px;
    border-radius: 4px;
}

#odyssey-hud .star-row.earned {
    color: var(--sb-gold);
}

#odyssey-hud .level-guide {
    color: var(--sb-text-muted);
    font-size: 11.5px;
    line-height: 1.5;
}

#odyssey-hud .level-guide summary {
    cursor: pointer;
    color: var(--sb-aqua);
    font-weight: 700;
}

#odyssey-hud .level-guide p {
    margin: 5px 0 0;
}

#odyssey-hud .level-guide summary:focus-visible {
    outline: 2px solid var(--sb-keystone);
    outline-offset: 4px;
}

#odyssey-hud .finish-hint {
    width: 100%;
    min-height: 36px;
    margin-bottom: 6px;
    animation: none;
    border-top: 0;
    color: var(--sb-keystone-ink);
    font-size: 12px;
    /* The pad's cap can be a long name ("View / Back"): it takes a second line when the panel
       is narrow instead of shrinking under the label (.sb-kbd's min-width lets it shrink). */
    flex-wrap: wrap;
    row-gap: 4px;
    padding-block: 6px;
}

#odyssey-hud .finish-hint .sb-kbd {
    flex: none;
}

#odyssey-hud .odyssey-pause-hint {
    margin: 3px 0 0;
    color: var(--sb-text-muted);
    font-size: 11px;
    line-height: 1.5;
}

/* Charms: a hotbar. One tile per charm held, in its own tone: its icon (drawn by the icon stage
   into a canvas on the tile, a glyph until then), the key that uses it on one shoulder, its count on the
   other, its name under it. One caption line under the row says what the charm that matters
   right now is doing. */
#odyssey-hud .charms-list {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 6px;
    padding: 5px 0 0;
}

#odyssey-hud .charm-chip__canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#odyssey-hud .charm-chip {
    --charm-rgb: var(--sb-lavender-rgb);
    --charm-left: 0;
    position: relative;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--sb-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 200ms ease;
}

#odyssey-hud .charm-chip[data-charm='tide'] { --charm-rgb: var(--sb-aqua-rgb); }
#odyssey-hud .charm-chip[data-charm='still-air'] { --charm-rgb: var(--sb-lavender-rgb); }
#odyssey-hud .charm-chip[data-charm='long-breath'] { --charm-rgb: var(--sb-gold-rgb); }
#odyssey-hud .charm-chip[data-charm='hearth'] { --charm-rgb: var(--sb-coral-rgb); }

#odyssey-hud .charm-chip:focus-visible {
    outline: none;
}

#odyssey-hud .charm-chip:focus-visible .charm-chip__icon {
    outline: 2px solid var(--sb-keystone);
    outline-offset: 2px;
}

/* The tile: the icon's stage, lit from below in the charm's tone. */
#odyssey-hud .charm-chip__icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1;
    box-sizing: border-box;
    border-radius: 13px;
    border: 1px solid rgba(var(--charm-rgb), 0.32);
    background:
        radial-gradient(circle at 50% 66%, rgba(var(--charm-rgb), 0.34), rgba(var(--charm-rgb), 0.05) 70%),
        linear-gradient(180deg, rgba(var(--sb-cream-rgb), 0.05), rgba(var(--sb-cream-rgb), 0.01));
    box-shadow: inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.06);
    transition: border-color 200ms ease, box-shadow 200ms ease, filter 200ms ease;
}

#odyssey-hud .charm-chip:hover .charm-chip__icon {
    border-color: rgba(var(--charm-rgb), 0.65);
    box-shadow: 0 0 0 1px rgba(var(--charm-rgb), 0.14), 0 8px 20px -10px rgba(var(--charm-rgb), 0.7);
}

#odyssey-hud .charm-chip__glyph {
    color: rgb(var(--charm-rgb));
    font-size: 18px;
    line-height: 1;
}

#odyssey-hud .charm-chip__icon[data-charm-icon='live'] .charm-chip__glyph {
    visibility: hidden;
}

/* The key on the tile's shoulder, the count on the other, a controller label at its foot. */
#odyssey-hud .charm-chip__key,
#odyssey-hud .charm-chip__pad,
#odyssey-hud .charm-chip__count {
    position: absolute;
    z-index: 2;
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    height: 15px;
    min-width: 15px;
    padding: 0 4px;
    border-radius: 6px;
    font: 700 9px / 1 var(--sb-font-display);
    letter-spacing: 0;
    white-space: nowrap;
}

#odyssey-hud .charm-chip__key {
    top: -5px;
    left: -5px;
    border: 1px solid var(--sb-line-strong);
    background: var(--sb-surface-solid);
    color: var(--sb-text);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

#odyssey-hud .charm-chip__pad {
    right: -5px;
    bottom: -5px;
    border: 1px solid var(--sb-line-strong);
    background: var(--sb-surface-solid);
    color: var(--sb-text-muted);
    font-size: 8px;
}

#odyssey-hud .charm-chip__pad[hidden] {
    display: none;
}

#odyssey-hud .charm-chip__count {
    top: -5px;
    right: -5px;
    border-radius: 8px;
    background: rgb(var(--charm-rgb));
    color: #140f26;
    font-variant-numeric: tabular-nums;
}

#odyssey-hud .charm-chip__count:empty {
    display: none;
}

#odyssey-hud .charm-chip__name {
    color: var(--sb-text-muted);
    font: 600 clamp(8.5px, 0.6vw, 9.5px) / 1.2 var(--sb-font-text);
    letter-spacing: 0;
    white-space: nowrap;
}

/* Lit while it runs or waits; Still Air's bar drains along the tile's foot. */
#odyssey-hud .charm-chip[data-state='active'] .charm-chip__icon,
#odyssey-hud .charm-chip[data-state='armed'] .charm-chip__icon {
    border-color: rgba(var(--charm-rgb), 0.8);
    box-shadow: 0 0 0 1px rgba(var(--charm-rgb), 0.3), 0 0 18px rgba(var(--charm-rgb), 0.35);
}

#odyssey-hud .charm-chip[data-state='active'] .charm-chip__name,
#odyssey-hud .charm-chip[data-state='armed'] .charm-chip__name {
    color: rgb(var(--charm-rgb));
}

#odyssey-hud .charm-chip[data-state='active'] .charm-chip__icon::after {
    content: '';
    position: absolute;
    right: 7px;
    bottom: 3px;
    left: 7px;
    height: 2px;
    border-radius: 1px;
    background:
        linear-gradient(90deg, rgb(var(--charm-rgb)) calc(var(--charm-left) * 100%), rgba(var(--charm-rgb), 0.18) 0);
}

/* Armed: the tile breathes until the top-out it waits for. */
#odyssey-hud .charm-chip[data-state='armed'] .charm-chip__icon {
    animation: charm-armed 1.6s var(--sb-ease-breathe) infinite alternate;
}

@keyframes charm-armed {
    from { box-shadow: 0 0 0 1px rgba(var(--charm-rgb), 0.3), 0 0 10px rgba(var(--charm-rgb), 0.2); }
    to { box-shadow: 0 0 0 1px rgba(var(--charm-rgb), 0.65), 0 0 22px rgba(var(--charm-rgb), 0.5); }
}

/* Spent, nothing to do here, or paused: the tile goes dim and its key is crossed out. */
#odyssey-hud .charm-chip[data-state='used'] .charm-chip__icon {
    border-style: dashed;
    background: rgba(var(--sb-cream-rgb), 0.02);
    filter: saturate(0.2);
}

#odyssey-hud .charm-chip[data-state='used'],
#odyssey-hud .charm-chip[data-reason]:not([data-reason='']),
#odyssey-hud .charm-chip[data-paused='true'] {
    opacity: 0.5;
}

#odyssey-hud .charm-chip[data-state='used'] .charm-chip__key,
#odyssey-hud .charm-chip[data-reason]:not([data-reason='']) .charm-chip__key,
#odyssey-hud .charm-chip[data-paused='true'] .charm-chip__key {
    color: var(--sb-text-faint);
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

/* A refused press: the tile flashes gold, the caption says why. */
#odyssey-hud .charm-chip[data-flash='true'] {
    opacity: 1;
}

#odyssey-hud .charm-chip[data-flash='true'] .charm-chip__icon {
    border-color: var(--sb-gold);
    box-shadow: 0 0 0 1px rgba(var(--sb-gold-rgb), 0.5), 0 0 16px rgba(var(--sb-gold-rgb), 0.4);
}

/* The caption: the charm's name in its tone, then what it says. */
#odyssey-hud .charms-caption {
    display: flex;
    gap: 5px;
    min-height: 15px;
    margin: 5px 0 0;
    overflow: hidden;
    color: var(--sb-text-muted);
    font: 500 10.5px / 1.4 var(--sb-font-text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

#odyssey-hud .charms-caption__name {
    --charm-rgb: var(--sb-lavender-rgb);
    flex: none;
    color: rgb(var(--charm-rgb));
    font-weight: 700;
}

#odyssey-hud .charms-caption__name:empty {
    display: none;
}

#odyssey-hud .charms-caption__name:not(:empty)::after {
    content: ' ·';
    color: var(--sb-text-faint);
    font-weight: 500;
}

#odyssey-hud .charms-caption__text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

#odyssey-hud .charms-caption[data-charm='tide'] .charms-caption__name { --charm-rgb: var(--sb-aqua-rgb); }
#odyssey-hud .charms-caption[data-charm='still-air'] .charms-caption__name { --charm-rgb: var(--sb-lavender-rgb); }
#odyssey-hud .charms-caption[data-charm='long-breath'] .charms-caption__name { --charm-rgb: var(--sb-gold-rgb); }
#odyssey-hud .charms-caption[data-charm='hearth'] .charms-caption__name { --charm-rgb: var(--sb-coral-rgb); }

#odyssey-hud .charms-caption[data-tone='active'] .charms-caption__text,
#odyssey-hud .charms-caption[data-tone='armed'] .charms-caption__text {
    color: var(--sb-text);
    font-weight: 600;
}

#odyssey-hud .charms-caption[data-tone='flash'] .charms-caption__text {
    color: var(--sb-gold);
    font-weight: 600;
}

/* Spoken once per state change; never seen. */
#odyssey-hud .charms-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Long Breath: the clock flashes as it gains its seconds. */
#odyssey-hud .time-value.is-extended {
    animation: charm-clock 1.2s ease-out;
}

@keyframes charm-clock {
    from { color: var(--sb-lavender); text-shadow: 0 0 14px rgba(var(--sb-lavender-rgb), 0.6); }
    to { text-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
    #odyssey-hud .charm-chip[data-state='armed'] .charm-chip__icon {
        animation: none;
        box-shadow: 0 0 0 1px rgba(var(--charm-rgb), 0.5), 0 0 14px rgba(var(--charm-rgb), 0.35);
    }

    #odyssey-hud .time-value.is-extended {
        animation: none;
        color: var(--sb-lavender);
    }
}

#odyssey-hud.is-paused {
    border-color: var(--sb-gold);
}

#odyssey-hud.is-duel .progress-value {
    display: none;
}

.single-player-stage:has(#odyssey-hud.is-duel.is-visible) .single-player-stats-bar {
    display: none !important;
    visibility: hidden !important;
    position: absolute;
}

.single-player-stage:has(#odyssey-hud.is-visible) .sp-level-caption {
    color: var(--sb-text-muted);
    font: 600 11px / 1.5 var(--sb-font-text);
}

.single-player-stage:has(#odyssey-hud.is-visible) .sp-level-caption .single-player-stat-value {
    color: inherit;
    font: inherit;
}

.odyssey-duel-scoreboard {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 14px 0 8px;
}

.odyssey-duel-scoreboard > div {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
}

.odyssey-duel-scoreboard span {
    color: var(--sb-text-muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.odyssey-duel-scoreboard strong {
    font: 600 34px / 1.2 var(--sb-font-display);
    color: var(--sb-cream);
    font-variant-numeric: tabular-nums;
}

.odyssey-duel-round,
.odyssey-duel-incoming {
    color: var(--sb-text-muted);
    font: 600 12px / 1.6 var(--sb-font-text);
    margin: 4px 0 0;
}

.odyssey-duel-incoming.has-garbage {
    color: var(--sb-coral);
}

.odyssey-duel-opponent {
    display: none;
    position: absolute;
    top: 50%;
    left: calc(50% + var(--board-width) / 2 + 36px);
    transform: translateY(-50%);
    width: 192px;
    padding: 14px;
    box-sizing: border-box;
    border: 1px solid var(--sb-line-strong);
    border-radius: var(--sb-r-md);
    background: var(--sb-surface-solid);
    z-index: 10;
}

.odyssey-duel-opponent.is-visible {
    display: block;
}

.odyssey-duel-opponent__label {
    color: var(--sb-gold);
    font: 600 10px / 1.6 var(--sb-font-display);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin: 0;
}

.odyssey-duel-opponent__name {
    color: var(--sb-text);
    font: 600 15px / 1.5 var(--sb-font-display);
    margin: 5px 0;
    overflow-wrap: anywhere;
}

.odyssey-duel-opponent__skill,
.odyssey-duel-opponent__next {
    color: var(--sb-text-muted);
    font: 600 11px / 1.6 var(--sb-font-text);
    margin: 4px 0 8px;
}

.odyssey-duel-opponent canvas {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--sb-line);
    border-radius: 6px;
}

/* Odyssey's gameplay surface uses the same open-top well as solo/Infinity. Only
   the ledger and the right-side observer reserve different space. The shared
   keystone-solo.css draws and sizes the human board, walls and queue. */
.single-player-stage[data-board='well'][data-odyssey-board] {
    --sp-hue: var(--sb-gold);
    --sp-hue-rgb: var(--sb-gold-rgb);
    --ody-hud-w: clamp(210px, 17vw, 264px);
    --ody-opponent-w: clamp(164px, 15vw, 224px);
    --sp-side: var(--ody-hud-w);
    --sp-board-w-room: calc(100vw - 32px - 2 * (var(--ody-hud-w) + var(--sp-side-gap)));
}

.single-player-stage[data-board='well'][data-odyssey-board].infinity-mode-active {
    --sp-hue: var(--sb-gold);
    --sp-hue-rgb: var(--sb-gold-rgb);
}

.single-player-stage[data-board='well'][data-odyssey-board] #single-player-container {
    display: flex !important;
    position: relative;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    width: 100%;
    padding: 0;
}

.single-player-stage[data-board='well'][data-odyssey-board] #single-player-card {
    order: 0;
    align-self: flex-start;
    padding: 0 !important;
    --board-width: inherit;
    --board-height: inherit;
}

.single-player-stage[data-board='well'][data-odyssey-board] .single-player-stats-bar {
    display: none !important;
    visibility: hidden !important;
}

.single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud {
    left: calc(50% - var(--board-width) / 2 - var(--sp-side-gap));
    right: auto;
    top: calc(var(--sp-top) + var(--sp-next-h) + var(--sp-queue-gap));
    bottom: auto;
    width: var(--ody-hud-w);
    max-height: calc(var(--board-height) / var(--ody-hud-fit, 1));
    transform: translateX(-100%) scale(var(--ody-hud-fit, 1));
    transform-origin: 100% 0;
    border-radius: 16px;
}

/* Three upcoming pieces share the well's mouth and the highlighted first tile,
   shrinking the later tiles before the board. */
.single-player-stage[data-board='well'][data-odyssey-board] #single-player-container .player-next-pieces {
    flex: 1 1 0;
    width: 100% !important;
    min-width: 0;
}

.single-player-stage[data-board='well'][data-odyssey-board] #single-player-container .player-next-piece {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.single-player-stage[data-board='well'][data-odyssey-board] #single-player-container .player-next-piece.highlight {
    flex: 1.25 1 0;
    width: auto;
}

.single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap.infinity-minimap {
    position: absolute !important;
    left: calc(50% + var(--board-width) / 2 + var(--sp-side-gap)) !important;
    right: auto;
    top: calc(var(--sp-next-h) + var(--sp-queue-gap)) !important;
    transform: none !important;
    width: var(--tower-w);
    height: var(--board-height);
    max-height: none;
}

.single-player-stage[data-board='well'][data-odyssey-board] #odyssey-duel-opponent {
    position: absolute;
    left: calc(50% + var(--board-width) / 2 + var(--sp-side-gap));
    right: auto;
    top: calc(var(--sp-top) + var(--sp-next-h) + var(--sp-queue-gap));
    width: var(--ody-opponent-w);
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    transform: none;
    --ody-bot-hue: var(--sb-coral);
    --ody-bot-glow: rgba(var(--sb-coral-rgb), 0.3);
}

.odyssey-duel-opponent__plate {
    padding: 10px 12px;
    margin-bottom: 10px;
    border: 1px solid var(--sb-line);
    border-left: 3px solid var(--ody-bot-hue);
    border-radius: var(--sb-r-sm);
    background: var(--sb-surface-solid);
}

#odyssey-duel-opponent .odyssey-duel-opponent__queue {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: clamp(28px, calc(var(--ody-opponent-w) * 0.21), 46px);
    margin-bottom: 10px;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
}

#odyssey-duel-opponent .odyssey-duel-opponent__queue .player-next-piece {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: 80%;
    padding: 2px;
    border: 1px solid var(--sb-line);
    border-radius: var(--sb-r-xs);
    background: rgba(12, 10, 30, 0.82);
    box-sizing: border-box;
    box-shadow: none;
    opacity: 0.8;
    transform: none;
}

#odyssey-duel-opponent .odyssey-duel-opponent__queue .player-next-piece.highlight {
    flex-grow: 1.25;
    height: 100%;
    border-color: var(--ody-bot-hue);
    opacity: 1;
}

#odyssey-duel-opponent .odyssey-duel-opponent__queue canvas {
    width: 100% !important;
    height: 100% !important;
    padding: 0;
    border: 0;
    border-radius: 0;
}

.odyssey-duel-opponent__well {
    position: relative;
    width: 100%;
    height: calc(var(--ody-opponent-w) * 2);
    --sp-wall: color-mix(in srgb, var(--ody-bot-hue) 82%, #fff6e9);
}

.odyssey-duel-opponent__well::after {
    content: '';
    position: absolute;
    inset: 0 -3px -3px;
    z-index: 4;
    border: 3px solid var(--sp-wall);
    border-top: 0;
    border-radius: 0 0 13px 13px;
    box-shadow: 0 10px 28px -8px var(--ody-bot-glow);
    -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 24%);
    mask-image: linear-gradient(180deg, transparent 0%, #000 24%);
    pointer-events: none;
}

.odyssey-duel-opponent__phaser-host {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 0 0 10px 10px;
    background: linear-gradient(180deg, rgba(9, 8, 24, 0.3), rgba(9, 8, 24, 0.9));
}

.odyssey-duel-opponent__phaser-host canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    border: 0;
    border-radius: 0;
}

.odyssey-duel-garbage {
    position: absolute;
    top: 0;
    bottom: 0;
    left: -12px;
    width: 6px;
    z-index: 5;
    pointer-events: none;
    overflow: hidden;
    border-radius: 3px;
    background: linear-gradient(180deg, transparent, rgba(var(--sb-cream-rgb), 0.12));
}

.odyssey-duel-garbage[hidden] {
    display: none;
}

.odyssey-duel-garbage::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, var(--sb-danger), var(--sb-coral) 55%, var(--sb-gold));
    transform: scaleY(var(--garbage-fill, 0));
    transform-origin: bottom;
    transition: transform var(--sb-dur-2) var(--sb-ease-lock);
}

.odyssey-duel-garbage[data-heavy='true']::after {
    filter: brightness(1.3);
    box-shadow: 0 0 12px rgba(var(--sb-danger-rgb), 0.5);
}

@media (prefers-reduced-motion: reduce) {
    .odyssey-duel-garbage::after {
        transition: none;
    }
}

#odyssey-duel-opponent[data-danger='true'] {
    --ody-bot-hue: var(--sb-danger);
    --ody-bot-glow: rgba(var(--sb-danger-rgb), 0.55);
}

@media (max-width: 860px) {
    #odyssey-hud.is-visible {
        position: fixed;
        animation: none;
    }

    #odyssey-hud .header-section {
        display: none;
    }

    /* The dock flows its sections into columns across the strip, so the strip holds them all. */
    #odyssey-hud.is-visible:not(.is-victory-lap) {
        column-width: 180px;
        column-gap: 18px;
    }

    #odyssey-hud .hud-section,
    #odyssey-hud .odyssey-pause-hint,
    #odyssey-hud .finish-hint {
        break-inside: avoid;
    }

    /* A strip too short for its columns at a legible size scrolls as one column instead. */
    #odyssey-hud.is-visible[data-fit='scroll'] {
        column-width: auto;
    }

    /* The dock keeps the hotbar's tiles at one size, four to a column, from the left. */
    #odyssey-hud .charms-list {
        justify-content: flex-start;
        gap: 6px;
    }

    #odyssey-hud .charm-chip {
        flex: 0 0 40px;
    }

    #odyssey-hud .odyssey-duel-scoreboard {
        margin: 6px 0 4px;
        gap: 10px;
    }

    #odyssey-hud .odyssey-duel-scoreboard > div {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    #odyssey-hud .odyssey-duel-scoreboard strong {
        font-size: 26px;
    }

    #odyssey-hud .odyssey-duel-round,
    #odyssey-hud .odyssey-duel-incoming {
        margin-top: 2px;
    }

    #odyssey-hud.is-visible.is-victory-lap {
        display: flex;
        flex-direction: column;
    }

    #odyssey-hud.is-victory-lap .hud-section,
    #odyssey-hud.is-victory-lap .finish-hint {
        flex: 0 0 auto;
    }

    #odyssey-hud.is-victory-lap .objective-section {
        order: -2;
    }

    #odyssey-hud.is-victory-lap .progress-value {
        display: none;
    }

    #odyssey-hud.is-victory-lap .finish-hint {
        order: -1;
        margin: 0 0 8px;
    }

    /* The goal banner keeps the top band, docked to the left beside the rail's two tiles; the
       dock below repeats "keep playing", so the banner drops it and keeps Finish. */
    #goal-complete-overlay.sb-goal-banner {
        left: max(var(--sb-play-inset), env(safe-area-inset-left));
        max-width: calc(100vw - 2 * var(--sb-play-inset) - 2 * var(--sb-play-tile) - 24px);
        gap: 10px;
        transform: none;
        animation: none;
    }

    @media (prefers-reduced-motion: no-preference) {
        #goal-complete-overlay.sb-goal-banner {
            animation: sb-goal-drop 0.5s var(--sb-ease-lock) both;
        }
    }

    #goal-complete-overlay .goal-complete-subtitle {
        display: none;
    }

    .odyssey-duel-opponent__label,
    .odyssey-duel-opponent__skill,
    .odyssey-duel-opponent__next,
    .odyssey-duel-opponent .odyssey-duel-incoming {
        display: none;
    }

    .odyssey-duel-opponent__name {
        font-size: 10px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] {
        --ody-dock-h: 168px;
        --ody-right-w: 0px;
        --ody-right-gap: 0px;
        --ody-opponent-w: clamp(76px, 23vw, 100px);
        --sp-bottom: calc(var(--ody-dock-h) + 24px);
        /* The goal ledger is the dock, not a strip under the well. */
        --sp-below: 0px;
        --sp-board-w-room: calc(100vw - 32px - var(--ody-right-w) - var(--ody-right-gap));
        --board-width: clamp(80px, min(calc(var(--sp-board-h) / 2), var(--sp-board-w-room)), 640px);
        padding-right: calc(16px + var(--ody-right-w) + var(--ody-right-gap));
    }

    .single-player-stage[data-board='well'][data-odyssey-board='duel'] {
        --ody-right-w: var(--ody-opponent-w);
        --ody-right-gap: 14px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board='tower'] {
        --tower-w: clamp(34px, 11vw, 52px);
        --ody-right-w: var(--tower-w);
        --ody-right-gap: 10px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board='tower'].infinity-mode-active {
        padding-right: calc(16px + var(--ody-right-w) + var(--ody-right-gap));
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #single-player-container {
        display: flex !important;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud {
        position: fixed;
        left: 50%;
        right: auto;
        top: auto;
        bottom: 12px;
        width: calc((100vw - 24px) / var(--ody-hud-fit, 1));
        max-height: calc(var(--ody-dock-h) / var(--ody-hud-fit, 1));
        transform: translateX(-50%) scale(var(--ody-hud-fit, 1));
        transform-origin: 50% 100%;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-duel-opponent {
        position: fixed;
        left: auto;
        right: 16px;
        top: var(--sp-top);
    }

    .odyssey-duel-opponent__plate {
        padding: 6px;
        margin-bottom: 8px;
        border-left-width: 2px;
    }

    #odyssey-duel-opponent .odyssey-duel-opponent__queue {
        height: 24px;
        gap: 3px;
        margin-bottom: 8px;
    }

    #odyssey-duel-opponent .odyssey-duel-opponent__queue .player-next-piece {
        padding: 1px;
        border-radius: 4px;
    }

    .odyssey-duel-opponent__garbage {
        left: -9px;
        width: 4px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap.infinity-minimap {
        position: fixed !important;
        left: auto !important;
        right: 16px;
        top: calc(var(--sp-top) + var(--sp-next-h) + var(--sp-queue-gap)) !important;
        width: var(--tower-w);
        height: var(--board-height);
        max-height: var(--board-height);
        padding: 6px 4px !important;
        z-index: 6;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap .minimap-canvas {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap .minimap-title,
    .single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap .minimap-instruction {
        display: none;
    }
}

@media (max-width: 860px) and (max-height: 600px) {
    .single-player-stage[data-board='well'][data-odyssey-board] {
        --ody-dock-h: 104px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud {
        padding: 8px 12px;
    }
}

/* A short landscape window has room beside the well. Keeping the goal ledger
   there avoids reducing the board to a sliver or covering the bot with a dock. */
@media (max-width: 860px) and (max-height: 600px) and (min-aspect-ratio: 1/1) {
    .single-player-stage[data-board='well'][data-odyssey-board] {
        --ody-hud-w: clamp(180px, 27vw, 220px);
        --ody-opponent-w: 84px;
        --sp-side-gap: 20px;
        --sp-bottom: 16px;
        --sp-board-h-room: calc(var(--sp-vh) - var(--sp-head) - var(--sp-next-h)
            - var(--sp-queue-gap) - var(--sp-bottom));
        --sp-board-w-room: calc(100vw - 32px - 2 * (var(--ody-hud-w) + var(--sp-side-gap)));
        padding-right: 16px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board].infinity-mode-active {
        padding-right: 16px;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud {
        position: absolute;
        left: calc(50% - var(--board-width) / 2 - var(--sp-side-gap));
        right: auto;
        top: calc(var(--sp-top) + var(--sp-next-h) + var(--sp-queue-gap));
        bottom: auto;
        width: var(--ody-hud-w);
        max-height: calc(var(--board-height) / var(--ody-hud-fit, 1));
        transform: translateX(-100%) scale(var(--ody-hud-fit, 1));
        transform-origin: 100% 0;
        column-width: auto;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud .odyssey-duel-scoreboard span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-hud .odyssey-duel-scoreboard strong {
        flex-shrink: 0;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #single-player-container .single-player-piece-previews::before {
        display: none;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #odyssey-duel-opponent {
        position: absolute;
        left: calc(50% + var(--board-width) / 2 + var(--sp-side-gap));
        right: auto;
    }

    .single-player-stage[data-board='well'][data-odyssey-board] #infinity-minimap.infinity-minimap {
        left: calc(50% + var(--board-width) / 2 + var(--sp-side-gap)) !important;
        right: auto;
    }
}

/* ---- Serenity mode notices --------------------------------------------------------- */
#serenity-notification {
    border-radius: var(--sb-r-md);
    border: 1px solid var(--sb-line-strong);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.94), rgba(12, 10, 30, 0.95));
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.07);
    color: var(--sb-text);
    font: 600 0.875rem / 1.4 var(--sb-font-text);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Outside Serenity Mode it names the theme N steps to (src/ui/theme-keys.js): a small pill
   along the top edge, clear of the board's next queue. */
body:not(.serenity-mode) #serenity-notification {
    top: max(12px, env(safe-area-inset-top));
    padding: 8px 18px;
}

#serenity-shortcuts-overlay {
    border-radius: var(--sb-r-lg);
    border: 1px solid var(--sb-line);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.94), rgba(12, 10, 30, 0.95));
    color: var(--sb-text-muted);
    font-family: var(--sb-font-text);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

#serenity-shortcuts-overlay h3,
#serenity-shortcuts-overlay strong {
    color: var(--sb-text);
    font-family: var(--sb-font-display);
    font-weight: 600;
}

#serenity-shortcuts-overlay kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    border: 1px solid var(--sb-line-strong);
    background: rgba(var(--sb-cream-rgb), 0.07);
    color: var(--sb-text-muted);
    font: 700 0.6875rem / 1 var(--sb-font-text);
}

/* ==================================================================================
 * Single-player stat rail (also Serenity's HUD): Keystone type and opaque fills, no
 * backdrop blur (seven pills used to re-sample the live theme every frame). Sizes and
 * layout stay with main.css — themes read this rail's rect for their composition.
 * ================================================================================ */
.single-player-stats-bar .single-player-stat {
    border: 1px solid var(--sb-line-strong);
    border-radius: var(--sb-r-md);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.9), rgba(12, 10, 30, 0.92));
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.06);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.single-player-stats-bar .single-player-stat:first-child {
    border-color: rgba(var(--sb-aqua-rgb), 0.36);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.07),
        0 0 22px rgba(var(--sb-aqua-rgb), 0.1);
}

.single-player-stats-bar .single-player-stat-label {
    font: 600 0.5rem / 1.2 var(--sb-font-display);
    letter-spacing: 0.22em;
    color: var(--sb-text-faint);
}

.single-player-stats-bar .single-player-stat .single-player-stat-value {
    font-family: var(--sb-font-display);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    color: var(--sb-text);
    text-shadow: none;
    white-space: nowrap;
}

.single-player-stats-bar .single-player-stat.stat-score .single-player-stat-value,
.single-player-stats-bar .single-player-stat.stat-lines .single-player-stat-value,
.single-player-stats-bar .single-player-stat.stat-level .single-player-stat-value,
.single-player-stats-bar .single-player-stat.stat-next-level .single-player-stat-value {
    font-size: 20px;
}

.single-player-stats-bar .single-player-stat.stat-speed .single-player-stat-value,
.single-player-stats-bar .single-player-stat.stat-bpm .single-player-stat-value,
.single-player-stats-bar .single-player-stat.stat-ppm .single-player-stat-value {
    font-size: 13px;
}

.single-player-stats-bar .single-player-stat .stat-icon {
    color: rgba(var(--sb-aqua-rgb), 0.85);
    filter: none;
}

.single-player-stats-bar .single-player-stat:first-child .stat-icon {
    color: var(--sb-aqua);
}

/* The next-queue frame keeps its shape; only the blur goes. */
.single-player-card .player-next-pieces {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* ==================================================================================
 * Replay playback bar (#playback-controls, src/ui/playback-controls.js): a two-row
 * night card in the bottom-left corner, beside the board — the board fills the height,
 * and at 1280 × 720 only ~40 px are left under it. Play/pause is the warm primary, the
 * position fills with the spectrum, speed is a row of tiles. No blur: a replay is live.
 * ================================================================================ */
#playback-controls.playback-controls {
    left: max(20px, env(safe-area-inset-left));
    right: auto;
    bottom: max(20px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    width: min(440px, calc(100vw - 40px));
    min-width: 0;
    max-width: none;
    margin: 0;
    padding: 12px;
    flex-wrap: wrap;
    gap: 10px 14px;
    border: 1px solid var(--sb-line-strong);
    border-radius: var(--sb-r-lg);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.94), rgba(12, 10, 30, 0.96));
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.06);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    color: var(--sb-text);
    font-family: var(--sb-font-text);
    transform: none;
    animation: sb-rise-in 0.36s var(--sb-ease-lock) both;
}

#playback-controls.playback-controls .playback-buttons {
    display: flex;
    gap: 6px;
    flex: none;
}

#playback-controls.playback-controls .pb-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 11px;
    background: rgba(var(--sb-cream-rgb), 0.04);
    color: var(--sb-text);
    font: 600 0.62rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition:
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        transform var(--sb-dur-1) var(--sb-ease-lock);
}

#playback-controls.playback-controls .pb-btn:hover {
    background: rgba(var(--sb-cream-rgb), 0.09);
    border-color: rgba(var(--sb-cream-rgb), 0.34);
}

#playback-controls.playback-controls .pb-btn:active {
    transform: translateY(1px);
}

#playback-controls #pb-play-pause.pb-btn {
    min-width: 108px;
    justify-content: center;
    border-color: transparent;
    background: var(--sb-keystone);
    color: var(--sb-keystone-ink);
    box-shadow: 0 10px 26px rgba(var(--sb-coral-rgb), 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

#playback-controls #pb-play-pause.pb-btn:hover {
    background: #ffbb9c;
}

#playback-controls #pb-stop.pb-btn:hover {
    border-color: rgba(var(--sb-danger-rgb), 0.45);
    background: rgba(var(--sb-danger-rgb), 0.08);
    color: var(--sb-danger);
}

#playback-controls.playback-controls .pb-btn__icon,
#playback-controls.playback-controls .pb-btn svg {
    display: inline-flex;
    flex: none;
}

#playback-controls.playback-controls .pb-btn:focus-visible,
#playback-controls.playback-controls .pb-speed:focus-visible,
#playback-controls #pb-progress:focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

#playback-controls.playback-controls .playback-info {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex: none;
    min-width: 0;
    color: var(--sb-text-faint);
    font: 600 0.82rem / 1 var(--sb-font-display);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

#playback-controls.playback-controls .pb-eyebrow {
    margin-right: 6px;
    color: rgba(var(--sb-aqua-rgb), 0.9);
    font-size: 0.58rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

#playback-controls #playback-time {
    color: var(--sb-text);
}

/* Too wide for the first row on purpose: the position and speed form the second. */
#playback-controls.playback-controls .playback-progress-container {
    flex: 1 1 160px;
    min-width: 0;
    display: flex;
    align-items: center;
    height: 32px;
}

#playback-controls #pb-progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    margin: 0;
    border-radius: 3px;
    background:
        var(--sb-spectrum) 0 0 / var(--pb-fill, 0%) 100% no-repeat,
        rgba(var(--sb-cream-rgb), 0.12);
    cursor: pointer;
    transition: none;
}

#playback-controls #pb-progress:hover {
    height: 6px;
}

#playback-controls #pb-progress::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 5px;
    background: var(--sb-cream);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    transform: none;
}

#playback-controls #pb-progress::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 5px;
    background: var(--sb-cream);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* Controller glyphs (replay-pad-controls.js): A, B, ← →, LB RB, shown only on a pad. */
#playback-controls .pb-pad.sb-kbd[data-pad] {
    flex: none;
    align-self: center;
}

body.sb-input-gamepad #playback-controls .playback-progress-container {
    gap: 8px;
}

#playback-controls.playback-controls .playback-speed {
    display: flex;
    gap: 3px;
    flex: none;
    padding: 3px;
    border: 1px solid var(--sb-line);
    border-radius: 11px;
    background: rgba(var(--sb-night-rgb), 0.5);
}

#playback-controls.playback-controls .pb-speed {
    min-width: 40px;
    height: 32px;
    padding: 0 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--sb-text-muted);
    font: 600 0.68rem / 1 var(--sb-font-display);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background var(--sb-dur-2) var(--sb-ease-lock), color var(--sb-dur-2) var(--sb-ease-lock);
}

#playback-controls.playback-controls .pb-speed:hover {
    color: var(--sb-text);
    background: rgba(var(--sb-cream-rgb), 0.06);
}

#playback-controls.playback-controls .pb-speed.is-current {
    background: var(--sb-cream);
    color: var(--sb-keystone-ink);
}

@media (max-width: 640px) {
    /* Leave the corner tiles' column free. */
    #playback-controls.playback-controls {
        left: 12px;
        right: 76px;
        width: auto;
        padding: 10px;
    }

    #playback-controls.playback-controls .pb-btn__label {
        display: none;
    }

    #playback-controls #pb-play-pause.pb-btn {
        min-width: 0;
    }

    #playback-controls.playback-controls .pb-eyebrow {
        display: none;
    }

    #playback-controls.playback-controls .playback-progress-container {
        order: 4;
        flex-basis: 100%;
        height: 24px;
    }

    #playback-controls.playback-controls .pb-speed {
        min-width: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #playback-controls.playback-controls {
        animation: none;
    }
}


/* ==================================================================================
 * The board's share of the window: every mode's well stands at this share of the height
 * it could fill, so the theme shows round it. A short window keeps more: the board is
 * never shorter than the floor unless the room itself is. Portrait screens have none to
 * spare, so the board takes it all. keystone-solo.css applies it to the solo well
 * (single player, Infinity, Stillfall, Odyssey); local-versus-layout.js reads it for
 * both versus stages (BOARD_FILL holds the same values).
 * ================================================================================ */
:root {
    --sb-board-fill: 0.85;
    --sb-board-floor: 520px;
}

@media (max-aspect-ratio: 1/1) {
    :root {
        --sb-board-fill: 1;
    }
}


/* ==================================================================================
 * Play rail (#sb-play-rail, src/ui/keystone/play-rail.js): the in-game controls —
 * Levels (Odyssey's board view), the Serenity Hub and Settings, Settings outermost —
 * as one tray in the top-right corner, identical in every mode: the same place, size,
 * icons, names and keys. The bottom of the screen belongs to the game: boards, chat,
 * stats, touch controls and toasts.
 *
 * The tray is a small night tile that rests dimmed while you play and wakes under the
 * pointer or focus (in Serenity it leaves with the cursor). Names and keys show beneath
 * it on hover or focus; a mode's first runs unroll them inside the tray for a moment
 * (.is-peek, and .is-folding on the way in and out).
 *
 * The modes keep the corner free rather than moving the tray: online versus reserves
 * the top of its info column (level with the spectator toolbar), local versus centres
 * its standings bar on the tray's line, Odyssey's board header ends its chips before it.
 * Only these differ, on purpose: Levels shows on the Odyssey map alone, touch screens
 * get larger tiles, phones a tighter corner.
 * ================================================================================ */
:root {
    --sb-play-tile: 40px;
    --sb-play-inset: 16px;
    /* Tile + 3px padding and 1px border each side: 48px on a desktop. */
    --sb-play-tray: calc(var(--sb-play-tile) + 8px);
}

#sb-play-rail {
    position: fixed;
    top: max(var(--sb-play-inset), env(safe-area-inset-top));
    right: max(var(--sb-play-inset), env(safe-area-inset-right));
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--sb-line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.84), rgba(12, 10, 30, 0.9));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(var(--sb-cream-rgb), 0.06);
    opacity: 0.72;
    transition: opacity 0.45s ease;
}

#sb-play-rail:hover,
#sb-play-rail:focus-within,
#sb-play-rail.is-peek {
    opacity: 1;
    transition-duration: var(--sb-dur-2);
}

body.start-modal-open #sb-play-rail,
body:has(> #breathing-guide:not([hidden])) #sb-play-rail,
body:has(> .sukha-flow:not([hidden])) #sb-play-rail {
    visibility: hidden;
}

/* Serenity hides the cursor after a few still seconds; the controls go with it. */
body.serenity-mode.cursor-hidden #sb-play-rail:not(:focus-within, .is-peek) {
    opacity: 0;
    transition-duration: 1.2s;
}

/* One tile for every control the rail holds: a line icon on the tray's fill. */
#sb-play-rail > :is(#serenity-hub-icon, #odyssey-navigator-btn, #settings-btn-global) {
    position: relative;
    inset: auto;
    z-index: auto;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--sb-play-tile);
    height: var(--sb-play-tile);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border: 0;
    border-radius: 11px;
    background: transparent;
    box-shadow: none;
    color: rgba(var(--sb-cream-rgb), 0.8);
    opacity: 1;
    transform: none;
    filter: none;
    cursor: pointer;
    pointer-events: auto;
    transition:
        background-color var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        color var(--sb-dur-2) var(--sb-ease-lock);
}

#sb-play-rail > #odyssey-navigator-btn:not(.visible) {
    display: none;
}

#sb-play-rail > :is(#serenity-hub-icon, #odyssey-navigator-btn, #settings-btn-global):hover {
    background: rgba(var(--sb-cream-rgb), 0.08);
    color: var(--sb-text);
    transform: none;
    filter: none;
}

#sb-play-rail > :is(#serenity-hub-icon, #odyssey-navigator-btn, #settings-btn-global):active {
    background: rgba(var(--sb-cream-rgb), 0.12);
    transform: scale(0.96);
}

#sb-play-rail > :is(#serenity-hub-icon, #odyssey-navigator-btn, #settings-btn-global):focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.85);
    outline-offset: 2px;
}

/* The Hub or the level list is open: its tile stays lit. */
#sb-play-rail > :is(#serenity-hub-icon, #odyssey-navigator-btn).active {
    background: rgba(var(--sb-cream-rgb), 0.1);
    color: var(--sb-text);
}

#sb-play-rail .sb-play-rail__icon,
#sb-play-rail .odyssey-navigator-icon-svg {
    flex: none;
    width: 20px;
    height: 20px;
    padding: 0;
    transform: none;
    filter: none;
}

/* The old tiles' glow layers: the tray has no idle motion. */
#sb-play-rail .hub-icon-glow,
#sb-play-rail .odyssey-navigator-icon-glow,
#sb-play-rail > #settings-btn-global::before {
    display: none;
}

/* While a breathing session runs, a mint ring breathes inside the Hub tile. */
#sb-play-rail .hub-icon-pulse {
    position: absolute;
    inset: 3px;
    width: auto;
    height: auto;
    border: 1px solid rgba(var(--sb-mint-rgb), 0.6);
    border-radius: 9px;
    background: none;
    opacity: 0;
    transform: none;
    animation: none;
    pointer-events: none;
}

#sb-play-rail .hub-icon-pulse.breathing-active {
    animation: sb-play-breathe var(--sb-breath) var(--sb-ease-breathe) infinite;
}

@keyframes sb-play-breathe {
    0%, 100% { opacity: 0.25; transform: scale(0.88); }
    50% { opacity: 1; transform: none; }
}

/* Names and keys: beneath the tray, on hover or focus. */
#sb-play-rail .sb-play-rail__label {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px 7px 11px;
    border: 1px solid var(--sb-line-strong);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.97), rgba(12, 10, 30, 0.98));
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
    color: var(--sb-text);
    font: 600 0.6rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    translate: 0 -4px;
    pointer-events: none;
    /* A name leaves at once and only arrives with a fade: two never cross-fade over each
       other (pointer moving tile to tile), and a peek cut short (a long frame swallowing
       the fold) never drops its names here, overlapping, on their way out. */
    transition: none;
}

#sb-play-rail .sb-play-rail__label .sb-kbd {
    height: 18px;
    min-width: 18px;
    font-size: 0.625rem;
    letter-spacing: 0;
    text-transform: none;
}

#sb-play-rail > :hover > .sb-play-rail__label,
#sb-play-rail > :focus-visible > .sb-play-rail__label,
body:not(.sb-input-pointer) #sb-play-rail > :focus > .sb-play-rail__label {
    opacity: 1;
    translate: 0 0;
    transition: opacity var(--sb-dur-2) var(--sb-ease-lock), translate var(--sb-dur-2) var(--sb-ease-lock);
}

/* One name at a time: the tile under the pointer speaks, even while another holds focus. */
body #sb-play-rail:not(.is-peek, .is-folding):has(> :hover) > :not(:hover) > .sb-play-rail__label {
    opacity: 0;
    translate: 0 -4px;
    transition: none;
}

/* A mode's first runs: the names unroll inside the tray, then fold back into it. */
#sb-play-rail:is(.is-peek, .is-folding) > :is(#serenity-hub-icon, #odyssey-navigator-btn, #settings-btn-global) {
    width: auto;
    padding: 0 10px;
}

#sb-play-rail:is(.is-peek, .is-folding) .sb-play-rail__label {
    position: static;
    max-width: 0;
    margin-left: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: none;
    box-shadow: none;
    opacity: 0;
    translate: none;
    transition:
        max-width 0.5s var(--sb-ease-lock),
        margin-left 0.5s var(--sb-ease-lock),
        opacity 0.3s linear;
}

#sb-play-rail.is-peek .sb-play-rail__label {
    max-width: 240px;
    margin-left: 9px;
    opacity: 1;
}

/* ---- Online versus: the info column keeps the corner ------------------------------ */
/* Both side columns open with a toolbar row: the spectator controls on the left, and on
   the right the room the tray floats in (.sb-play-room), so the scoreboard starts below
   it and the chat runs to the bottom corner. */
@media (min-width: 901px) {
    /* Edges on the tray's inset at every width, so the column lines up under it. */
    #online-multiplayer-container.online-game-area {
        grid-template-rows: auto minmax(0, 1fr);
        row-gap: 12px;
        padding: var(--sb-play-inset);
    }

    #online-multiplayer-container > .opponents-panel {
        grid-column: 1;
        grid-row: 1 / span 2;
        display: grid;
        grid-template-rows: subgrid;
        row-gap: normal;
    }

    #online-multiplayer-container > .main-board-panel {
        grid-column: 2;
        grid-row: 1 / span 2;
    }

    #online-multiplayer-container > .sb-play-room {
        grid-column: 3;
        grid-row: 1;
        min-height: var(--sb-play-tray);
    }

    #online-multiplayer-container > .right-panel {
        grid-column: 3;
        grid-row: 2;
    }
}

/* Stacked online layout: the spectator row ends before the tray. */
@media (max-width: 900px) {
    #online-multiplayer-container > .sb-play-room {
        display: none;
    }

    #online-multiplayer-container > .opponents-panel {
        margin-right: 112px;
    }
}

/* ---- Per mode ---------------------------------------------------------------------- */
/* Odyssey's board view: the header lines up with the tray and its chips end before it.
   The tray sits above the board overlay (1001), whose header takes the pointer, and the
   level list (1002) that Levels opens and closes. */
body:has(#sb-play-rail > #odyssey-navigator-btn.visible) #odyssey-board-overlay .odyssey-header-bar {
    /* The chips (27px) centred on the tray's line; three tiles, the tray's edges, a gap. */
    padding-top: calc(var(--sb-play-inset) + var(--sb-play-tray) / 2 - 14px);
    padding-right: calc(var(--sb-play-inset) + 3 * var(--sb-play-tile) + 28px);
}

body:has(#sb-play-rail > #odyssey-navigator-btn.visible) #sb-play-rail {
    z-index: 1003;
}

/* Phones: a tighter corner. Touch screens: larger tiles, and no keyboard keys to show. */
@media (max-width: 640px) {
    :root {
        --sb-play-inset: 6px;
    }

    /* The tray takes the top band; the board starts beneath it. */
    #single-player-card.single-player-card {
        margin-top: 34px;
    }
}

@media (hover: none) and (pointer: coarse) {
    :root {
        --sb-play-tile: 44px;
    }

    #sb-play-rail {
        opacity: 0.86;
    }

    #sb-play-rail .sb-kbd[data-key] {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    #sb-play-rail,
    #sb-play-rail > *,
    #sb-play-rail .sb-play-rail__label {
        transition: none !important;
    }

    #sb-play-rail .hub-icon-pulse.breathing-active {
        animation: none;
        opacity: 1;
    }
}

/* ==== Serenity Mode over the theme, in the breathing guide's language ====================
   (src/ui/serenity-mode/). Words on the world itself, never panels: the guide's three levels
   (an eyebrow in the world's own light with its small square, a title in Unbounded, a line in
   Manrope), carried by soft night shades that come and go with them, and quiet tiles for what
   you can do. Each theme lends its light (--world-accent on the caption, --serenity-accent on
   the page for everything else; serenity-theme-accent.js). Motion is opacity and transform
   only; no backdrop blur: the theme beneath is live. */

/* ---- The world caption (serenity-world-bar.js) --------------------------------------- */
#serenity-world-bar {
    --world-accent: var(--serenity-accent, var(--sb-mint-rgb));
    --world-ink: var(--sb-cream-rgb);
    --world-tray: 0px;
    position: fixed;
    inset: 0;
    z-index: 1000;
    color: rgb(var(--world-ink));
    font-family: var(--sb-font-text);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.9s ease;
    -webkit-font-smoothing: antialiased;
}

#serenity-world-bar.is-awake,
#serenity-world-bar:focus-within {
    opacity: 1;
    transition-duration: 0.45s;
}

#serenity-world-bar.is-covered,
body.serenity-hub-open #serenity-world-bar,
body:not(.serenity-mode) #serenity-world-bar {
    visibility: hidden;
    opacity: 0;
}

/* Only the buttons take the pointer, and only while they can be seen. */
#serenity-world-bar button { pointer-events: none; }

#serenity-world-bar:is(.is-awake, :focus-within):not(.is-covered) button { pointer-events: auto; }

/* The night shades the words stand on: deep at the edge, gone a third of the way in, with a
   breath of the world's light where its name is. */
#serenity-world-bar .serenity-world__shade {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
}

#serenity-world-bar .serenity-world__shade--top {
    top: 0;
    height: min(46vh, 380px);
    background:
        radial-gradient(ellipse 34% 62% at 50% 0%, rgba(var(--world-accent), 0.14), transparent 72%),
        linear-gradient(180deg, rgba(7, 6, 22, 0.7) 0%, rgba(7, 6, 22, 0.36) 40%, rgba(7, 6, 22, 0) 100%);
}

#serenity-world-bar .serenity-world__shade--bottom {
    bottom: 0;
    height: min(36vh, 300px);
    background: linear-gradient(0deg, rgba(7, 6, 22, 0.74) 0%, rgba(7, 6, 22, 0.42) 40%, rgba(7, 6, 22, 0) 100%);
}

#serenity-world-bar .serenity-world__caption {
    position: absolute;
    top: max(4.5vh, 22px);
    left: calc((100% - var(--world-tray)) / 2);
    display: grid;
    /* The arrows keep close to the words they change, however short the name. */
    grid-template-columns: 52px fit-content(640px) 52px;
    justify-content: center;
    align-items: center;
    column-gap: 28px;
    width: min(92vw, 780px, calc(100vw - var(--world-tray) - 32px));
    transform: translate(-50%, -8px);
    transition: transform 0.9s var(--sb-ease-breathe), left 0.45s var(--sb-ease-breathe);
}

#serenity-world-bar:is(.is-awake, :focus-within) .serenity-world__caption {
    transform: translate(-50%, 0);
    transition-duration: 0.45s;
}

#serenity-world-bar .serenity-world__words {
    min-width: 0;
    text-align: center;
}

#serenity-world-bar .serenity-world__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    color: rgb(var(--world-accent));
    font: 600 var(--sb-fs-label) / 1.4 var(--sb-font-display);
    letter-spacing: var(--sb-track-label);
    text-transform: uppercase;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}

#serenity-world-bar .serenity-world__eyebrow::before {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
    box-shadow: 0 0 10px rgba(var(--world-accent), 0.6);
}

#serenity-world-bar .serenity-world__name {
    margin: 0;
    overflow: hidden;
    color: rgb(var(--world-ink));
    font: 700 clamp(26px, 3.1vw, 44px) / 1.12 var(--sb-font-display);
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.75), 0 0 40px rgba(var(--world-accent), 0.18);
}

/* A theme seen for the first time takes a moment to build: its name breathes until it is here. */
#serenity-world-bar.is-arriving .serenity-world__name {
    animation: serenity-world-arriving 1.6s var(--sb-ease-breathe) infinite;
}

@keyframes serenity-world-arriving {
    50% { opacity: 0.5; }
}

#serenity-world-bar .serenity-world__song {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 10px 0 0;
    overflow: hidden;
    color: rgba(var(--world-ink), 0.76);
    font: 500 clamp(13px, 1.1vw, 15px) / 1.5 var(--sb-font-text);
    white-space: nowrap;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85);
}

#serenity-world-bar .serenity-world__song[hidden] { display: none; }

#serenity-world-bar .serenity-world__note {
    display: inline-flex;
    flex: none;
    color: rgb(var(--world-accent));
}

#serenity-world-bar .serenity-world__song-text {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Your themes at a glance, like the guide's breath: the one on screen lit, and while the
   world drifts, filling toward the next. */
#serenity-world-bar .serenity-world__strip {
    display: flex;
    gap: 3px;
    width: min(64vw, 380px);
    margin: 18px auto 0;
}

#serenity-world-bar .serenity-world__strip[hidden] { display: none; }

#serenity-world-bar .serenity-world__strip i {
    position: relative;
    flex: 1 1 0;
    min-width: 2px;
    height: 4px;
    overflow: hidden;
    border-radius: 2px;
    background: rgba(var(--world-ink), 0.16);
}

#serenity-world-bar .serenity-world__strip i.is-here {
    background: rgb(var(--world-accent));
    box-shadow: 0 0 10px rgba(var(--world-accent), 0.6);
}

#serenity-world-bar .serenity-world__strip i.is-here:has(b) { background: rgba(var(--world-accent), 0.3); }

#serenity-world-bar .serenity-world__strip b {
    position: absolute;
    inset: 0;
    background: rgb(var(--world-accent));
    transform-origin: left center;
    animation: serenity-drift-fill linear forwards;
}

@keyframes serenity-drift-fill {
    from { transform: scaleX(var(--fill-from, 0)); }
    to { transform: scaleX(1); }
}

/* The arrows: the guide's tiles, lighter, beside the name they change. */
#serenity-world-bar .serenity-world__arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    border: 1px solid rgba(var(--world-ink), 0.2);
    background: rgba(7, 6, 22, 0.3);
    color: rgba(var(--world-ink), 0.88);
    font: 400 1.6rem / 1 var(--sb-font-display);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    transition:
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-world-bar .serenity-world__arrow:hover:not(:disabled) {
    border-color: rgba(var(--world-accent), 0.6);
    background: rgba(7, 6, 22, 0.5);
    color: rgb(var(--world-accent));
}

#serenity-world-bar .serenity-world__arrow:active:not(:disabled) { transform: translateY(1px); }
#serenity-world-bar .serenity-world__arrow:disabled { opacity: 0.3; cursor: default; }

/* The dock: what you can do, along the bottom, in the guide's own tiles. */
#serenity-world-bar .serenity-world__dock {
    position: absolute;
    bottom: max(4vh, 22px, env(safe-area-inset-bottom));
    left: calc((100% - var(--world-tray)) / 2);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - var(--world-tray) - 32px);
    transform: translate(-50%, 8px);
    transition: transform 0.9s var(--sb-ease-breathe), left 0.45s var(--sb-ease-breathe);
}

#serenity-world-bar:is(.is-awake, :focus-within) .serenity-world__dock {
    transform: translate(-50%, 0);
    transition-duration: 0.45s;
}

#serenity-world-bar .serenity-world__tile {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 16px 0 14px;
    border-radius: 12px;
    border: 1px solid rgba(var(--world-ink), 0.22);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.66), rgba(12, 10, 30, 0.76));
    color: rgba(var(--world-ink), 0.86);
    font: 600 0.6875rem / 1 var(--sb-font-display);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background var(--sb-dur-2) var(--sb-ease-lock),
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-world-bar .serenity-world__tile-icon {
    display: inline-flex;
    color: rgba(var(--world-ink), 0.56);
    transition: color var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-world-bar .serenity-world__tile:hover {
    border-color: rgba(var(--world-ink), 0.4);
    background: linear-gradient(180deg, rgba(38, 33, 80, 0.8), rgba(16, 13, 38, 0.86));
    color: rgb(var(--world-ink));
}

#serenity-world-bar .serenity-world__tile:active { transform: translateY(1px); }

#serenity-world-bar .serenity-world__tile.is-on {
    border-color: rgba(var(--world-accent), 0.55);
    color: rgb(var(--world-accent));
}

#serenity-world-bar .serenity-world__tile.is-on .serenity-world__tile-icon { color: rgb(var(--world-accent)); }

/* Previous, next and Stop while Play all runs with the effects tray folded away: square tiles,
   the icon alone. */
#serenity-world-bar .serenity-world__tile--icon {
    justify-content: center;
    width: 44px;
    padding: 0;
}

#serenity-world-bar .serenity-world__tile--icon .serenity-world__tile-text { display: none; }
#serenity-world-bar .serenity-world__tile--icon .serenity-world__tile-icon { color: inherit; }
#serenity-world-bar .serenity-world__tile--icon .cs-icon { fill: currentColor; }
#serenity-world-bar .serenity-world__tile[hidden] { display: none; }

#serenity-world-bar .serenity-world__tile:disabled {
    opacity: 0.32;
    cursor: default;
    pointer-events: none;
}

#serenity-world-bar :is(.serenity-world__arrow, .serenity-world__tile):focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 3px;
}

/* While the effects tray holds the right edge, the caption, the dock and the notices centre on
   what is left. */
@media (min-width: 901px) and (min-height: 521px) {
    body.serenity-effects-open #serenity-world-bar { --world-tray: max(360px, min(480px, 42vw)); }
    body.serenity-mode.serenity-effects-open #serenity-notification { left: calc((100% - max(360px, min(480px, 42vw))) / 2); }
}

/* A narrower window: while the rail unrolls its names (the first visits), the caption steps
   below it rather than under it. */
@media (min-width: 641px) and (max-width: 1199px) {
    body:has(#sb-play-rail.is-peek, #sb-play-rail.is-folding) #serenity-world-bar .serenity-world__caption {
        top: calc(max(var(--sb-play-inset), env(safe-area-inset-top)) + var(--sb-play-tile) + 18px);
    }
}

/* A phone: the rail holds the corner, so the caption starts below it and spans the width. */
@media (max-width: 640px) {
    #serenity-world-bar .serenity-world__caption {
        top: calc(max(var(--sb-play-inset), env(safe-area-inset-top)) + var(--sb-play-tile) + 16px);
        grid-template-columns: 44px minmax(0, 1fr) 44px;
        column-gap: 8px;
        width: calc(100vw - 24px);
    }

    #serenity-world-bar .serenity-world__arrow {
        width: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 1.35rem;
    }

    #serenity-world-bar .serenity-world__eyebrow { margin-bottom: 8px; letter-spacing: 0.16em; }
    #serenity-world-bar .serenity-world__name { font-size: 22px; }
    #serenity-world-bar .serenity-world__strip { width: 62vw; margin-top: 14px; }
    #serenity-world-bar .serenity-world__dock { gap: 6px; }

    #serenity-world-bar .serenity-world__tile {
        min-height: 40px;
        padding: 0 12px 0 10px;
        gap: 8px;
        letter-spacing: 0.1em;
    }

    #serenity-world-bar .serenity-world__tile--icon { width: 40px; padding: 0; }
}

/* ---- The effects tray (serenity-effects-tray.js): the right edge's own night ------------
   Every reaction a theme has to play, on demand: the guide's words and tiles over a shade that
   deepens toward the edge, clear of the middle where the themes play their effects; along the
   bottom on a phone. */
#serenity-effects {
    --fx-accent: var(--serenity-accent, var(--sb-mint-rgb));
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Taller than the window, it starts at the top and scrolls, rather than losing its head. */
    justify-content: safe center;
    gap: 18px;
    width: min(480px, 42vw);
    min-width: 360px;
    box-sizing: border-box;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: calc(var(--sb-play-inset) + var(--sb-play-tile) + 28px) max(28px, env(safe-area-inset-right)) 36px 104px;
    border: 0;
    border-radius: 0;
    /* Dense where the words are, fading only in the margin before them. */
    background: linear-gradient(270deg, rgba(7, 6, 22, 0.92) 0%, rgba(7, 6, 22, 0.86) 66%, rgba(7, 6, 22, 0.5) 84%, rgba(7, 6, 22, 0) 100%);
    box-shadow: none;
    color: rgb(var(--sb-cream-rgb));
    font-family: var(--sb-font-text);
    scrollbar-width: none;
    opacity: 0;
    transform: translateX(18px);
    transition: opacity 0.45s ease, transform 0.45s var(--sb-ease-breathe);
    -webkit-font-smoothing: antialiased;
}

#serenity-effects::-webkit-scrollbar { display: none; }

#serenity-effects[hidden] { display: none; }

#serenity-effects.is-open {
    opacity: 1;
    transform: none;
}

#serenity-effects.is-covered,
body.serenity-hub-open #serenity-effects,
body:not(.serenity-mode) #serenity-effects {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* The eyebrow shares its row with Repeat, Play all and ×; the theme's name has the width to itself. */
#serenity-effects .serenity-effects__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-areas:
        'eyebrow repeat all close'
        'title title title title'
        'line line line line';
    align-items: center;
    column-gap: 8px;
}

#serenity-effects .serenity-effects__titles { display: contents; }
#serenity-effects .serenity-effects__head .serenity-effects__eyebrow { grid-area: eyebrow; }
#serenity-effects .serenity-effects__head .serenity-effects__title { grid-area: title; margin-top: 10px; }
#serenity-effects .serenity-effects__head .serenity-effects__subtitle { grid-area: line; }
#serenity-effects .serenity-effects__head .serenity-effects__repeat { grid-area: repeat; }
#serenity-effects .serenity-effects__head .serenity-effects__all { grid-area: all; }
#serenity-effects .serenity-effects__head .serenity-effects__close { grid-area: close; }

#serenity-effects .serenity-effects__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    color: rgb(var(--fx-accent));
    font: 600 var(--sb-fs-label) / 1.4 var(--sb-font-display);
    letter-spacing: var(--sb-track-label);
    text-transform: uppercase;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
}

#serenity-effects .serenity-effects__eyebrow::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: currentColor;
    box-shadow: 0 0 10px rgba(var(--fx-accent), 0.6);
}

#serenity-effects .serenity-effects__title {
    margin: 0;
    overflow: hidden;
    font: 700 clamp(20px, 1.8vw, 26px) / 1.15 var(--sb-font-display);
    letter-spacing: -0.005em;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.75);
}

#serenity-effects .serenity-effects__subtitle {
    margin: 8px 0 0;
    color: rgba(var(--sb-cream-rgb), 0.72);
    font: 500 0.875rem / 1.5 var(--sb-font-text);
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
}

#serenity-effects .serenity-effects__groups {
    display: grid;
    gap: 16px;
}

#serenity-effects .serenity-effects__group-label {
    margin: 0 0 8px;
    color: rgba(var(--sb-cream-rgb), 0.64);
    font: 600 0.5625rem / 1 var(--sb-font-display);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

#serenity-effects .serenity-effects__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

#serenity-effects :is(.serenity-effects__effect, .serenity-effects__repeat, .serenity-effects__all, .serenity-effects__close) {
    min-height: 38px;
    padding: 0 13px;
    border-radius: 11px;
    border: 1px solid rgba(var(--sb-cream-rgb), 0.2);
    background: linear-gradient(180deg, rgba(27, 23, 60, 0.6), rgba(12, 10, 30, 0.7));
    color: rgba(var(--sb-cream-rgb), 0.86);
    font: 600 0.625rem / 1 var(--sb-font-display);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition:
        border-color var(--sb-dur-2) var(--sb-ease-lock),
        color var(--sb-dur-2) var(--sb-ease-lock),
        background var(--sb-dur-2) var(--sb-ease-lock),
        box-shadow var(--sb-dur-2) var(--sb-ease-lock);
}

#serenity-effects :is(.serenity-effects__repeat, .serenity-effects__all) { min-height: 40px; }

#serenity-effects .serenity-effects__all {
    border-color: rgba(var(--fx-accent), 0.45);
    color: rgb(var(--fx-accent));
}

#serenity-effects .serenity-effects__close {
    width: 40px;
    min-height: 40px;
    padding: 0;
    font: 400 1.25rem / 1 var(--sb-font-display);
    letter-spacing: 0;
}

#serenity-effects :is(.serenity-effects__effect, .serenity-effects__repeat, .serenity-effects__all, .serenity-effects__close):hover {
    border-color: rgba(var(--sb-cream-rgb), 0.42);
    background: linear-gradient(180deg, rgba(38, 33, 80, 0.8), rgba(16, 13, 38, 0.86));
    color: rgb(var(--sb-cream-rgb));
}

#serenity-effects :is(.serenity-effects__effect, .serenity-effects__repeat, .serenity-effects__all, .serenity-effects__close):active {
    transform: translateY(1px);
}

#serenity-effects .serenity-effects__effect { position: relative; }

/* The effect that is playing fills a thin line for as long as it plays (--fx-ms, from the
   player), so you can see how long it lasts and when it is done. */
#serenity-effects .serenity-effects__effect.is-playing::after {
    content: '';
    position: absolute;
    right: 12px;
    bottom: 6px;
    left: 12px;
    height: 2px;
    border-radius: 1px;
    background: rgb(var(--fx-accent));
    box-shadow: 0 0 8px rgba(var(--fx-accent), 0.6);
    transform-origin: left center;
    animation: serenity-fx-run var(--fx-ms, 1s) linear forwards;
}

@keyframes serenity-fx-run {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* The effect that is playing, Play all while it walks through them, and Repeat when on: the
   world's light. */
#serenity-effects :is(.serenity-effects__effect.is-playing, .serenity-effects__repeat.is-on, .serenity-effects__all.is-on) {
    border-color: rgba(var(--fx-accent), 0.7);
    background: rgba(var(--fx-accent), 0.12);
    color: rgb(var(--fx-accent));
    box-shadow: 0 0 18px rgba(var(--fx-accent), 0.28);
}

#serenity-effects :is(.serenity-effects__effect, .serenity-effects__repeat, .serenity-effects__all, .serenity-effects__close):focus-visible {
    outline: 2px solid rgba(var(--sb-cream-rgb), 0.82);
    outline-offset: 2px;
}

#serenity-effects .serenity-effects__note {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--sb-gold);
    font: 500 0.8125rem / 1.45 var(--sb-font-text);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

#serenity-effects .serenity-effects__note[hidden] { display: none; }

#serenity-effects .serenity-effects__hint {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 8px;
    margin: 4px 0 0;
    color: rgba(var(--sb-cream-rgb), 0.56);
    font: 500 0.75rem / 1.4 var(--sb-font-text);
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.8);
}

#serenity-effects .serenity-effects__hint span + kbd { margin-left: 10px; }

/* No keys to show on a touch screen. */
@media (pointer: coarse) {
    #serenity-effects .serenity-effects__hint { display: none; }
}

/* With a mouse, the panel steps back while an effect you pressed plays and the pointer is
   elsewhere, so the effect can be watched whole; reaching for it brings it straight back, and it
   returns by itself when the effect is done. The keyboard's focus keeps it. */
@media (hover: hover) and (min-width: 901px) and (min-height: 521px) {
    #serenity-effects.is-open.is-watching:not(:hover, :has(:focus-visible)) {
        opacity: 0.14;
        transition: opacity 0.8s ease 0.6s, transform 0.45s var(--sb-ease-breathe);
    }
}

/* A phone, a tablet held upright, or a short window (a phone on its side): a strip along the
   bottom, so the theme keeps most of the screen. The head is one line, the theme's name, Play
   all and × (the chips say what they are). Notices stand on it (the tray publishes its height);
   the dock steps out while it is open. */
@media (max-width: 900px), (max-height: 520px) {
    #serenity-effects {
        top: auto;
        left: 0;
        width: auto;
        min-width: 0;
        max-height: 50vh;
        justify-content: flex-end;
        align-items: center;
        gap: 10px;
        padding: 28px 0 max(14px, env(safe-area-inset-bottom));
        background: linear-gradient(0deg, rgba(7, 6, 22, 0.9) 0%, rgba(7, 6, 22, 0.78) 70%, rgba(7, 6, 22, 0) 100%);
        transform: translateY(14px);
    }

    #serenity-effects > * {
        box-sizing: border-box;
        width: min(100%, 760px);
    }

    #serenity-effects.is-open { transform: none; }

    #serenity-effects .serenity-effects__head {
        grid-template-columns: minmax(0, 1fr) auto auto auto;
        grid-template-areas: 'title repeat all close';
        column-gap: 8px;
        padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    }

    #serenity-effects :is(.serenity-effects__eyebrow, .serenity-effects__subtitle, .serenity-effects__hint) {
        display: none;
    }

    #serenity-effects .serenity-effects__head .serenity-effects__title { margin-top: 0; font-size: 18px; }

    #serenity-effects .serenity-effects__group {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    #serenity-effects .serenity-effects__group-label {
        margin: 0 2px 0 0;
        letter-spacing: 0.12em;
        white-space: nowrap;
    }

    #serenity-effects .serenity-effects__list { flex-wrap: nowrap; }
    #serenity-effects .serenity-effects__effect { min-height: 36px; padding: 0 11px; }
    #serenity-effects .serenity-effects__note { padding: 0 16px; }

    body.serenity-mode.serenity-effects-open #serenity-notification {
        bottom: calc(var(--serenity-effects-h, 200px) + 8px);
    }

    /* The tray lies over the dock's place: the dock steps out while it is open. */
    body.serenity-effects-open #serenity-world-bar .serenity-world__dock {
        visibility: hidden;
        opacity: 0;
    }
}

/* Upright with room to spare (a tablet): the groups wrap onto the lines they need, centred, and
   nothing scrolls. */
@media (min-width: 641px) and (max-width: 900px) and (min-height: 521px) {
    #serenity-effects .serenity-effects__head { padding: 0 24px; }

    #serenity-effects .serenity-effects__groups {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 24px;
        padding: 0 24px;
    }
}

/* A phone: the effects scroll sideways, fading at the edge where more wait. */
@media (max-width: 640px), (max-height: 520px) {
    #serenity-effects .serenity-effects__groups {
        gap: 8px 18px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        padding: 0 40px 0 max(16px, env(safe-area-inset-left));
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
        mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent);
    }

    #serenity-effects .serenity-effects__groups::-webkit-scrollbar { display: none; }
}

/* Upright: two rows that scroll together, three groups to a row. */
@media (max-width: 640px) and (min-height: 521px) {
    #serenity-effects .serenity-effects__groups { grid-template-columns: repeat(3, max-content); }
}

/* On its side (a short window): one row, so the strip stays low. */
@media (max-height: 520px) {
    #serenity-effects {
        gap: 8px;
        padding-top: 20px;
    }

    #serenity-effects .serenity-effects__groups {
        grid-auto-columns: max-content;
        grid-auto-flow: column;
    }
}

/* ---- Notices: one line of words over the world, above the dock -------------------------- */
body.serenity-mode #serenity-notification {
    top: auto;
    bottom: calc(max(4vh, 22px) + 100px);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    /* Its own width, not what is left of the screen right of its left: 50%. */
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 18px 52px;
    border: 0;
    border-radius: 999px;
    background: radial-gradient(closest-side, rgba(7, 6, 22, 0.86), rgba(7, 6, 22, 0.62) 58%, rgba(7, 6, 22, 0));
    box-shadow: none;
    color: rgb(var(--sb-cream-rgb));
    font: 600 0.9375rem / 1.4 var(--sb-font-text);
    letter-spacing: 0.005em;
    text-align: center;
    text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85);
    transform: translateX(-50%) translateY(10px);
}

body.serenity-mode #serenity-notification::before {
    content: '';
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: rgb(var(--serenity-accent, var(--sb-mint-rgb)));
    box-shadow: 0 0 10px rgba(var(--serenity-accent, var(--sb-mint-rgb)), 0.6);
}

body.serenity-mode #serenity-notification.visible {
    transform: translateX(-50%) translateY(0);
}

/* ---- The first visits' keys: a line of keycaps over the world, just above the dock ------ */
#serenity-first-hints {
    position: fixed;
    left: 50%;
    bottom: calc(max(4vh, 22px) + 58px);
    z-index: 1000;
    max-width: calc(100vw - 32px);
    padding: 16px 52px;
    border: 0;
    border-radius: 999px;
    background: radial-gradient(closest-side, rgba(7, 6, 22, 0.84), rgba(7, 6, 22, 0.6) 60%, rgba(7, 6, 22, 0));
    box-shadow: none;
    color: rgba(var(--sb-cream-rgb), 0.94);
    font: 600 var(--sb-fs-small) / 1.4 var(--sb-font-text);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 1px 12px rgba(0, 0, 0, 0.85);
    opacity: 0;
    transform: translate(-50%, 10px);
    pointer-events: none;
    transition: opacity 0.9s ease, transform 0.9s var(--sb-ease-breathe);
}

#serenity-first-hints.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

#serenity-first-hints .sb-hints {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 22px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#serenity-first-hints li {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

body.serenity-hub-open #serenity-first-hints,
body:not(.serenity-mode) #serenity-first-hints {
    visibility: hidden;
}

/* ---- The rest veil: the screen dims to night over the fade, then stays dark ------------- */
#serenity-rest-veil {
    position: fixed;
    inset: 0;
    z-index: 1990;
    display: grid;
    place-items: end center;
    padding-bottom: max(48px, 8vh);
    background: rgb(var(--sb-night-rgb));
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
}

#serenity-rest-veil.is-dimming {
    opacity: 0.97;
    pointer-events: auto;
    cursor: none;
    transition: opacity var(--rest-fade, 45s) cubic-bezier(0.3, 0, 0.2, 1);
}

#serenity-rest-veil .serenity-rest-veil__note {
    margin: 0;
    color: rgba(var(--sb-cream-rgb), 0.5);
    font: 500 var(--sb-fs-small) / 1.4 var(--sb-font-text);
    letter-spacing: 0.04em;
    opacity: 0;
}

/* The words appear as the dimming ends, and leave after a while so the dark is dark. */
#serenity-rest-veil.is-dimming .serenity-rest-veil__note {
    animation: serenity-rest-note 14s ease var(--rest-fade, 45s) both;
}

@keyframes serenity-rest-note {
    0%, 100% { opacity: 0; }
    20%, 70% { opacity: 1; }
}

/* ---- A touch on the world: one soft ring of light, in the world's own colour ------------ */
body.serenity-mode .serenity-click-ripple {
    width: 46px;
    height: 46px;
    border: 1px solid rgba(var(--serenity-accent, var(--sb-cream-rgb)), 0.66);
    box-shadow:
        0 0 14px rgba(var(--serenity-accent, var(--sb-cream-rgb)), 0.3),
        inset 0 0 10px rgba(var(--serenity-accent, var(--sb-cream-rgb)), 0.16);
    animation: serenity-touch-ring 1.1s var(--sb-ease-breathe) forwards;
}

@keyframes serenity-touch-ring {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0.9; }
    100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}

@keyframes serenity-touch-fade {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    #serenity-world-bar .serenity-world__caption,
    #serenity-world-bar:is(.is-awake, :focus-within) .serenity-world__caption,
    #serenity-world-bar .serenity-world__dock,
    #serenity-world-bar:is(.is-awake, :focus-within) .serenity-world__dock {
        transform: translate(-50%, 0);
        transition: none;
    }

    #serenity-world-bar { transition: opacity 0.3s ease; }
    #serenity-world-bar.is-arriving .serenity-world__name { animation: none; }

    #serenity-first-hints,
    #serenity-first-hints.visible {
        transform: translate(-50%, 0);
        transition: opacity 0.3s ease;
    }

    body.serenity-mode .serenity-click-ripple {
        transform: translate(-50%, -50%);
        animation: serenity-touch-fade 0.9s ease forwards;
    }

    #serenity-effects,
    #serenity-effects.is-open {
        transform: none;
        transition: opacity 0.3s ease;
    }
}
