/* =========================================================================
   COSMIC MINES GAME, HUD, 3D TILES, PIXEL-PERFECT GRID ALIGNED CONTROLS (60FPS)
   ========================================================================= */

/* --- SUBGAME MINES WRAPPER & BALANCED VIEWPORT --- */
.mines-screen-wrapper {
    background: #080a18 !important;
    background-image: 
        radial-gradient(circle at 50% 15%, rgba(168, 85, 247, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 50% 85%, rgba(0, 210, 255, 0.1) 0%, transparent 60%) !important;
    padding-top: 54px !important;
    padding-bottom: 80px !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    box-sizing: border-box;
    height: 100%;
}

/* --- MINES TOP NAV BAR --- */
.mines-top-nav-bar {
    width: 92%;
    max-width: 360px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 32px;
    flex-shrink: 0;
}

.mines-header-title {
    font-size: 16px;
    font-weight: 900;
    color: #c084fc;
    text-shadow: 0 0 16px rgba(168, 85, 247, 0.8);
    letter-spacing: 1.2px;
}

/* --- KEYFRAME ANIMATIONS --- */
@keyframes mineFlipOpen {
    0% { transform: perspective(400px) rotateY(0deg) scale(0.95); }
    50% { transform: perspective(400px) rotateY(90deg) scale(1.1); }
    100% { transform: perspective(400px) rotateY(0deg) scale(1); }
}

@keyframes mineBlackholeSpin {
    0% { transform: rotate(0deg) scale(0.85); }
    50% { transform: rotate(180deg) scale(1.15); filter: drop-shadow(0 0 14px #ef4444); }
    100% { transform: rotate(360deg) scale(0.85); }
}

@keyframes mineBlackholePulseExpandShrink {
    0% { transform: scale(0.2) rotate(0deg); opacity: 0; filter: drop-shadow(0 0 0px #ef4444); }
    35% { transform: scale(4.5) rotate(360deg); opacity: 1; filter: drop-shadow(0 0 35px #ef4444); }
    60% { transform: scale(5.2) rotate(540deg); opacity: 0.9; filter: drop-shadow(0 0 50px #a855f7); }
    100% { transform: scale(0) rotate(900deg); opacity: 0; filter: drop-shadow(0 0 0px #ef4444); }
}

@keyframes cellAbsorbAndRestore {
    0% { transform: scale(1) rotate(0deg); opacity: 1; filter: none; }
    40% { transform: scale(0.15) rotate(-45deg); opacity: 0.2; filter: blur(4px); }
    65% { transform: scale(0.15) rotate(-45deg); opacity: 0.2; filter: blur(4px); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; filter: none; }
}

@keyframes minePreviewBlackholeAbsorb {
    0% { transform: scale(0.85) rotate(0deg); opacity: 0.6; filter: drop-shadow(0 0 4px #ef4444); }
    30% { transform: scale(1.0) rotate(120deg); opacity: 1; filter: drop-shadow(0 0 8px #ef4444); }
    100% { transform: scale(2.8) rotate(360deg); opacity: 1; filter: drop-shadow(0 0 18px #ef4444); }
}

@keyframes minesGridShake {
    0%, 100% { transform: translate(0, 0); }
    15% { transform: translate(-8px, 6px) rotate(-1deg); }
    30% { transform: translate(8px, -6px) rotate(1deg); }
    45% { transform: translate(-6px, -4px); }
    60% { transform: translate(6px, 4px); }
    75% { transform: translate(-3px, 2px); }
}

@keyframes minePreviewCrystalPulse {
    0% { transform: scale(0.9); filter: drop-shadow(0 0 4px #c084fc); }
    100% { transform: scale(1.15); filter: drop-shadow(0 0 12px #c084fc); }
}

@keyframes hudGlowPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(168, 85, 247, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2); }
    50% { box-shadow: 0 0 25px rgba(168, 85, 247, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
}

/* Animation Classes */
.mine-cell-opening { animation: mineFlipOpen 0.35s ease-out forwards; }
.mine-blackhole-animated { animation: mineBlackholeSpin 2.5s linear infinite; }
.mine-blackhole-expand-shrink { animation: mineBlackholePulseExpandShrink 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards !important; z-index: 100 !important; }
.mine-cell-absorb-restore { animation: cellAbsorbAndRestore 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards !important; }
.mines-loss-shake { animation: minesGridShake 0.6s ease-in-out !important; }

/* --- DYNAMIC CRYSTAL TIERS (STEPS 1-3: SAPPHIRE, STEPS 4-7: AMETHYST, STEPS 8+: ROYAL RUBY) --- */
@keyframes rubyJackpotGlow {
    0% { box-shadow: 0 0 16px rgba(255, 59, 119, 0.8), inset 0 0 8px rgba(255, 215, 0, 0.5); }
    100% { box-shadow: 0 0 28px rgba(255, 59, 119, 1), 0 0 45px rgba(255, 215, 0, 0.8), inset 0 0 14px rgba(255, 215, 0, 0.9); }
}

@keyframes crystalShimmerPulse {
    0% { transform: scale(0.95); }
    100% { transform: scale(1.08); }
}

/* Tier 1 (Steps 1-3): Sapphire Blue */
.crystal-tier-sapphire {
    background: radial-gradient(circle, rgba(0, 210, 255, 0.42) 0%, rgba(10, 24, 48, 0.95) 80%) !important;
    border-color: #00d2ff !important;
    box-shadow: 0 0 14px rgba(0, 210, 255, 0.75), inset 0 0 8px rgba(0, 210, 255, 0.35) !important;
}
.crystal-tier-sapphire img {
    filter: drop-shadow(0 0 10px #00d2ff) hue-rotate(180deg) brightness(1.2) !important;
}

/* Tier 2 (Steps 4-7): Amethyst Purple */
.crystal-tier-amethyst {
    background: radial-gradient(circle, rgba(192, 132, 252, 0.48) 0%, rgba(28, 12, 50, 0.95) 80%) !important;
    border-color: #c084fc !important;
    box-shadow: 0 0 18px rgba(192, 132, 252, 0.85), inset 0 0 10px rgba(192, 132, 252, 0.45) !important;
}
.crystal-tier-amethyst img {
    filter: drop-shadow(0 0 12px #c084fc) hue-rotate(0deg) brightness(1.25) !important;
}

/* Tier 3 (Steps 8+): Royal Ruby & Gold Jackpot */
.crystal-tier-ruby {
    background: radial-gradient(circle, rgba(255, 59, 119, 0.55) 0%, rgba(255, 215, 0, 0.25) 50%, rgba(45, 10, 28, 0.98) 100%) !important;
    border-color: #ff3b77 !important;
    box-shadow: 0 0 22px rgba(255, 59, 119, 0.95), 0 0 35px rgba(255, 215, 0, 0.5), inset 0 0 12px rgba(255, 215, 0, 0.7) !important;
    animation: rubyJackpotGlow 1.5s ease-in-out infinite alternate !important;
}
.crystal-tier-ruby img {
    filter: drop-shadow(0 0 14px #ff3b77) drop-shadow(0 0 20px #ffd700) hue-rotate(290deg) brightness(1.35) !important;
    animation: crystalShimmerPulse 1.2s ease-in-out infinite alternate !important;
}

/* --- DYNAMIC JACKPOT & STEP HUD BANNER --- */
.mines-jackpot-hud {
    width: 92%;
    max-width: 360px;
    background: linear-gradient(135deg, rgba(28, 18, 52, 0.95) 0%, rgba(14, 10, 32, 0.98) 100%);
    border: 1.5px solid rgba(192, 132, 252, 0.55);
    border-radius: 14px;
    padding: 5px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(168, 85, 247, 0.3);
    flex-shrink: 0;
    box-sizing: border-box;
    animation: hudGlowPulse 3s ease-in-out infinite;
}

.mines-jackpot-hud.active-game {
    border-color: #ffd700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 215, 0, 0.45);
}

.hud-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.hud-title {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.8px;
    color: #c084fc;
    text-transform: uppercase;
}

.hud-val-gold {
    font-size: 13px;
    font-weight: 900;
    color: #ffe875;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    display: flex;
    align-items: center;
    gap: 3px;
    transition: transform 0.2s ease;
}

.hud-val-purple {
    font-size: 13px;
    font-weight: 900;
    color: #e9d5ff;
    text-shadow: 0 0 10px #a855f7;
    display: flex;
    align-items: center;
}

.hud-val-cyan {
    font-size: 12px;
    font-weight: 900;
    color: #67e8f9;
    text-shadow: 0 0 10px rgba(0, 210, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 3px;
}

.hud-separator {
    width: 1px;
    height: 20px;
    background: rgba(192, 132, 252, 0.3);
}

/* --- MULTIPLIER RIBBON CONTAINER --- */
.mines-ribbon-container {
    width: 92%;
    max-width: 360px;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    overflow: visible;
}

#minesMultipliersBar {
    display: flex;
    gap: 4px;
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 3px 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-x !important;
    width: 100%;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

#minesMultipliersBar::-webkit-scrollbar {
    display: none;
}

.mines-mult-chip {
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.35);
    color: #c084fc;
    border-radius: 7px;
    padding: 2px 5px;
    font-size: 9px;
    font-weight: 800;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.35s ease, border-color 0.3s ease, box-shadow 0.35s ease;
    flex-shrink: 0 !important;
    min-width: 52px;
    will-change: transform, opacity;
}

.mines-mult-chip.active-step {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff;
    border-color: #e9d5ff;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.9);
    transform: scale(1.04);
}

.mines-mult-chip.passed-step {
    opacity: 0.5;
    transform: scale(0.92);
}

/* --- RESPONSIVE 5X5 GRID --- */
.mines-grid-responsive {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 5px;
    width: 92%;
    max-width: min(280px, 75vw, 31vh);
    aspect-ratio: 1 / 1;
    background: rgba(10, 12, 26, 0.92);
    border: 2px solid rgba(168, 85, 247, 0.5);
    border-radius: 16px;
    padding: 5px;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.95), 0 0 25px rgba(168, 85, 247, 0.25);
    box-sizing: border-box;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    z-index: 10;
}

.mine-cell {
    background: linear-gradient(135deg, rgba(28, 32, 60, 0.95) 0%, rgba(16, 18, 40, 0.98) 100%);
    border: 1.5px solid rgba(168, 85, 247, 0.4);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.25);
    transition: transform 0.12s cubic-bezier(0.2, 1, 0.4, 1), box-shadow 0.15s ease, border-color 0.15s ease, background 0.2s ease;
    transform: perspective(300px) translateZ(0);
    will-change: transform, box-shadow;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

.mine-cell:active,
.mine-cell.cell-pressing {
    transform: perspective(300px) scale(0.9) translateZ(-10px) !important;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.9), 0 0 16px rgba(192, 132, 252, 0.9) !important;
    border-color: #c084fc !important;
    background: linear-gradient(135deg, rgba(38, 22, 68, 0.98) 0%, rgba(20, 12, 45, 0.99) 100%) !important;
}

.mine-cell-loss-red {
    background: radial-gradient(circle, rgba(239, 68, 68, 0.45) 0%, rgba(30, 10, 20, 0.95) 80%) !important;
    border: 1.5px solid #ef4444 !important;
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.6) !important;
}

/* --- MINI HISTORY STRIP --- */
.mines-history-strip {
    width: 92%;
    max-width: 360px;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
    padding: 0 4px;
    box-sizing: border-box;
}

.mines-history-strip::-webkit-scrollbar {
    display: none;
}

.mines-history-item {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    animation: historyItemSlide 0.35s cubic-bezier(0.25, 1, 0.5, 1);
    flex-shrink: 0;
    box-sizing: border-box;
    line-height: 1.2;
}

.mines-history-item.win {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.55);
    color: #6ee7b7;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.25);
}

.mines-history-item.loss {
    background: rgba(239, 68, 68, 0.18);
    border: 1px solid rgba(239, 68, 68, 0.45);
    color: #fca5a5;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

@keyframes historyItemSlide {
    0% { transform: scale(0.8) translateY(-4px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* --- DUAL TACTICAL SETTINGS CARD (PIXEL-PERFECT GRID ALIGNMENT) --- */
.mines-dual-controls-card {
    width: 92%;
    max-width: 360px;
    background: linear-gradient(135deg, rgba(20, 15, 38, 0.96), rgba(12, 10, 28, 0.98));
    border: 1.5px solid rgba(168, 85, 247, 0.45);
    border-radius: 14px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
}

.mines-ctrl-row {
    display: grid;
    grid-template-columns: 50px 88px 1fr;
    align-items: center;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.mines-ctrl-tag {
    font-size: 10px;
    font-weight: 800;
    color: #c084fc;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-align: left;
}

.mines-stepper-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 88px;
    box-sizing: border-box;
}

.mines-step-btn {
    background: rgba(24, 13, 43, 0.85);
    border: 1.5px solid rgba(168, 85, 247, 0.4);
    color: #e9d5ff;
    font-weight: 900;
    font-size: 13px;
    width: 24px;
    height: 24px;
    border-radius: 7px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.1s, background 0.15s;
    flex-shrink: 0;
}

.mines-step-btn:active:not(:disabled) {
    transform: scale(0.9);
    background: rgba(168, 85, 247, 0.4);
}

.mines-step-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mines-count-step-btn {
    border-color: rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.mines-val-text {
    font-size: 12px;
    font-weight: 900;
    color: #ffe875;
    width: 36px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
}

.mines-chips-group {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
}

.mines-bet-btn {
    background: rgba(24, 13, 43, 0.85);
    border: 1.5px solid rgba(168, 85, 247, 0.4);
    color: #e9d5ff;
    font-weight: 900;
    font-size: 9.5px;
    padding: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.mines-bet-btn.active,
.mines-bet-btn:active {
    background: linear-gradient(135deg, #a855f7, #6366f1);
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.6);
}

.mines-bet-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mines-count-chip {
    background: rgba(36, 16, 40, 0.85);
    border: 1.5px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-weight: 900;
    font-size: 9.5px;
    padding: 4px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.mines-count-chip.active,
.mines-count-chip:active {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
    color: #fff;
    border-color: #fca5a5;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

.mines-count-chip:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- BOTTOM ACTION ROW --- */
.mines-action-row {
    width: 92%;
    max-width: 360px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    height: 44px;
}

.mines-random-btn {
    background: linear-gradient(135deg, rgba(38, 24, 66, 0.95), rgba(20, 14, 40, 0.98));
    border: 1.5px solid rgba(192, 132, 252, 0.55);
    color: #e9d5ff;
    font-family: 'GameFont', sans-serif;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.8px;
    padding: 0 14px;
    height: 44px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 0.15s ease, background 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
}

.mines-random-btn:active:not(:disabled) {
    transform: scale(0.94);
    background: rgba(168, 85, 247, 0.4);
}

.mines-random-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

.dice-icon-3d {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
}

@keyframes minesPlayPulse {
    0% {
        transform: scale(1);
        box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.35);
    }
    50% {
        transform: scale(1.025);
        box-shadow: 0 8px 24px rgba(16, 185, 129, 0.7), 0 0 16px rgba(52, 211, 153, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.35);
    }
}

.mines-submit-btn {
    flex: 1;
    height: 44px;
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: 1.5px solid rgba(110, 231, 183, 0.6);
    border-radius: 14px;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.35);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
    animation: minesPlayPulse 2.2s infinite ease-in-out;
    transform: translateZ(0);
    will-change: transform, box-shadow;
}

.mines-submit-btn:active:not(:disabled) {
    transform: scale(0.96) !important;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.5) !important;
}

.mines-submit-btn:disabled {
    animation: none !important;
}
