/* --- IMPORTING A PLAYFUL FONT --- */
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@500;800&display=swap');

/* --- LAYOUT FIXES & NEW BACKGROUND --- */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* A bright, grassy turf green colour */
    background-color: #6bc04b; 
    background-image: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.1) 0px,
        rgba(255, 255, 255, 0.1) 20px,
        transparent 20px,
        transparent 40px
    );
}

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    color: #333333;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* --- THE MAIN GAME WINDOW --- */
.gacha-container {
    /* Clean white base with a slight blue tint, exactly like the game menus */
    background-color: #f7f9fc; 
    padding: 30px;
    border-radius: 20px;
    border: 4px solid #ffffff;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2); 
    max-width: 900px;
    width: 100%;
    text-align: center;
}

h1 {
    color: #e04a73; /* A bright, idol-style pink */
    margin-top: 0;
    font-weight: 800;
}

.rates p {
    font-weight: 500;
    color: #555555;
}

/* --- GLOSSY BUTTONS --- */
.controls button {
    background: linear-gradient(180deg, #38c8ff 0%, #1da0f2 100%);
    color: white;
    border: 2px solid #1a8ccf;
    padding: 12px 25px;
    margin: 5px;
    font-size: 16px;
    border-radius: 30px; /* Highly rounded pill shape */
    cursor: pointer;
    font-weight: 800;
    box-shadow: 0 4px 0 #1579b5;
    transition: transform 0.1s, box-shadow 0.1s;
}

.controls button:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #1579b5;
}

.controls .clear-btn { 
    background: linear-gradient(180deg, #ff7b7b 0%, #ed4245 100%);
    border-color: #c03537;
    box-shadow: 0 4px 0 #c03537;
}

.controls .clear-btn:active {
    box-shadow: 0 0 0 #c03537;
}

/* --- GRIDS & CARDS --- */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 20px;
    min-height: 150px; 
}

.character-card {
    background-color: #ffffff;
    padding: 15px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    animation: popIn 0.3s ease-out;
}

.char-img {
    width: 80px;
    height: 80px;
    object-fit: cover; 
    border-radius: 10px; 
    margin: 10px 0;
    border: 2px solid #e2e8f0;
    background-color: #f1f5f9; 
    /* Add these two lines to pull the image forward */
    position: relative;
    z-index: 1;
}

.char-name { 
    font-weight: 800; 
    margin-top: 10px; 
    font-size: 14px; 
    /* Add these two lines to pull the text forward */
    position: relative;
    z-index: 1;
}

.char-stars { 
    margin-top: 5px; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); 
    /* Add these two lines to pull the stars forward */
    position: relative;
    z-index: 1;
}

/* --- INVENTORY STYLING --- */
.divider {
    border: 0;
    height: 2px;
    background: #e2e8f0;
    margin: 30px 0;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.inventory-item {
    background-color: #ffffff;
    padding: 10px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    font-weight: 800;
    border: 2px solid #e2e8f0;
    border-left: 6px solid #1da0f2;
}

.inventory-item.inv-star-3 { border-left-color: #ff00ff; }
.inventory-item.inv-star-2 { border-left-color: #ffd700; }
.inventory-item.inv-star-1 { border-left-color: #a0aec0; }

.item-count {
    background-color: #e2e8f0;
    color: #333333;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 12px;
}

.empty-msg {
    grid-column: 1 / -1;
    color: #a0aec0;
    font-style: italic;
}

/* --- RARITY COLOURS & ANIMATIONS --- */
.star-1 { border: 3px solid #a0aec0; }
.star-2 { border: 3px solid #ffd700; box-shadow: 0 0 10px rgba(255, 215, 0, 0.4); }

/* --- UPDATED 3-STAR STYLING --- */
.star-3 { 
    border: 3px solid transparent;
    background: linear-gradient(#ffffff, #ffffff) padding-box,
                linear-gradient(45deg, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #9400d3) border-box;
    background-size: 200% 200%;
    position: relative;
    overflow: hidden; 
    /* Uses the new epicPopIn animation for 0.8s, then starts the pulse */
    animation: epicPopIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, 
               rainbowGlow 3s linear infinite, 
               pulse 2s ease-in-out infinite 0.8s;
    /* A stronger shadow to make it pop off the background */
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    z-index: 10; /* Ensures it pops over the other cards */
}

.star-3::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.8) 50%, rgba(255,255,255,0) 100%);
    transform: rotate(30deg);
    animation: shimmer 2.5s infinite;
    pointer-events: none;
}

/* --- NEW DRAMATIC ENTRANCE ANIMATION --- */
@keyframes epicPopIn { 
    0% { transform: scale(0); opacity: 0; filter: brightness(2); } 
    50% { transform: scale(1.3); opacity: 1; filter: brightness(1.5); } 
    100% { transform: scale(1); filter: brightness(1); } 
}

/* --- LIVE CHAT SIDEBAR --- */
#chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 900;
    background: linear-gradient(180deg, #38c8ff 0%, #1da0f2 100%);
    color: white;
    border: 2px solid #1a8ccf;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 0 #1579b5, 0 10px 20px rgba(0,0,0,0.2);
    transition: transform 0.1s, box-shadow 0.1s;
}

#chat-toggle-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #1579b5;
}

.chat-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 350px; /* Width of the chat box */
    height: 100vh;
    background-color: #f7f9fc;
    border-left: 4px solid #1da0f2;
    box-shadow: -10px 0 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* This class pushes the sidebar off the screen to the right */
.chat-sidebar.hidden {
    transform: translateX(110%);
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #ffffff;
    border-bottom: 2px solid #e2e8f0;
}

.chat-header h3 {
    margin: 0;
    color: #e04a73;
    font-weight: 800;
}

.close-chat-btn {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.2s;
}

.close-chat-btn:hover {
    color: #ed4245;
}