/**
 * Items, lootboxes and gems (items.js): the gem counter and price tags, the gem purchase dialog, lootboxes on the
 * main screen, the Items menu, the open/merge reveal and the shop's Treasury tab. Loaded after styles.css.
 */

.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; }
@keyframes fade-in { from { opacity: 0; } }

/* ========== Gems: the premium currency ========== */
.gem-ico { width: 18px; height: 18px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 0 4px rgba(94, 231, 255, 0.6)); }
.gem-price { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-variant-numeric: tabular-nums; color: #c9f6ff; white-space: nowrap; }
.gem-price .gem-ico { width: 16px; height: 16px; }

/* balance in the top bar; the + opens the Treasury */
.gem-chip {
    position: relative;
    isolation: isolate;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 5px 0 9px;
    border-radius: 999px;
    border: 1px solid rgba(94, 231, 255, 0.5);
    background: linear-gradient(180deg, rgba(34, 64, 112, 0.92), rgba(14, 22, 46, 0.94));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 0 20px rgba(94, 231, 255, 0.16);
    color: #ecfbff;
    font-weight: 800;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    overflow: hidden;
    transition: transform 120ms ease, box-shadow 160ms ease;
}
/* a light sweep across the chip every few seconds */
.gem-chip::after {
    content: '';
    position: absolute;
    z-index: -1;
    top: -10%;
    bottom: -10%;
    left: -50%;
    width: 36%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.28), transparent);
    transform: skewX(-18deg);
    animation: gem-sweep 6s ease-in-out infinite;
}
.gem-chip:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 28px rgba(94, 231, 255, 0.34); }
.gem-chip .gem-ico { width: 24px; height: 24px; }
.gem-chip-plus {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(180deg, var(--gem), var(--gem-deep));
    color: #03122b;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.gem-chip--sm { height: 34px; font-size: 14px; }
.gem-chip--sm .gem-ico { width: 20px; height: 20px; }
.gem-chip--sm .gem-chip-plus { width: 24px; height: 24px; font-size: 16px; }
.gem-chip.is-bump { animation: gem-bump 420ms cubic-bezier(.2, .9, .2, 1.4); }
.gem-chip.is-shake { animation: gem-shake 360ms ease; }
@keyframes gem-sweep { 0%, 70% { left: -50%; } 100% { left: 130%; } }
@keyframes gem-bump { 40% { transform: scale(1.14); box-shadow: 0 0 0 4px rgba(94, 231, 255, 0.25), 0 0 34px rgba(94, 231, 255, 0.6); } }
@keyframes gem-shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }

/* the button for every gem purchase */
.btn-gem {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #8af0ff 0%, #4fa3ff 55%, var(--gem-violet) 100%);
    border-color: rgba(255, 255, 255, 0.25);
    color: #03122b;
    box-shadow: 0 6px 18px rgba(79, 140, 255, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.btn-gem .gem-price { color: inherit; }
.btn-gem .gem-ico { filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45)); }
.btn-gem::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    transform: skewX(-18deg);
    transition: left 500ms ease;
    pointer-events: none;
}
.btn-gem:hover:not(:disabled)::after { left: 130%; }
.btn-gem.is-poor { filter: saturate(0.4) brightness(0.8); box-shadow: none; }

