/* ============================================================
   AVALON — Showtime layer (narrator, title cards, transitions, effects)
   Loaded after polish.css on both the display and phones.
   ============================================================ */

:root {
    --st-gold: #e9c46a;
    --st-gold-deep: #9a6a1c;
    --st-ivory: #fbf1d6;
    --st-ink: #1b130a;
    --st-velvet: #3a0f1a;
    --st-velvet-deep: #1a050b;
    --st-blood: #c0392b;
    --st-royal: #3557a8;
    --st-ease-pop: cubic-bezier(0.2, 1.4, 0.35, 1);
    --st-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---- Particle canvas ---------------------------------------------------- */
.st-fx-canvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1300;
}

/* ---- Curtain transition (replaces the plain black fade) ------------------ */
#page-transition {
    background: none;
    opacity: 1;
    transition: none;
    overflow: hidden;
}
#page-transition::before,
#page-transition::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 51%;
    background:
        repeating-linear-gradient(90deg, rgba(0,0,0,0.28) 0 3px, transparent 3px 46px, rgba(255,255,255,0.04) 46px 52px, transparent 52px 86px),
        linear-gradient(180deg, #5a1424 0%, var(--st-velvet) 45%, var(--st-velvet-deep) 100%);
    box-shadow: inset 0 -40px 80px rgba(0,0,0,0.55);
    transition: transform 0.36s cubic-bezier(0.7, 0, 0.3, 1);
    will-change: transform;
}
#page-transition::before {
    left: 0;
    transform: translateX(-102%);
    border-right: 4px solid var(--st-gold);
    box-shadow: inset 0 -40px 80px rgba(0,0,0,0.55), 6px 0 22px rgba(233,196,106,0.35);
}
#page-transition::after {
    right: 0;
    transform: translateX(102%);
    border-left: 4px solid var(--st-gold);
    box-shadow: inset 0 -40px 80px rgba(0,0,0,0.55), -6px 0 22px rgba(233,196,106,0.35);
}
#page-transition.active::before,
#page-transition.active::after {
    transform: translateX(0);
    transition-duration: 0.27s;
}

/* ---- Screen shake ---------------------------------------------------------- */
@keyframes st-shake-light {
    0%, 100% { transform: translate3d(0,0,0); }
    20% { transform: translate3d(-4px, 1px, 0); }
    40% { transform: translate3d(4px, -2px, 0); }
    60% { transform: translate3d(-3px, 2px, 0); }
    80% { transform: translate3d(2px, -1px, 0); }
}
@keyframes st-shake-heavy {
    0%, 100% { transform: translate3d(0,0,0) rotate(0); }
    10% { transform: translate3d(-14px, 6px, 0) rotate(-0.6deg); }
    25% { transform: translate3d(12px, -8px, 0) rotate(0.5deg); }
    40% { transform: translate3d(-10px, 5px, 0) rotate(-0.4deg); }
    55% { transform: translate3d(8px, -4px, 0) rotate(0.3deg); }
    70% { transform: translate3d(-5px, 3px, 0); }
    85% { transform: translate3d(3px, -1px, 0); }
}
.st-shake-light { animation: st-shake-light 0.45s ease-out; }
.st-shake-medium { animation: st-shake-light 0.3s ease-out 2; }
.st-shake-heavy { animation: st-shake-heavy 0.7s ease-out; }

@keyframes st-pop {
    0% { transform: scale(1); }
    35% { transform: scale(1.18); }
    100% { transform: scale(1); }
}
.st-pop { animation: st-pop 0.5s var(--st-ease-pop); }

/* ---- The Court Narrator (raven herald) ----------------------------------- */
.st-herald {
    --jaw: 0;
    position: fixed;
    z-index: 10000;
    right: max(1.2rem, env(safe-area-inset-right));
    bottom: max(1.1rem, env(safe-area-inset-bottom));
    display: flex;
    align-items: flex-end;
    gap: 0;
    pointer-events: none;
    opacity: 0;
    transform: translateY(30px) scale(0.92);
    transition: opacity 0.3s ease, transform 0.45s var(--st-ease-pop);
    max-width: min(46rem, calc(100vw - 2rem));
    flex-direction: row-reverse;
}
.st-herald.visible { opacity: 1; transform: none; }
.st-herald.leaving { opacity: 0; transform: translateY(18px) scale(0.96); transition-duration: 0.4s; }

