/* ── Shared chest column layout ── */
.chest {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.chest:hover {
    transform: scale(1.05);
}

/* Chest image fills its column */
.chest-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

/* No dim overlay behind either popup — backdrop disabled in JS */
#treasurechestModal,
#grandChestModal {
    background: transparent;
}

/* ── Normal chest modal — 525px wide, 80vw on small screens ── */
#treasurechestModal .modal-dialog {
    max-width: 525px;
    width: 525px;
    margin: 5vh auto;
}

@media (max-width: 650px) {
    #treasurechestModal .modal-dialog {
        max-width: 80vw;
        width: 80vw;
    }
}

#treasurechestModal .modal-content {
    background-color: #000000 !important;
    border: 1px solid #ffd700 !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    max-height: 90vh;
    overflow-y: auto;
}

#treasurechestModal .modal-header {
    border-bottom: 1px solid #ffd700 !important;
    background-color: #000000 !important;
    border-radius: 7px 7px 0 0;
}

#treasurechestModal .modal-title {
    color: #ffffff !important;
}

#treasurechestModal .close {
    color: #ffffff !important;
    text-shadow: none;
    opacity: 0.8;
}

#treasurechestModal .modal-body {
    background-color: #000000 !important;
    border-radius: 0 0 7px 7px;
    color: #ffffff !important;
}

#treasurechestModal .chests {
    align-items: stretch;
    gap: 1rem;
}

/* Revealed reward — centred flex column, same width as chest image */
#treasurechestModal .revealed-reward {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

#treasurechestModal .revealed-reward img {
    display: block;
    margin-bottom: 0.4rem;
}

/* ── Grand Chest Modal — gold pulsating aura ── */
@keyframes grand-chest-aura {
    0%   {
        box-shadow:
            0 0  8px  3px  rgba(255, 215,   0, 0.80),
            0 0 20px  8px  rgba(255, 165,   0, 0.55),
            0 0 40px 14px  rgba(255, 215,   0, 0.25);
    }
    50%  {
        box-shadow:
            0 0 18px  7px  rgba(255, 215,   0, 1.00),
            0 0 40px 18px  rgba(255, 165,   0, 0.75),
            0 0 75px 30px  rgba(255, 215,   0, 0.40);
    }
    100% {
        box-shadow:
            0 0  8px  3px  rgba(255, 215,   0, 0.80),
            0 0 20px  8px  rgba(255, 165,   0, 0.55),
            0 0 40px 14px  rgba(255, 215,   0, 0.25);
    }
}

/* Modal dialog — 525px wide, 80vw on small screens, height grows to fit but caps at 90 vh */
#grandChestModal .modal-dialog {
    max-width: 525px;
    width: 525px;
    margin: 5vh auto;
}

@media (max-width: 650px) {
    #grandChestModal .modal-dialog {
        max-width: 80vw;
        width: 80vw;
    }
}

#grandChestModal .modal-content {
    border: 1px solid #ffd700 !important;
    border-radius: 14px !important;
    background-color: #000000 !important;
    color: #ffffff !important;
    animation: grand-chest-aura 2s ease-in-out infinite;
    max-height: 90vh;
    overflow-y: auto;
}

#grandChestModal .modal-header {
    border-bottom: 1px solid #ffd700 !important;
    background-color: #000000 !important;
    border-radius: 12px 12px 0 0;
}

#grandChestModal .modal-title {
    color: #ffd700 !important;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
}

#grandChestModal .close {
    color: #ffd700 !important;
    text-shadow: none;
    opacity: 0.8;
}

#grandChestModal .modal-body {
    background-color: #000000 !important;
    border-radius: 0 0 12px 12px;
    padding: 1.5rem;
    color: #ffffff !important;
}

/* Three chests side by side, each taking equal space */
#grandChestModal .chests {
    align-items: stretch;
    gap: 1rem;
}

#grandChestModal .grand-chest {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease;
}

#grandChestModal .grand-chest:hover {
    transform: scale(1.05);
}

/* Chest image fills its column */
#grandChestModal .grand-chest-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
}

/* Revealed reward — centred flex column, same width as chest image */
#grandChestModal .revealed-reward {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
}

#grandChestModal .revealed-reward img {
    display: block;
    margin-bottom: 0.4rem;
}

/* Peeked (greyed-out) reward — same centred layout */
#grandChestModal .peeked-reward {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-align: center;
    opacity: 0.4;
    filter: grayscale(100%);
}

#grandChestModal .peeked-reward img {
    display: block;
    margin-bottom: 0.4rem;
}

/* ── Stash Bar ── */
/*
 * Default: position:sticky inside .main-inner-wrapper.
 * The sticky element lives in the document flow — content renders below it
 * naturally, drawers are never covered, no spacer/padding hacks needed.
 * JS overrides position to "fixed" when the student drags the bar free.
 */