/* the shop sells for gems: its balance and buy buttons get the gem look */
.gem-balance {
    background: linear-gradient(180deg, rgba(34, 64, 112, 0.9), rgba(14, 22, 46, 0.92));
    border-color: rgba(94, 231, 255, 0.45);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 0 18px rgba(94, 231, 255, 0.14);
    color: #ecfbff;
}
.gem-balance img { filter: drop-shadow(0 0 6px rgba(94, 231, 255, 0.7)); }
.shop-menu button[id^="buy"] {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(180deg, #8af0ff 0%, #4fa3ff 55%, var(--gem-violet) 100%);
    color: #03122b;
    box-shadow: 0 4px 14px rgba(79, 140, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.shop-menu button[id^="buy"] .gem-price { color: inherit; }
.shop-item-info .gem-price { color: #c9f6ff; }
.shop-tab-btn--gem { color: #bff4ff; }
.shop-tab-btn--gem.active { background: linear-gradient(180deg, var(--gem), var(--gem-deep)); color: #03122b; }

/* gems flying into the counter */
#gemFxLayer { position: fixed; inset: 0; z-index: 3200; pointer-events: none; overflow: hidden; }
.gem-fly { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; filter: drop-shadow(0 0 8px rgba(94, 231, 255, 0.9)); will-change: transform, opacity; }
.gem-spark { position: absolute; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px 2px var(--gem); }
.gem-float {
    position: absolute;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 24px;
    color: #bff4ff;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), 0 0 14px rgba(94, 231, 255, 0.8);
    white-space: nowrap;
    animation: gem-float-up 1200ms cubic-bezier(.2, .7, .3, 1) forwards;
}
.gem-float img { width: 26px; height: 26px; }
.gem-float--wh { color: var(--gold); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 170, 40, 0.6); }
@keyframes gem-float-up {
    0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
    18% { opacity: 1; transform: translate(-50%, -80%) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}

/* purchase dialog */
.gem-confirm-wrap { position: fixed; inset: 0; z-index: 2700; display: grid; place-items: center; padding: 16px; }
.gem-confirm-wrap.is-out { opacity: 0; transition: opacity 150ms ease; }
.gem-confirm-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 14, 0.66); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade-in 160ms ease; }
.gem-confirm {
    position: relative;
    width: min(100%, 360px);
    margin-top: 44px;
    padding: 0 20px 18px;
    border-radius: var(--radius-lg);
    text-align: center;
    background: radial-gradient(120% 70% at 50% 0%, rgba(94, 231, 255, 0.16), transparent 60%), var(--surface-solid);
    border: 1px solid rgba(94, 231, 255, 0.4);
    box-shadow: var(--shadow-lg), 0 0 40px rgba(79, 140, 255, 0.18);
    animation: gc-in 220ms cubic-bezier(.2, .9, .2, 1.2);
}
@keyframes gc-in { from { opacity: 0; transform: translateY(12px) scale(0.96); } }
.gc-art {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    margin: -46px auto 10px;
    border-radius: 22px;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid rgba(94, 231, 255, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.gc-art img { width: 100%; height: 100%; object-fit: cover; }
.gc-art .box-svg { width: 84%; height: 84%; }
.gc-emoji { font-size: 46px; line-height: 1; }
.gc-kicker { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--gem); }
.gc-title { margin: 4px 0; font-size: 20px; }
.gc-desc { margin: 0 0 12px; color: var(--text-dim); font-size: 13px; line-height: 1.45; }
.gc-ledger { display: grid; gap: 6px; margin: 0 0 16px; padding: 10px 12px; border-radius: var(--radius); background: rgba(0, 0, 0, 0.28); border: 1px solid var(--border); font-size: 14px; }
.gc-ledger > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.gc-ledger dt { color: var(--text-dim); }
.gc-ledger dd { margin: 0; display: inline-flex; align-items: center; gap: 2px; }
.gc-minus dd, .gc-minus .gem-price { color: #ffb3bb; }
.gc-after { padding-top: 6px; border-top: 1px solid var(--border); font-weight: 800; }
.gc-actions { display: grid; grid-template-columns: 1fr 1.5fr; gap: 8px; }

/* ========== Lootboxes on the main screen ========== */
.loot-drop {
    position: fixed;
    z-index: 1550;
    width: 96px;
    height: 96px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: loot-in 520ms cubic-bezier(.2, .9, .2, 1.35) both;
}
.loot-drop .box-svg {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 12px var(--lc));
    animation: loot-bob 1.8s ease-in-out infinite;
}
.loot-drop-rays {
    position: absolute;
    inset: -38px;
    border-radius: 50%;
    background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--lc) 55%, transparent) 0deg 9deg, transparent 9deg 30deg);
    -webkit-mask: radial-gradient(circle, #000 18%, transparent 68%);
    mask: radial-gradient(circle, #000 18%, transparent 68%);
    animation: loot-spin 8s linear infinite;
    pointer-events: none;
}
.loot-drop-tag {
    position: absolute;
    z-index: 2;
    left: 50%;
    bottom: -14px;
    transform: translateX(-50%);
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(8, 10, 16, 0.88);
    border: 1px solid color-mix(in srgb, var(--lc) 60%, transparent);
    color: var(--lc);
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    pointer-events: none;
}
.loot-drop:hover .box-svg, .loot-drop:focus-visible .box-svg { animation-duration: 0.6s; }
.loot-drop:focus-visible { outline: 2px solid var(--lc); outline-offset: 6px; border-radius: 20px; }
.loot-drop.is-leaving { animation: loot-blink 600ms ease-in-out infinite; }
.loot-drop.is-gone { animation: loot-out 380ms ease-in forwards; pointer-events: none; }
.loot-drop.is-lite .loot-drop-rays { display: none; }
@keyframes loot-in { from { opacity: 0; transform: translateY(-30px) scale(0.4) rotate(-12deg); } }
@keyframes loot-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
@keyframes loot-spin { to { transform: rotate(360deg); } }
@keyframes loot-blink { 50% { opacity: 0.35; } }
@keyframes loot-out { to { opacity: 0; transform: scale(0.3) translateY(20px); } }
.nav-btn.is-bump { animation: nav-bump 420ms cubic-bezier(.2, .9, .2, 1.4); }
@keyframes nav-bump { 40% { transform: scale(1.12); border-color: var(--gold); } }

/* ========== Items menu ========== */
/* fixed size: the content area scrolls, so switching tabs never resizes the window */
.items-menu { width: min(94vw, 1000px); height: min(88vh, 780px); }
.items-menu .items-content { min-height: 0; }

/* skeleton placeholders shown while a tab "loads" */
.sk-card { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.sk-card .sk-art { width: 56px; height: 56px; border-radius: 12px; }
.sk-card.sk-box { align-items: center; padding: 14px 10px 10px; }
.sk-card.sk-box .sk-art { width: 72px; height: 72px; }
.sk-row { display: flex; align-items: center; gap: 10px; }
.items-title { margin: 0; font-size: 18px; white-space: nowrap; }
.items-head-right { display: flex; align-items: center; gap: 8px; }
.items-tab-count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); font-size: 11px; line-height: 18px; text-align: center; }
.items-tab-count:empty { display: none; }
.shop-tab-btn.active .items-tab-count { background: rgba(0, 0, 0, 0.18); }
.items-boosts { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, 0.18); }
.items-boosts:empty { display: none; }
.boost-pill {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px 8px;
    border-radius: 999px;
    overflow: hidden;
    background: color-mix(in srgb, var(--rc) 14%, var(--surface-2));
    border: 1px solid color-mix(in srgb, var(--rc) 50%, transparent);
    font-size: 13px;
}
.boost-pill b { font-weight: 800; }
.boost-pill > span:not([aria-hidden]) { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.boost-pill i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--rc); }
.items-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.items-hint { margin: 0 0 12px; color: var(--text-dim); font-size: 13px; line-height: 1.45; max-width: 64ch; }
.items-toolbar .items-hint { margin: 0; }
.items-section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 20px 0 10px; font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text-faint); }
.items-section-h:first-child { margin-top: 0; }
.items-section-h span { color: var(--text-dim); letter-spacing: 0.5px; }
.items-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 12.5px; }
.items-lure { color: #ff9db1; }

/* lootbox ladder: each tier merges into the next */
.box-ladder { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.box-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 10px 10px;
    border-radius: var(--radius);
    text-align: center;
    background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 14%, var(--surface-2)), var(--surface-2) 70%);
    border: 1px solid color-mix(in srgb, var(--tc) 38%, transparent);
}
.box-card:not(:last-child)::after {
    content: '›';
    position: absolute;
    z-index: 1;
    top: 56px;
    right: -12px;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--text-dim);
    font-weight: 900;
    font-size: 15px;
    line-height: 1;
}
.box-card-art { position: relative; width: 92px; height: 92px; transition: filter 200ms; }
.box-card-art .box-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--tc) 55%, transparent)); }
.box-card.is-empty .box-card-art { filter: grayscale(0.85) brightness(0.55); }
.box-count { position: absolute; right: -6px; bottom: 2px; padding: 1px 8px; border-radius: 999px; background: var(--tc); color: #12100a; font-weight: 900; font-size: 13px; box-shadow: 0 0 0 2px var(--surface-solid); }
.box-card-name { font-weight: 800; font-size: 14px; color: var(--tc); }
.box-card-sub { min-height: 2.8em; color: var(--text-dim); font-size: 11.5px; line-height: 1.4; }
.odds-bar { display: flex; gap: 1px; width: 100%; height: 6px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, 0.06); }
.odds-bar i { display: block; height: 100%; }
.box-card-actions { display: flex; gap: 6px; width: 100%; }
.box-card-actions .btn { flex: 1; padding: 7px 8px; font-size: 12.5px; }
.btn-open { background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 80%, #fff), var(--tc)); color: #12100a; }
.box-merge {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px 8px;
    border-radius: 999px;
    border: 1px dashed color-mix(in srgb, var(--tc) 45%, transparent);
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 700;
}
.box-merge:disabled { cursor: default; opacity: 0.75; }
.box-merge.is-ready { border-style: solid; color: var(--text); background: color-mix(in srgb, var(--tc) 16%, transparent); animation: merge-ready 1.6s ease-in-out infinite; }
.box-merge.is-ready:hover { background: color-mix(in srgb, var(--tc) 28%, transparent); }
.box-merge--top { border-color: transparent; color: var(--text-faint); }
.merge-dots { display: inline-flex; gap: 3px; }
.merge-dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); }
.merge-dots i.on { background: var(--tc); box-shadow: 0 0 6px var(--tc); }
@keyframes merge-ready { 0%, 100% { box-shadow: 0 0 10px color-mix(in srgb, var(--tc) 25%, transparent); } 50% { box-shadow: 0 0 22px color-mix(in srgb, var(--tc) 55%, transparent); } }

