/* Newzino Timeline daily game styles.
 *
 * Most layout is Tailwind classes inline in the templates. This file holds:
 *   - Sortable drag affordances (handle hover, dragging/ghost states)
 *   - Position badges + Oldest/Newest rail labels so the player can always
 *     see where they are in the sequence at a glance
 *   - Type pill shown during play (context, not a leak — types repeat
 *     within a story)
 *   - Hint annotation (📌 oldest date) when the player asks for the anchor
 *   - Reveal animation (slide-into-correct-position + date fade-in)
 *   - Color-coded slot borders (green/yellow/red) that Tailwind can't keep
 *     consistent across both light- and dark-bg surfaces
 *   - Win badge + confetti celebration on average-reader "wins"
 *     (correct >= 3 OR within_one >= 5)
 */

.tl-shell { transition: border-color 200ms ease-out; position: relative; }

/* Story-title subtitle under the modal "Timeline" heading. Single-line with
 * ellipsis on long titles; the full title is in the title= attr for a
 * tooltip. Color sits between the violet heading and the gray description
 * so the three lines read as a hierarchy. */
.tl-story-subtitle {
    font-size: 0.85rem;
    font-weight: 600;
    color: rgb(196, 181, 253);
    line-height: 1.25;
    max-width: 28rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* "You played" pill on the launcher banner — emerald check + score.
 * Shown only when the logged-in user has a prior submission for this story.
 * Sits in the title row next to "Timeline" so it reads as a status label,
 * not a CTA. The CTA itself swaps from "Play" to "See result" when this is
 * visible. */
.tl-played-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgb(167, 243, 208);
    background: rgba(16, 185, 129, 0.22);
    border: 1px solid rgba(16, 185, 129, 0.45);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    letter-spacing: 0.01em;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.tl-played-pill__score { line-height: 1; }

/* Visually hidden but still announced by screen readers. Used for the
 * aria-live status region that narrates card movements, hint usage, etc. */
.tl-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Strategy tip (shown above puzzle until player dismisses or interacts) ===
 * Teaches the win-strategy in one sentence. Auto-collapses after first
 * interaction so it doesn't stay visible during the actual play. */
.tl-tip {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.85rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(251, 191, 36, 0.30);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.06), rgba(167, 139, 250, 0.04));
    color: rgb(254, 243, 199);
    font-size: 0.78rem;
    line-height: 1.35;
    transition: opacity 200ms ease-out, max-height 240ms ease-out, margin 200ms ease-out, padding 200ms ease-out, border-color 200ms ease-out;
    max-height: 200px;
    overflow: hidden;
}
.tl-tip[data-tl-tip-dismissed] {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
    pointer-events: none;
}
.tl-tip__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
    color: rgb(251, 191, 36);
}
.tl-tip__text { flex: 1 1 auto; }
.tl-tip__text strong { font-weight: 700; color: #fff; }
.tl-tip__dismiss {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    color: rgb(254, 240, 138);
    line-height: 1;
    font-size: 1.05rem;
    transition: background-color 120ms ease-out;
}
.tl-tip__dismiss:hover { background-color: rgba(251, 191, 36, 0.15); }
.tl-tip__dismiss:focus-visible {
    outline: 2px solid rgb(251, 191, 36);
    outline-offset: 1px;
}

/* === Chronological-settle caption (appears as cards slide into truth) ===
 * The cards-falling-into-place moment is the climactic beat of the reveal.
 * Pill styling gives it the visual weight of a "section divider" — the player
 * sees the puzzle transition from "your guess" to "the truth." */
.tl-settle-caption {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: rgb(196, 181, 253);
    background: rgba(139, 92, 246, 0.14);
    border: 1px solid rgba(139, 92, 246, 0.32);
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    width: max-content;
    margin: 0 auto 0.85rem;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 320ms ease-out, transform 320ms ease-out;
}
.tl-settle-caption:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
    .tl-settle-caption { transition: none; }
}

/* === Oldest / Newest rail labels === */
.tl-rail-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgb(196, 181, 253);
    background: rgba(139, 92, 246, 0.10);
    border: 1px solid rgba(139, 92, 246, 0.25);
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    margin-bottom: 0.4rem;
}
.tl-rail-label--bottom {
    margin-bottom: 0;
    margin-top: 0.4rem;
}
.tl-list { position: relative; }

