/* ===== TREASURE HUNT - FINANCIAL GRADE UI ===== */

/* CSS Variables */
:root {
    /* Profit/Success Colors */
    --profit-primary: #10B981;
    --profit-light: #D1FAE5;
    --profit-dark: #065F46;
    
    /* Loss/Failure Colors */
    --loss-primary: #EF4444;
    --loss-light: #FEE2E2;
    --loss-dark: #991B1B;
    
    /* Dark Theme */
    --dark-bg: #0F172A;
    --dark-card: #1E293B;
    --dark-border: #334155;
    --dark-text: #F8FAFC;
    --dark-muted: #94A3B8;
    
    /* Casino Gold */
    --casino-gold: #FFD700;
    --casino-gold-light: #FFF4B8;
    --casino-gold-dark: #B8860B;
    
    /* Tier Colors */
    --tier-iron: #B45309;
    --tier-silver: #94A3B8;
    --tier-gold: #FFD700;
}

/* ===== ANIMATED BACKGROUND ===== */
.particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.particles-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(255, 215, 0, 0.15), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(255, 68, 68, 0.1), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 215, 0, 0.1), transparent),
        radial-gradient(1px 1px at 80% 10%, rgba(16, 185, 129, 0.1), transparent);
    background-size: 200% 200%;
    animation: particleFloat 20s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% { background-position: 0% 0%, 100% 100%, 50% 50%, 80% 10%; }
    25% { background-position: 100% 0%, 0% 100%, 30% 70%, 60% 30%; }
    50% { background-position: 100% 100%, 0% 0%, 70% 30%, 40% 50%; }
    75% { background-position: 0% 100%, 100% 0%, 50% 50%, 80% 70%; }
}

/* ===== REWARD DISPLAY CARD ===== */
.reward-display-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 
        0 0 40px rgba(255, 215, 0, 0.15),
        inset 0 0 20px rgba(255, 215, 0, 0.05);
    animation: rewardPulse 3s ease-in-out infinite;
}

@keyframes rewardPulse {
    0%, 100% { 
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.15), inset 0 0 20px rgba(255, 215, 0, 0.05);
        border-color: rgba(255, 215, 0, 0.3);
    }
    50% { 
        box-shadow: 0 0 60px rgba(255, 215, 0, 0.25), inset 0 0 30px rgba(255, 215, 0, 0.1);
        border-color: rgba(255, 215, 0, 0.5);
    }
}

.reward-amount {
    font-family: 'Orbitron', 'JetBrains Mono', monospace;
    font-size: clamp(3rem, 10vw, 5rem);
    font-weight: 900;
    background: linear-gradient(180deg, var(--casino-gold-light) 0%, var(--casino-gold) 50%, var(--casino-gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 40px rgba(255, 215, 0, 0.4);
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.reward-amount.changing {
    animation: rewardChange 0.6s ease-out;
}

@keyframes rewardChange {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.5); }
    100% { transform: scale(1); filter: brightness(1); }
}

/* ===== TIER CARDS ===== */
.tier-card {
    background: rgba(30, 41, 59, 0.6);
    border: 2px solid var(--dark-border);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.tier-card:hover {
    transform: translateY(-4px);
}

.tier-card.active {
    transform: scale(1.02);
}

/* Iron Tier */
.tier-card.iron {
    border-color: rgba(180, 83, 9, 0.3);
}
.tier-card.iron:hover,
.tier-card.iron.active {
    border-color: var(--tier-iron);
    box-shadow: 0 10px 40px rgba(180, 83, 9, 0.2);
}

/* Silver Tier */
.tier-card.silver {
    border-color: rgba(148, 163, 184, 0.3);
}
.tier-card.silver:hover,
.tier-card.silver.active {
    border-color: var(--tier-silver);
    box-shadow: 0 10px 40px rgba(148, 163, 184, 0.2);
}

/* Gold Tier */
.tier-card.gold {
    border-color: rgba(255, 215, 0, 0.3);
}
.tier-card.gold:hover,
.tier-card.gold.active {
    border-color: var(--tier-gold);
    box-shadow: 0 10px 40px rgba(255, 215, 0, 0.25);
}

.tier-card.featured {
    transform: scale(1.02);
}

.tier-badge {
    position: absolute;
    top: -1px;
    right: -1px;
    background: linear-gradient(135deg, var(--loss-primary) 0%, #DC2626 100%);
    color: white;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 4px 12px;
    border-radius: 0 16px 0 16px;
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tier-header {
    padding: 1.5rem 1rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tier-body {
    padding: 0 1rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tier-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tier-stat:last-of-type {
    border-bottom: none;
}

.tier-stat .label {
    color: var(--dark-muted);
    font-size: 0.875rem;
}

.tier-stat .value {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 1.1rem;
}

.tier-stat.highlight .value {
    font-size: 1.25rem;
}

.tier-footer {
    padding-top: 0.75rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* ===== REWARD PROGRESS ===== */
.reward-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.progress-item {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--dark-border);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    text-align: center;
    min-width: 70px;
}

.progress-item .level {
    display: block;
    font-size: 0.65rem;
    color: var(--dark-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.progress-item .amount {
    display: block;
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    color: var(--casino-gold);
    font-size: 0.9rem;
}

.progress-item.final {
    border-color: var(--profit-primary);
    background: rgba(16, 185, 129, 0.1);
}

.progress-item.final .amount {
    color: var(--profit-primary);
}

/* ===== DUAL ACTION BUTTONS ===== */
.dual-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .dual-actions {
        grid-template-columns: 1fr 1fr;
    }
}

.btn-take,
.btn-challenge {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 16px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}

/* Take Button - Green */
.btn-take {
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.4) 0%, rgba(16, 185, 129, 0.2) 100%);
    border-color: rgba(16, 185, 129, 0.4);
}

.btn-take:hover {
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.5) 0%, rgba(16, 185, 129, 0.3) 100%);
    border-color: var(--profit-primary);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.25);
    transform: translateY(-2px);
}

.btn-take .btn-icon {
    color: var(--profit-primary);
}

/* Challenge Button - Red */
.btn-challenge {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.4) 0%, rgba(239, 68, 68, 0.2) 100%);
    border-color: rgba(239, 68, 68, 0.4);
}