/* charms */
.charm-slots { display: flex; flex-wrap: wrap; gap: 10px; }
.charm-slot {
    position: relative;
    width: 84px;
    height: 94px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px;
    border-radius: 16px;
    border: 2px dashed var(--border-strong);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-faint);
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
}
.charm-slot .item-art { width: 46px; height: 46px; font-size: 25px; border-radius: 13px; }
.charm-slot .stars { font-size: 10px; letter-spacing: 0; }
.charm-slot.is-filled { border-style: solid; border-color: var(--rc); background: color-mix(in srgb, var(--rc) 12%, var(--surface-2)); color: var(--text); }
.charm-slot.is-filled:hover { background: color-mix(in srgb, var(--rc) 20%, var(--surface-2)); }
.charm-slot.is-filled:hover::after { content: '✕'; position: absolute; top: 4px; right: 7px; font-size: 11px; color: var(--text-dim); }
.charm-slot.is-locked { border-style: solid; border-color: rgba(94, 231, 255, 0.35); background: linear-gradient(180deg, rgba(34, 64, 112, 0.45), rgba(14, 22, 46, 0.45)); color: #bff4ff; }
.charm-slot.is-locked:hover { border-color: var(--gem); box-shadow: 0 0 16px rgba(94, 231, 255, 0.25); }
.charm-slot.is-far { opacity: 0.4; }
.charm-summary { margin: 12px 0 0; font-size: 13px; color: var(--text-dim); }
.charm-summary b { color: var(--primary); }

/* item cards (charms and consumables) */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.item-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: var(--radius);
    background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 10%, var(--surface-2)), var(--surface-2) 60%);
    border: 1px solid color-mix(in srgb, var(--rc) 30%, var(--border));
}
.item-card.is-equipped { border-color: var(--rc); box-shadow: 0 0 0 1px var(--rc), 0 8px 24px color-mix(in srgb, var(--rc) 20%, transparent); }
.item-card.is-equipped::before { content: 'Equipped'; position: absolute; top: -9px; right: 10px; padding: 1px 8px; border-radius: 999px; background: var(--rc); color: #0b0d13; font-size: 10px; font-weight: 900; letter-spacing: 0.5px; text-transform: uppercase; }
.item-btns { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.item-btns .gem-ico--sm { width: 14px; height: 14px; margin: 0 3px 0 2px; vertical-align: -2px; }
.items-empty { grid-column: 1 / -1; margin: 8px 0; text-align: center; }
.item-card-head { display: flex; align-items: center; gap: 10px; }
.item-name { font-weight: 800; font-size: 14px; line-height: 1.2; }
.item-rarity { font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--rc); }
.item-effect { font-size: 13px; font-weight: 700; line-height: 1.35; color: var(--primary); }
.item-next { font-size: 11.5px; color: var(--text-dim); }
.item-flavor { margin: 0; font-size: 12px; font-style: italic; line-height: 1.4; color: #d6c9ae; }
.item-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 6px; }
.item-copies { font-weight: 800; font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.item-art {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    font-size: 28px;
    line-height: 1;
    background: radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.28), transparent 55%), linear-gradient(155deg, color-mix(in srgb, var(--rc) 75%, #000), color-mix(in srgb, var(--rc) 25%, #05060a));
    box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.14), 0 0 0 1px color-mix(in srgb, var(--rc) 60%, transparent);
}
.item-art img { width: 70%; height: 70%; object-fit: contain; }
.item-art--lg { width: 76px; height: 76px; border-radius: 20px; font-size: 42px; }
.stars { font-size: 13px; letter-spacing: 1px; color: rgba(255, 255, 255, 0.18); }
.stars-on { color: var(--gold); text-shadow: 0 0 6px rgba(255, 200, 61, 0.5); }

/* ========== Reveal: opening, merging, buying ========== */
.loot-reveal {
    position: fixed;
    inset: 0;
    z-index: 2600;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 16px;
    overflow-x: hidden;
    overflow-y: auto;
    background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--tc) 22%, rgba(6, 8, 14, 0.94)), rgba(4, 5, 9, 0.97) 62%);
    animation: fade-in 200ms ease;
    cursor: pointer;
    outline: none;
}
.loot-reveal.is-done { cursor: default; }
.loot-reveal.is-out { opacity: 0; transition: opacity 180ms ease; }
.lr-glow {
    position: fixed;
    inset: -50%;
    pointer-events: none;
    opacity: 0;
    background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--best) 22%, transparent) 0deg 8deg, transparent 8deg 24deg);
    -webkit-mask: radial-gradient(circle, #000 0, transparent 38%);
    mask: radial-gradient(circle, #000 0, transparent 38%);
    transition: opacity 500ms ease;
    animation: loot-spin 30s linear infinite;
}
.loot-reveal.is-epic .lr-glow { opacity: 1; }
.lr-head, .lr-stage, .lr-sub, .lr-cards, .lr-actions, .lr-hint { position: relative; }
/* centered vertically, but scrollable from the top when the cards don't fit (justify-content: center would cut off the title) */
.lr-head { margin-top: auto; }
.lr-hint { margin-bottom: auto; }
.lr-head { text-align: center; }
.lr-kicker { font-size: 12px; font-weight: 800; letter-spacing: 1.4px; text-transform: uppercase; color: var(--text-dim); }
.lr-title { font-family: var(--font-display); font-size: clamp(24px, 5vw, 36px); line-height: 1.15; color: var(--tc); text-shadow: 0 4px 24px color-mix(in srgb, var(--tc) 50%, transparent); }
.lr-sub { margin: 0; color: var(--text-dim); font-size: 14px; text-align: center; }
.lr-stage { width: 100%; height: 200px; display: grid; place-items: center; transition: height 320ms ease, opacity 220ms ease; }
.lr-stage.is-collapsed { height: 0; opacity: 0; overflow: hidden; }
.lr-chest { position: relative; width: 180px; height: 180px; }
.lr-chest .box-svg { position: relative; display: block; width: 100%; height: 100%; filter: drop-shadow(0 0 24px var(--glow, var(--tc))); }
/* light gathering behind the chest while it shakes */
.lr-chest::before { content: ''; position: absolute; inset: -10%; border-radius: 50%; background: radial-gradient(circle, var(--glow, var(--tc)), transparent 65%); opacity: 0; }
.lr-chest.is-shaking { animation: lr-shake 1050ms ease-in both; }
.lr-chest.is-shaking::before { animation: lr-charge 1050ms ease-in forwards; }
.lr-chest.is-burst { animation: lr-burst 320ms ease-in forwards; }
.lr-chest.is-drop { animation: lr-drop 700ms cubic-bezier(.3, 1.4, .5, 1) both; }
.lr-chest.is-drop .box-svg, .lr-chest--pop .box-svg { animation: loot-bob 2s ease-in-out 700ms infinite; }
.lr-chest--pop { animation: lr-pop 620ms cubic-bezier(.2, .9, .2, 1.4) both; }
@keyframes lr-shake {
    0% { opacity: 0; transform: scale(0.6); }
    14% { opacity: 1; transform: scale(1); }
    26% { transform: rotate(-3deg); }
    36% { transform: rotate(3deg); }
    46% { transform: rotate(-5deg) scale(1.02); }
    56% { transform: rotate(5deg) scale(1.02); }
    66% { transform: rotate(-7deg) scale(1.04); }
    76% { transform: rotate(7deg) scale(1.05); }
    86% { transform: rotate(-9deg) scale(1.07); }
    100% { transform: rotate(0) scale(1.1); }
}
@keyframes lr-charge { 0% { opacity: 0; transform: scale(0.6); } 100% { opacity: 0.9; transform: scale(1.3); } }
@keyframes lr-burst { to { opacity: 0; transform: scale(1.6); filter: brightness(2.5); } }
@keyframes lr-drop { 0% { opacity: 0; transform: translateY(-140px) scale(0.7); } 60% { opacity: 1; transform: translateY(8px) scale(1.04); } 100% { transform: none; } }
@keyframes lr-pop { 0% { opacity: 0; transform: scale(0.2); } 100% { opacity: 1; transform: scale(1); } }
.lr-flash {
    position: fixed;
    inset: 0;
    z-index: 2601;
    pointer-events: none;
    background: radial-gradient(circle at 50% 42%, #fff 0, color-mix(in srgb, var(--best) 70%, transparent) 22%, transparent 60%);
    animation: lr-flash 650ms ease-out forwards;
}
@keyframes lr-flash { 0% { opacity: 0; } 15% { opacity: 0.75; } 100% { opacity: 0; } }

/* merging: three boxes slide into one, then the new one pops out */
.lr-merge { position: relative; width: 300px; max-width: 100%; height: 180px; }
.lr-mini { position: absolute; top: 50%; left: 50%; width: 84px; height: 84px; margin: -42px 0 0 -42px; animation: lr-converge 700ms cubic-bezier(.6, 0, .4, 1) forwards; }
.lr-mini .box-svg { display: block; width: 100%; height: 100%; }
.lr-mini:nth-child(1) { --sx: -110px; }
.lr-mini:nth-child(2) { --sy: -36px; }
.lr-mini:nth-child(3) { --sx: 110px; }
@keyframes lr-converge {
    0% { opacity: 1; transform: translate(var(--sx, 0px), var(--sy, 0px)); }
    80% { opacity: 1; transform: translate(0, 0) scale(0.8); }
    100% { opacity: 0; transform: scale(0.4); }
}
.lr-chest--new { position: absolute; inset: 0; margin: auto; animation: lr-pop 620ms cubic-bezier(.2, .9, .2, 1.4) 650ms both; }
.lr-merge .lr-chest--new { width: 170px; height: 170px; }

/* result cards */
.lr-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 840px; perspective: 900px; }
.lr-cards:empty { display: none; }
.lr-card {
    position: relative;
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 16px 10px 12px;
    border-radius: 16px;
    text-align: center;
    background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 22%, var(--surface-solid)), var(--surface-solid) 75%);
    border: 1px solid color-mix(in srgb, var(--rc) 65%, transparent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 22px color-mix(in srgb, var(--rc) 28%, transparent);
    cursor: default;
    animation: lr-card-in 560ms cubic-bezier(.2, .9, .25, 1.15) both;
    animation-delay: var(--d, 0ms);
}
.lr-card b { font-size: 13.5px; line-height: 1.2; }
.lr-card .stars { font-size: 12px; }
.lr-rarity { font-size: 10.5px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--rc); }
.lr-note { font-size: 11.5px; line-height: 1.3; color: var(--text-dim); }
.lr-new { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); padding: 1px 9px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 900; letter-spacing: 0.6px; text-transform: uppercase; box-shadow: 0 0 0 2px #05060a; white-space: nowrap; }
.lr-qty { position: absolute; top: 8px; right: 10px; font-weight: 900; font-size: 13px; color: var(--rc); }
.lr-box { width: 76px; height: 76px; }
.lr-box .box-svg { display: block; width: 100%; height: 100%; }
.lr-card.is-shiny { overflow: hidden; }
.lr-card.is-shiny::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.22) 45%, transparent 60%);
    background-size: 250% 100%;
    animation: lr-sheen 2.4s ease-in-out infinite;
    animation-delay: calc(var(--d, 0ms) + 600ms);
    pointer-events: none;
}
.lr-card.is-shiny .lr-new { top: 6px; left: 10px; transform: none; }
@keyframes lr-card-in {
    0% { opacity: 0; transform: translateY(26px) rotateY(85deg) scale(0.8); }
    60% { opacity: 1; transform: translateY(-4px) rotateY(-8deg) scale(1.04); }
    100% { opacity: 1; transform: none; }
}
@keyframes lr-sheen { 0% { background-position: 150% 0; } 60%, 100% { background-position: -100% 0; } }
.lr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; animation: fade-in 240ms ease; }
.lr-actions[hidden] { display: none; }
.lr-actions .btn { min-width: 140px; }
.lr-hint { font-size: 12px; color: var(--text-faint); }
.loot-reveal.is-done .lr-hint { visibility: hidden; }
/* skipping: show everything at once */
.loot-reveal.is-instant .lr-card { animation-delay: 0ms; animation-duration: 1ms; }
.loot-reveal.is-instant .lr-mini { animation: none; opacity: 0; }
.loot-reveal.is-instant .lr-chest--new { animation: none; }