/* Vertical "timeline track": a subtle violet rail running behind the
 * position pills, connecting them into a sequence. Communicates "this is an
 * axis you're ordering along" without text. Hidden in the reveal state where
 * the position pills themselves are hidden, and faded at the ends so it blends
 * into the OLDEST/NEWEST rail pills without a hard stop. */
.tl-list::before {
    content: '';
    position: absolute;
    top: 14px;
    bottom: 14px;
    /* The pill center varies a touch between mobile (p-3 -> 12px) and desktop
     * (p-4 -> 16px) — 23px on mobile, 27px on desktop. 25px sits in the middle
     * and looks centered at both. */
    left: 25px;
    width: 2px;
    background: linear-gradient(to bottom,
        rgba(139, 92, 246, 0.0),
        rgba(139, 92, 246, 0.28) 12%,
        rgba(139, 92, 246, 0.28) 88%,
        rgba(139, 92, 246, 0.0)
    );
    z-index: 0;
    pointer-events: none;
}
.tl-list:has(.tl-card[data-reveal])::before { display: none; }
.tl-card { z-index: 1; }
.tl-card__pos {
    position: relative;
    z-index: 2;
}

/* === Position number badge on each card during play === */
.tl-card__pos {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: rgb(196, 181, 253);
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.35);
    font-variant-numeric: tabular-nums;
    transition: background-color 150ms ease-out, color 150ms ease-out;
}
.tl-card[data-reveal] .tl-card__pos { display: none; }
@keyframes tlPosBump {
    0%   { transform: scale(1); background: rgba(139, 92, 246, 0.15); }
    35%  { transform: scale(1.18); background: rgba(167, 139, 250, 0.32); color: #fff; }
    100% { transform: scale(1); background: rgba(139, 92, 246, 0.15); }
}
.tl-card__pos--bumped {
    animation: tlPosBump 360ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .tl-card__pos--bumped { animation: none; }
}

/* === Type pill shown during play === */
.tl-card__meta-play {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.25rem;
    min-height: 0;
}
.tl-card__meta-play:empty { margin-top: 0; }
.tl-type-pill {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgb(196, 181, 253);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.22);
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    white-space: nowrap;
}
/* On narrow screens the card content area shrinks; "TECHNOLOGY LAUNCH" and
 * similar two-word types would wrap to two lines without this tighter scale. */
@media (max-width: 420px) {
    .tl-type-pill {
        font-size: 0.6rem;
        letter-spacing: 0.04em;
        padding: 0.08rem 0.4rem;
    }
}

/* === Hint annotation (📌 oldest date) on the anchored card === */
.tl-card--hinted {
    border-color: rgba(251, 191, 36, 0.6) !important;
    box-shadow: inset 3px 0 0 rgba(251, 191, 36, 0.7);
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.06) 0%, transparent 35%);
}
.tl-card__hint-date {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgb(251, 191, 36);
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* === Hint button ===
 * "Available" state pulses subtly so first-time players notice the free
 * anchor. Pulse fades out the moment the player interacts with the puzzle
 * (drag, arrow, or hint click), so it never feels nagging. */
.tl-hint__icon {
    font-size: 0.95rem;
    line-height: 1;
    display: inline-block;
}
@keyframes tlHintAvailablePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
    50%      { box-shadow: 0 0 0 5px rgba(251, 191, 36, 0.18); }
}
.tl-hint.tl-hint--available {
    animation: tlHintAvailablePulse 2.6s ease-in-out infinite;
}
.tl-hint.tl-hint--available .tl-hint__icon {
    animation: tlHintWiggle 2.6s ease-in-out infinite;
    transform-origin: 50% 80%;
}
@keyframes tlHintWiggle {
    0%, 80%, 100% { transform: rotate(0deg); }
    85%           { transform: rotate(-12deg); }
    90%           { transform: rotate(10deg); }
    95%           { transform: rotate(-6deg); }
}
/* Used state: settle to a calm "done" look. The amber spotlight retires once
 * the player has taken the hint — keeping it bright would compete with the
 * submit button for attention. The icon swap to ✓ (done via JS) confirms the
 * action registered without needing the player to re-read the label. */
