/* Chest Screen */
#chest-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 360; /* Above upgrade (350) and Svelte HUD (300) */
    color: white;
    pointer-events: auto;
    touch-action: manipulation;
}

#chest-screen.hidden {
    display: none !important;
    pointer-events: none !important;
}

#chest-container {
    background-color: #1a1a1a;
    border: 2px solid #ffd700; /* Gold border */
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    width: 80%;
    max-width: 500px;
    max-height: 92vh; /* ensure it doesn't overflow tall/narrow screens */
    box-sizing: border-box; /* include padding in size */
    overflow-y: auto; /* allow internal scroll when content is large */
    box-shadow: 0 0 30px rgba(255, 223, 0, 0.5);
}

#chest-container h2 {
    margin-top: 0;
    color: #ffd700;
    text-shadow: 0 0 10px #ffd700;
}

#chest-options {
    margin: 20px 0;
}

#chest-options button {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    border: 2px solid #ffd700;
    background-color: #332e00;
    color: #ffd700;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    text-align: center;
}

#chest-options button:hover {
    background-color: #ffd700;
    color: #1a1a1a;
}

#chest-options button img {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
}

#chest-options button .upgrade-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

#chest-options button h3 {
    margin: 0;
    font-size: 1.2em;
}

#chest-options button p {
    margin: 0;
    font-size: 0.9em;
    opacity: 0.8;
}

#chest-upgrade-gear-button {
    width: 70%;
    max-width: 300px;
    padding: 15px;
    margin: 20px auto 0;
    border: 2px solid #aaa;
    background-color: transparent;
    color: #aaa;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
    display: block;
}

#chest-upgrade-gear-button:hover {
    background-color: #aaa;
    color: #1a1a1a;
    border-color: #aaa;
}

/* Phase 2b — free weapon offers */
#chest-options button.chest-offer-free {
    border-color: #00ffcc !important;
    background-color: rgba(0, 40, 36, 0.9) !important;
    color: #00ffcc !important;
    box-shadow: 0 0 12px rgba(0, 255, 204, 0.25);
}

#chest-options button.chest-offer-free:hover {
    background-color: rgba(0, 255, 204, 0.25) !important;
    color: #e8fffa !important;
}

/* Phase 4 — UNIQUE shop stock */
#chest-options button.chest-offer-unique {
    border-color: #ffd700 !important;
    background: linear-gradient(160deg, rgba(40, 32, 0, 0.95), rgba(20, 16, 0, 0.92)) !important;
    color: #ffe566 !important;
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.35), inset 0 0 20px rgba(255, 215, 0, 0.06);
    position: relative;
}

#chest-options button.chest-offer-unique:hover {
    background: linear-gradient(160deg, rgba(70, 55, 0, 0.98), rgba(30, 24, 0, 0.95)) !important;
    color: #fff8c8 !important;
    box-shadow: 0 0 22px rgba(255, 215, 0, 0.5);
}

#chest-options button.chest-offer-unique .unique-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.55em;
    font-weight: 900;
    letter-spacing: 0.08em;
    vertical-align: middle;
    background: #ffd700;
    color: #1a1200;
}

#chest-options button.chest-offer-unique[data-unique-rarity="legendary"] {
    border-color: #ffea80 !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.55), inset 0 0 24px rgba(255, 180, 0, 0.1);
}

#chest-options button.chest-offer-unique[data-unique-rarity="rare"] {
    border-color: #66ddff !important;
    box-shadow: 0 0 14px rgba(51, 204, 255, 0.4);
}

/* Phase 2 — shop reroll token + close row */
.chest-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
    width: 100%;
}

.chest-reroll-btn {
    width: 100%;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px !important;
    border: 2px solid rgba(0, 255, 204, 0.65) !important;
    background: rgba(0, 40, 36, 0.85) !important;
    color: #00ffcc !important;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
}

.chest-reroll-btn:hover:not(:disabled) {
    background: rgba(0, 255, 204, 0.2) !important;
    color: #e8fffa !important;
}

.chest-reroll-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: #555 !important;
    color: #8a99a8 !important;
}

.chest-reroll-icon {
    font-size: 1.1rem;
    font-weight: 800;
}

.chest-reroll-count {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.9;
}

.chest-close-btn {
    width: 100%;
    padding: 10px 16px !important;
    border: 2px solid #555 !important;
    background: transparent !important;
    color: #aaa !important;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
}

.chest-close-btn:hover {
    border-color: #ffd700 !important;
    color: #ffd700 !important;
}