#tc-stash-bar {
    position: sticky;
    top: 0;             /* JS overwrites with actual navbar height                 */
    z-index: 1029;
    background: #000000;
    border-top: 1px solid #ffd700;
    border-bottom: 2px solid #ffd700;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

/* ── Collapsible content row ── */
.tc-stash-bar-inner {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0 14px 0 0;  /* right pad; left spacing comes from the ☰ drag handle */
    gap: 12px;
    min-width: 0;
    max-height: 120px;    /* JS animates between 0 and 120px for collapse/expand   */
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

/* ── ☰ Drag handle (injected by JS as first item in inner row) ── */
.tc-stash-drag-handle {
    flex-shrink: 0;
    padding: 0 8px 0 12px;
    color: rgba(255, 215, 0, 0.55);
    font-size: 1rem;
    line-height: 1;
    cursor: grab;
    user-select: none;
    touch-action: none;  /* prevent page scroll while dragging on touch screens    */
}
.tc-stash-drag-handle:active {
    cursor: grabbing;
}

/* ── ▲/▼ Toggle row (injected by JS, always visible, never clipped) ── */
/*    Inline in the bar's normal flow — visible on all screen sizes.    */
.tc-stash-toggle-row {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
    border-top: 1px solid rgba(255, 215, 0, 0.22);
    flex-shrink: 0;
    cursor: pointer;
}
.tc-stash-toggle-tab {
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 0.6rem;
    letter-spacing: 3px;
    padding: 2px 50px 3px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s ease;
    line-height: 1.4;
}
.tc-stash-toggle-tab:hover,
.tc-stash-toggle-row:hover .tc-stash-toggle-tab {
    background: rgba(255, 215, 0, 0.12);
}

.tc-stash-bar-label {
    color: #ffd700;
    font-weight: 700;
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.5px;
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.5);
}

.tc-stash-items-scroll {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;  /* smooth momentum scroll on iOS            */
    flex: 1 1 0;
    min-width: 0;
    padding: 2px 0 6px;               /* extra bottom room so scrollbar shows      */
    scrollbar-width: thin;
    scrollbar-color: #ffd700 #2d1f00;
}

/* ── Mobile: hide the label text so items get maximum scroll space ── */
@media (max-width: 540px) {
    .tc-stash-bar-label {
        display: none;
    }
}

.tc-stash-items-scroll::-webkit-scrollbar {
    height: 3px;
}

.tc-stash-items-scroll::-webkit-scrollbar-track {
    background: #2d1f00;
}

.tc-stash-items-scroll::-webkit-scrollbar-thumb {
    background: #ffd700;
    border-radius: 2px;
}

.tc-stash-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
    min-width: 46px;
    max-width: 56px;
    position: relative;
    cursor: default;
}

.tc-stash-item-img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
}

.tc-stash-item-qty {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ffd700;
    color: #1a1100;
    font-size: 0.55rem;
    font-weight: 700;
    border-radius: 7px;
    padding: 0 3px;
    line-height: 1.5;
    min-width: 14px;
    text-align: center;
}

.tc-stash-item-name {
    font-size: 0.58rem;
    color: #f0e0a0;
    text-align: center;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 1px;
}

.tc-stash-bar-empty {
    color: #7a6030;
    font-size: 0.78rem;
    font-style: italic;
    white-space: nowrap;
}

/* ── Reward flight animation ── */
.tc-flying-reward {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.9));
    /* width and height are set dynamically by JS */
}

.tc-flying-reward img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tc-reward-star {
    position: fixed;
    z-index: 10001;
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

.tc-qty-increase {
    position: fixed;
    z-index: 10002;
    font-size: 1rem;
    font-weight: 700;
    color: #ffd700;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.9);
    pointer-events: none;
    user-select: none;
}

@keyframes tc-item-pulse {
    0%   { transform: scale(1);    filter: brightness(1); }
    40%  { transform: scale(1.4);  filter: brightness(1.8) drop-shadow(0 0 8px #ffd700); }
    100% { transform: scale(1);    filter: brightness(1); }
}

.tc-stash-item-pulse {
    animation: tc-item-pulse 0.7s ease-out forwards;
}

@keyframes tc-label-pulse {
    0%   { text-shadow: 0 0 6px rgba(255, 215, 0, 0.5); }
    50%  { text-shadow: 0 0 24px rgba(255, 215, 0, 1.0); }
    100% { text-shadow: 0 0 6px rgba(255, 215, 0, 0.5); }
}

.tc-stash-label-pulse {
    animation: tc-label-pulse 0.9s ease-in-out forwards;
}