.tl-hint[data-tl-hint-used] {
    color: rgb(110, 231, 183);
    border-color: rgba(16, 185, 129, 0.35);
    background: rgba(16, 185, 129, 0.08);
    cursor: default;
    animation: none;
    opacity: 0.95;
}
.tl-hint[data-tl-hint-used] .tl-hint__icon {
    animation: none;
    color: rgb(52, 211, 153);
    font-weight: 700;
}
@media (prefers-reduced-motion: reduce) {
    .tl-hint.tl-hint--available,
    .tl-hint.tl-hint--available .tl-hint__icon { animation: none; }
}

/* === Hint anchor pulse (fired when card is auto-moved to slot 1) === */
@keyframes tlHintPulse {
    0%   { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
    30%  { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.35); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.0); }
}
.tl-card--hint-pulse {
    animation: tlHintPulse 700ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .tl-card--hint-pulse { animation: none; }
}

/* === Cards in play state === */
.tl-card {
    position: relative;
    transition: transform 180ms ease-out, border-color 180ms ease-out, box-shadow 180ms ease-out;
    user-select: none;
    touch-action: pan-y;  /* lets the page scroll vertically; SortableJS takes over for drags */
}

/* Deal-in: on initial render the JS stamps each card with --tl-i = 0,1,2…
 * so the cards rise/fade in sequence (60ms stagger). Makes the start of the
 * puzzle feel intentional — cards arrive on the table rather than just blink
 * into place. Only fires on first render; ignored once the player drags. */
@keyframes tlDealIn {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}
.tl-card[data-tl-dealing] {
    opacity: 0;
    animation: tlDealIn 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
    animation-delay: calc(var(--tl-i, 0) * 60ms);
}
@media (prefers-reduced-motion: reduce) {
    .tl-card[data-tl-dealing] {
        opacity: 1;
        animation: none;
    }
}

/* First-time drag affordance: on the very first puzzle a player ever opens,
 * the first card's drag handle gets a small horizontal nudge so the player
 * sees the card flex — telegraphing "this is moveable." JS toggles
 * data-tl-drag-hint after the deal-in finishes (so the wiggle isn't lost in
 * the entrance motion) and clears it on first interaction or after ~6s.
 * sessionStorage-gated so it only shows once per session. */
@keyframes tlDragHint {
    0%, 100% { transform: translateX(0); }
    35%      { transform: translateX(-5px); }
    60%      { transform: translateX(4px); }
    80%      { transform: translateX(-2px); }
}
.tl-card[data-tl-drag-hint] {
    animation: tlDragHint 1.1s cubic-bezier(0.4, 0, 0.6, 1) 1;
}
.tl-card[data-tl-drag-hint] .tl-card__handle {
    color: rgb(196, 181, 253);
}
@media (prefers-reduced-motion: reduce) {
    .tl-card[data-tl-drag-hint] { animation: none; }
}

/* Desktop hover lift: invites "you can grab this" before the player tries.
 * Skip the lift while a card is being dragged (Sortable adds .tl-card--dragging
 * which has its own elevated state) or after the reveal. Touch devices skip
 * it entirely via the (hover:hover) gate. */
@media (hover: hover) and (pointer: fine) {
    .tl-card:not([data-reveal]):not(.tl-card--dragging):hover {
        border-color: rgba(139, 92, 246, 0.45);
        box-shadow: 0 4px 18px -6px rgba(139, 92, 246, 0.28);
        transform: translateY(-1px);
    }
    .tl-card:not([data-reveal]):not(.tl-card--dragging):hover .tl-card__handle {
        color: rgb(196, 181, 253);
    }
}

/* Keyboard focus echo: when a focusable child of a card (the up/down arrow
 * buttons) has focus, highlight the parent card so keyboard users can tell
 * which card they're about to move. The arrow buttons themselves still get
 * their own focus outline — this is just adding a "you are here" signal at
 * the card level. */
.tl-card:has(:focus-visible):not([data-reveal]) {
    border-color: rgba(196, 181, 253, 0.7);
    box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35);
}

/* Drag handle: the only region with grab cursor. Whole card is NOT draggable
 * to keep vertical page-scroll predictable on mobile (documented anti-pattern
 * to make the whole row draggable). */
.tl-card__handle {
    cursor: grab;
    color: rgb(148, 163, 184);
    transition: color 150ms ease-out, background-color 150ms ease-out;
    touch-action: none;  /* the handle itself never scrolls — only drags */
}
.tl-card__handle:hover { color: rgb(196, 181, 253); }
.tl-card__handle:active { cursor: grabbing; }

