/* Cubez - scoped to .cz-root because Dash loads every assets/*.css on every page. */

.cz-root {
    --cz-unique: #c7b377;
    --cz-set: #1ed41e;
    --cz-rare: #ffff6e;
    --cz-magic: #8080ff;
    --cz-rune: #ffa800;
    --cz-normal: #e8e8e8;
    --cz-low: #8f8f8f;
    --cz-gold: #e8c86a;
    --cz-heading: 'Cinzel', 'Times New Roman', serif;

    position: relative;
    max-width: 520px;
    margin: 0 auto;
    padding: 14px 12px 32px;
    color: #cfc6b4;
    font-family: var(--cz-heading);
    text-align: center;
    background:
        radial-gradient(ellipse at 50% 20%, rgba(120, 30, 10, 0.35), transparent 60%),
        #050404;
    border-radius: 6px;
    box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.9);
    -webkit-tap-highlight-color: transparent;
    overflow: hidden;
    user-select: none;
}

.cz-q-unique { color: var(--cz-unique); }
.cz-q-set { color: var(--cz-set); }
.cz-q-rare { color: var(--cz-rare); }
.cz-q-magic { color: var(--cz-magic); }
.cz-q-rune { color: var(--cz-rune); }
.cz-q-normal, .cz-q-superior { color: var(--cz-normal); }
.cz-q-low { color: var(--cz-low); }