/* ========== Treasury (shop tab) ========== */
.treasury { display: flex; flex-direction: column; }
.treasury .items-section-h { margin-top: 22px; }
.treasury-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: radial-gradient(90% 140% at 0% 0%, rgba(94, 231, 255, 0.2), transparent 60%), radial-gradient(80% 120% at 100% 100%, rgba(123, 92, 255, 0.22), transparent 60%), var(--surface-2);
    border: 1px solid rgba(94, 231, 255, 0.32);
}
.treasury-gem { flex: 0 0 auto; width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 0 18px rgba(94, 231, 255, 0.75)); animation: treasury-float 3.2s ease-in-out infinite; }
.treasury-hero-text { min-width: 0; }
.treasury-hero h4 { margin: 0 0 4px; font-family: var(--font-display); font-size: 22px; letter-spacing: 0.5px; background: linear-gradient(180deg, #e7fcff, var(--gem)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.treasury-hero p { margin: 0 0 10px; max-width: 58ch; color: var(--text-dim); font-size: 13px; line-height: 1.45; }
.treasury-sources { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.treasury-sources li { padding: 3px 10px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.treasury-balance { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.treasury-balance .gem-price { font-size: 26px; color: #ecfbff; }
.treasury-balance .gem-ico { width: 28px; height: 28px; }
.treasury-balance > span:last-child { font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); }
.treasury-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.tr-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 12px 12px;
    border-radius: var(--radius);
    text-align: center;
    background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 14%, var(--surface-2)), var(--surface-2) 70%);
    border: 1px solid color-mix(in srgb, var(--tc) 40%, transparent);
    transition: transform 140ms ease, border-color 140ms ease;
}
.tr-card:hover { transform: translateY(-2px); border-color: var(--tc); }
.tr-art { width: 96px; height: 96px; display: grid; place-items: center; font-size: 54px; line-height: 1; }
.tr-art .box-svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 0 12px color-mix(in srgb, var(--tc) 50%, transparent)); }
.tr-name { font-weight: 800; font-size: 15px; color: var(--tc); }
.tr-desc { min-height: 2.8em; color: var(--text-dim); font-size: 12.5px; line-height: 1.4; }
.tr-status { font-size: 12px; font-weight: 800; color: var(--primary); }
.tr-card .btn-gem { width: 100%; margin-top: auto; }
@keyframes treasury-float { 50% { transform: translateY(-6px) rotate(4deg); } }