.st-herald-medallion {
    position: relative;
    flex: 0 0 auto;
    width: 8.6rem;
    height: 8.6rem;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 38%, #4b3a6b 0%, #24183a 52%, #120b1e 100%);
    border: 4px solid var(--st-gold);
    box-shadow:
        0 0 0 3px rgba(26, 14, 4, 0.9),
        0 0 0 7px rgba(233,196,106,0.55),
        0 14px 34px rgba(0,0,0,0.6),
        0 0 46px rgba(233,196,106,0.25);
    overflow: hidden;
    z-index: 2;
}
.st-herald-medallion::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.18), transparent 45%);
}
.st-herald-medallion svg { width: 100%; height: 100%; display: block; }
.st-raven { transform-origin: 60px 100px; animation: st-raven-idle 3.2s ease-in-out infinite; }
.st-herald.speaking .st-raven { animation: st-raven-talk 0.9s ease-in-out infinite; }
.st-raven-head { transform-origin: 58px 56px; }
.st-herald.speaking .st-raven-head { animation: st-raven-nod 1.35s ease-in-out infinite; }
.st-raven-jaw {
    transform-origin: 75px 50px;
    transform: rotate(calc(var(--jaw) * 26deg));
    transition: transform 0.05s linear;
}
.st-raven-beak-top {
    transform-origin: 75px 46px;
    transform: rotate(calc(var(--jaw) * -7deg));
    transition: transform 0.05s linear;
}
.st-raven-eye { transform-origin: 64px 40px; animation: st-raven-blink 4.6s infinite; }
.st-raven-brow { transform-origin: 64px 33px; transition: transform 0.25s ease; transform: rotate(-4deg); }
.st-herald.speaking .st-raven-brow { transform: rotate(-14deg) translateY(-1.5px); }
@keyframes st-raven-idle {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(1.5px) rotate(-1deg); }
}
@keyframes st-raven-talk {
    0%, 100% { transform: translateY(0) rotate(0); }
    30% { transform: translateY(-2px) rotate(1.5deg); }
    65% { transform: translateY(1px) rotate(-1.2deg); }
}
@keyframes st-raven-nod {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-5deg); }
    60% { transform: rotate(4deg); }
}
@keyframes st-raven-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(0.08); }
}

.st-herald-scroll {
    position: relative;
    margin-right: -1.6rem;
    margin-bottom: 1rem;
    padding: 0.85rem 2.6rem 0.9rem 1.3rem;
    min-width: 13rem;
    max-width: 36rem;
    color: var(--st-ink);
    background:
        radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.55), transparent 60%),
        linear-gradient(180deg, #fff6dc 0%, #f1dfae 55%, #e3c88c 100%);
    border: 2px solid #a4782c;
    border-radius: 14px 30px 30px 14px;
    box-shadow:
        inset 0 0 0 2px rgba(255,255,255,0.45),
        inset 0 -10px 22px rgba(120, 78, 20, 0.22),
        0 12px 28px rgba(0,0,0,0.5);
    transform-origin: right center;
    transform: scaleX(0.2);
    opacity: 0;
    transition: transform 0.45s var(--st-ease-out) 0.05s, opacity 0.2s ease 0.05s;
}
.st-herald.visible .st-herald-scroll { transform: none; opacity: 1; }
.st-herald.captions-off .st-herald-scroll { display: none; }
.st-herald-name {
    display: block;
    font-family: var(--font-heading, 'Cinzel', serif);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #8a5a14;
    margin-bottom: 0.15rem;
}
.st-herald-text {
    margin: 0;
    font-family: var(--font-body, 'Crimson Pro', Georgia, serif);
    font-size: 1.32rem;
    line-height: 1.28;
    font-weight: 600;
}
.st-herald.long .st-herald-text { font-size: 1.12rem; }
.st-herald-text span {
    opacity: 0.12;
    animation: st-word-in 0.22s ease forwards;
}
@keyframes st-word-in {
    from { opacity: 0.12; filter: blur(1px); }
    to { opacity: 1; filter: none; }
}

/* Phones: a compact narrator pinned above the content. */
.st-herald-player {
    right: 0.6rem;
    left: 0.6rem;
    bottom: auto;
    top: max(0.6rem, env(safe-area-inset-top));
    max-width: none;
    justify-content: flex-start;
}
.st-herald-player .st-herald-medallion { width: 3.6rem; height: 3.6rem; border-width: 2px; }
.st-herald-player .st-herald-scroll {
    margin-right: -0.9rem;
    margin-bottom: 0;
    padding: 0.5rem 1.4rem 0.55rem 0.8rem;
    max-width: none;
    flex: 1 1 auto;
    min-width: 0;
}
.st-herald-player .st-herald-text { font-size: 0.98rem; }
.st-herald-player .st-herald-name { font-size: 0.58rem; }

@media (max-width: 900px) {
    .st-herald-host .st-herald-medallion { width: 5.6rem; height: 5.6rem; }
    .st-herald-host .st-herald-text { font-size: 1.05rem; }
}

/* ---- Unlock chip -------------------------------------------------------------- */
.st-unlock-chip {
    position: fixed;
    z-index: 10001;
    left: 50%;
    bottom: 1.2rem;
    transform: translate(-50%, 140%);
    padding: 0.7rem 1.3rem;
    border: 2px solid var(--st-gold);
    border-radius: 999px;
    background: rgba(20, 12, 4, 0.92);
    color: var(--st-ivory);
    font-family: var(--font-heading, serif);
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 24px rgba(233,196,106,0.3);
    cursor: pointer;
    transition: transform 0.45s var(--st-ease-pop);
}
.st-unlock-chip.visible { transform: translate(-50%, 0); animation: st-chip-bob 2.4s ease-in-out infinite 0.6s; }
@keyframes st-chip-bob {
    0%, 100% { transform: translate(-50%, 0); }
    50% { transform: translate(-50%, -5px); }
}