/* top bar */
.cz-topbar { display: flex; align-items: center; justify-content: space-between; }
.cz-title {
    margin: 0;
    font-weight: 900;
    font-size: 1.9rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: linear-gradient(180deg, #fff3c4 0%, #d9b45a 45%, #7a5a1c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.cz-gold {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--cz-gold);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #5c4b2c;
    border-radius: 20px;
}
.cz-coin { color: #f2c94c; text-shadow: 0 0 6px rgba(242, 201, 76, 0.7); font-size: 0.8rem; }

/* views */
.cz-select, .cz-stage { display: none; }
.view-select .cz-select { display: block; animation: cz-view-in 0.25s ease-out both; }
.view-cube .cz-stage, .view-reveal .cz-stage { display: block; animation: cz-view-in 0.25s ease-out both; }
.view-reveal .cz-open-btn, .view-reveal .cz-back { display: none; }
.view-cube .cz-actions, .view-cube .cz-result { display: none; }
@keyframes cz-view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* boss selector */
.cz-toast { min-height: 1.4em; margin: 10px 0 4px; font-size: 0.85rem; color: #b4a88c; }
.cz-carousel { position: relative; margin: 0 -12px; }
.cz-bosses {
    position: relative;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding: 8px 13%;
    scrollbar-width: none;
}
.cz-bosses::-webkit-scrollbar { display: none; }
.cz-boss {
    flex: 0 0 74%;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 22px 12px 16px;
    font-family: var(--cz-heading);
    color: inherit;
    background:
        radial-gradient(circle at 50% 30%, var(--cz-boss-glow, rgba(0, 0, 0, 0)) 0%, transparent 55%),
        linear-gradient(180deg, var(--cz-boss-tint, #2a1a10) 0%, #0d0a07 85%);
    border: 2px solid #5c4b2c;
    border-radius: 6px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 6px 18px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    touch-action: pan-x;
    opacity: 0.5;
    transform: scale(0.9);
    transition: opacity 0.25s, transform 0.25s, border-color 0.25s;
}
.cz-boss.active { opacity: 1; transform: none; border-color: #a88a4c; }
.cz-boss.active:active { transform: scale(0.98); }
.cz-boss-icon { width: 96px; height: 96px; object-fit: contain; margin-bottom: 8px; filter: drop-shadow(0 0 14px var(--cz-boss-glow, #000)); }
.cz-boss-name { font-weight: 900; font-size: 1.8rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cz-boss-color, #e8e1cf); line-height: 1.1; }
.cz-boss-sub { font-size: 0.75rem; color: #8c836f; letter-spacing: 0.2em; text-transform: uppercase; }
.cz-boss-price { margin-top: 10px; font-weight: 700; color: var(--cz-gold); font-size: 1.2rem; }
.cz-boss-price::before { content: "● "; color: #f2c94c; font-size: 0.75rem; vertical-align: middle; }
.cz-boss-hint { margin-top: 8px; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #6f6550; }
.cz-boss.active .cz-boss-hint { animation: cz-pulse-hint 1.8s ease-in-out infinite; }
@keyframes cz-pulse-hint { 50% { color: #c9b27a; } }
.cz-arrow {
    position: absolute;
    top: 50%;
    z-index: 5;
    width: 40px;
    height: 40px;
    border: 1px solid #5c4b2c;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #c9b27a;
    font-size: 1.8rem;
    line-height: 1;
    padding-bottom: 4px;
    transform: translateY(-50%);
    cursor: pointer;
}
.cz-arrow-prev { left: 6px; }
.cz-arrow-next { right: 6px; }
@media (hover: none) { .cz-arrow { display: none; } }
.cz-dots { display: flex; justify-content: center; gap: 8px; margin: 6px 0 4px; }
.cz-dot { width: 8px; height: 8px; border-radius: 50%; background: #3b3020; transition: background 0.2s, box-shadow 0.2s; }
.cz-dot.active { background: var(--cz-unique); box-shadow: 0 0 6px var(--cz-unique); }.cz-boss-andariel { --cz-boss-tint: #1d2a12; --cz-boss-color: #9be36a; --cz-boss-glow: rgba(120, 220, 80, 0.35); }
.cz-boss-mephisto { --cz-boss-tint: #141c33; --cz-boss-color: #8fb0ff; --cz-boss-glow: rgba(90, 130, 255, 0.35); }
.cz-boss-baal { --cz-boss-tint: #2e0f0c; --cz-boss-color: #ff6a4a; --cz-boss-glow: rgba(255, 70, 30, 0.35); }
.cz-reset { margin-top: 12px; max-width: none; width: 100%; }

/* stage */
.cz-stage { position: relative; padding-top: 6px; }
.cz-back {
    position: absolute;
    left: 0;
    top: 2px;
    padding: 8px 6px;
    font-family: var(--cz-heading);
    font-size: 0.85rem;
    color: #a99467;
    background: none;
    border: none;
    cursor: pointer;
}
.cz-stage-name { margin: 6px 0 2px; font-weight: 900; font-size: 1.5rem; letter-spacing: 0.1em; text-transform: uppercase; }
.cz-dim { color: #8c836f; font-weight: 500; font-size: 0.9rem; }
.cz-name-andariel { color: #9be36a; text-shadow: 0 0 10px rgba(120, 220, 80, 0.5); }
.cz-name-mephisto { color: #8fb0ff; text-shadow: 0 0 10px rgba(90, 130, 255, 0.6); }
.cz-name-baal { color: #ff6a4a; text-shadow: 0 0 12px rgba(255, 60, 20, 0.7); }
.cz-open-btn { margin-top: 6px; }
.view-reveal .cz-cube { animation: cz-cube-out 0.35s 1.3s ease-in forwards; }
@keyframes cz-cube-out { to { height: 0; margin: 0; opacity: 0; transform: scale(0.2); } }
/* cube */
.cz-cube { position: relative; width: 190px; height: 190px; margin: 0 auto 4px; display: grid; place-items: center; pointer-events: none; }
.cz-cube-img {
    position: relative;
    z-index: 2;
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.9));
    animation: cz-idle 3.2s ease-in-out infinite;
}
.cz-cube-andariel .cz-cube-img { filter: hue-rotate(60deg) saturate(1.3) drop-shadow(0 0 14px rgba(120, 220, 80, 0.5)); }
.cz-cube-mephisto .cz-cube-img { filter: hue-rotate(190deg) saturate(1.4) drop-shadow(0 0 14px rgba(80, 110, 255, 0.55)); }
.cz-cube-baal .cz-cube-img { filter: sepia(0.6) hue-rotate(-30deg) saturate(3) drop-shadow(0 0 16px rgba(255, 60, 20, 0.7)); }
.cz-cube-rays {
    position: absolute;
    inset: -30px;
    z-index: 1;
    border-radius: 50%;
    opacity: 0;
    background: conic-gradient(from 0deg, transparent 0 8%, var(--cz-glow, #fff) 10%, transparent 12% 20%,
        var(--cz-glow, #fff) 22%, transparent 24% 36%, var(--cz-glow, #fff) 38%, transparent 40% 52%,
        var(--cz-glow, #fff) 54%, transparent 56% 70%, var(--cz-glow, #fff) 72%, transparent 74% 86%,
        var(--cz-glow, #fff) 88%, transparent 90%);
    mask-image: radial-gradient(circle, #000 25%, transparent 70%);
    -webkit-mask-image: radial-gradient(circle, #000 25%, transparent 70%);
}
.cz-cube-flash {
    position: absolute;
    inset: -60px;
    z-index: 3;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(circle, var(--cz-glow, #fff) 0%, transparent 65%);
}
.cz-glow-1 { --cz-glow: #9a9a9a; }
.cz-glow-2 { --cz-glow: var(--cz-set); }
.cz-glow-3 { --cz-glow: var(--cz-unique); }
.cz-glow-4 { --cz-glow: #ff3b1f; }

/* open animation: two identical copies so re-adding the class restarts it */
.cz-cube.cz-open-0 .cz-cube-img { animation: cz-shake-a 1.25s cubic-bezier(.36, .07, .19, .97) both; }
.cz-cube.cz-open-1 .cz-cube-img { animation: cz-shake-b 1.25s cubic-bezier(.36, .07, .19, .97) both; }
.cz-cube.cz-open-0 .cz-cube-rays { animation: cz-rays-a 1.6s ease-out both; }
.cz-cube.cz-open-1 .cz-cube-rays { animation: cz-rays-b 1.6s ease-out both; }
.cz-cube.cz-open-0 .cz-cube-flash { animation: cz-flash-a 0.7s 1.15s ease-out both; }
.cz-cube.cz-open-1 .cz-cube-flash { animation: cz-flash-b 0.7s 1.15s ease-out both; }

@keyframes cz-idle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes cz-shake-a {
    10%, 30%, 50%, 70% { transform: scale(1.04) rotate(-6deg) translateX(-3px); }
    20%, 40%, 60%, 80% { transform: scale(1.06) rotate(6deg) translateX(3px); }
    88% { transform: scale(1.25); filter: brightness(2.2) drop-shadow(0 0 18px var(--cz-glow)); }
    100% { transform: none; }
}
@keyframes cz-shake-b {
    10%, 30%, 50%, 70% { transform: scale(1.04) rotate(-6deg) translateX(-3px); }
    20%, 40%, 60%, 80% { transform: scale(1.06) rotate(6deg) translateX(3px); }
    88% { transform: scale(1.25); filter: brightness(2.2) drop-shadow(0 0 18px var(--cz-glow)); }
    100% { transform: none; }
}
@keyframes cz-rays-a { 0% { opacity: 0; transform: rotate(0) scale(0.6); } 60% { opacity: 0.9; } 100% { opacity: 0; transform: rotate(160deg) scale(1.3); } }
@keyframes cz-rays-b { 0% { opacity: 0; transform: rotate(0) scale(0.6); } 60% { opacity: 0.9; } 100% { opacity: 0; transform: rotate(160deg) scale(1.3); } }
@keyframes cz-flash-a { 0% { opacity: 0; transform: scale(0.3); } 30% { opacity: 0.85; } 100% { opacity: 0; transform: scale(1.4); } }
@keyframes cz-flash-b { 0% { opacity: 0; transform: scale(0.3); } 30% { opacity: 0.85; } 100% { opacity: 0; transform: scale(1.4); } }

/* transmute button */
.cz-btn {
    width: 100%;
    max-width: 360px;
    min-height: 64px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--cz-heading);
    font-weight: 700;
    color: #ffe6a6;
    background: linear-gradient(180deg, #6b1a10 0%, #3d0d07 55%, #210604 100%);
    border: 2px solid #b08d4a;
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255, 230, 170, 0.15), 0 2px 8px rgba(0, 0, 0, 0.8);
    text-shadow: 0 1px 2px #000;
    cursor: pointer;
    touch-action: manipulation;
    transition: filter 0.1s, transform 0.08s;
}
.cz-btn:active { transform: translateY(1px) scale(0.99); filter: brightness(1.2); }
.cz-btn-main { font-size: 1.35rem; letter-spacing: 0.14em; text-transform: uppercase; line-height: 1.1; }
.cz-btn-sub { font-size: 0.8rem; color: var(--cz-gold); }

/* result */
.cz-result { min-height: 150px; margin-top: 14px; display: flex; justify-content: center; align-items: flex-start; perspective: 900px; }
.cz-note { color: #a99467; font-size: 0.9rem; padding-top: 50px; }
.cz-reveal { display: flex; flex-direction: column; align-items: center; width: 100%; }
.cz-card { width: 140px; height: 150px; animation: cz-deal 0.4s 1.2s cubic-bezier(.2, .9, .3, 1.3) both; }
.cz-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    animation: cz-flip 0.55s 1.6s cubic-bezier(.4, .2, .2, 1) both;
}
@keyframes cz-deal { from { opacity: 0; transform: translateY(-60px) scale(0.5); } to { opacity: 1; transform: none; } }
@keyframes cz-flip { from { transform: rotateY(0); } to { transform: rotateY(180deg); } }
.cz-card-back, .cz-card-front {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 4px;
}
.cz-card-back {
    background:
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 6px, transparent 6px 12px),
        radial-gradient(circle at 50% 40%, #2b1d10, #0b0805 70%);
    border: 2px solid #4a3a21;
}
.cz-card-front {
    transform: rotateY(180deg);
    display: grid;
    place-items: center;
    padding: 12px;
    background: radial-gradient(circle at 50% 40%, #1a1712, #050404 75%);
    border: 1px solid #2c2618;
}
.cz-card-front img { max-width: 100%; max-height: 120px; object-fit: contain; filter: drop-shadow(0 4px 6px #000); }

/* D2-style item tooltip */
.cz-reveal-tt { width: 100%; max-width: 360px; margin-top: 10px; animation: cz-fade-in 0.35s 2s ease-out both; }
@keyframes cz-fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.cz-tt {
    background: rgba(0, 0, 0, 0.92);
    border: 1px solid #3a3226;
    padding: 9px 10px 10px;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.85rem;
    line-height: 1.35;
}
.cz-tt-name { font-family: var(--cz-heading); font-weight: 700; font-size: 1rem; line-height: 1.2; }
.cz-tt-base { font-family: var(--cz-heading); font-size: 0.85rem; margin-bottom: 2px; }
.cz-tt-line { color: var(--cz-normal); }
.cz-tt-stat { color: var(--cz-magic); }
.cz-tt-set { color: var(--cz-set); margin-top: 4px; font-family: var(--cz-heading); font-size: 0.8rem; }

/* stash / sell */
.cz-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.cz-actions.show-0 { animation: cz-fade-in-a 0.35s 2.1s ease-out both; }
.cz-actions.show-1 { animation: cz-fade-in-b 0.35s 2.1s ease-out both; }
@keyframes cz-fade-in-a { from { opacity: 0; } to { opacity: 1; } }
@keyframes cz-fade-in-b { from { opacity: 0; } to { opacity: 1; } }
.cz-btn-small { flex: 1 1 0; max-width: 175px; min-height: 48px; font-size: 1rem; letter-spacing: 0.08em; text-transform: uppercase; }
.cz-btn-sell { background: linear-gradient(180deg, #4a3a12 0%, #2a1f08 60%, #171005 100%); color: var(--cz-gold); }
.cz-btn:disabled { filter: grayscale(0.9) brightness(0.55); cursor: not-allowed; }

.cz-stash { margin-top: 26px; text-align: left; }
.cz-stash-title {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #c9b27a;
    padding: 0 2px 6px;
}
.cz-stash-total { color: var(--cz-gold); font-size: 0.8rem; letter-spacing: 0; text-transform: none; }
.cz-stash-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 2px;
    padding: 4px;
    background: #0b0a08;
    border: 2px solid #3b3020;
}
.cz-cell {
    aspect-ratio: 1;
    padding: 3px;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #16130e, #0d0b08);
    border: 1px solid #241e14;
    border-radius: 0;
    cursor: pointer;
    touch-action: manipulation;
}
.cz-cell img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }
.cz-cell-empty { cursor: default; }
.cz-cell-unique { background: radial-gradient(circle, rgba(199, 179, 119, 0.22), #0d0b08 75%); }
.cz-cell-set { background: radial-gradient(circle, rgba(30, 212, 30, 0.18), #0d0b08 75%); }
.cz-cell-rare { background: radial-gradient(circle, rgba(255, 255, 110, 0.12), #0d0b08 75%); }
.cz-cell-magic { background: radial-gradient(circle, rgba(128, 128, 255, 0.16), #0d0b08 75%); }
.cz-cell-rune { background: radial-gradient(circle, rgba(255, 168, 0, 0.18), #0d0b08 75%); }
.cz-cell.selected { border-color: var(--cz-unique); box-shadow: inset 0 0 8px rgba(199, 179, 119, 0.7); }
.cz-detail { display: none; margin-top: 8px; text-align: center; }
.cz-detail.open { display: block; }
.cz-detail .cz-btn-small { margin-top: 8px; width: 100%; }

.cz-rank-2 .cz-card-front { border-color: var(--cz-set); box-shadow: 0 0 16px rgba(30, 212, 30, 0.45); }
.cz-rank-3 .cz-card-front { border-color: var(--cz-unique); box-shadow: 0 0 20px rgba(199, 179, 119, 0.6); }
.cz-rank-4 .cz-card-front { border: 2px solid #ff6a2a; box-shadow: 0 0 30px rgba(255, 90, 30, 0.85); }

.cz-root.cz-hit-flash::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle, var(--cz-flash, rgba(199, 179, 119, 0.55)), transparent 70%);
    animation: cz-screen-flash 0.9s ease-out both;
    z-index: 2000;
}
@keyframes cz-screen-flash { from { opacity: 1; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .cz-root * { animation-duration: 0.01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
}