/* ========== Responsive ========== */
@media (max-width: 900px) {
    .box-ladder { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .box-card:not(:last-child)::after { display: none; }
}
@media (max-width: 760px) {
    .gem-chip { height: 38px; padding-left: 7px; gap: 5px; font-size: 14px; }
    .gem-chip .gem-ico { width: 20px; height: 20px; }
    .gem-chip-plus { width: 24px; height: 24px; font-size: 16px; }
    .loot-drop { width: 80px; height: 80px; }
    .shop-tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
    .shop-tabs::-webkit-scrollbar { display: none; }
    .shop-tab-btn { white-space: nowrap; padding: 8px 11px; }
    /* Items header: balance and close sit beside the title, tabs get the full second row */
    .items-menu .shop-header { position: relative; }
    .items-menu .shop-left { width: 100%; row-gap: 10px; }
    .items-menu .items-head-right { position: absolute; top: 12px; right: 14px; }
    .items-toolbar { flex-direction: column; align-items: stretch; }
    .item-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .treasury-hero { flex-wrap: wrap; }
    .treasury-gem { width: 60px; height: 60px; }
    .treasury-balance { margin-left: 0; align-items: flex-start; }
    .lr-stage { height: 160px; }
    .lr-chest { width: 140px; height: 140px; }
    .lr-card { width: calc(50% - 6px); max-width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
    .gem-chip::after, .loot-drop-rays, .lr-glow, .treasury-gem, .box-merge.is-ready, .lr-card.is-shiny::after { animation: none; }
    .loot-drop .box-svg, .lr-chest .box-svg { animation: none; }
    .lr-card { animation-duration: 1ms; animation-delay: 0ms; }
}