/* While Sortable is moving a card, lift it visually so the drop target is
 * unambiguous. The ghost is the placeholder left behind. */
.tl-card.tl-card--dragging {
    box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.6);
    transform: scale(1.02) rotate(0.4deg);
    z-index: 50;
}
.tl-card--ghost {
    opacity: 0.35;
    background: rgba(139, 92, 246, 0.08) !important;
    border-style: dashed !important;
}

/* === Reveal state === */
@keyframes tlSlotFlash {
    0%   { box-shadow: 0 0 0 0 currentColor; }
    40%  { box-shadow: 0 0 0 6px currentColor; opacity: 0.6; }
    100% { box-shadow: 0 0 0 0 currentColor; }
}

.tl-card--exact     { border-left: 4px solid rgb(34, 197, 94); }
.tl-card--within-one { border-left: 4px solid rgb(234, 179, 8); }
.tl-card--off       { border-left: 4px solid rgb(239, 68, 68); }

/* Per-card exact-match flash: a soft green glow on the row + a tiny pop
 * on the ✓ icon when the reveal animation lights the card. Each exact card
 * gets its own micro-celebration — feels noticeably better than a static
 * green border alone. */
@keyframes tlExactFlash {
    0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.0); background: rgba(34, 197, 94, 0.0); }
    20%  { box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25); background: rgba(34, 197, 94, 0.10); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.0); background: rgba(34, 197, 94, 0.0); }
}
@keyframes tlExactIconPop {
    0%   { transform: scale(0.6); opacity: 0; }
    50%  { transform: scale(1.35); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.tl-card--exact[data-reveal] {
    animation: tlExactFlash 900ms ease-out;
}
.tl-card--exact[data-reveal] .tl-reveal-icon {
    animation: tlExactIconPop 520ms cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
    color: rgb(74, 222, 128);
}

/* Within-one cards get a softer amber glow — same shape as the exact flash
 * but quieter, since the player was close-but-not-exact. */
@keyframes tlWithinFlash {
    0%   { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.0); background: rgba(234, 179, 8, 0.0); }
    25%  { box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.18); background: rgba(234, 179, 8, 0.06); }
    100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.0); background: rgba(234, 179, 8, 0.0); }
}
.tl-card--within-one[data-reveal] {
    animation: tlWithinFlash 700ms ease-out;
}
.tl-card--within-one[data-reveal] .tl-reveal-icon {
    color: rgb(250, 204, 21);
    font-weight: 700;
}

/* Off cards get a tiny horizontal jiggle — communicates "this one was off"
 * without being punishing. Same idea as a form-validation shake but gentler. */
@keyframes tlOffJiggle {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(1px); }
}
.tl-card--off[data-reveal] {
    animation: tlOffJiggle 420ms ease-out;
}
.tl-card--off[data-reveal] .tl-reveal-icon {
    color: rgb(248, 113, 113);
}

@media (prefers-reduced-motion: reduce) {
    .tl-card--exact[data-reveal],
    .tl-card--exact[data-reveal] .tl-reveal-icon,
    .tl-card--within-one[data-reveal],
    .tl-card--off[data-reveal] {
        animation: none;
    }
}

/* Position-delta chip on off-by-more-than-one reveal cards.
 * Slightly bumped contrast so the "Should be #N" learning moment is harder
 * to miss — it's the only feedback on off cards aside from the left border. */