/* ---- Title cards ------------------------------------------------------------------ */
.st-title-card {
    position: fixed;
    inset: 0;
    z-index: 9990;
    display: grid;
    place-items: center;
    pointer-events: none;
    visibility: hidden;
    --tone-a: var(--st-gold);
    --tone-b: #6b4410;
    --tone-glow: rgba(233, 196, 106, 0.45);
}
.st-title-card.tone-blood { --tone-a: #ff6b5b; --tone-b: #5c0f0b; --tone-glow: rgba(255, 70, 50, 0.45); }
.st-title-card.tone-royal { --tone-a: #9cc0ff; --tone-b: #1c2f66; --tone-glow: rgba(120, 160, 255, 0.45); }
.st-title-card.tone-night { --tone-a: #d9d0ff; --tone-b: #241a4a; --tone-glow: rgba(170, 150, 255, 0.4); }
.st-title-card.visible { visibility: visible; }
.st-title-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.78) 70%);
    opacity: 0;
    transition: opacity 0.25s ease;
}
.st-title-card.visible::before { opacity: 1; }
.st-title-card.leaving::before { opacity: 0; transition-duration: 0.45s; }
.st-title-rays {
    position: absolute;
    width: 160vmax;
    height: 160vmax;
    background: repeating-conic-gradient(from 0deg, var(--tone-glow) 0deg 6deg, transparent 6deg 18deg);
    mask-image: radial-gradient(circle, black 0%, transparent 55%);
    -webkit-mask-image: radial-gradient(circle, black 0%, transparent 55%);
    opacity: 0;
    transform: scale(0.6) rotate(0);
}
.st-title-card.visible .st-title-rays { animation: st-rays 2.8s linear forwards; }
.st-title-card.leaving .st-title-rays { opacity: 0 !important; transition: opacity 0.3s; }
@keyframes st-rays {
    0% { opacity: 0; transform: scale(0.6) rotate(0deg); }
    15% { opacity: 0.55; }
    100% { opacity: 0.35; transform: scale(1.05) rotate(40deg); }
}
.st-title-banner {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 0.3rem;
    padding: 1.6rem 4.5rem 2rem;
    min-width: min(44rem, 86vw);
    text-align: center;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), transparent 30%),
        linear-gradient(180deg, #2a1a0b 0%, #120b05 100%);
    border-top: 3px solid var(--tone-a);
    border-bottom: 3px solid var(--tone-a);
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.8),
        0 0 0 6px rgba(0,0,0,0.25),
        0 30px 80px rgba(0,0,0,0.7),
        0 0 90px var(--tone-glow);
    clip-path: polygon(0 0, 100% 0, 96% 50%, 100% 100%, 0 100%, 4% 50%);
    opacity: 0;
    transform: translateY(-60vh) rotate(-3deg) scale(1.1);
}
.st-title-card.visible .st-title-banner { animation: st-banner-drop 0.62s var(--st-ease-pop) forwards; }
.st-title-card.leaving .st-title-banner { animation: st-banner-leave 0.48s cubic-bezier(0.6, 0, 0.8, 0.4) forwards; }
@keyframes st-banner-drop {
    0% { opacity: 0; transform: translateY(-60vh) rotate(-3deg) scale(1.1); }
    60% { opacity: 1; transform: translateY(2vh) rotate(0.6deg) scale(1); }
    100% { opacity: 1; transform: none; }
}
@keyframes st-banner-leave {
    to { opacity: 0; transform: translateY(40vh) rotate(2deg) scale(0.92); }
}
.st-title-eyebrow {
    font-family: var(--font-heading, serif);
    font-size: clamp(0.8rem, 1.4vw, 1.15rem);
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: var(--tone-a);
    opacity: 0.85;
}
.st-title-main {
    font-family: var(--font-heading, serif);
    font-size: clamp(2.6rem, 8vw, 7.2rem);
    line-height: 0.95;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fffbe9 0%, var(--tone-a) 48%, var(--tone-b) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 0 rgba(0,0,0,0.65)) drop-shadow(0 0 22px var(--tone-glow));
}
.st-title-card.visible .st-title-main { animation: st-title-punch 0.9s var(--st-ease-pop) 0.18s both; }
@keyframes st-title-punch {
    0% { transform: scale(2.2); opacity: 0; letter-spacing: 0.3em; }
    55% { transform: scale(0.94); opacity: 1; }
    100% { transform: scale(1); letter-spacing: 0.04em; }
}
.st-title-sub {
    font-family: var(--font-body, serif);
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.6rem);
    color: var(--st-ivory);
    opacity: 0;
}
.st-title-sub:empty, .st-title-eyebrow:empty { display: none; }
.st-title-card.visible .st-title-sub { animation: st-fade-up 0.5s ease 0.55s forwards; }
.st-title-flourish {
    width: 60%;
    height: 2px;
    margin-top: 0.4rem;
    background: linear-gradient(90deg, transparent, var(--tone-a), transparent);
    transform: scaleX(0);
}
.st-title-card.visible .st-title-flourish { animation: st-flourish 0.7s var(--st-ease-out) 0.4s forwards; }
@keyframes st-flourish { to { transform: scaleX(1); } }
@keyframes st-fade-up {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
    .st-title-banner { padding: 1.1rem 2rem 1.3rem; min-width: 0; width: 92vw; }
}

