/* Treasure Hunt (cave). Everything is prefixed th- except the explorer
   character rules and the cave lineup, which other screens reuse. */

/* ---------- explorer characters (characters.js image set) ---------- */

.character-anim-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: 50% 100%;
    user-select: none;
    pointer-events: none;
}
.character-anim.idle .character-anim-img { animation: thExplorerIdle 1.5s ease-in-out infinite; }
@keyframes thExplorerIdle {
    0%, 100% { transform: none; }
    30%      { transform: translateY(-5%) rotate(-3deg) scaleY(1.03); }
    55%      { transform: translateY(0) scale(1.03, .97); }
    80%      { transform: translateY(-3%) rotate(2deg); }
}

/* ---------- cave lineup (team setup for this game) ---------- */

.lineup.lineup-cave {
    background:
        radial-gradient(ellipse 70% 50% at 50% 60%, rgba(255, 186, 92, .16), transparent 70%),
        linear-gradient(180deg, rgba(14, 10, 30, .35), rgba(14, 10, 30, .78)),
        url(../img/treasure/cave-bg.webp) center / cover no-repeat,
        #16122a;
}
.lineup-cave::before {   /* drifting torch light */
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 6% 40%, rgba(255, 150, 50, .28), transparent 22%),
        radial-gradient(circle at 94% 40%, rgba(255, 150, 50, .28), transparent 22%);
    animation: thTorch 2.6s ease-in-out infinite alternate;
}
.lineup-cave .lineup-title {
    color: #ffd76a;
    text-shadow: 0 3px 0 #8a4b12, 0 0 28px rgba(255, 200, 90, .55);
    letter-spacing: .02em;
}
.lineup-cave .lineup-hint,
.lineup-cave .lineup-opt-label,
.lineup-cave .lineup-credit { color: #eadfc4; }
.lineup-cave .lineup-close { background: #2b2340; color: #fff; }
.lineup-cave .lineup-line {   /* a stone ledge instead of a finish line */
    top: calc(var(--char) - 18px);
    height: 30px;
    border-radius: 14px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .22) 0 3px, transparent 3px),
        repeating-linear-gradient(90deg, transparent 0 88px, rgba(0, 0, 0, .25) 88px 91px),
        linear-gradient(180deg, #7b6754, #4a3a2c 70%, #2f241b);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .55);
    opacity: 1;
}
.lineup-cave .lineup-char { filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .45)); }
.lineup-cave .lineup-char::after { background: rgba(0, 0, 0, .45); }
.lineup-cave .lineup-add-btn {
    border-color: rgba(255, 215, 106, .35);
    background: rgba(255, 255, 255, .07);
    color: #eadfc4;
}
.lineup-cave .lineup-add-btn:hover { background: rgba(255, 215, 106, .16); border-color: #ffd76a; color: #fff; }
.lineup-cave .lineup-picker { background: #231b34; color: #fff; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.lineup-cave .lineup-picker h3,
.lineup-cave .lineup-pick-name,
.lineup-cave .lineup-picker-note { color: #f3e9cf; }
.lineup-cave .lineup-pick { background: rgba(255, 255, 255, .06); }
.lineup-cave .lineup-pick:hover { background: rgba(255, 215, 106, .16); }
.lineup-cave .lineup-pick.current { background: rgba(255, 215, 106, .2); }

/* ---------- game shell ---------- */

.th-shell {
    --th-gold: #ffd76a;
    --th-gold-deep: #c98a1b;
    --th-ink: #f6ecd2;
    --th-stone: rgba(28, 22, 44, .78);
    background: #120e22;
    color: var(--th-ink);
}
.th-bg {
    position: absolute;
    inset: -3%;
    background: url(../img/treasure/cave-bg.webp) center / cover no-repeat;
    animation: thBreath 24s ease-in-out infinite alternate;
    transition: filter .6s ease-out;
}
.th-shell.th-dark .th-bg { filter: brightness(.45) saturate(.8); }
@keyframes thBreath {
    from { transform: scale(1); }
    to   { transform: scale(1.05) translateY(-1%); }
}
.th-vignette {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse 75% 70% at 50% 55%, transparent 40%, rgba(8, 5, 18, .82) 100%);
}
.th-glow {
    position: absolute;
    top: 18%;
    width: 46vw;
    height: 70vh;
    pointer-events: none;
    mix-blend-mode: screen;
    background: radial-gradient(circle, rgba(255, 140, 40, .34), transparent 62%);
    animation: thTorch 2.2s ease-in-out infinite alternate;
}
.th-glow-l { left: -22vw; }
.th-glow-r { right: -22vw; animation-delay: -1.1s; }
@keyframes thTorch {
    0%   { opacity: .75; }
    35%  { opacity: 1; }
    55%  { opacity: .82; }
    100% { opacity: .95; }
}

/* floating gold motes */
.th-dust { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.th-dust i {
    position: absolute;
    bottom: -12px;
    width: calc(5px * var(--s));
    height: calc(5px * var(--s));
    border-radius: 50%;
    background: #ffe3a1;
    box-shadow: 0 0 10px 2px rgba(255, 200, 90, .7);
    animation: thMote linear infinite;
}
@keyframes thMote {
    0%   { transform: translate(0, 0); opacity: 0; }
    10%  { opacity: .9; }
    50%  { transform: translate(24px, -55vh); }
    90%  { opacity: .7; }
    100% { transform: translate(-16px, -108vh); opacity: 0; }
}

.th-layout {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 16px;
    padding: 12px 18px 14px;
}
.th-main {
    position: relative;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- top pills ---------- */

.th-top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: center; }
.th-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: 999px;
    background: var(--th-stone);
    border: 1px solid rgba(255, 215, 106, .25);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1rem;
    color: var(--th-ink);
    backdrop-filter: blur(4px);
}
.th-pill-team { border-color: var(--tc); box-shadow: 0 0 0 2px rgba(0, 0, 0, .2), inset 0 0 18px color-mix(in srgb, var(--tc) 35%, transparent); padding-left: 6px; }

/* ---------- the room of doors ---------- */

.th-room {
    --door: min(calc((100vw - 340px) / var(--n, 3) - 16px), calc((100dvh - 330px) * .914), 290px);
    --gap: clamp(4px, calc(26px - var(--n, 3) * 2px), 14px);
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: var(--gap);
    padding: 18px 0 6px;
}
.th-door {
    position: relative;
    width: max(70px, var(--door));
    aspect-ratio: 447 / 489;
    flex: none;
    perspective: 900px;
    cursor: default;
    transition: transform .3s ease-out, opacity .3s ease-out, filter .3s ease-out;
    animation: thDoorIn .55s cubic-bezier(.2, .9, .25, 1.15) backwards;
    animation-delay: calc(var(--i) * 90ms);
}
@keyframes thDoorIn {
    from { opacity: 0; transform: translateY(70px) scale(.9); }
    to   { opacity: 1; transform: none; }
}
/* warm torchlight behind every door */
.th-door::before {
    content: '';
    position: absolute;
    inset: -12% -16% 0;
    z-index: -1;
    border-radius: 50%;
    background: radial-gradient(ellipse at 50% 60%, rgba(255, 170, 70, .32), transparent 65%);
    animation: thTorch 1.8s ease-in-out infinite alternate;
    animation-delay: calc(var(--i) * -.37s);
}
/* dust puff where it lands */
.th-door::after {
    content: '';
    position: absolute;
    left: 6%; right: 6%; bottom: -4px;
    height: 22%;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(ellipse, rgba(220, 200, 170, .55), transparent 70%);
    opacity: 0;
    animation: thPuff .9s ease-out both;
    animation-delay: calc(var(--i) * 90ms + .3s);
}
@keyframes thPuff {
    0%   { opacity: 0; transform: scale(.4); }
    25%  { opacity: 1; }
    100% { opacity: 0; transform: scale(1.5, 1.2) translateY(-10%); }
}

.th-door-hole {
    position: absolute;
    left: 24%; right: 24%;
    top: 22%; bottom: 9.5%;
    border-radius: 50% 50% 0 0 / 28% 28% 0 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 70%, #2a1f3d, #07050d 75%);
}
.th-door-light {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .4s ease-out;
    background: radial-gradient(ellipse at 50% 62%, #fff6cf 0, #ffcc55 30%, rgba(255, 140, 30, .2) 70%, transparent 85%);
}
.th-door.tone-bad .th-door-light  { background: radial-gradient(ellipse at 50% 62%, #ffd3c2 0, #ff5a3c 34%, rgba(120, 10, 10, .35) 72%, transparent 88%); }
.th-door.tone-doom .th-door-light { background: radial-gradient(ellipse at 50% 62%, #e3c2ff 0, #8a2be2 34%, rgba(30, 0, 40, .6) 72%, #000 95%); }
.th-door.tone-meh .th-door-light  { background: radial-gradient(ellipse at 50% 62%, #f0f4ff 0, #9fb4d8 36%, rgba(60, 70, 110, .3) 74%, transparent 90%); }
.th-door-loot {
    position: absolute;
    left: 50%;
    top: 58%;
    width: 86%;
    translate: -50% -50%;
    opacity: 0;
    scale: .3;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .5));
}
.th-door.open .th-door-light { opacity: 1; }
.th-door.open .th-door-loot { animation: thLootOut .7s cubic-bezier(.2, 1.4, .4, 1) .18s both; }
@keyframes thLootOut {
    0%   { opacity: 0; scale: .3; transform: translateY(30%); }
    60%  { opacity: 1; scale: 1.12; transform: translateY(-8%); }
    100% { opacity: 1; scale: 1; transform: none; }
}
.th-door.open:not(.missed) .th-door-loot { animation-name: thLootOut, thLootBob; animation-duration: .7s, 1.6s; animation-delay: .18s, .9s; animation-iteration-count: 1, infinite; animation-timing-function: cubic-bezier(.2, 1.4, .4, 1), ease-in-out; }
@keyframes thLootBob {
    0%, 100% { opacity: 1; scale: 1; transform: none; }
    50%      { opacity: 1; scale: 1; transform: translateY(-6%); }
}

.th-leaf {
    position: absolute;
    left: 22.2%;
    width: 55.6%;
    top: 19.5%;
    height: 72%;
    object-fit: fill;
    transform-origin: 0% 50%;
    transition: transform .75s cubic-bezier(.25, .8, .25, 1), filter .75s ease-out;
    user-select: none;
    pointer-events: none;
}
.th-door.open .th-leaf { transform: rotateY(-82deg); filter: brightness(.45); }
.th-arch {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    user-select: none;
    pointer-events: none;
    filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .55));
}
.th-plaque {
    position: absolute;
    left: 50%;
    bottom: -2px;
    translate: -50% 0;
    min-width: 34px;
    padding: 2px 10px;
    border-radius: 10px;
    background: linear-gradient(180deg, #ffe08a, #c98a1b);
    border: 2px solid #6b3d0b;
    color: #3d2205;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1rem;
    text-align: center;
    box-shadow: 0 4px 0 #4a2a06;
}

/* choosing */
.th-door.pickable { cursor: pointer; }
.th-door.pickable:hover { transform: translateY(-10px); filter: drop-shadow(0 0 18px rgba(255, 210, 110, .55)); }
.th-door.pickable:hover .th-leaf { animation: thLeafTease .5s ease-in-out infinite alternate; }
.th-door.pickable:active { transform: translateY(-6px) scale(.97); }
@keyframes thLeafTease {
    from { transform: rotateY(0); }
    to   { transform: rotateY(-9deg); }
}
.th-room.peeking .th-door.pickable:not(.peeked) { filter: drop-shadow(0 0 16px rgba(120, 220, 255, .75)); cursor: help; }
.th-room.peeking .th-door.pickable:not(.peeked):hover { filter: drop-shadow(0 0 26px rgba(120, 220, 255, 1)); }

/* the chosen door takes the stage */
.th-room.focus .th-door:not(.chosen):not(.missed) { opacity: .3; filter: brightness(.45) blur(1.5px); transform: scale(.9); }
.th-room.focus .th-door.chosen { transform: translateY(-14px) scale(1.12); z-index: 5; }
.th-door.missed { opacity: .92; transform: scale(.9); }
.th-door.missed .th-door-loot { animation-duration: .45s; }

/* drumroll: the leaf rattles and light leaks round its edges */
.th-door.rattle:not(.open) .th-leaf { animation: thRattle .11s linear infinite alternate; filter: drop-shadow(0 0 14px rgba(255, 210, 110, .95)); }
.th-door.rattle:not(.open) .th-door-hole { box-shadow: 0 0 40px 10px rgba(255, 200, 90, .55); animation: thLeak .5s ease-in-out infinite alternate; }
@keyframes thRattle {
    0%   { transform: rotateY(0) rotate(-.6deg); }
    50%  { transform: rotateY(-5deg) rotate(.5deg); }
    100% { transform: rotateY(-2deg) rotate(-.3deg) translateX(1px); }
}
@keyframes thLeak {
    from { box-shadow: 0 0 26px 4px rgba(255, 200, 90, .35); }
    to   { box-shadow: 0 0 60px 18px rgba(255, 220, 120, .75); }
}
/* rays behind the chosen open door */
.th-door.chosen.open::before {
    inset: -30% -40% -10%;
    background:
        radial-gradient(circle, rgba(255, 230, 150, .55), transparent 55%),
        repeating-conic-gradient(from 0deg, rgba(255, 220, 120, .35) 0 8deg, transparent 8deg 22deg);
    -webkit-mask: radial-gradient(circle, #000 25%, transparent 68%);
            mask: radial-gradient(circle, #000 25%, transparent 68%);
    animation: thSpin 9s linear infinite;
}
.th-door.chosen.open.tone-bad::before,
.th-door.chosen.open.tone-doom::before { display: none; }

/* peek bubble (torch / map / orb) */
.th-peek {
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    width: 58%;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 35% 30%, rgba(200, 240, 255, .55), rgba(40, 90, 160, .55) 60%, rgba(10, 20, 60, .75));
    border: 3px solid rgba(170, 230, 255, .85);
    box-shadow: 0 0 24px rgba(120, 220, 255, .8), inset 0 0 20px rgba(255, 255, 255, .4);
    animation: thPeekIn .45s cubic-bezier(.2, 1.4, .4, 1) both, thFloat 2.4s ease-in-out .45s infinite;
}
.th-peek img { width: 70%; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .5)); }
.th-peek b, .th-missed-tag b {
    position: absolute;
    bottom: -14px;
    padding: 1px 10px;
    border-radius: 999px;
    background: #10172e;
    border: 2px solid rgba(170, 230, 255, .85);
    font-family: var(--font-head);
    font-size: .95rem;
    color: #fff;
    white-space: nowrap;
}
.th-door.tone-good .th-peek b, .th-door.tone-good .th-missed-tag b { color: #ffe28a; }
.th-door.tone-bad .th-peek b, .th-door.tone-bad .th-missed-tag b { color: #ff8f7a; }
.th-door.tone-doom .th-peek b, .th-door.tone-doom .th-missed-tag b { color: #d6a6ff; }
@keyframes thPeekIn {
    from { opacity: 0; scale: .5; }
    to   { opacity: 1; scale: 1; }
}
@keyframes thFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}
.th-missed-tag {
    position: absolute;
    left: 50%;
    bottom: 22%;
    translate: -50% 0;
    display: flex;
    justify-content: center;
    animation: thPeekIn .3s ease-out both;
}
.th-missed-tag b { position: static; }

/* ---------- under the doors: hint + power-ups ---------- */

.th-under {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 10px;
    animation: thUp .3s ease-out both;
}
@keyframes thUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.th-hint {
    font-family: var(--font-title);
    font-size: clamp(1.2rem, 2vw, 1.7rem);
    color: var(--th-gold);
    text-shadow: 0 2px 0 #6b3d0b, 0 0 18px rgba(255, 200, 90, .5);
    animation: thHintPulse 1.4s ease-in-out infinite;
}
@keyframes thHintPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}
.th-powers { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.th-power {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    border-radius: 16px;
    border: 2px solid rgba(255, 215, 106, .45);
    background: linear-gradient(180deg, rgba(60, 46, 84, .92), rgba(30, 22, 46, .92));
    color: var(--th-ink);
    text-align: left;
    cursor: pointer;
    transition: transform .15s ease-out, box-shadow .15s ease-out, opacity .15s ease-out;
    box-shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
.th-power img { width: 42px; height: 42px; object-fit: contain; }
.th-power-txt { display: flex; flex-direction: column; line-height: 1.1; }
.th-power-txt b { font-family: var(--font-head); font-size: .95rem; }
.th-power-txt small { font-size: .72rem; opacity: .75; max-width: 150px; }
.th-power-n {
    position: absolute;
    top: -8px; left: -6px;
    min-width: 24px; height: 24px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--th-gold);
    color: #3d2205;
    font-weight: 800;
    font-size: .85rem;
    box-shadow: 0 2px 0 #6b3d0b;
}
.th-power:not(:disabled):hover { transform: translateY(-3px); box-shadow: 0 7px 0 rgba(0, 0, 0, .35), 0 0 22px rgba(255, 215, 106, .45); }
.th-power:not(:disabled):active { transform: scale(.97); }
.th-power:not(:disabled) img { animation: thFloat 2s ease-in-out infinite; }
.th-power:disabled { cursor: default; opacity: .38; filter: grayscale(.7); }
.th-power.on { opacity: 1; filter: none; border-color: #8fe3ff; box-shadow: 0 0 22px rgba(120, 220, 255, .7); }
.th-shield-on {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 14px 4px 6px;
    border-radius: 999px;
    background: rgba(40, 110, 170, .55);
    border: 2px solid #8fe3ff;
    font-weight: 800;
    animation: thPeekIn .3s ease-out both;
}
.th-shield-on img { width: 30px; }

/* ---------- question overlay + small cards ---------- */

.th-q-overlay { background: rgba(10, 7, 22, .6); border-radius: 24px; }
.th-q-overlay .question-panel { box-shadow: 0 0 0 4px rgba(255, 215, 106, .55), 0 30px 80px rgba(0, 0, 0, .6); }

.th-center-card {
    position: absolute;
    left: 50%;
    top: 46%;
    translate: -50% -50%;
    z-index: 25;
    width: min(460px, 92%);
    padding: 26px 26px 22px;
    border-radius: 28px;
    text-align: center;
    background: linear-gradient(180deg, rgba(48, 36, 70, .96), rgba(24, 18, 38, .96));
    border: 3px solid rgba(255, 215, 106, .55);
    box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
    animation: thCardIn .45s cubic-bezier(.2, 1.3, .4, 1) both;
    overflow: hidden;
}
.th-center-card h2 { font-family: var(--font-title); font-size: 1.9rem; margin: 6px 0 4px; color: var(--th-gold); position: relative; }
.th-center-card p { margin: 0; font-size: 1.05rem; opacity: .9; position: relative; }
@keyframes thCardIn {
    from { opacity: 0; scale: .85; }
    to   { opacity: 1; scale: 1; }
}
.th-miss-torch { width: 110px; animation: thBlowOut 1.2s ease-out both; }
@keyframes thBlowOut {
    0%   { filter: brightness(1.2); transform: rotate(0); }
    30%  { transform: rotate(-8deg); }
    60%  { transform: rotate(5deg); }
    100% { filter: brightness(.45) grayscale(.8); transform: rotate(0); }
}
.th-trial-res.won { border-color: #8fe3ff; }
.th-trial-res .th-new {
    position: relative;
    display: inline-block;
    padding: 3px 14px;
    border-radius: 999px;
    background: #8fe3ff;
    color: #10213a;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-size: .8rem;
}
.th-res-icon { position: relative; width: 130px; margin-top: 8px; animation: thLootOut .7s cubic-bezier(.2, 1.4, .4, 1) .1s both; }
.th-res-icon.sad { width: 96px; filter: grayscale(.6); animation: none; }

.th-banner {
    position: absolute;
    left: 50%;
    top: 40%;
    z-index: 30;
    translate: -50% -50%;
    pointer-events: none;
    white-space: nowrap;
}
.th-banner span {
    display: block;
    padding: 14px 40px;
    border-radius: 18px;
    font-family: var(--font-title);
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: #fff;
    background: linear-gradient(180deg, #ff9a3c, #d4421b);
    border: 4px solid #ffe08a;
    box-shadow: 0 10px 0 #7a1d07, 0 0 60px rgba(255, 120, 40, .7);
    text-shadow: 0 3px 0 #7a1d07;
    animation: thSlam .5s cubic-bezier(.2, 1.4, .4, 1) both;
    rotate: -3deg;
}
@keyframes thSlam {
    0%   { opacity: 0; scale: 2.4; }
    60%  { opacity: 1; scale: .94; }
    100% { opacity: 1; scale: 1; }
}

/* ---------- outcome card ---------- */

.th-outcome {
    position: absolute;
    left: 50%;
    top: 44%;
    translate: -50% -50%;
    z-index: 26;
    width: min(520px, 92%);
    padding: 18px 26px 22px;
    border-radius: 30px;
    text-align: center;
    background: linear-gradient(180deg, rgba(56, 42, 80, .97), rgba(26, 19, 40, .97));
    border: 4px solid var(--th-gold);
    box-shadow: 0 0 0 6px rgba(0, 0, 0, .25), 0 30px 90px rgba(0, 0, 0, .65), 0 0 70px rgba(255, 200, 90, .35);
    animation: thOutIn .55s cubic-bezier(.2, 1.35, .4, 1) backwards;
    transition: translate .5s cubic-bezier(.3, .8, .3, 1), scale .5s cubic-bezier(.3, .8, .3, 1);
    overflow: hidden;
}
@keyframes thOutIn {
    from { opacity: 0; scale: .6; }
    to   { opacity: 1; scale: 1; }
}
.th-outcome.docked { top: 0; translate: -50% 0; scale: .66; transform-origin: 50% 0; }
.th-out-icon {
    position: relative;
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .55));
    animation: thIconPop .7s cubic-bezier(.2, 1.5, .4, 1) .1s both;
}
@keyframes thIconPop {
    0%   { transform: scale(.2) rotate(-30deg); opacity: 0; }
    70%  { transform: scale(1.15) rotate(6deg); opacity: 1; }
    100% { transform: none; opacity: 1; }
}
.th-out-text {
    position: relative;
    margin: 6px 0 8px;
    font-family: var(--font-head);
    font-weight: 700;
    font-size: clamp(1.15rem, 1.9vw, 1.45rem);
    line-height: 1.25;
}
.th-out-line {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-title);
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1;
    color: var(--th-gold);
    text-shadow: 0 3px 0 #6b3d0b, 0 0 24px rgba(255, 200, 90, .6);
    animation: thSlam .5s cubic-bezier(.2, 1.4, .4, 1) .35s both;
}
.th-out-line img { width: 44px; }
.th-rays {
    position: absolute;
    left: 50%;
    top: 90px;
    width: 520px;
    height: 520px;
    margin: -260px 0 0 -260px;
    background: repeating-conic-gradient(from 0deg, rgba(255, 220, 120, .28) 0 9deg, transparent 9deg 24deg);
    -webkit-mask: radial-gradient(circle, #000 10%, transparent 62%);
            mask: radial-gradient(circle, #000 10%, transparent 62%);
    animation: thSpin 10s linear infinite;
    pointer-events: none;
}
.th-trial-res .th-rays { top: 120px; background: repeating-conic-gradient(from 0deg, rgba(140, 225, 255, .3) 0 9deg, transparent 9deg 24deg); }
@keyframes thSpin { to { transform: rotate(360deg); } }

.th-outcome.tone-bad { border-color: #ff6a4d; box-shadow: 0 30px 90px rgba(0, 0, 0, .65), 0 0 70px rgba(255, 80, 50, .4); }
.th-outcome.tone-bad .th-out-line { color: #ff8f7a; text-shadow: 0 3px 0 #6b120b, 0 0 24px rgba(255, 80, 50, .55); }
.th-outcome.tone-bad .th-out-icon { animation-name: thIconPop, thWobble; animation-duration: .7s, .5s; animation-delay: .1s, .8s; animation-iteration-count: 1, 2; }
@keyframes thWobble {
    0%, 100% { transform: none; }
    25%      { transform: rotate(-8deg) translateX(-4px); }
    75%      { transform: rotate(8deg) translateX(4px); }
}
.th-outcome.tone-meh { border-color: #9fb4d8; box-shadow: 0 30px 90px rgba(0, 0, 0, .65); }
.th-outcome.tone-meh .th-out-line { color: #dbe5f7; text-shadow: 0 3px 0 #2c3550; }
.th-outcome.tone-doom {
    border-color: #b46cff;
    background: radial-gradient(ellipse at 50% 30%, rgba(90, 20, 60, .97), rgba(12, 4, 14, .98));
    box-shadow: 0 0 0 6px rgba(0, 0, 0, .35), 0 0 120px rgba(255, 40, 60, .55);
    animation: thOutIn .55s cubic-bezier(.2, 1.35, .4, 1) backwards, thDoomShake .5s ease-in-out .9s 2;
}
.th-outcome.tone-doom .th-out-line { color: #ff6b8a; text-shadow: 0 3px 0 #3a0010, 0 0 30px rgba(255, 40, 80, .8); }
@keyframes thDoomShake {
    0%, 100% { transform: none; }
    20% { transform: translate(-8px, 2px) rotate(-1deg); }
    40% { transform: translate(7px, -3px) rotate(1deg); }
    60% { transform: translate(-5px, 2px); }
    80% { transform: translate(4px, -1px); }
}
.th-lostall {
    position: relative;
    margin: 4px 0;
    font-family: var(--font-title);
    font-size: clamp(2.2rem, 5vw, 3.6rem);
    line-height: 1;
    color: #fff;
    letter-spacing: .03em;
    text-shadow: 0 0 2px #000, 0 4px 0 #8a0020, 0 0 40px rgba(255, 40, 80, .9);
    animation: thSlam .6s cubic-bezier(.2, 1.4, .4, 1) .55s both;
    rotate: -4deg;
}
.th-outcome.blocked { border-color: #8fe3ff; box-shadow: 0 30px 90px rgba(0, 0, 0, .65), 0 0 70px rgba(120, 220, 255, .55); }
.th-outcome.blocked .th-out-icon { filter: grayscale(.6) brightness(.7); translate: -24px 0; }
.th-outcome.blocked .th-out-line { color: #8fe3ff; text-shadow: 0 3px 0 #0f3550; }
.th-out-shield {
    position: absolute;
    left: 50%;
    top: 70px;
    width: 96px;
    margin-left: 20px;
    animation: thShieldIn .55s cubic-bezier(.2, 1.5, .4, 1) .35s both;
    filter: drop-shadow(0 0 24px rgba(120, 220, 255, .9));
}
@keyframes thShieldIn {
    from { opacity: 0; transform: scale(2.2); }
    to   { opacity: .95; transform: scale(1); }
}

.th-hungry {
    position: absolute;
    left: 50%;
    top: 215px;
    z-index: 27;
    translate: -50% 0;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 92%;
    padding: 10px 22px 10px 12px;
    border-radius: 999px;
    background: linear-gradient(90deg, #3a0614, #6b0d24, #3a0614);
    border: 3px solid #ff4d6d;
    box-shadow: 0 0 50px rgba(255, 40, 80, .55);
    font-family: var(--font-head);
    font-weight: 800;
    font-size: clamp(1rem, 1.7vw, 1.3rem);
    color: #ffe0e6;
    animation: thUp .4s ease-out both, thHungry 1.2s ease-in-out .4s infinite;
}
.th-hungry img { width: 44px; animation: thChomp .6s ease-in-out infinite; }
@keyframes thHungry {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 40, 80, .4); }
    50%      { box-shadow: 0 0 70px rgba(255, 40, 80, .85); }
}
@keyframes thChomp {
    0%, 100% { transform: scale(1) rotate(0); }
    50%      { transform: scale(1.15) rotate(-8deg); }
}
.th-missed-title {
    position: absolute;
    left: 50%;
    bottom: 8px;
    translate: -50% 0;
    padding: 4px 16px;
    border-radius: 999px;
    background: var(--th-stone);
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: .04em;
    color: #eadfc4;
    animation: thUp .3s ease-out .3s both;
    white-space: nowrap;
}

/* ---------- screen effects ---------- */

.th-shell::after {   /* flash layer */
    content: '';
    position: absolute;
    inset: 0;
    z-index: 60;
    pointer-events: none;
    opacity: 0;
}
.th-shell.fx-flash-good::after { background: radial-gradient(circle at 50% 45%, rgba(255, 230, 140, .65), transparent 60%); animation: thFlash .7s ease-out both; }
.th-shell.fx-shake::after { background: radial-gradient(circle at 50% 50%, transparent 30%, rgba(255, 40, 30, .55)); animation: thFlash .6s ease-out both; }
.th-shell.fx-shake .th-layout { animation: thShake .45s ease-in-out both; }
.th-shell.fx-doom::after { background: radial-gradient(circle at 50% 45%, rgba(0, 0, 0, .2), rgba(80, 0, 20, .85)); animation: thDoomFlash 2.4s ease-out both; }
.th-shell.fx-doom .th-layout { animation: thShake .5s ease-in-out .1s 2 both; }
.th-shell.fx-doom .th-bg { filter: brightness(.35) saturate(.4) hue-rotate(-20deg); }
@keyframes thFlash {
    0%   { opacity: 0; }
    20%  { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes thDoomFlash {
    0%   { opacity: 0; }
    10%  { opacity: 1; }
    100% { opacity: .55; }
}
@keyframes thShake {
    0%, 100% { transform: none; }
    15% { transform: translate(-10px, 4px); }
    30% { transform: translate(9px, -5px); }
    45% { transform: translate(-7px, 3px); }
    60% { transform: translate(6px, -2px); }
    80% { transform: translate(-3px, 1px); }
}

.th-flyers { position: fixed; inset: 0; z-index: 210; pointer-events: none; }
.th-flycoin {
    position: absolute;
    left: 0; top: 0;
    width: 34px; height: 34px;
    margin: -17px 0 0 -17px;
    filter: drop-shadow(0 0 6px rgba(255, 210, 90, .9));
    will-change: transform, opacity;
}
.th-flycoin.out { filter: drop-shadow(0 0 6px rgba(255, 60, 60, .8)) saturate(.7); }

/* ---------- scoreboard ---------- */

.th-panel { position: relative; z-index: 3; }
.th-exit { color: #eadfc4; }
.th-scores { display: flex; flex-direction: column; gap: 8px; min-height: 0; overflow-y: auto; padding: 8px 4px 4px; }
.th-score-row {
    position: relative;
    display: grid;
    grid-template-columns: 46px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border-radius: 16px;
    background: var(--th-stone);
    border: 2px solid rgba(255, 255, 255, .08);
    border-left: 6px solid var(--tc);
    transition: transform .25s ease-out, box-shadow .25s ease-out, border-color .25s ease-out;
    backdrop-filter: blur(4px);
}
.th-score-row.active {
    transform: scale(1.04);
    border-color: var(--th-gold);
    border-left-color: var(--tc);
    box-shadow: 0 0 24px rgba(255, 215, 106, .45);
}
.th-score-row.danger { animation: thDanger 1.3s ease-in-out infinite; }
@keyframes thDanger {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 40, 80, 0); }
    50%      { box-shadow: 0 0 22px rgba(255, 40, 80, .65); }
}
.th-crown { position: absolute; top: -12px; left: 4px; font-size: 1.1rem; rotate: -18deg; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.th-av { display: grid; place-items: center; }
.th-sc-mid { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.th-name { font-family: var(--font-head); font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-coins {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-title);
    font-size: 1.45rem;
    line-height: 1;
    color: var(--th-gold);
    text-shadow: 0 2px 0 #6b3d0b;
    font-variant-numeric: tabular-nums;
    animation: thBump .35s ease-out;
    transform-origin: 0 50%;
}
.th-coins img { width: 22px; height: 22px; }
@keyframes thBump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.22); }
    100% { transform: scale(1); }
}
.th-inv { display: flex; gap: 3px; flex-wrap: wrap; }
.th-inv-i { display: inline-flex; align-items: center; font-size: .72rem; font-weight: 800; }
.th-inv-i img { width: 22px; height: 22px; }
.th-danger { display: flex; flex-direction: column; gap: 1px; }
.th-danger img { width: 20px; animation: thChomp .9s ease-in-out infinite; }

/* ---------- trials ---------- */

.th-trial-wrap {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    background: rgba(8, 5, 18, .7);
    backdrop-filter: blur(3px);
    border-radius: 24px;
    animation: fadeIn .2s ease-out;
}
.th-trial {
    width: min(920px, 98%);
    height: min(640px, 96%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border-radius: 28px;
    background: linear-gradient(180deg, #3a2c52, #1c1530);
    border: 4px solid var(--th-gold);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .7), 0 0 60px rgba(255, 200, 90, .3);
    animation: thCardIn .4s cubic-bezier(.2, 1.3, .4, 1) both;
}
.th-trial-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 14px; }
.th-trial-head h2 { margin: 0; font-family: var(--font-title); font-size: clamp(1.2rem, 2.3vw, 1.9rem); color: var(--th-gold); }
.th-trial-badge {
    padding: 4px 12px;
    border-radius: 999px;
    background: #ff8a3c;
    color: #fff;
    font-weight: 800;
    font-size: .8rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.th-trial-count { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-title); font-size: 1.5rem; color: var(--th-gold); }
.th-trial-count img { width: 30px; }
.th-trial-bar { grid-column: 1 / -1; height: 12px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.th-trial-bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #ffd76a, #ff9a3c); transition: width .1s linear; }
.th-trial-bar i.low { background: linear-gradient(90deg, #ff6a4d, #ff2d55); animation: thHintPulse .4s ease-in-out infinite; }

.th-trial-box {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 18px;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 40%, #3b2d55, #15101f);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, .6);
}
.th-trial-crown .th-trial-box { background: url(../img/treasure/mess-room.webp) center / cover; }
.th-trial-coins .th-trial-box { background: linear-gradient(rgba(10, 6, 20, .35), rgba(10, 6, 20, .55)), url(../img/treasure/cave-bg.webp) center / cover; }
.th-trial.ready .th-trial-box > :not(.th-trial-count3) { filter: blur(6px) brightness(.6); }

.th-trial-count3 {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    pointer-events: none;
}
.th-trial-count3 span {
    font-family: var(--font-title);
    font-size: 8rem;
    color: #fff;
    text-shadow: 0 6px 0 #6b3d0b, 0 0 40px rgba(255, 200, 90, .9);
    animation: thSlam .45s cubic-bezier(.2, 1.4, .4, 1) both;
}
.th-trial-over {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: rgba(40, 0, 10, .55);
}
.th-trial-over.won { background: rgba(10, 40, 30, .45); }
.th-trial-over span {
    padding: 12px 36px;
    border-radius: 20px;
    font-family: var(--font-title);
    font-size: clamp(2rem, 5vw, 3.4rem);
    color: #fff;
    background: linear-gradient(180deg, #ff6a4d, #b3122e);
    border: 4px solid #ffd0c4;
    animation: thSlam .5s cubic-bezier(.2, 1.4, .4, 1) both;
}
.th-trial-over.won span { background: linear-gradient(180deg, #4fd18b, #128a4f); border-color: #d4ffe6; }

/* find the crown: items are placed inside a layer that is one item
   smaller than the room, so nothing (and never the crown) is cut off */
.th-junk-layer {
    --junk: clamp(52px, 7.6vw, 94px);
    position: absolute;
    left: 1%; top: 1%;
    right: calc(var(--junk) + 1%);
    bottom: calc(var(--junk) + 1%);
}
.th-junk {
    position: absolute;
    width: var(--junk);
    aspect-ratio: 1;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    transform: rotate(var(--r)) scale(var(--s));
    transition: transform .15s ease-out;
}
.th-junk img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .55)); pointer-events: none; }
.th-junk:hover { transform: rotate(var(--r)) scale(calc(var(--s) * 1.1)); }
.th-junk.wig img { animation: thNope .3s ease-in-out; }
@keyframes thNope {
    0%, 100% { transform: none; }
    25% { transform: translateX(-6px) rotate(-6deg); }
    75% { transform: translateX(6px) rotate(6deg); }
}

/* memory pairs */
.th-mem {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 14px;
    padding: 18px;
}
.th-mem-card {
    position: relative;
    border: none;
    padding: 0;
    background: none;
    cursor: pointer;
    perspective: 700px;
}
.th-mem-back, .th-mem-face {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    backface-visibility: hidden;
    transition: transform .35s ease-out;
    display: grid;
    place-items: center;
}
.th-mem-back {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 215, 106, .35) 0 18%, transparent 19%),
        repeating-linear-gradient(45deg, #5a3d1e 0 10px, #4a3218 10px 20px);
    border: 3px solid var(--th-gold);
    box-shadow: 0 6px 0 #2b1c0c;
}
.th-mem-face {
    background: radial-gradient(circle, #fff6dc, #f0d9a2);
    border: 3px solid var(--th-gold);
    transform: rotateY(180deg);
}
.th-mem-face img { width: 78%; height: 78%; object-fit: contain; }
.th-mem-card.flipped .th-mem-back { transform: rotateY(-180deg); }
.th-mem-card.flipped .th-mem-face { transform: rotateY(0); }
.th-mem-card.done .th-mem-face { box-shadow: 0 0 24px rgba(120, 255, 170, .8); border-color: #6ff0a6; animation: thHintPulse .5s ease-out 1; }
.th-mem-card:not(.flipped):hover .th-mem-back { transform: translateY(-4px); }
.th-mem-card:active { transform: scale(.97); }

/* catch the coins */
.th-fall {
    position: absolute;
    width: clamp(54px, 7vw, 80px);
    aspect-ratio: 1;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    translate: -50% -50%;
    transform: rotate(var(--r));
    touch-action: manipulation;
}
.th-fall img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; filter: drop-shadow(0 0 10px rgba(255, 210, 90, .8)); }
.th-fall.rock img { filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .6)); }
.th-fall.hit { animation: thCaught .26s ease-out both; }
.th-fall.rock.hit { animation: thNope .26s ease-in-out both; }
@keyframes thCaught {
    to { scale: 1.8; opacity: 0; }
}

/* odd one out */
.th-odd {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 6px;
    padding: 14px;
}
.th-odd-item {
    border: none;
    padding: 4px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .05);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: background .15s ease-out;
}
.th-odd-item:hover { background: rgba(255, 255, 255, .12); }
.th-odd-item img { max-width: 82%; max-height: 82%; object-fit: contain; pointer-events: none; animation: thFloat 2.2s ease-in-out infinite; }
.th-odd-item:nth-child(3n) img { animation-delay: -.7s; }
.th-odd-item:nth-child(3n+1) img { animation-delay: -1.4s; }
.th-odd-item.odd img { filter: hue-rotate(45deg) saturate(1.25); }
.th-odd-item.odd.flip img { filter: hue-rotate(-45deg) saturate(1.2); }
.th-odd-item.nope { background: rgba(255, 60, 60, .45); animation: thNope .3s ease-in-out; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
    .th-layout { flex-direction: column; overflow-y: auto; }
    .th-room { --door: min(calc((100vw - 40px) / var(--n, 3) - 10px), 200px); gap: 8px; min-height: 260px; }
    .th-power-txt small { display: none; }
    .th-scores { flex-direction: row; flex-wrap: wrap; }
    .th-score-row { flex: 1 1 150px; }
}

@media (prefers-reduced-motion: reduce) {
    .th-bg, .th-glow, .th-dust, .th-door::before, .th-door::after,
    .th-hint, .th-power img, .th-peek, .th-hungry, .th-hungry img,
    .th-danger img, .th-score-row.danger, .th-odd-item img,
    .character-anim.idle .character-anim-img, .lineup-cave::before { animation: none !important; }
    .th-dust { display: none; }
    .th-shell.fx-shake .th-layout, .th-shell.fx-doom .th-layout, .th-outcome.tone-doom { animation: none; }
    .th-door.rattle .th-leaf { animation: none; }
}


/* ---------- cave question screen ---------- */

.th-q-overlay {
    background:
        radial-gradient(ellipse 60% 55% at 50% 50%, rgba(255, 170, 70, .14), transparent 70%),
        rgba(8, 5, 18, .62);
}
.th-q-overlay .question-panel.th-qpanel {
    position: relative;
    overflow: visible;
    max-width: 820px;
    padding: 30px 34px 28px;
    color: var(--th-ink);
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 215, 106, .14), transparent 70%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 9px),
        linear-gradient(180deg, #3b2d55 0%, #261d3a 60%, #1c152c 100%);
    border: 4px solid var(--th-gold);
    border-radius: 30px;
    box-shadow:
        0 0 0 3px #6b3d0b,
        0 0 0 9px rgba(255, 215, 106, .16),
        inset 0 0 40px rgba(0, 0, 0, .45),
        0 30px 90px rgba(0, 0, 0, .65),
        0 0 80px rgba(255, 180, 70, .25);
    animation: thCardIn .45s cubic-bezier(.2, 1.3, .4, 1) both;
}
/* gems set into the frame */
.th-q-gem {
    position: absolute;
    top: -14px;
    width: 26px; height: 26px;
    rotate: 45deg;
    border-radius: 6px;
    background: linear-gradient(135deg, #ff9ab0, #e0123f 55%, #7a0620);
    border: 3px solid var(--th-gold);
    box-shadow: 0 0 16px rgba(255, 60, 90, .7);
}
.th-q-gem-l { left: 40px; }
.th-q-gem-r { right: 40px; background: linear-gradient(135deg, #9fe3ff, #1d7bd8 55%, #0a2e6b); box-shadow: 0 0 16px rgba(60, 160, 255, .7); }
.th-q-char {
    position: absolute;
    left: -46px;
    bottom: -18px;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .55));
    animation: thUp .4s ease-out .2s both;
    pointer-events: none;
}
.th-qpanel .th-q-for {
    display: inline-flex; align-items: center; gap: 8px;
    background: rgba(255, 215, 106, .12);
    border: 1px solid rgba(255, 215, 106, .35);
    color: #eadfc4;
}
.th-qpanel .th-q-for b { color: var(--th-gold); }
.th-qpanel .question-text {
    color: #fff4d6;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .45);
    font-size: clamp(1.4rem, 2.4vw, 1.9rem);
}
.th-qpanel .q-image { box-shadow: 0 0 0 3px var(--th-gold), 0 10px 30px rgba(0, 0, 0, .5); }
.th-qpanel .btn-tts { background: rgba(255, 215, 106, .16); color: var(--th-gold); }
.th-qpanel .btn-tts:hover { background: var(--th-gold); color: #3d2205; }
.th-qpanel .timer-pill { background: rgba(0, 0, 0, .35); color: var(--th-gold); }

/* answers: carved stone tablets with a gem for each letter */
.th-qpanel .answer-btn {
    border: 3px solid rgba(255, 215, 106, .28);
    background: linear-gradient(180deg, #4a3a66, #33284a);
    color: #fff4d6;
    box-shadow: 0 5px 0 #17112a, inset 0 1px 0 rgba(255, 255, 255, .12);
}
.th-qpanel .answer-btn:not(.locked):hover {
    border-color: var(--th-gold);
    box-shadow: 0 8px 0 #17112a, 0 0 26px rgba(255, 215, 106, .45);
}
.th-qpanel .answer-btn:not(.locked):active { transform: translateY(2px) scale(.97); }
.th-qpanel .answer-btn .a-letter {
    width: 36px; height: 36px;
    border-radius: 8px;
    rotate: 45deg;
    border: 2px solid rgba(255, 255, 255, .55);
    box-shadow: 0 0 12px rgba(255, 255, 255, .25), inset 0 -6px 10px rgba(0, 0, 0, .25);
}
.th-qpanel .answer-btn:nth-child(4n+1) .a-letter { background: linear-gradient(135deg, #ff9ab0, #e0123f 60%, #7a0620); }
.th-qpanel .answer-btn:nth-child(4n+2) .a-letter { background: linear-gradient(135deg, #9fe3ff, #1d7bd8 60%, #0a2e6b); }
.th-qpanel .answer-btn:nth-child(4n+3) .a-letter { background: linear-gradient(135deg, #fff0a8, #f2b40c 60%, #8a5a00); color: #fff; }
.th-qpanel .answer-btn:nth-child(4n+4) .a-letter { background: linear-gradient(135deg, #b4ffd0, #18b35e 60%, #075c2c); }
.th-qpanel .a-letter span { display: block; rotate: -45deg; font-size: 1.05rem; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.th-qpanel .answer-btn.picked { border-color: var(--th-gold); background: linear-gradient(180deg, #6b5420, #4a3a16); }
.th-qpanel .answer-btn.correct {
    background: linear-gradient(180deg, #2fbf74, #138a4c);
    border-color: #b4ffd0;
    color: #fff;
    box-shadow: 0 5px 0 #0b4d2a, 0 0 34px rgba(80, 255, 160, .55);
}
.th-qpanel .answer-btn.wrong {
    background: linear-gradient(180deg, #e0413a, #9c1722);
    border-color: #ffc2bd;
    color: #fff;
    box-shadow: 0 5px 0 #4d0a10;
}
.th-qpanel .answer-btn.dim { opacity: .4; }
.th-qpanel .reveal-msg.good { color: #6ff0a6; text-shadow: 0 0 18px rgba(80, 255, 160, .5); }
.th-qpanel .reveal-msg.bad { color: #ff8f7a; }

/* crown glint in the messy room */
.th-junk.crown::after {
    content: '';
    position: absolute;
    left: 50%; top: 30%;
    width: 46%; aspect-ratio: 1;
    translate: -50% -50%;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 46%, #fff 50%, transparent 54%),
        linear-gradient(0deg, transparent 46%, #fff 50%, transparent 54%),
        radial-gradient(circle, rgba(255, 255, 255, .95) 0 12%, transparent 40%);
    opacity: 0;
    animation: thGlint 2.6s ease-in-out 1.2s infinite;
    z-index: 2;
}
@keyframes thGlint {
    0%, 70%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); }
    80%           { opacity: 1; transform: scale(1) rotate(45deg); }
    90%           { opacity: 0; transform: scale(.5) rotate(90deg); }
}

@media (max-width: 900px) { .th-q-char { display: none; } }
@media (prefers-reduced-motion: reduce) { .th-junk.crown::after { animation: none; } }

/* live room lobby in the cave */
.lineup-cave .room-switch { background: #2b2340; color: #f6e7c1; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); }
.lineup-cave .room-switch-track { background: #4a3f5e; }
.lineup-cave .room-switch.on .room-switch-track { background: #e0a526; }
.lineup-cave .room-qr-card { background: linear-gradient(180deg, #fff8e6, #f4e3bb); border: 3px solid #c9952e; }
.lineup-cave .room-players { color: #f6e7c1; background: rgba(20, 14, 30, .45); border-color: rgba(233, 196, 106, .45); }
.lineup-cave .room-player { background: linear-gradient(180deg, #3a2f4f, #2a2139); color: #fff3d6; }
.lineup-cave .room-kick { background: rgba(255, 255, 255, .12); color: #f6e7c1; }

/* board while the turn player plays the trial on the phone */
.th-phone-trial { text-align: center; }
.th-phone-trial h2 { margin-top: 6px; }
.th-phone-glass { animation: thGlass 1.6s ease-in-out infinite; }
@keyframes thGlass { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.th-q-phone {
    margin-left: 10px; padding: 2px 10px; border-radius: 999px;
    background: rgba(255, 255, 255, .18); font-size: .85em; font-weight: 800; white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) { .th-phone-glass { animation: none; } }