.btn-challenge:hover {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.5) 0%, rgba(239, 68, 68, 0.3) 100%);
    border-color: var(--loss-primary);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.25);
    transform: translateY(-2px);
}

.btn-challenge .btn-icon {
    color: var(--loss-primary);
}

.btn-icon {
    flex-shrink: 0;
}

.btn-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.btn-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--dark-text);
}

.btn-subtitle {
    font-size: 0.875rem;
    color: var(--dark-muted);
}

/* ===== LEVEL PROGRESS ===== */
.level-progress {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.progress-dot.active {
    background: var(--casino-gold);
    border-color: var(--casino-gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.progress-dot.completed {
    background: var(--profit-primary);
    border-color: var(--profit-primary);
}

.progress-line {
    width: 40px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
}

/* ===== CHESTS CONTAINER ===== */
.chests-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    min-height: 180px;
    margin-bottom: 2rem;
    padding: 1rem;
}

/* ===== TREASURE CHEST ===== */
.treasure-chest {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, #8B4513 0%, #D2691E 50%, #8B4513 100%);
    border: 3px solid var(--casino-gold);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.treasure-chest::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--casino-gold) 0%, transparent 50%, var(--casino-gold) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.treasure-chest:hover::before {
    opacity: 0.5;
}

.treasure-chest:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 12px 40px rgba(255, 215, 0, 0.25);
    border-color: var(--casino-gold-light);
}

.treasure-chest.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.treasure-chest.disabled:hover {
    transform: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.treasure-chest .chest-number {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 28px;
    height: 28px;
    background: var(--casino-gold);
    color: var(--dark-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 0.875rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    font-family: 'Orbitron', monospace;
}

/* Chest States */
.treasure-chest.opening {
    animation: chestShake 0.6s ease-in-out;
}

/* Player's Choice Marker */
.treasure-chest.player-choice {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), inset 0 0 20px rgba(255, 215, 0, 0.3);
    transform: scale(1.1);
    z-index: 10;
}

.treasure-chest.player-choice.success {
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.8), inset 0 0 30px rgba(16, 185, 129, 0.4);
}

.treasure-chest.player-choice.fail {
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.8), inset 0 0 30px rgba(239, 68, 68, 0.4);
}

/* Other Chests Reveal */
.treasure-chest.was-winning {
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.3) 0%, rgba(16, 185, 129, 0.2) 100%);
    border-color: var(--profit-primary);
    opacity: 0.8;
}

.treasure-chest.was-empty {
    background: linear-gradient(135deg, rgba(71, 85, 105, 0.3) 0%, rgba(100, 116, 139, 0.2) 100%);
    border-color: var(--dark-border);
    opacity: 0.6;
}

.treasure-chest.was-winning::after,
.treasure-chest.was-empty::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    animation: chestReveal 0.5s ease;
}

@keyframes chestReveal {
    0% { 
        transform: scale(0.8); 
        opacity: 0;
        background: rgba(255, 255, 255, 0.2);
    }
    50% { 
        transform: scale(1.05); 
        background: rgba(255, 255, 255, 0.1);
    }
    100% { 
        transform: scale(1); 
        opacity: 1;
        background: transparent;
    }
}

/* "You Missed This" Label for winning chests */
.treasure-chest.was-winning::before {
    content: '中獎!';
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--profit-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    animation: labelPop 0.3s ease 0.5s both;
}

