/* ================= CRAFT TAB ================= */
body.tab-craft #live-mult { visibility: hidden; }
.craft-view {
    --cr-safe: #34e08a;
    --cr-normal: #3db4ff;
    --cr-risky: #ff4d8d;
    --cr-card: rgba(18, 28, 52, 0.78);
    --cr-line: rgba(120, 170, 255, 0.16);
    position: absolute;
    inset: 0;
    /* above everything of the crash view, below the top bar (9999) and the nav */
    z-index: 950;
    color: #fff;
    font-family: Inter, sans-serif;
    background:
        radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.7), transparent 60%),
        radial-gradient(1px 1px at 78% 9%, rgba(255, 255, 255, 0.6), transparent 60%),
        radial-gradient(1.5px 1.5px at 42% 33%, rgba(180, 210, 255, 0.7), transparent 60%),
        radial-gradient(1px 1px at 88% 46%, rgba(255, 255, 255, 0.5), transparent 60%),
        radial-gradient(1px 1px at 22% 63%, rgba(255, 255, 255, 0.5), transparent 60%),
        radial-gradient(1.5px 1.5px at 65% 74%, rgba(180, 210, 255, 0.6), transparent 60%),
        radial-gradient(1px 1px at 8% 88%, rgba(255, 255, 255, 0.5), transparent 60%),
        radial-gradient(ellipse 90% 40% at 50% 0%, rgba(40, 90, 200, 0.28), transparent 70%),
        radial-gradient(ellipse 80% 50% at 50% 100%, rgba(30, 70, 170, 0.22), transparent 70%),
        linear-gradient(180deg, #050a18 0%, #071026 50%, #040814 100%);
}
.craft-view[hidden] { display: none; }
.craft-scroll {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--craft-top, 52px) 12px calc(var(--nav-float) + var(--nav-gap) + 16px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    scrollbar-width: none;
}
.craft-scroll::-webkit-scrollbar { display: none; }

.craft-head {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--craft-head-h, 38px);
    padding-left: 4px;
    /* the wallet capsule from the top bar sits on the right of this row */
    padding-right: 190px;
}
.craft-logo {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #9fd0ff;
    background: linear-gradient(145deg, rgba(80, 150, 255, 0.35), rgba(140, 80, 255, 0.25));
    border: 1px solid rgba(140, 190, 255, 0.45);
    box-shadow: 0 0 14px rgba(70, 150, 255, 0.45);
}
.craft-head h1 { margin: 0; font: 800 24px/1 Inter, sans-serif; letter-spacing: 0.2px; }
.craft-subrow { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; padding-left: 4px; }
.craft-subrow p { flex: 1; margin: 0; color: #a9b8dc; font: 500 12.5px/1.3 Inter, sans-serif; }
.craft-history-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 11px;
    border-radius: 15px;
    border: 1px solid var(--cr-line);
    background: rgba(30, 40, 66, 0.7);
    color: #dfe8ff;
    font: 600 12.5px Inter, sans-serif;
}
.craft-history-btn ion-icon { font-size: 15px; }
.craft-test-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 4px;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255, 196, 60, 0.1);
    border: 1px solid rgba(255, 196, 60, 0.3);
    color: #ffd47a;
    font: 600 11.5px/1.3 Inter, sans-serif;
}
.craft-test-badge[hidden] { display: none; }
.craft-test-badge ion-icon { font-size: 14px; flex: 0 0 auto; }