/* ---- Announcements (lobby arrivals etc.) ------------------------------------------ */
.st-announce-stack {
    position: fixed;
    z-index: 9500;
    top: max(1rem, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 0.5rem;
    justify-items: center;
    pointer-events: none;
}
.st-announce {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.55rem 1.4rem 0.6rem 0.65rem;
    border-radius: 999px;
    background: linear-gradient(180deg, #2c1d0b, #140d05);
    border: 2px solid var(--st-gold);
    box-shadow: 0 10px 26px rgba(0,0,0,0.55), 0 0 28px rgba(233,196,106,0.25);
    color: var(--st-ivory);
    opacity: 0;
    transform: translateY(-26px) scale(0.8);
    transition: opacity 0.25s, transform 0.5s var(--st-ease-pop);
}
.st-announce.visible { opacity: 1; transform: none; }
.st-announce.leaving { opacity: 0; transform: translateY(-14px) scale(0.95); }
.st-announce-icon {
    display: grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: radial-gradient(circle, #f6d77d, #a4762a);
    color: #2a1904;
    font-size: 1.15rem;
}
.st-announce strong {
    display: block;
    font-family: var(--font-heading, serif);
    font-size: 1.15rem;
    letter-spacing: 0.04em;
    color: #ffe9a3;
}
.st-announce small { display: block; font-size: 0.85rem; opacity: 0.85; font-style: italic; }

/* ---- Stamp (phone confirmations) ----------------------------------------------------- */
.st-stamp {
    position: fixed;
    z-index: 9400;
    left: 50%;
    top: 42%;
    padding: 0.4rem 1.2rem;
    border: 4px double currentColor;
    border-radius: 10px;
    color: #f1c75b;
    font-family: var(--font-heading, serif);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    background: rgba(20, 12, 4, 0.75);
    pointer-events: none;
    transform: translate(-50%, -50%) rotate(-8deg) scale(2.6);
    opacity: 0;
    animation: st-stamp 1.5s var(--st-ease-pop) forwards;
}
.st-stamp.tone-blood { color: #ff7a6b; }
@keyframes st-stamp {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(2.6); }
    18% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(0.95); }
    26% { transform: translate(-50%, -50%) rotate(-8deg) scale(1.03); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
}

/* ---- Settings ------------------------------------------------------------------------- */
.st-settings { display: grid; gap: 0.6rem; margin: 0.4rem 0 0.9rem; }
.st-toggle {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    cursor: pointer;
}
.st-toggle input { width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; accent-color: var(--st-gold); flex: 0 0 auto; }
.st-toggle strong { display: block; }
.st-toggle small { display: block; opacity: 0.75; font-size: 0.82em; }
.st-range { display: grid; grid-template-columns: 7.5rem 1fr; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.st-range input { accent-color: var(--st-gold); }
.st-settings .st-test-voice { justify-self: start; }

/* ==========================================================================
   DISPLAY SCREEN EFFECTS
   ========================================================================== */

/* Proposal chips drop in like tokens on the table. */
@keyframes st-chip-drop {
    0% { opacity: 0; transform: translateY(-60px) scale(1.5) rotate(-8deg); }
    60% { opacity: 1; transform: translateY(6px) scale(0.96) rotate(1deg); }
    100% { opacity: 1; transform: none; }
}
.proposed-player-chip.st-new { animation: st-chip-drop 0.55s var(--st-ease-pop) both; }
.proposed-players.st-locked .proposed-player-chip {
    box-shadow: 0 0 0 2px var(--st-gold), 0 0 26px rgba(233,196,106,0.55);
}
.st-seal {
    position: absolute;
    right: 8%;
    top: 18%;
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    text-align: center;
    font-family: var(--font-heading, serif);
    font-weight: 900;
    font-size: 1.05rem;
    letter-spacing: 0.08em;
    line-height: 1.05;
    color: #ffe2d8;
    background: radial-gradient(circle at 38% 32%, #e2554a 0%, #a61f17 55%, #5f0d08 100%);
    box-shadow: inset 0 -6px 14px rgba(0,0,0,0.45), inset 0 4px 10px rgba(255,255,255,0.25), 0 10px 26px rgba(0,0,0,0.5);
    transform: rotate(-12deg) scale(3);
    opacity: 0;
    pointer-events: none;
    animation: st-seal-in 0.55s var(--st-ease-pop) forwards;
    z-index: 5;
}
.st-seal::before {
    content: '';
    position: absolute;
    inset: 0.55rem;
    border: 2px dashed rgba(255,226,216,0.6);
    border-radius: 50%;
}
@keyframes st-seal-in {
    to { opacity: 1; transform: rotate(-12deg) scale(1); }
}

/* Leader crown dropping onto the name. */
.st-crown-drop { position: relative; display: inline-block; }
.st-crown-drop::before {
    content: '♛';
    position: absolute;
    left: 50%;
    top: -0.95em;
    font-size: 0.9em;
    color: var(--st-gold);
    text-shadow: 0 0 16px rgba(233,196,106,0.8);
    transform: translate(-50%, -120%) rotate(-25deg);
    opacity: 0;
    animation: st-crown 0.9s var(--st-ease-pop) 0.35s forwards;
}
@keyframes st-crown {
    0% { opacity: 0; transform: translate(-50%, -260%) rotate(-40deg); }
    70% { opacity: 1; transform: translate(-50%, 4%) rotate(6deg); }
    100% { opacity: 1; transform: translate(-50%, 0) rotate(-6deg); }
}

/* Vote status: each ballot flips to sealed. */
@keyframes st-ballot-flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg) scale(1.08); }
    100% { transform: rotateX(0); }
}
.vote-status-chip.st-just-voted { animation: st-ballot-flip 0.5s ease; }

/* Vote reveal tally */
.st-vote-tally {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    width: min(46rem, 88vw);
    margin: 0.4rem auto 0.8rem;
    font-family: var(--font-heading, serif);
    color: var(--st-ivory);
}
.st-vote-tally b {
    display: grid;
    justify-items: center;
    min-width: 5.5rem;
    font-size: 2.6rem;
    line-height: 1;
    text-shadow: 0 3px 0 rgba(0,0,0,0.6);
}
.st-vote-tally b small { font-size: 0.75rem; letter-spacing: 0.24em; opacity: 0.8; }
.st-vote-tally .approve { color: #ffe08a; }
.st-vote-tally .reject { color: #ff8a7a; }
.st-vote-tally-bar {
    position: relative;
    height: 1.1rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(233,196,106,0.5);
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}
.st-vote-tally-bar i {
    position: absolute;
    top: 0;
    bottom: 0;
    transition: width 0.45s var(--st-ease-out);
}
.st-vote-tally-bar .approve { left: 0; background: linear-gradient(90deg, #a77a22, #ffe08a); }
.st-vote-tally-bar .reject { right: 0; background: linear-gradient(270deg, #7c140e, #ff6b5b); }
.st-vote-tally-bar::after {
    content: '';
    position: absolute;
    left: 50%;
    top: -3px;
    bottom: -3px;
    width: 2px;
    background: var(--st-ivory);
    box-shadow: 0 0 8px var(--st-ivory);
}
.cinematic-vote-card.revealed.approve { animation: st-card-glow-gold 0.9s ease; }
.cinematic-vote-card.revealed.reject { animation: st-card-glow-red 0.9s ease; }
@keyframes st-card-glow-gold { 0% { filter: brightness(2.2) drop-shadow(0 0 30px #ffe08a); } 100% { filter: none; } }
@keyframes st-card-glow-red { 0% { filter: brightness(1.6) drop-shadow(0 0 30px #ff5a4f); } 100% { filter: none; } }
.vote-result-banner.st-slam { animation: st-slam 0.65s var(--st-ease-pop); }
@keyframes st-slam {
    0% { transform: scale(2.6); opacity: 0; }
    55% { transform: scale(0.92); opacity: 1; }
    100% { transform: scale(1); }
}

/* Quest card shuffle before the reveal */
@keyframes st-shuffle {
    0%, 100% { transform: translateX(0) rotate(0); }
    20% { transform: translateX(calc(var(--st-dir, 1) * 46px)) rotate(calc(var(--st-dir, 1) * 8deg)) translateY(-14px); }
    45% { transform: translateX(calc(var(--st-dir, 1) * -30px)) rotate(calc(var(--st-dir, 1) * -6deg)); }
    70% { transform: translateX(calc(var(--st-dir, 1) * 18px)) rotate(calc(var(--st-dir, 1) * 3deg)) translateY(-6px); }
}
.mission-result-card.sealed.st-shuffling,
.cinematic-quest-card.sealed.st-shuffling {
    animation: st-shuffle 0.95s cubic-bezier(0.5, 0, 0.5, 1) both;
    animation-delay: calc(var(--st-index, 0) * 50ms);
}
.mission-result-card.st-last-card,
.cinematic-quest-card.st-last-card {
    animation: st-last-card 1.05s ease-in-out infinite;
}
@keyframes st-last-card {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(233,196,106,0); }
    50% { transform: scale(1.06); box-shadow: 0 0 40px rgba(233,196,106,0.6); }
}
.mission-result-card.revealed-fail,
.cinematic-quest-card.fail { animation: st-fail-hit 0.6s ease; }
.mission-result-card.revealed-success,
.cinematic-quest-card.success { animation: st-success-hit 0.6s ease; }
@keyframes st-fail-hit {
    0% { filter: brightness(2.4) saturate(1.6); transform: scale(1.18) rotate(-3deg); }
    100% { filter: none; transform: none; }
}
@keyframes st-success-hit {
    0% { filter: brightness(2) drop-shadow(0 0 40px #ffe08a); transform: scale(1.12); }
    100% { filter: none; transform: none; }
}

/* Quest seal counter */
.mission-progress.st-pop, #mission-played.st-pop { display: inline-block; }

/* Mission shield update in the header */
.mission-shield.st-shield-new { animation: st-shield-flip 1.2s var(--st-ease-pop); }
@keyframes st-shield-flip {
    0% { transform: rotateY(0) scale(1); }
    40% { transform: rotateY(180deg) scale(1.5); filter: brightness(2); }
    100% { transform: rotateY(360deg) scale(1); filter: none; }
}

/* Night candles */
.st-candles {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.4rem;
    margin: 1.6rem auto 0.4rem;
    max-width: 52rem;
}
.st-candle {
    position: relative;
    width: 1.1rem;
    height: 3.6rem;
    border-radius: 4px 4px 2px 2px;
    background: linear-gradient(90deg, #d8cfb5, #fff7e3 45%, #b9ad8e);
    box-shadow: inset 0 -6px 8px rgba(0,0,0,0.2);
}
.st-candle::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -0.7rem;
    width: 2px;
    height: 0.7rem;
    background: #2a2014;
    transform: translateX(-50%);
}
.st-candle::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: calc(100% + 0.45rem);
    width: 0.9rem;
    height: 1.5rem;
    border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
    background: radial-gradient(ellipse at 50% 75%, #fff 0%, #ffe39a 30%, #ff9b2e 65%, rgba(255,110,20,0) 100%);
    transform: translateX(-50%) scale(0);
    transform-origin: 50% 100%;
    filter: blur(0.3px) drop-shadow(0 0 12px rgba(255,170,60,0.95));
    transition: transform 0.45s var(--st-ease-pop);
}
.st-candle.lit::after { transform: translateX(-50%) scale(1); animation: st-flicker 1.4s ease-in-out infinite alternate; }
@keyframes st-flicker {
    0% { transform: translateX(-50%) scale(1, 1) rotate(-2deg); }
    40% { transform: translateX(-50%) scale(0.92, 1.08) rotate(2deg); }
    100% { transform: translateX(-50%) scale(1.04, 0.95) rotate(-1deg); }
}
#screen-night .st-moon {
    position: absolute;
    top: 9%;
    right: 12%;
    width: 9rem;
    height: 9rem;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 36%, #fffdf3 0%, #f1ead2 40%, #cfc5a5 75%, #a59b7c 100%);
    box-shadow: 0 0 60px rgba(255,248,220,0.55), 0 0 160px rgba(200,210,255,0.25);
    animation: st-moonrise 3.6s var(--st-ease-out) both;
    pointer-events: none;
}
#screen-night .st-moon::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        radial-gradient(circle at 62% 40%, rgba(0,0,0,0.12) 0 9%, transparent 10%),
        radial-gradient(circle at 40% 66%, rgba(0,0,0,0.1) 0 7%, transparent 8%),
        radial-gradient(circle at 70% 70%, rgba(0,0,0,0.08) 0 5%, transparent 6%);
}
@keyframes st-moonrise {
    from { transform: translateY(70vh) scale(0.7); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* Discussion final countdown */
#screen-round.st-final-seconds .timer-container { animation: st-heartbeat 1s ease-in-out infinite; }
@keyframes st-heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.08); }
    30% { transform: scale(0.98); }
    45% { transform: scale(1.05); }
}

/* Assassin spotlight sweep */
#screen-assassin { overflow: hidden; }
#screen-assassin .st-spotlight {
    position: absolute;
    inset: -20%;
    pointer-events: none;
    background: radial-gradient(circle 22vmin at var(--sx, 50%) var(--sy, 60%), rgba(255,240,210,0.16) 0%, rgba(255,240,210,0.05) 55%, transparent 70%),
                radial-gradient(circle at 50% 50%, transparent 30%, rgba(0,0,0,0.55) 100%);
    animation: st-sweep 7s ease-in-out infinite;
    mix-blend-mode: screen;
}
@property --sx { syntax: '<percentage>'; inherits: false; initial-value: 50%; }
@property --sy { syntax: '<percentage>'; inherits: false; initial-value: 60%; }
@keyframes st-sweep {
    0% { --sx: 20%; --sy: 55%; }
    25% { --sx: 70%; --sy: 40%; }
    50% { --sx: 85%; --sy: 70%; }
    75% { --sx: 35%; --sy: 75%; }
    100% { --sx: 20%; --sy: 55%; }
}
#screen-assassin .crosshair-icon { animation: st-crosshair 2.4s ease-in-out infinite; }
@keyframes st-crosshair {
    0%, 100% { transform: scale(1) rotate(0); opacity: 0.8; }
    50% { transform: scale(1.15) rotate(45deg); opacity: 1; }
}

/* Lobby room code shimmer */
.room-code.st-shimmer {
    background: linear-gradient(100deg, var(--st-gold) 20%, #fffbe9 40%, var(--st-gold) 60%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: st-shimmer 4.5s linear infinite;
}
@keyframes st-shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---- Royal Honours ceremony (display) -------------------------------------------------- */
.st-honours {
    position: fixed;
    inset: 0;
    z-index: 9200;
    display: grid;
    place-items: center;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(90, 60, 20, 0.55), rgba(8, 5, 2, 0.94) 70%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0s linear 0.5s;
    cursor: pointer;
}
.st-honours.visible { opacity: 1; visibility: visible; transition: opacity 0.5s ease; }
.st-honours-heading {
    position: absolute;
    top: 6vh;
    left: 0;
    right: 0;
    text-align: center;
    font-family: var(--font-heading, serif);
    color: var(--st-gold);
    letter-spacing: 0.4em;
    font-size: clamp(1rem, 2vw, 1.6rem);
    text-transform: uppercase;
}
.st-honours-heading::after {
    content: '';
    display: block;
    width: min(30rem, 60vw);
    height: 2px;
    margin: 0.7rem auto 0;
    background: linear-gradient(90deg, transparent, var(--st-gold), transparent);
}
.st-honours-skip {
    position: absolute;
    bottom: 3vh;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.55;
    color: var(--st-ivory);
}
.st-award {
    position: absolute;
    display: grid;
    justify-items: center;
    gap: 0.6rem;
    width: min(40rem, 86vw);
    padding: 2.4rem 2rem 2rem;
    text-align: center;
    color: var(--st-ink);
    background:
        radial-gradient(ellipse at 30% 0%, rgba(255,255,255,0.6), transparent 60%),
        linear-gradient(180deg, #fff6dc, #ecd49b);
    border: 3px solid #a4782c;
    border-radius: 18px;
    box-shadow: inset 0 0 0 3px rgba(255,255,255,0.5), 0 30px 80px rgba(0,0,0,0.7), 0 0 80px rgba(233,196,106,0.35);
    opacity: 0;
    transform: perspective(900px) rotateY(-80deg) scale(0.8);
}
.st-award.tone-evil { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.5), 0 30px 80px rgba(0,0,0,0.7), 0 0 80px rgba(255,80,60,0.45); }
.st-award.tone-good { box-shadow: inset 0 0 0 3px rgba(255,255,255,0.5), 0 30px 80px rgba(0,0,0,0.7), 0 0 80px rgba(120,160,255,0.5); }
.st-award.active { animation: st-award-in 0.8s var(--st-ease-pop) forwards; }
.st-award.leaving { animation: st-award-out 0.5s ease-in forwards; }
@keyframes st-award-in {
    to { opacity: 1; transform: none; }
}
@keyframes st-award-out {
    from { opacity: 1; transform: none; }
    to { opacity: 0; transform: perspective(900px) rotateY(70deg) scale(0.85); }
}
.st-award-ribbon {
    position: absolute;
    top: -1.4rem;
    padding: 0.4rem 2.2rem;
    font-family: var(--font-heading, serif);
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #fff3cf;
    background: linear-gradient(180deg, #8c1d16, #5a0f0a);
    clip-path: polygon(0 0, 100% 0, 94% 50%, 100% 100%, 0 100%, 6% 50%);
}
.st-award-icon { font-size: 2.6rem; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.35)); }
.st-award-portrait {
    width: 8.5rem;
    height: 8.5rem;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #a4782c;
    box-shadow: 0 8px 22px rgba(0,0,0,0.35), 0 0 0 6px rgba(233,196,106,0.4);
    background: #2b1d0c;
    display: grid;
    place-items: center;
}
.st-award-portrait img, .st-award-portrait svg, .st-award-portrait > * { width: 100%; height: 100%; object-fit: cover; }
.st-award-title {
    font-family: var(--font-heading, serif);
    font-size: clamp(1.6rem, 3.6vw, 2.6rem);
    font-weight: 900;
    line-height: 1.05;
    color: #5a3608;
}
.st-award-name {
    font-family: var(--font-heading, serif);
    font-size: clamp(1.3rem, 2.8vw, 2rem);
    color: #1b130a;
    padding: 0.1rem 1rem;
    border-bottom: 2px solid rgba(164,120,44,0.6);
}
.st-award-stat { font-style: italic; font-size: 1.15rem; color: #4a3517; }

/* Honours summary list on the finale screens */
.st-honours-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.7rem;
    margin: 0.6rem 0 0.4rem;
}
.st-honours-list:empty { display: none; }
.st-honour-chip {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.1rem 0.6rem;
    align-items: center;
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255,246,220,0.1), rgba(255,246,220,0.03));
    border: 1px solid rgba(233,196,106,0.45);
    text-align: left;
}
.st-honour-chip span { grid-row: span 2; font-size: 1.6rem; }
.st-honour-chip strong { font-family: var(--font-heading, serif); color: #ffe08a; font-size: 0.92rem; }
.st-honour-chip small { opacity: 0.85; }
.st-honours-section h3 { margin-bottom: 0.2rem; }
.st-honours-section:has(.st-honours-list:empty) { display: none; }

/* ==========================================================================
   PHONE EFFECTS
   ========================================================================== */
.st-press { animation: st-press 0.35s var(--st-ease-pop); }
@keyframes st-press {
    0% { transform: scale(1); }
    40% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.btn.st-shine { position: relative; overflow: hidden; }
.btn.st-shine::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    left: -60%;
    background: linear-gradient(100deg, transparent, rgba(255,255,255,0.45), transparent);
    animation: st-btn-shine 2.8s ease-in-out infinite;
}
@keyframes st-btn-shine {
    0%, 60% { left: -60%; }
    100% { left: 130%; }
}

@media (prefers-reduced-motion: reduce) {
    .st-raven, .st-raven-head, .st-title-rays, #screen-assassin .st-spotlight { animation: none !important; }
}

/* ==========================================================================
   WAITING LIST AND GAME-FLOW CONTROL
   ========================================================================== */
.st-waiting {
    position: fixed;
    left: 50%;
    z-index: 70;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 0.5rem;
    max-width: min(44rem, calc(100vw - 2rem));
    padding: 0.5rem 0.95rem;
    border: 1px solid rgba(233, 196, 106, 0.55);
    border-radius: 999px;
    background: rgba(18, 12, 8, 0.88);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    color: #f4e7c8;
    font-family: 'Crimson Pro', Georgia, serif;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
    transition: opacity 0.35s ease, transform 0.35s var(--st-ease-pop, ease);
}
.st-waiting.visible { opacity: 1; transform: translate(-50%, 0); }
.st-waiting-host { top: max(5.4rem, env(safe-area-inset-top)); font-size: clamp(0.95rem, 1.35vw, 1.25rem); }
.st-waiting-player { bottom: calc(4.9rem + env(safe-area-inset-bottom)); font-size: 0.92rem; border-radius: 1.1rem; }
.st-wait-label {
    font-family: 'Cinzel', Georgia, serif;
    font-size: 0.72em;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--st-gold);
}
.st-wait-name {
    padding: 0.08rem 0.55rem;
    border-radius: 999px;
    background: rgba(233, 196, 106, 0.16);
    font-weight: 600;
    animation: st-wait-pulse 2.4s ease-in-out infinite;
}
.st-wait-name.offline { background: rgba(179, 38, 30, 0.28); color: #ffd6cf; }
.st-wait-name em { font-style: normal; font-size: 0.72em; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.85; margin-left: 0.2rem; }
.st-wait-more, .st-wait-stage { opacity: 0.78; font-style: italic; }
.st-wait-hint {
    flex-basis: 100%;
    text-align: center;
    font-size: 0.78em;
    color: #ffcf8a;
}
@keyframes st-wait-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(233, 196, 106, 0); }
    50% { box-shadow: 0 0 0 4px rgba(233, 196, 106, 0.16); }
}
@media (prefers-reduced-motion: reduce) {
    .st-wait-name { animation: none; }
}

.st-flow-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.75rem 0.8rem;
    margin-bottom: 0.4rem;
    border: 1px solid rgba(233, 196, 106, 0.4);
    border-radius: 0.75rem;
    background: rgba(233, 196, 106, 0.06);
    text-align: left;
}
.st-flow-card[hidden] { display: none; }
.st-flow-head strong { display: block; font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.06em; }
.st-flow-head small, .st-flow-note { display: block; opacity: 0.75; font-size: 0.8rem; }
.st-flow-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; font-size: 0.92rem; }
.st-flow-status .st-wait-name { animation: none; }
.st-flow-force { width: 100%; font-size: 0.85rem; }
.st-flow-force:not(:disabled) { border-color: var(--st-gold); color: var(--st-gold); }

.st-select { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; }
.st-select strong { display: block; }
.st-select small { display: block; opacity: 0.75; font-size: 0.82em; }
.st-select select { min-width: 7rem; padding: 0.35rem 0.5rem; border-radius: 0.4rem; background: rgba(0, 0, 0, 0.35); color: inherit; border: 1px solid rgba(233, 196, 106, 0.45); }
