/* --- Glitchcore Pixel Theme --- */
:root {
    --color-bg: #1c1c2a; /* Dark background color (used for containers and modals) */
    --color-primary: #ff00ff; /* Neon Pink/Magenta */
    --color-secondary: #00ffff; /* Neon Cyan */
    --color-accent: #ff0077; /* Deeper Pink/Red */
    --color-text: #ffffff;
    --color-screen: #00ff00; /* Neon Green */
}

/* General Reset and Pixel Font */
body {
    font-family: 'Press Start 2P', cursive;
    background-image: url('crt.jpg'); 
    background-color: var(--color-bg); 
    background-size: cover;
    background-attachment: fixed;
    background-blend-mode: overlay;
    
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    text-align: center;
    text-shadow: 1px 1px var(--color-primary); 
    overflow-x: hidden;
}

h1, h2 {
    color: var(--color-secondary);
    text-shadow: 2px 2px var(--color-accent);
}

/* --- GAME LAYOUT STYLES --- */

.slot-machine-container {
    background-color: var(--color-bg); 
    border: 5px solid var(--color-primary);
    box-shadow: 0 0 15px var(--color-secondary), 0 0 5px var(--color-primary) inset;
    padding: 30px;
    border-radius: 0;
    margin-top: 20px;
    /* FIX: Added a fixed width to prevent text overflow from stretching the container */
    width: 364px; 
}

/* Reels Display */
#reels-display {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background-color: #333344;
    padding: 10px;
    border: 3px dashed var(--color-secondary);
    width: 304px; 
}

.reel {
    width: 80px;
    height: 80px;
    background-color: var(--color-screen);
    border: 4px solid var(--color-secondary);
    box-shadow: 0 0 10px var(--color-screen) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px; 
    color: var(--color-bg); 
    text-shadow: none;
    transition: transform 0.1s linear;
    overflow: hidden; 
    line-height: 80px; 
    transform: translateY(2px);
}

/* Info Panel */
.info-panel {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    margin-bottom: 20px;
    border-top: 2px solid var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    font-size: 10px;
}

.stat span {
    color: var(--color-screen); 
}

/* Button Styling (Spin) */
#spin-button {
    font-family: 'Press Start 2P', cursive;
    padding: 15px 30px;
    font-size: 14px;
    background-color: var(--color-primary); 
    color: var(--color-bg);
    border: 3px solid var(--color-secondary);
    cursor: pointer;
    box-shadow: 0 4px var(--color-secondary);
    transform: translateY(0);
    transition: all 0.1s;
}

#spin-button:active:not(:disabled) {
    box-shadow: 0 2px var(--color-secondary);
    transform: translateY(2px);
}

#spin-button:disabled {
    background-color: #555566;
    border-color: #777788;
    cursor: not-allowed;
}

/* Message Display */
#message-display {
    margin-top: 20px;
    font-size: 10px;
    color: var(--color-secondary);
    /* FIX: Constrain width to prevent text from expanding the container */
    max-width: 304px; 
    white-space: nowrap; 
    overflow: hidden;    
    /* Center the message within the slot machine container's content area */
    margin-left: auto;
    margin-right: auto;
}

/* Spinning Animation Class */
.spinning {
    animation: spin-effect 0.1s infinite alternate;
}

@keyframes spin-effect {
    from { color: var(--color-primary); }
    to { color: var(--color-accent); } 
}

/* --- Shop and Inventory General Styling --- */
.shop-container, .inventory-container {
    margin-top: 30px;
    padding: 20px;
    background-color: #2a2a38b0; 
    border: 2px solid var(--color-secondary);
    box-shadow: 0 0 10px var(--color-secondary) inset;
    width: 100%;
    max-width: 500px;
    border-radius: 0;
    position: relative; 
}

/* Market Header and Purchase Log Position */
.shop-container h2 {
    white-space: nowrap; 
    overflow: hidden;
    text-overflow: clip; 
    text-align: center; 
}

#purchase-message {
    position: absolute; 
    top: 45px; 
    left: 0;
    right: 0;
    margin: 0;
    padding: 5px 10px;
    font-size: 8px;
    color: var(--color-accent);
    word-wrap: break-word; 
    white-space: normal;
    text-align: center;
    background-color: rgba(28, 28, 42, 0.8); 
    border-bottom: 1px solid var(--color-accent);
    line-height: 1.2;
}