.tl-reveal-delta {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgb(252, 165, 165);
    background: rgba(239, 68, 68, 0.16);
    border: 1px solid rgba(239, 68, 68, 0.40);
    padding: 0.12rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.tl-card[data-reveal] .tl-card__handle,
.tl-card[data-reveal] .tl-card__arrows {
    visibility: hidden;
}

/* Date pill that fades in during reveal. */
.tl-card__date {
    opacity: 0;
    transition: opacity 320ms ease-out;
}
.tl-card[data-reveal] .tl-card__date { opacity: 1; }

/* Reveal description: a touch more breathing room from the type pill above
 * + slight leading so the two-line clamp reads naturally. */
.tl-card__desc {
    display: block;
    width: 100%;
    margin-top: 0.2rem;
    line-height: 1.4;
    font-size: 0.78rem;
}

/* Up/down arrow buttons — visible always, but only used as a bailout for
 * users who don't want to drag. WCAG min 44x44 touch target on mobile;
 * desktop can compress slightly since hover-state makes them findable. */
.tl-card__arrow {
    min-width: 44px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: rgb(148, 163, 184);
    transition: background-color 120ms ease-out, color 120ms ease-out;
}
@media (hover: none) {
    /* Touch-first devices: enforce full 44x44 hit area on both axes. */
    .tl-card__arrow {
        min-height: 44px;
    }
}
.tl-card__arrow:hover:not(:disabled) {
    color: rgb(196, 181, 253);
    background-color: rgba(139, 92, 246, 0.12);
}
.tl-card__arrow:focus-visible {
    outline: 2px solid rgb(196, 181, 253);  /* violet-300 */
    outline-offset: 2px;
    color: rgb(196, 181, 253);
}
.tl-card__arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* === Skip-reveal-animation button ===
 * Appears only during the reveal/settle window. Lets repeat players bypass
 * the 2-3s animation and jump to the end state. */
.tl-skip-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.6rem;
    min-height: 1.5rem;
}
.tl-skip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgb(156, 163, 175);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 120ms ease-out, background-color 120ms ease-out;
}
/* Tailwind's .hidden ships before timeline.css and so loses the cascade
 * battle against `.tl-skip { display: inline-flex }`. Force-restore the
 * hidden state here. Without this, the skip-animation button bleeds into
 * the play state — visible before there's anything to skip. */
.tl-skip.hidden {
    display: none;
}
.tl-skip:hover {
    color: rgb(196, 181, 253);
    background: rgba(139, 92, 246, 0.10);
}
.tl-skip:focus-visible {
    outline: 2px solid rgb(196, 181, 253);
    outline-offset: 1px;
}

/* === Score stats (Exact / Within 1) === */
.tl-score-stat {
    text-align: center;
    padding: 0.5rem 0.85rem;
    border-radius: 0.6rem;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.22);
    min-width: 84px;
    transition: background-color 220ms ease-out, border-color 220ms ease-out;
}
.tl-score-stat--soft {
    background: rgba(234, 179, 8, 0.06);
    border-color: rgba(234, 179, 8, 0.20);
}
/* When the player has earned a "win tier" on this stat, tint the box in the
 * matching reveal color: green for exact >= 2 (the win threshold), amber for
 * within >= 4. Makes the stat boxes feel like they recognized the achievement,
 * not just displayed a number. */
.tl-score-stat[data-tl-tier="exact"] {
    background: rgba(34, 197, 94, 0.10);
    border-color: rgba(34, 197, 94, 0.45);
}
.tl-score-stat[data-tl-tier="exact"] .tl-score-stat__label {
    color: rgb(110, 231, 183) !important;
}
.tl-score-stat--soft[data-tl-tier="within"] {
    background: rgba(234, 179, 8, 0.14);
    border-color: rgba(234, 179, 8, 0.50);
}
.tl-score-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.tl-score-stat__total {
    color: rgb(107, 114, 128);
    font-weight: 600;
    font-size: 1rem;
}
.tl-score-stat__label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgb(156, 163, 175);
    margin-top: 0.35rem;
}
.tl-score-stat--soft .tl-score-stat__label { color: rgb(234, 179, 8); }
.tl-score-stat:not(.tl-score-stat--soft) .tl-score-stat__label { color: rgb(196, 181, 253); }