.craft-sec {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 2px 8px;
    font: 700 14.5px Inter, sans-serif;
}
.craft-step {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 800 11px Inter, sans-serif;
    background: linear-gradient(180deg, #4aa8ff, #2a73e8);
    box-shadow: 0 0 8px rgba(60, 145, 255, 0.6);
}
.craft-sec-icon { font-size: 18px; color: #8fc4ff; }
.craft-clear, .craft-all, .craft-info {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    color: #59b2ff;
    font: 600 12.5px Inter, sans-serif;
    padding: 2px 0;
}
.craft-clear ion-icon { font-size: 14px; }
.craft-info { margin-left: 0; font-size: 19px; padding: 0; }
.craft-all {
    padding: 4px 10px;
    border-radius: 13px;
    border: 1px solid rgba(80, 160, 255, 0.45);
    color: #cfe6ff;
}
.craft-all:disabled { opacity: 0.4; }
.craft-all ion-icon { font-size: 13px; }

/* 10 slots, 2 rows of 5 */
.craft-slots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.cr-slot {
    position: relative;
    aspect-ratio: 1;
    border-radius: 14px;
    padding: 0;
    color: #cfe0ff;
}
.cr-slot.empty {
    border: 1.5px dashed rgba(130, 170, 255, 0.35);
    background: rgba(20, 30, 56, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}
.cr-slot.empty:active { background: rgba(40, 70, 130, 0.5); }
.cr-slot.filled {
    border: 1.5px solid rgba(170, 120, 255, 0.75);
    background: radial-gradient(circle at 50% 35%, rgba(130, 90, 255, 0.35), rgba(30, 20, 70, 0.7) 75%);
    box-shadow: 0 0 10px rgba(150, 100, 255, 0.4), inset 0 0 10px rgba(150, 100, 255, 0.2);
    animation: crPop 0.25s ease-out;
}
.cr-slot-img { position: absolute; left: 12%; top: 6%; width: 76%; height: 66%; object-fit: contain; }
.cr-slot-x {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 19px;
    height: 19px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: #2a2f4a;
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.cr-slot-price {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font: 700 10px Inter, sans-serif;
    font-variant-numeric: tabular-nums;
}
.cr-ton { width: 1em; height: 1em; vertical-align: -0.12em; margin-right: 0.18em; }
.cr-slot-price .cr-ton { width: 10px; height: 10px; margin: 0; }
@keyframes crPop { from { transform: scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }

.craft-summary {
    display: flex;
    align-items: center;
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--cr-card);
    border: 1px solid var(--cr-line);
}
.craft-sum-cell { flex: 1; display: flex; align-items: center; gap: 10px; }
.craft-sum-cell > ion-icon { font-size: 24px; color: #9fc3ff; }
.craft-sum-cell div { display: flex; flex-direction: column; gap: 2px; }
.craft-sum-cell small { color: #9aa9cc; font: 500 11px Inter, sans-serif; }
.craft-sum-cell span { display: flex; align-items: center; font: 700 16px Inter, sans-serif; font-variant-numeric: tabular-nums; }
.craft-count b { color: #59b2ff; }
.craft-sum-sep { width: 1px; height: 30px; background: var(--cr-line); margin: 0 12px; }

/* modes: three compact cards in a row */
.craft-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cr-mode {
    --c: var(--cr-normal);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 7px 4px 6px;
    border-radius: 14px;
    border: 1.5px solid color-mix(in srgb, var(--c) 35%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, #0b1430), #0a1226);
    color: var(--c);
    transition: box-shadow 0.2s, border-color 0.2s, transform 0.15s;
}
.cr-mode:active { transform: scale(0.97); }
.cr-mode:disabled { opacity: 0.35; }
.cr-mode ion-icon { font-size: 18px; }
.cr-mode-name { font: 800 11.5px Inter, sans-serif; letter-spacing: 0.5px; color: #e8f0ff; }
.cr-mode-mult { font: 800 20px/1.1 Inter, sans-serif; }
.cr-mode-safe { --c: var(--cr-safe); }
.cr-mode-normal { --c: var(--cr-normal); }
.cr-mode-risky { --c: var(--cr-risky); }
.cr-mode.active {
    border-color: var(--c);
    box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent), inset 0 0 12px color-mix(in srgb, var(--c) 25%, transparent);
}
.cr-c-safe { color: #34e08a; }
.cr-c-normal { color: #3db4ff; }
.cr-c-risky { color: #ff4d8d; }

.craft-maxbar {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 8px;
    padding: 9px 12px;
    border-radius: 14px;
    background: var(--cr-card);
    border: 1px solid var(--cr-line);
    font: 600 13px Inter, sans-serif;
    color: #dbe5ff;
}
.craft-maxbar > ion-icon { font-size: 20px; color: #9fc3ff; }
.craft-max { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.craft-max b { font: 800 17px Inter, sans-serif; color: #59b2ff; font-variant-numeric: tabular-nums; }
.craft-max .cr-ton { width: 15px; height: 15px; margin: 0; }
.cr-muted { color: #8494b8; font-weight: 500; font-size: 12.5px; }

.craft-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cr-top-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    border-radius: 14px;
    border: 1.5px solid rgba(170, 120, 255, 0.6);
    background: radial-gradient(circle at 50% 30%, rgba(130, 90, 255, 0.28), rgba(18, 16, 52, 0.85) 70%);
    box-shadow: 0 0 10px rgba(150, 100, 255, 0.25);
    min-width: 0;
    animation: crPop 0.25s ease-out;
}
.cr-top-img { width: 62px; height: 62px; object-fit: contain; }
.cr-top-name, .cr-top-model { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-top-name { margin-top: 4px; font: 700 12px Inter, sans-serif; }
.cr-top-model { font: 500 10.5px Inter, sans-serif; color: #9aa9cc; }
.cr-top-price { margin-top: 3px; display: flex; align-items: center; font: 800 13px Inter, sans-serif; }
.cr-top-price .cr-ton { width: 12px; height: 12px; }
.cr-top-empty {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 64px;
    padding: 12px;
    border-radius: 14px;
    border: 1px dashed rgba(120, 170, 255, 0.2);
    color: #8494b8;
    font: 500 13px/1.4 Inter, sans-serif;
    text-align: center;
}

.craft-go {
    width: 100%;
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border-radius: 22px;
    border: 1px solid rgba(170, 215, 255, 0.55);
    background: linear-gradient(180deg, #5db8ff 0%, #2f88f2 55%, #1d62d6 100%);
    box-shadow: 0 0 24px rgba(56, 148, 255, 0.55), 0 6px 18px rgba(0, 40, 120, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -3px 8px rgba(0, 30, 90, 0.25);
    color: #fff;
    font: 800 17px Inter, sans-serif;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 30, 80, 0.4);
    transition: filter 0.2s, opacity 0.2s, transform 0.15s;
}
.craft-go ion-icon { font-size: 22px; }
.craft-go:active { transform: scale(0.98); }
.craft-go:disabled { filter: grayscale(0.85) brightness(0.65); opacity: 0.75; box-shadow: none; }

.cr-dots::after { content: '…'; animation: crBlink 1s infinite; color: #8494b8; }
@keyframes crBlink { 50% { opacity: 0.3; } }

/* ---------- craft modals ---------- */
.cr-modal { position: fixed; inset: 0; z-index: 20000; display: flex; align-items: flex-end; justify-content: center; font-family: Inter, sans-serif; color: #fff; }
.cr-modal-bg { position: absolute; inset: 0; background: rgba(2, 5, 14, 0.7); opacity: 0; transition: opacity 0.2s; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.cr-modal-card {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: calc(var(--app-h, 100vh) * 0.86);
    overflow-y: auto;
    padding: 16px 16px calc(18px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    border-radius: 24px 24px 0 0;
    background: linear-gradient(180deg, #0f1a36 0%, #081024 100%);
    border: 1px solid rgba(110, 160, 255, 0.25);
    border-bottom: none;
    box-shadow: 0 -10px 40px rgba(30, 90, 220, 0.35);
    transform: translateY(100%);
    transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.cr-modal.full .cr-modal-card {
    height: calc(var(--app-h, 100vh) - var(--tg-safe-area-inset-top, 0px) - var(--tg-content-safe-area-inset-top, 0px) - 24px);
    max-height: none;
}
.cr-modal.open .cr-modal-bg { opacity: 1; }
.cr-modal.open .cr-modal-card { transform: none; }
.cr-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cr-modal-head h3 { margin: 0; font: 800 19px Inter, sans-serif; }
.cr-x {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cr-modal-sub { margin: -4px 0 12px; color: #9aa9cc; font-size: 13px; }
.cr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px;
    border-radius: 18px;
    border: 1px solid rgba(170, 215, 255, 0.5);
    background: linear-gradient(180deg, #5db8ff 0%, #2f88f2 55%, #1d62d6 100%);
    box-shadow: 0 0 16px rgba(56, 148, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    color: #fff;
    font: 700 15px Inter, sans-serif;
}
.cr-btn ion-icon { font-size: 18px; }
.cr-btn:disabled { filter: grayscale(0.9) brightness(0.6); box-shadow: none; }
.cr-btn-ghost { background: rgba(40, 60, 100, 0.45); border-color: rgba(120, 170, 255, 0.3); box-shadow: none; }
.cr-btn-test { margin-top: 18px; background: rgba(255, 196, 60, 0.12); border-color: rgba(255, 196, 60, 0.4); color: #ffd47a; box-shadow: none; }

/* inventory */
.cr-inv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding-bottom: 12px; }
.cr-inv-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-radius: 14px;
    border: 1.5px solid rgba(120, 170, 255, 0.18);
    background: rgba(20, 32, 62, 0.7);
    color: #fff;
    min-width: 0;
}
.cr-inv-item.on { border-color: #59b2ff; box-shadow: 0 0 12px rgba(70, 160, 255, 0.5); background: rgba(30, 60, 120, 0.6); }
.cr-inv-item:disabled { opacity: 0.4; }
.cr-inv-img { width: 64px; height: 64px; object-fit: contain; }
.cr-inv-name, .cr-inv-model { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-inv-name { margin-top: 4px; font: 700 12px Inter, sans-serif; }
.cr-inv-model { font: 500 10.5px Inter, sans-serif; color: #9aa9cc; }
.cr-inv-price { margin-top: 3px; display: flex; align-items: center; font: 700 12.5px Inter, sans-serif; }
.cr-inv-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: transparent;
}
.cr-inv-item.on .cr-inv-check { background: #2f88f2; border-color: #8cc8ff; color: #fff; }
.cr-inv-done { position: sticky; bottom: 0; }

/* empty inventory */
.cr-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.cr-empty p { margin: 0; color: #c4d0ee; font: 500 14px/1.45 Inter, sans-serif; }
.cr-empty small { font-size: 12px; }
.cr-empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #9fd0ff;
    background: radial-gradient(circle, rgba(80, 150, 255, 0.35), rgba(20, 40, 90, 0.5));
    border: 1px solid rgba(140, 190, 255, 0.4);
    box-shadow: 0 0 20px rgba(70, 150, 255, 0.4);
}
.cr-or { width: 100%; display: flex; align-items: center; gap: 10px; margin: 6px 0; color: #7d8db3; font-size: 12px; }
.cr-or::before, .cr-or::after { content: ''; flex: 1; height: 1px; background: rgba(120, 170, 255, 0.2); }

/* all rewards: header, two info cards, count + sort + view switch, then a grid (or list) */
.cr-all .cr-modal-card { padding-top: 14px; }
.cr-all-head h3 { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.cr-all-head h3 ion-icon { font-size: 24px; color: #4aa8ff; }
.cr-all-info { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cr-all-info > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 9px 14px 10px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(26, 42, 80, 0.75), rgba(14, 24, 50, 0.75));
    border: 1px solid rgba(110, 160, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.cr-all-info small { color: #a9b8dc; font-size: 12.5px; font-weight: 500; }
.cr-all-info b { display: flex; align-items: center; gap: 6px; font: 800 19px Inter, sans-serif; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cr-all-info b .cr-ton { width: 20px; height: 20px; margin: 0; }
.cr-all-info b ion-icon { font-size: 22px; }
.cr-all-bar { display: flex; align-items: center; gap: 8px; margin: 12px 0 10px; }
.cr-all-count { flex: 1; min-width: 0; display: flex; align-items: center; gap: 5px; color: #c4d0ee; font: 500 12.5px Inter, sans-serif; white-space: nowrap; overflow: hidden; }
.cr-all-count span { overflow: hidden; text-overflow: ellipsis; }
.cr-all-count ion-icon { font-size: 18px; flex: 0 0 auto; }
.cr-all-count b { color: #fff; font-weight: 800; }
.cr-all-sort {
    position: relative;
    display: flex;
    align-items: center;
    gap: 5px;
    height: 32px;
    padding: 0 8px 0 9px;
    border-radius: 11px;
    border: 1px solid rgba(110, 160, 255, 0.3);
    background: rgba(16, 26, 54, 0.8);
    color: #dfe8ff;
}
.cr-all-sort ion-icon { font-size: 15px; flex: 0 0 auto; }
.cr-all-sort select {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
    color: #dfe8ff;
    font: 600 12.5px Inter, sans-serif;
    padding: 0 18px 0 0;
    margin-right: -16px;
    outline: none;
}
.cr-all-sort .cr-all-caret { font-size: 13px; pointer-events: none; }
.cr-all-views { display: flex; padding: 2px; border-radius: 11px; border: 1px solid rgba(110, 160, 255, 0.3); background: rgba(16, 26, 54, 0.8); }
.cr-all-views button {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: #a9b8dc;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cr-all-views button.on {
    color: #fff;
    border-color: rgba(90, 170, 255, 0.8);
    background: linear-gradient(180deg, rgba(60, 140, 255, 0.45), rgba(30, 90, 210, 0.45));
    box-shadow: 0 0 10px rgba(60, 145, 255, 0.45);
}
.cr-all-list.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cr-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding: 8px 6px 7px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(24, 40, 82, 0.85), rgba(12, 22, 50, 0.85));
    border: 1px solid rgba(90, 150, 255, 0.35);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 0 10px rgba(50, 120, 255, 0.12);
    animation: crPop 0.2s ease-out;
}
.cr-tile-img { width: 70px; height: 70px; object-fit: contain; }
.cr-tile b, .cr-tile small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-tile b { margin-top: 4px; font: 800 12.5px Inter, sans-serif; }
.cr-tile small { color: #a9b8dc; font: 500 11px Inter, sans-serif; }
.cr-tile-price {
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 6px;
    padding: 4px 0;
    border-radius: 10px;
    background: rgba(10, 20, 46, 0.85);
    border: 1px solid rgba(90, 150, 255, 0.3);
    font: 800 13px Inter, sans-serif;
    font-variant-numeric: tabular-nums;
}
.cr-tile-price .cr-ton { width: 14px; height: 14px; margin-right: 4px; }
.cr-all-loader { grid-column: 1 / -1; display: flex; justify-content: center; padding: 14px 0 4px; }
.cr-all-loader[hidden] { display: none; }
.cr-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-bottom: 1px solid rgba(120, 170, 255, 0.08); }
.cr-row-img { width: 40px; height: 40px; flex: 0 0 40px; object-fit: contain; }
.cr-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cr-row-text b, .cr-row-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-row-text b { font-size: 13.5px; }
.cr-row-text small { color: #9aa9cc; font-size: 11.5px; }
.cr-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cr-row-right b { display: flex; align-items: center; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cr-row-right small { color: #59b2ff; font: 600 11.5px Inter, sans-serif; font-variant-numeric: tabular-nums; }
.cr-all-more { margin-top: 12px; }
.cr-all-more[hidden] { display: none; }

/* how it works */
.cr-how-steps { display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: 16px; background: rgba(20, 32, 62, 0.6); border: 1px solid rgba(120, 170, 255, 0.16); }
.cr-how-step { display: flex; gap: 12px; align-items: flex-start; }
.cr-how-n { width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font: 800 14px Inter, sans-serif; background: linear-gradient(180deg, #8c7bff, #5b4bdc); box-shadow: 0 0 10px rgba(130, 110, 255, 0.6); }
.cr-how-step b { font-size: 15px; }
.cr-how-step p { margin: 2px 0 0; color: #b9c6e6; font: 500 13px/1.4 Inter, sans-serif; }
.cr-how-h { margin: 16px 2px 10px; font: 800 16px Inter, sans-serif; }
.cr-how-mode { --c: #3db4ff; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 8px; padding: 11px 12px; border-radius: 16px; border: 1.5px solid color-mix(in srgb, var(--c) 55%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, #0b1430), #0a1226); box-shadow: 0 0 12px color-mix(in srgb, var(--c) 25%, transparent); }
.cr-how-mode.cr-mode-safe { --c: #34e08a; }
.cr-how-mode.cr-mode-risky { --c: #ff4d8d; }
.cr-how-mode-icon { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; background: var(--c); }
.cr-how-mode b { font-size: 16px; color: var(--c); }
.cr-how-mode b span { margin-left: 4px; }
.cr-how-mode p { margin: 3px 0 0; color: #c4d0ee; font: 500 12.5px/1.4 Inter, sans-serif; }
.cr-how-note { margin: 8px 2px 0; color: #8494b8; font: 500 12px/1.4 Inter, sans-serif; }

/* confirm */
.cr-confirm { display: flex; flex-direction: column; gap: 4px; }
.cr-confirm-gifts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 6px; }
.cr-confirm-img { width: 40px; height: 40px; object-fit: contain; padding: 3px; border-radius: 10px; background: rgba(130, 90, 255, 0.2); border: 1px solid rgba(170, 120, 255, 0.5); }
.cr-kv { display: flex; justify-content: space-between; align-items: center; padding: 7px 2px; border-bottom: 1px solid rgba(120, 170, 255, 0.08); font-size: 14px; color: #b9c6e6; }
.cr-kv b { display: flex; align-items: center; color: #fff; font-variant-numeric: tabular-nums; }
.cr-kv b.cr-c-risky { color: #ff4d8d; }
.cr-kv b.cr-c-safe { color: #34e08a; }
.cr-kv b.cr-c-normal { color: #3db4ff; }
.cr-warn { margin: 6px 0 0; padding: 8px 10px; border-radius: 10px; background: rgba(255, 77, 141, 0.08); border: 1px solid rgba(255, 77, 141, 0.25); color: #ffb3cd; font: 500 12.5px/1.4 Inter, sans-serif; }
.cr-warn-test { background: rgba(255, 196, 60, 0.08); border-color: rgba(255, 196, 60, 0.3); color: #ffd47a; }
.cr-confirm-btns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 10px; }

/* history */
.cr-hist { display: flex; flex-direction: column; gap: 8px; }
.cr-hist-item { padding: 10px 12px; border-radius: 14px; background: rgba(20, 32, 62, 0.7); border: 1px solid rgba(120, 170, 255, 0.16); }
.cr-hist-item.won { border-color: rgba(52, 224, 138, 0.35); }
.cr-hist-item.lost { border-color: rgba(255, 77, 141, 0.3); }
.cr-hist-top { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.cr-hist-date { color: #9aa9cc; }
.cr-hist-mode { font-weight: 800; }
.cr-hist-status { margin-left: auto; font-weight: 700; }
.cr-hist-item.won .cr-hist-status { color: #34e08a; }
.cr-hist-item.lost .cr-hist-status { color: #ff4d8d; }
.cr-hist-body { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cr-hist-col { flex: 1; min-width: 0; }
.cr-hist-col small { display: flex; align-items: center; color: #9aa9cc; font-size: 11.5px; }
.cr-hist-inputs { display: flex; flex-wrap: wrap; gap: 3px; margin: 5px 0 4px; }
.cr-hist-inputs img { width: 26px; height: 26px; object-fit: contain; }
.cr-hist-names { color: #7d8db3; font-size: 10.5px; line-height: 1.35; }
.cr-hist-arrow { color: #59b2ff; font-size: 16px; flex: 0 0 auto; }
.cr-hist-res { width: 92px; flex: 0 0 92px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 1px; }
.cr-hist-res > img { width: 44px; height: 44px; object-fit: contain; }
.cr-hist-res b { font-size: 11.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-hist-res small { color: #9aa9cc; font-size: 10.5px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-hist-res span { display: flex; align-items: center; font: 700 12px Inter, sans-serif; }
.cr-hist-none { color: #ff4d8d; font: 700 13px Inter, sans-serif; padding: 12px 0; }

/* ---------- craft animation: gifts fly into a glowing cube ---------- */
.cr-anim {
    position: fixed;
    inset: 0;
    z-index: 30000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 45%, rgba(30, 60, 160, 0.55), rgba(2, 4, 12, 0.96) 65%);
    opacity: 0;
    transition: opacity 0.25s;
    font-family: Inter, sans-serif;
    color: #fff;
}
.cr-anim.go { opacity: 1; }
.cr-anim.out { opacity: 0; }
.cr-anim-glow {
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(90, 170, 255, 0.45), transparent 65%);
    animation: crGlow 2.6s ease-in forwards;
}
@keyframes crGlow { 0% { transform: scale(0.6); opacity: 0.4; } 85% { transform: scale(1.3); opacity: 1; } 100% { transform: scale(1.6); opacity: 0.6; } }
.cr-anim-stage { position: relative; width: 300px; height: 300px; }
.cr-orb {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
    border-radius: 16px;
    padding: 5px;
    background: radial-gradient(circle, rgba(140, 100, 255, 0.45), rgba(30, 20, 80, 0.7));
    border: 1.5px solid rgba(180, 140, 255, 0.8);
    box-shadow: 0 0 14px rgba(150, 110, 255, 0.6);
    transform: translate(var(--x), var(--y)) scale(0.2);
    opacity: 0;
    animation: crOrbIn 0.4s ease-out var(--d) forwards, crOrbSuck 0.7s cubic-bezier(0.55, 0, 0.9, 0.4) calc(1.1s + var(--d) * 0.6) forwards;
}
.cr-orb img { width: 100%; height: 100%; object-fit: contain; }
@keyframes crOrbIn { to { transform: translate(var(--x), var(--y)) scale(1); opacity: 1; } }
@keyframes crOrbSuck { from { transform: translate(var(--x), var(--y)) scale(1) rotate(0); opacity: 1; } to { transform: translate(0, 0) scale(0.1) rotate(180deg); opacity: 0; } }
.cr-cube-wrap { position: absolute; left: 50%; top: 50%; width: 80px; height: 80px; margin: -40px 0 0 -40px; perspective: 500px; animation: crCubePulse 2.6s ease-in forwards; }
.cr-cube { position: absolute; inset: 0; transform-style: preserve-3d; animation: crSpin 2.2s linear infinite; }
.cr-cube i {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(150, 210, 255, 0.95);
    background: linear-gradient(135deg, rgba(80, 160, 255, 0.35), rgba(140, 90, 255, 0.3));
    box-shadow: 0 0 18px rgba(90, 170, 255, 0.8), inset 0 0 18px rgba(120, 190, 255, 0.6);
}
.cr-cube .f1 { transform: translateZ(40px); }
.cr-cube .f2 { transform: rotateY(180deg) translateZ(40px); }
.cr-cube .f3 { transform: rotateY(90deg) translateZ(40px); }
.cr-cube .f4 { transform: rotateY(-90deg) translateZ(40px); }
.cr-cube .f5 { transform: rotateX(90deg) translateZ(40px); }
.cr-cube .f6 { transform: rotateX(-90deg) translateZ(40px); }
@keyframes crSpin { from { transform: rotateX(-20deg) rotateY(0); } to { transform: rotateX(-20deg) rotateY(360deg); } }
@keyframes crCubePulse { 0% { transform: scale(0.6); } 60% { transform: scale(1); } 85% { transform: scale(1.25); filter: brightness(1.8); } 100% { transform: scale(1.1); filter: brightness(2.2); } }
.cr-flash { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border-radius: 50%; background: #fff; opacity: 0; }
.cr-anim.finish .cr-flash { animation: crFlash 0.6s ease-out forwards; }
@keyframes crFlash { 0% { opacity: 1; transform: scale(0.5); } 100% { opacity: 0; transform: scale(14); } }
.cr-anim.finish .cr-cube-wrap, .cr-anim.finish .cr-orb, .cr-anim.finish .cr-anim-label { opacity: 0; transition: opacity 0.2s; }
.cr-anim-label { margin-top: 18px; color: #bcd6ff; font: 600 15px Inter, sans-serif; animation: crBlink 1.2s infinite; }
.cr-result { position: absolute; left: 16px; right: 16px; top: 50%; transform: translateY(-50%); display: flex; justify-content: center; pointer-events: none; }
.cr-anim.finish .cr-result { pointer-events: auto; }
.cr-result-card {
    width: 100%;
    max-width: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px 18px 18px;
    border-radius: 24px;
    text-align: center;
    background: linear-gradient(180deg, rgba(25, 40, 90, 0.95), rgba(10, 16, 40, 0.97));
    border: 1.5px solid rgba(52, 224, 138, 0.6);
    box-shadow: 0 0 40px rgba(52, 224, 138, 0.35);
    animation: crResultIn 0.45s cubic-bezier(0.2, 1.3, 0.4, 1) 0.15s both;
}
.cr-result-card.lost { border-color: rgba(255, 77, 141, 0.55); box-shadow: 0 0 40px rgba(255, 77, 141, 0.3); }
@keyframes crResultIn { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
.cr-result-title { font: 800 22px Inter, sans-serif; color: #34e08a; margin-bottom: 6px; }
.cr-result-card.lost .cr-result-title { color: #ff4d8d; }
.cr-result-img { width: 130px; height: 130px; object-fit: contain; filter: drop-shadow(0 0 18px rgba(120, 190, 255, 0.6)); }
.cr-result-card b { font-size: 17px; margin-top: 4px; }
.cr-result-card small { color: #9aa9cc; font-size: 13px; }
.cr-result-price { display: flex; align-items: center; font: 800 20px Inter, sans-serif; margin-top: 4px; }
.cr-result-card p { margin: 6px 0 12px; color: #b9c6e6; font-size: 13px; }
.cr-result-broken { font-size: 70px; color: #ff4d8d; opacity: 0.8; filter: drop-shadow(0 0 14px rgba(255, 77, 141, 0.6)); }

/* ---------- LIVE strip: latest craft drops, newest slides in on the left ---------- */
.craft-live {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 2px;
    padding: 4px 6px 4px 10px;
    border-radius: 18px;
    border: 1px solid rgba(90, 220, 150, 0.35);
    background: linear-gradient(180deg, rgba(16, 30, 52, 0.9), rgba(10, 18, 38, 0.9));
    box-shadow: 0 0 14px rgba(60, 220, 140, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    color: #fff;
    overflow: hidden;
}
.craft-live-tag { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; font: 800 13px Inter, sans-serif; letter-spacing: 0.5px; }
.craft-live-tag i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #34e08a;
    box-shadow: 0 0 8px #34e08a;
    animation: clPulse 1.6s ease-in-out infinite;
}
@keyframes clPulse { 50% { opacity: 0.35; box-shadow: 0 0 2px #34e08a; } }
.craft-live-track {
    flex: 1;
    min-width: 0;
    height: 40px;
    display: flex;
    gap: 5px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
    mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.craft-live-more { flex: 0 0 auto; padding: 0 4px; font: 800 20px/1 Inter, sans-serif; color: #dfe8ff; }
.cl-tile {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    padding: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.18);
}
.cl-tile img { width: 100%; height: 100%; object-fit: contain; }
/* colour by value: blue < 40, purple < 200, red < 1000, gold above */
.cl-tile.t1 { background: linear-gradient(160deg, #2f7cf0, #1b4fb0); }
.cl-tile.t2 { background: linear-gradient(160deg, #8a4df0, #5a28b8); }
.cl-tile.t3 { background: linear-gradient(160deg, #f0446a, #a81f45); }
.cl-tile.t4 { background: linear-gradient(160deg, #f6c544, #c47f12); box-shadow: 0 0 10px rgba(246, 197, 68, 0.55); }
.cl-tile.in { animation: clIn 0.5s cubic-bezier(0.2, 1.3, 0.4, 1); }
@keyframes clIn {
    0% { flex-basis: 0; width: 0; opacity: 0; transform: scale(0.3) translateY(-12px); }
    60% { flex-basis: 40px; width: 40px; opacity: 1; }
    100% { transform: none; }
}
.cl-list .cl-tile { flex: 0 0 40px; }
.cl-ago { color: #8494b8 !important; font-weight: 500 !important; }

/* ---------- fit the whole craft page on one phone screen, also with gifts picked ----------
   The top-rewards row has the same height empty and filled, so nothing jumps when gifts are added. */
.craft-sec { margin: 10px 2px 7px; }
.craft-slots { gap: 6px; }
.craft-summary { margin-top: 7px; padding: 4px 12px; }
.craft-sum-cell > ion-icon { font-size: 21px; }
.craft-sum-cell span { font-size: 15px; }
.craft-sum-sep { height: 26px; }
.cr-mode { padding: 4px 4px 3px; gap: 0; }
.cr-mode ion-icon { font-size: 15px; }
.cr-mode-name { font-size: 11px; }
.cr-mode-mult { font-size: 18px; }
.craft-maxbar { margin-top: 6px; padding: 6px 12px; }
.craft-top { --cr-top-h: 84px; }
.cr-top-card { height: var(--cr-top-h); padding: 5px 6px; justify-content: center; }
.cr-top-img { width: 38px; height: 38px; }
.cr-top-name { margin-top: 2px; }
.cr-top-price { margin-top: 1px; }
.cr-top-empty { min-height: var(--cr-top-h); }
.craft-go { margin-top: 8px; padding: 10px; font-size: 16px; }

/* ---------- fill the whole screen like the upgrade page: the top-rewards row takes the spare
   height (bigger pictures on tall phones), small phones keep the compact look ---------- */
#craft-view .craft-scroll { display: flex; flex-direction: column; }
#craft-view .craft-scroll > * { flex: 0 0 auto; }
#craft-view .craft-top { flex: 1 1 84px; min-height: 84px; max-height: 170px; }
#craft-view .cr-top-card { height: auto; min-height: 0; overflow: hidden; }
#craft-view .cr-top-img { flex: 1 1 38px; min-height: 0; width: 100%; height: auto; max-height: 96px; }
#craft-view .cr-top-empty { min-height: 0; height: 100%; }
@media (min-height: 780px) {
    #craft-view .cr-top-name { font-size: 13px; }
    #craft-view .cr-top-price { font-size: 14px; }
}

/* every tab page (craft, upgrade, cases): the scrolling area starts at the title row and the title
   row stays put, so content never slides under the wallet when the page is scrolled */
.craft-view .craft-scroll { margin-top: var(--craft-top, 52px); height: calc(100% - var(--craft-top, 52px)); padding-top: 0; }
.craft-view .craft-head {
    position: sticky;
    top: 0;
    z-index: 5;
    box-sizing: content-box;
    padding-bottom: 6px;
    margin-bottom: -6px;
    background: linear-gradient(180deg, #050a18 75%, rgba(5, 10, 24, 0));
}

/* tab pages: the content fades out into a dark band under the floating menu, so the menu
   sits on the page instead of hanging over scrolled cards */
.craft-view::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--nav-float) + var(--nav-gap) + 14px + var(--tg-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
    background: linear-gradient(180deg, rgba(4, 8, 20, 0) 0%, rgba(4, 8, 20, 0.88) 22%, #040814 50%);
    pointer-events: none;
    z-index: 4;
}
body.tab-craft .bottom-nav { background: rgba(16, 24, 42, 0.92); }

.craft-logo-svg { width: 22px; height: 22px; }

/* title row without the dark band: it sits above the scrolling area (not inside it), so scrolled
   content simply ends at the top edge of that area and never slides under the title */
.craft-view .craft-head {
    position: absolute;
    top: var(--craft-top, 52px);
    left: 12px;
    right: 12px;
    z-index: 6;
    margin: 0;
    padding-bottom: 0;
    background: none;
}
.craft-view .craft-scroll {
    margin-top: calc(var(--craft-top, 52px) + var(--craft-head-h, 38px) + 2px);
    height: calc(100% - var(--craft-top, 52px) - var(--craft-head-h, 38px) - 2px);
}