.items-list {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 40px; 
}

.shop-item {
    background-color: #1c1c2a;
    border: 1px solid var(--color-primary);
    padding: 10px;
    text-align: center;
    width: 120px;
    box-shadow: 0 0 5px var(--color-primary);
}

.item-name {
    font-size: 7px;
    margin: 5px 0;
    color: var(--color-secondary);
    word-wrap: break-word; 
    white-space: normal;
}

.item-price {
    font-size: 9px;
    margin-bottom: 10px;
    color: var(--color-screen);
}

.buy-button {
    font-family: 'Press Start 2P', cursive;
    padding: 5px 10px;
    font-size: 8px;
    background-color: var(--color-screen);
    color: var(--color-bg);
    border: 2px solid var(--color-secondary);
    cursor: pointer;
    transition: all 0.1s;
}

.buy-button:active:not(:disabled) {
    box-shadow: 0 2px var(--color-secondary);
    transform: translateY(2px);
}

.buy-button:disabled {
    background-color: #555566;
    border-color: #777788;
    cursor: not-allowed;
}

/* --- Inventory Styling --- */
.inventory-list {
    min-height: 50px;
    padding: 10px;
    background-color: var(--color-bg);
    border: 2px solid var(--color-primary);
    text-align: left;
}

.inventory-list.empty {
    text-align: center;
    color: #9999aa;
    line-height: 30px;
    font-size: 8px;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px dashed #555566;
    font-size: 10px;
}

.inventory-name {
    flex-grow: 1;
    color: var(--color-text);
    word-wrap: break-word; 
    white-space: normal;
    padding-right: 5px; 
}

.sell-button {
    font-family: 'Press Start 2P', cursive;
    padding: 3px 6px;
    font-size: 7px;
    background-color: var(--color-accent); 
    color: var(--color-text);
    border: 1px solid var(--color-primary);
    cursor: pointer;
    transition: all 0.1s;
    flex-shrink: 0; 
}

.sell-button:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* --- Image Specific Styling --- */
.pixel-card-image {
    width: 60px; 
    height: 60px;
    image-rendering: pixelated; 
    border: 1px solid var(--color-secondary);
    object-fit: contain; 
}

.pixel-card-image-small {
    width: 20px; 
    height: 20px;
    image-rendering: pixelated;
    vertical-align: middle;
    object-fit: contain;
}

.shop-item .item-icon {
    height: 60px; 
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 5px;
}

/* --- MODAL / POPUP STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(2px);
    display: none; 
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--color-bg);
    border: 3px solid var(--color-primary);
    box-shadow: 0 0 20px var(--color-secondary), 0 0 5px var(--color-primary) inset;
    padding: 30px;
    width: 90%; 
    max-width: 380px; 
    max-height: 90vh; 
    overflow-y: auto; 
    animation: fadeIn 0.3s;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 14px;
}

.modal-content p {
    font-size: 8px;
    margin: 15px 0;
}

.card-display-area {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 350px; 
    max-height: 35vh; 
    width: 100%; 
    height: auto;
}

.card-display-area .item-icon {
    max-width: 350px; 
    max-height: 350px;
    width: 100%;
    height: auto;
    border: 3px solid var(--color-secondary);
    margin-bottom: 10px;
    display: flex; 
    justify-content: center;
    align-items: center;
}

.card-display-area .item-icon img, .pixel-card-image-large {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
    border: none; 
}


#claim-link-btn, #close-welcome, #close-card-popup {
    margin: 10px;
    padding: 8px 15px;
    font-size: 10px;
}

/* --- GLITCH EFFECTS --- */
#glitch-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.glitch-bar {
    position: absolute;
    background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
    opacity: 0.8;
    animation: glitchMove 0.5s infinite alternate;
}

@keyframes glitchMove {
    0% { transform: translate(0, 0); opacity: 0.1; }
    50% { transform: translate(1px, -1px); opacity: 0.4; }
    100% { transform: translate(-1px, 2px); opacity: 0.1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}