@keyframes labelPop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    80% { transform: translateX(-50%) scale(1.2); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes chestShake {
    0%, 100% { transform: rotate(0deg); }
    15% { transform: rotate(-12deg); }
    30% { transform: rotate(12deg); }
    45% { transform: rotate(-8deg); }
    60% { transform: rotate(8deg); }
    75% { transform: rotate(-4deg); }
    90% { transform: rotate(4deg); }
}

.treasure-chest.success {
    background: linear-gradient(135deg, #065F46 0%, #10B981 50%, #065F46 100%);
    border-color: var(--profit-primary);
    animation: chestSuccess 0.5s ease;
}

@keyframes chestSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 60px rgba(16, 185, 129, 0.6); }
    100% { transform: scale(1); }
}

.treasure-chest.fail {
    background: linear-gradient(135deg, #7F1D1D 0%, #991B1B 50%, #7F1D1D 100%);
    border-color: var(--loss-primary);
    animation: chestFail 0.5s ease;
}

@keyframes chestFail {
    0% { transform: translateX(0); }
    25% { transform: translateX(-12px); }
    50% { transform: translateX(12px); }
    75% { transform: translateX(-6px); }
    100% { transform: translateX(0); }
}

/* ===== CHEST RESULT DISPLAY ===== */
.chest-result {
    margin: 2rem 0;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    animation: resultFadeIn 0.6s ease;
}

.chest-result.win {
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.3) 0%, rgba(16, 185, 129, 0.15) 100%);
    border: 2px solid var(--profit-primary);
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.2);
}

.chest-result.lose {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.3) 0%, rgba(239, 68, 68, 0.15) 100%);
    border: 2px solid var(--loss-primary);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.2);
}

.result-reveal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.result-icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: iconPop 0.5s ease;
}

.chest-result.win .result-icon-wrapper {
    background: linear-gradient(135deg, var(--profit-primary) 0%, var(--profit-dark) 100%);
    box-shadow: 0 0 30px rgba(16, 185, 129, 0.5);
}

.chest-result.lose .result-icon-wrapper {
    background: linear-gradient(135deg, var(--loss-primary) 0%, var(--loss-dark) 100%);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
}

.result-icon-wrapper svg {
    color: white;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@keyframes iconPop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-title {
    font-size: 1.75rem;
    font-weight: 900;
    margin: 0;
}

.chest-result.win .result-title {
    color: var(--profit-primary);
}

.chest-result.lose .result-title {
    color: var(--loss-primary);
}

.result-desc {
    color: var(--dark-muted);
    font-size: 0.9375rem;
    margin: 0;
    white-space: pre-line;
    line-height: 1.6;
}

.result-reward {
    margin-top: 0.5rem;
    padding: 1rem 2rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.reward-label {
    font-size: 0.75rem;
    color: var(--dark-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.reward-value {
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--casino-gold);
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.reward-unit {
    font-size: 0.875rem;
    color: var(--dark-muted);
}

/* ===== RESULT SCREEN ===== */
.result-success {
    border-color: var(--profit-primary);
    background: linear-gradient(135deg, rgba(6, 95, 70, 0.2) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.result-fail {
    border-color: var(--loss-primary);
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-title {
    font-size: 1.75rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

.result-title.win {
    color: var(--profit-primary);
}

.result-title.lose {
    color: var(--loss-primary);
}

.result-amount {
    font-family: 'Orbitron', monospace;
    font-size: 3rem;
    font-weight: 900;
    color: var(--casino-gold);
    margin: 1rem 0;
}

.result-message {
    color: var(--dark-muted);
    font-size: 0.9375rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* ===== HISTORY ===== */
.history-list {
    max-height: 300px;
    overflow-y: auto;
    space-y: 0.5rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-item .info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.history-item .tier {
    color: var(--casino-gold);
    font-weight: 700;
    font-size: 0.875rem;
}

.history-item .time {
    color: var(--dark-muted);
    font-size: 0.75rem;
}

.history-item .result {
    text-align: right;
}

.history-item .amount {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 1rem;
}

.history-item .amount.win {
    color: var(--profit-primary);
}

.history-item .amount.lose {
    color: var(--loss-primary);
}

.history-item .status {
    font-size: 0.75rem;
    color: var(--dark-muted);
}

/* ===== PARTICLE EFFECTS ===== */
.coin-particle {
    position: fixed;
    font-size: 1.5rem;
    pointer-events: none;
    z-index: 1000;
    animation: coinFloat 1s ease-out forwards;
}

@keyframes coinFloat {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-120px) rotate(720deg) scale(0.5);
    }
}

.dust-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    background: var(--dark-muted);
    border-radius: 50%;
    pointer-events: none;
    z-index: 1000;
    animation: dustFade 0.8s ease-out forwards;
}

@keyframes dustFade {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0) translateY(30px);
    }
}

/* ===== UTILITY ===== */
.hidden {
    display: none !important;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
    .reward-amount {
        font-size: 2.5rem;
    }
    
    .treasure-chest {
        width: 75px;
        height: 75px;
    }
    
    .chests-container {
        gap: 0.75rem;
    }
    
    .reward-progress {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .reward-progress svg {
        transform: rotate(90deg);
    }
}