/* === Win badge === */
.tl-win-badge {
    display: inline-block;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: #fff;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #f0abfc 100%);
    padding: 0.55rem 1.25rem;
    border-radius: 999px;
    box-shadow: 0 10px 28px -10px rgba(167, 139, 250, 0.75),
                0 0 0 1px rgba(255, 255, 255, 0.08) inset;
    animation: tlWinPop 540ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
/* Perfect-run halo: the badge gets a subtle pulsing ring so a perfect 5/5
 * lands with a little more pageantry than a "Sharp eye" or "Nicely done". */
.tl-win-badge[data-tl-tier="perfect"] {
    background: linear-gradient(135deg, #f59e0b 0%, #f0abfc 45%, #a855f7 100%);
    box-shadow: 0 12px 32px -8px rgba(245, 158, 11, 0.55),
                0 0 0 1px rgba(255, 255, 255, 0.12) inset;
    animation: tlWinPop 540ms cubic-bezier(0.34, 1.56, 0.64, 1) both,
               tlPerfectHalo 2.4s ease-in-out 540ms infinite;
}
@keyframes tlWinPop {
    0%   { transform: scale(0.4); opacity: 0; }
    60%  { transform: scale(1.10); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes tlPerfectHalo {
    0%, 100% { box-shadow: 0 12px 32px -8px rgba(245, 158, 11, 0.55),
                           0 0 0 0 rgba(245, 158, 11, 0.0),
                           0 0 0 1px rgba(255, 255, 255, 0.12) inset; }
    50%      { box-shadow: 0 12px 32px -8px rgba(245, 158, 11, 0.75),
                           0 0 0 8px rgba(245, 158, 11, 0.10),
                           0 0 0 1px rgba(255, 255, 255, 0.12) inset; }
}
@media (prefers-reduced-motion: reduce) {
    .tl-win-badge[data-tl-tier="perfect"] {
        animation: none;
    }
}

/* === Confetti canvas — overlays the modal content area === */
.tl-confetti {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    opacity: 0;
    pointer-events: none;
}
.tl-confetti--active { opacity: 1; }

/* === Achievement chips on the end screen === */
.tl-achievements {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0 0.85rem;
}
.tl-achievement {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    color: rgb(254, 240, 138);
    background: rgba(234, 179, 8, 0.10);
    border: 1px solid rgba(234, 179, 8, 0.40);
    animation: tlWinPop 460ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: 120ms;
}
.tl-achievement--solo {
    color: rgb(110, 231, 183);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.40);
}
.tl-achievement--first {
    color: rgb(252, 211, 77);
    background: rgba(244, 114, 182, 0.12);
    border-color: rgba(244, 114, 182, 0.45);
}
@media (prefers-reduced-motion: reduce) {
    .tl-achievement { animation: none; }
}

/* === "Play next: {title}" CTA on the end state ===
 * Replaces the generic "Play another timeline" label with a concrete preview
 * of the next puzzle. The story title can be long, so we cap the visible
 * title with ellipsis — the full text lives in the title= attribute for the
 * tooltip. The "Play next:" lead stays in normal weight; the title is bold
 * so it's the eye-grabber. */
.tl-next-cta {
    min-width: 0;
}
.tl-next-cta__lead {
    font-weight: 500;
    opacity: 0.85;
    flex-shrink: 0;
    white-space: nowrap;
}
.tl-next-cta__title {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 18rem;
}
@media (max-width: 480px) {
    .tl-next-cta__title { max-width: 11rem; }
}

/* === Tertiary "See the full story timeline" link === */
.tl-see-timeline {
    padding: 0.35rem 0.7rem;
    border-radius: 0.4rem;
    letter-spacing: 0.01em;
}
.tl-see-timeline:hover {
    background: rgba(139, 92, 246, 0.08);
}

/* === End-state mini stats ("4 played · best 5/6") === */
.tl-end-stats {
    font-size: 0.7rem;
    color: rgb(156, 163, 175);
    margin-bottom: 0.85rem;
    letter-spacing: 0.02em;
}
.tl-end-stats__sep {
    color: rgb(75, 85, 99);
    margin: 0 0.4rem;
}
.tl-end-stats__value {
    color: rgb(196, 181, 253);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* === Share grid (emoji squares) === */
.tl-share-grid {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 1.55rem;
    letter-spacing: 0.12em;
    line-height: 1;
    text-align: center;
}

/* Submit button — pulse only kicks in after the player has interacted
 * with the puzzle (.tl-submit--ready). Avoids two pulses (hint + submit)
 * competing for attention at startup. */
@keyframes tlSubmitPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50%      { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}
.tl-submit.tl-submit--ready:not(:disabled) {
    animation: tlSubmitPulse 2.4s ease-out infinite;
}
@keyframes tlSubmitLockedPop {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.04); }
    100% { transform: scale(1); }
}
.tl-submit[data-tl-submit-state="locked"] {
    background-color: rgb(124, 58, 237);  /* violet-600 deepened */
    animation: tlSubmitLockedPop 380ms ease-out;
}
@media (prefers-reduced-motion: reduce) {
    .tl-submit[data-tl-submit-state="locked"] { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
    .tl-card,
    .tl-card__date,
    .tl-card.tl-card--dragging {
        transition: none;
        animation: none;
    }
    .tl-submit:not(:disabled) { animation: none; }
    .tl-win-badge { animation: none; }
}
