/* Global Resets and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #1a1a2e; /* Dark blueish-purple */
    color: #e0e0e0; /* Light grey for text */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top to see content if it overflows */
    min-height: 100vh;
    padding: 20px;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.game-container {
    width: 100%;
    max-width: 1400px; /* Max width for larger screens */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-header h1 {
    font-family: 'Press Start 2P', cursive; /* Retro game font */
    color: #ffc107; /* Bright yellow */
    text-align: center;
    font-size: 2.5rem; /* Larger title */
    text-shadow: 2px 2px 0px #c0392b; /* Reddish shadow for depth */
    margin-bottom: 20px;
}

.game-main-content {
    display: flex;
    gap: 20px;
    width: 100%;
}

.chart-section {
    flex: 3; /* Chart takes more space */
    background-color: #2c2c54; /* Slightly lighter dark shade */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    min-height: 500px; /* Ensure chart area has some height */
}

@keyframes pulseYellow {
    0% { background-color: #ffc107; }
    50% { background-color: rgba(255, 193, 7, 0.5); }
    100% { background-color: #ffc107; }
}

.chart-section-holding {
    animation: pulseYellow 1s infinite;
    /* background-color: #ffc107 !important; /* Important to override existing background */ /* This line will be replaced by the animation */
}

.chart-wrapper {
    position: relative;
    height: 100%; /* Make canvas responsive within its wrapper */
    min-height: 450px; /* Explicit min-height for canvas parent */
}

#indexFundChart {
    background-color: #1e1e3f;
    border-radius: 5px;
    width: 100%; /* Ensure canvas takes full width of its container */
    height: 100%; /* Ensure canvas takes full height of its container */
    display: block; /* Recommended for canvas sizing */
}

.sidebar-section {
    width: 360px;
    min-width: 360px; /* Explicitly prevent shrinking */
    max-width: 360px; /* Explicitly prevent growing */
    flex-shrink: 0;   /* Reinforce no shrinking in flex context */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background-color: #2c2c54; /* Consistent panel background */
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.4);
    min-height: 120px; /* Ensure a minimum height for all panels */
    min-width: 200px;
}

.panel h2 {
    font-family: 'Press Start 2P', cursive;
    color: #82aaff; /* Light blue for panel titles */
    font-size: 1.2rem;
    margin-bottom: 15px;
    border-bottom: 2px solid #82aaff;
    padding-bottom: 5px;
}

.status-panel p,
.portfolio-item {
    font-size: 1rem;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.portfolio-item span:first-child {
    color: #a0a0a0; /* Grey for labels */
}

.portfolio-item span:last-child {
    color: #f0f0f0; /* Brighter for values */
    font-weight: bold;
}

.portfolio-divider {
    border: 0;
    height: 1px;
    background-color: #4a4a7a;
    margin: 15px 0;
}

.total-profit span:last-child {
    font-size: 1.1rem;
}

/* Game Buttons Styling */
.controls-panel {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Make buttons take full width of panel */
    gap: 15px;
}

.game-button {
    font-family: 'Press Start 2P', cursive; /* Retro font */
    font-weight: normal; /* Pixel fonts usually don't need bold */
    font-size: 1rem; /* Adjusted for pixel font */
    padding: 12px 18px; /* Adjusted padding */
    border: 2px solid #000000; /* Simple black border */
    border-radius: 4px; /* Slightly blocky */
    cursor: pointer;
    transition: all 0.1s ease-in-out; /* Faster transition */
    color: #ffffff; /* White text */
    text-transform: uppercase;
    letter-spacing: 1px;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.6); /* Pixel text shadow */
    box-shadow: 3px 3px 0px rgba(0,0,0,0.4); /* Blocky shadow */
    background-color: #007bff; /* Default blue, can be overridden */
}

.game-button:hover {
    transform: translateY(-2px) translateX(-2px);
    box-shadow: 5px 5px 0px rgba(0,0,0,0.5);
    /* Optional: slightly change background or text color on hover */
}

.game-button:active {
    transform: translateY(1px) translateX(1px);
    box-shadow: 1px 1px 0px rgba(0,0,0,0.3);
}

.start-button {
    background-color: #28a745; /* Green */
}

.start-button:hover {
    background-color: #218838; /* Darker Green */
}

.buy-button {
    background-color: #28a745; /* Green for BUY */
}

.buy-button:hover {
    background-color: #218838; /* Darker Green */
}

.sell-button {
    background-color: #dc3545; /* Red for SELL */
}

.sell-button:hover {
    background-color: #c82333; /* Darker Red */
}

.game-button:disabled {
    background-color: #444444; /* Darker grey for disabled */
    color: #888888;
    text-shadow: none;
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2);
    cursor: not-allowed;
    transform: none;
}

/* Responsive adjustments if needed */
@media (max-width: 992px) { /* Adjust for tablets and smaller screens */
    .game-main-content {
        flex-direction: column;
    }
    .chart-section,
    .sidebar-section {
        flex: none; /* Reset flex proportions */
        width: 100%;
    }
    .game-header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 768px) { /* Further adjustments for mobile */
    body {
        padding: 10px;
    }
    .game-header h1 {
        font-size: 1.5rem;
    }
    .panel h2 {
        font-size: 1rem;
    }
    .game-button {
        font-size: 1rem;
        padding: 12px 15px;
    }
    .chart-wrapper {
        min-height: 300px; /* Reduce chart min-height on mobile */
    }
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75); /* Darker overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background-color: #2c2c54; /* Consistent with panel background */
    color: #e0e0e0;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 800px; /* Increased from 600px */
    text-align: center;
    position: relative;
}

.modal-content h2 {
    font-family: 'Press Start 2P', cursive;
    color: #ffc107; /* Bright yellow, like game header */
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.modal-content h3 {
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    color: #82aaff; /* Light blue, like panel titles */
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.summary-section p {
    font-size: 1rem;
    margin-bottom: 8px;
    text-align: left;
}

.summary-section span {
    font-weight: bold;
    color: #ffffff;
}

.modal-divider {
    border: 0;
    height: 1px;
    background-color: #4a4a7a;
    margin: 20px 0;
}

.comparison-message {
    font-size: 1.1rem;
    font-weight: bold;
    margin-top: 15px;
    margin-bottom: 25px;
}

.modal-content .game-button {
    margin-top: 10px;
    /* background-color will be inherited or can be set if specific modal buttons need different colors */
    /* Example: keep modal confirm buttons green by default */
    /* background-color: #28a745; */ 
}
.modal-content .game-button:hover {
    /* background-color: #218838; */
}

.modal-close-button {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2.5rem; /* Make X larger */
    color: #aaa; /* Lighter grey for X */
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s ease-in-out;
}

.modal-close-button:hover {
    color: #fff; /* White on hover */
}

/* Countdown Timer Style */
.countdown-timer {
    font-family: 'Press Start 2P', cursive; /* Using the game font */
    font-size: 3rem; /* Big font */
    color: #ffc107; /* Bright yellow, like game header */
    text-align: center;
    padding: 10px 0;
    margin-top: 10px; /* Add some space from the panel title */
    text-shadow: 2px 2px 0px #c0392b; /* Reddish shadow for depth, matching header */
}

/* New Portfolio Value Large Display Style */
.portfolio-item-large {
    text-align: center; /* Center the large value */
    padding: 15px 0; /* Add some padding around it */
}

.portfolio-value-highlight {
    font-family: 'Press Start 2P', cursive;
    font-size: 2.5rem; /* Slightly smaller than countdown, but still large */
    color: #ffc107; /* Bright yellow */
    text-shadow: 2px 2px 0px #c0392b; /* Matching shadow */
    display: block; /* Allow text-align to work if it was inline */
    white-space: nowrap; /* Prevent the text from wrapping to a new line */
    overflow: hidden; /* Hide the part of the text that overflows */
    text-overflow: ellipsis; /* Display an ellipsis (...) for overflowed text */
    margin: 15px 0; /* Added margin for consistency */
}

/* Increase font size for the random number in its specific modal */
#randomNumberModal .portfolio-value-highlight {
    font-size: 4rem; /* Larger font size for the award number */
}

/* New Game Over Modal Styles */
.modal-game-over .modal-game-over-content {
    /* background-color: #0d1b2a; Dark blue, from image */ 
    /* Vercel brand blue: #0070F3 (for a Vercel themed version) */
    /* Keeping existing panel color for consistency first: #2c2c54 */
    /* If a specific dark blue from image is preferred, replace #2c2c54 */
    border: 3px solid #ffc107; /* Yellow border, similar to image button */
    padding: 20px;
    max-width: 400px; /* Adjust as needed */
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.5); /* Yellow glow */
}

.modal-title-game-over {
    font-family: 'Press Start 2P', cursive;
    color: #f0f0f0; /* Light/White text, from image */
    font-size: 2.5rem; /* Large */
    text-align: center;
    margin-bottom: 25px;
    text-shadow: none; /* Remove previous shadow if any inherited */
}

.leaderboard-container {
    margin-bottom: 30px;
    max-height: 300px; /* Or adjust as needed */
    overflow-y: auto; /* Scroll if many entries */
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    font-family: 'Press Start 2P', cursive; /* Pixel font */
    font-size: 0.9rem; /* Adjust as needed */
    color: #e0e0e0; /* Light text */
}

.leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 6px 5px;
    border-bottom: 1px dashed #4a4a7a; /* Subtle separator */
}

.leaderboard-list li:last-child {
    border-bottom: none;
}

.leaderboard-list .rank {
    flex-basis: 15%;
    text-align: left;
}

.leaderboard-list .name {
    flex-basis: 55%; /* More space for name */
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-list .score {
    flex-basis: 30%;
    text-align: right;
}

/* Styling for the RETRY button (uses existing #startGameButton) */
/* We need to ensure these styles apply when the modal is open */
/* This might require adding a class to startGameButton when modal is shown, */
/* or making these styles more specific if they conflict with default. */
/* For now, assuming JS will handle text change. */

/* Renamed and repurposed for the new modal-internal Try Again button */
.modal-try-again-button {
    /* Keep 'Press Start 2P' as it was already set */
    /* font-family: 'Press Start 2P', cursive; */ /* Already set */
    font-size: 1rem; /* Align with new .game-button size */
    padding: 12px 18px; /* Align with new .game-button padding */
    color: #0d1b2a; /* Dark blue text */
    background-color: #ffcc00; /* Light yellow/beige */
    border: 2px solid #e68a00; /* Orange/darker yellow border */
    border-radius: 4px; /* Align with .game-button */
    display: block; 
    width: 100%; 
    margin-top: 20px; 
    box-shadow: 3px 3px 0px rgba(0,0,0,0.3); /* Align with .game-button shadow style */
    text-shadow: none; /* Or add a light one if desired for this specific button */
    text-transform: uppercase;
    /* transition: all 0.1s ease-in-out; */ /* Add if not inheriting from .game-button if it's separate */
}

.modal-try-again-button:hover {
    background-color: #e6b800; 
    border-color: #cc7a00;
    transform: translateY(-2px) translateX(-2px); /* Match .game-button hover */
    box-shadow: 5px 5px 0px rgba(0,0,0,0.4); /* Match .game-button hover */
}

.modal-try-again-button:active {
    transform: translateY(1px) translateX(1px); /* Match .game-button active */
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2); /* Match .game-button active */
}

/* Game Over Summary Area within Modal */
.game-over-summary-area {
    margin-bottom: 20px;
    padding: 20px;
    background-color: #1e1e3f; /* Match chart background for consistency */
    border: 3px solid #82aaff; /* Light blue border like panel titles */
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(130, 170, 255, 0.3); /* Blue glow */
}

.game-over-summary-area p {
    margin-bottom: 12px; /* Consistent spacing */
    font-size: 1rem; /* Retro arcade size for labels */
    font-family: 'Press Start 2P', cursive; /* Retro pixelated font */
    color: #82aaff; /* Light blue like panel titles */
    text-shadow: 1px 1px 0px rgba(0,0,0,0.8); /* Pixelated text shadow */
    letter-spacing: 1px; /* Spacing for retro feel */
    text-transform: uppercase; /* Arcade style */
}

.game-over-summary-area .game-dates-highlight,
.game-over-summary-area .final-portfolio-highlight {
    font-family: 'Press Start 2P', cursive; /* Retro pixelated font */
    font-weight: normal; /* Pixel fonts don't need bold */
    color: #ffc107; /* Bright yellow like game title */
    font-size: 1.8rem; /* Large but readable for values */
    text-shadow: 2px 2px 0px #c0392b; /* Red shadow like title */
    letter-spacing: 2px; /* Wide spacing for impact */
    text-transform: uppercase;
    display: block; /* Make values appear on new line */
    margin-bottom: 15px; /* Space after values */
    padding: 8px 12px; /* Add padding around values */
    background-color: #2c2c54; /* Panel background */
    border: 2px solid #ffc107; /* Yellow border */
    border-radius: 4px; /* Slightly blocky */
    box-shadow: 3px 3px 0px rgba(0,0,0,0.4); /* Blocky shadow like buttons */
}

.game-over-summary-area .game-dates-highlight {
    font-size: 1.4rem; /* Slightly smaller for dates to fit better */
    color: #50fa7b; /* Green color for dates */
    border-color: #50fa7b; /* Match border to text color */
    text-shadow: 2px 2px 0px #2d5a3d; /* Darker green shadow */
}

.game-over-summary-area .performance-result-message {
    font-size: 0.8rem; /* Smaller retro size */
    font-family: 'Press Start 2P', cursive; /* Keep retro font */
    color: #ff5555; /* Red for performance message */
    text-shadow: 1px 1px 0px rgba(0,0,0,0.8); /* Text shadow */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 20px; /* More space above */
    padding: 10px;
    background-color: rgba(255, 85, 85, 0.1); /* Subtle red background */
    border: 1px dashed #ff5555; /* Dashed red border */
    border-radius: 4px;
}

.game-over-summary-area .modal-divider {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    height: 3px; /* Thicker for retro feel */
    background: linear-gradient(90deg, #82aaff, #ffc107, #50fa7b, #ff5555); /* Rainbow gradient */
    box-shadow: 0 2px 4px rgba(0,0,0,0.3); /* Shadow for depth */
}

.game-over-summary-area .prepare-to-enter-name {
    font-size: 0.8rem;
    font-family: 'Press Start 2P', cursive; /* Retro font */
    color: #82aaff; /* Light blue */
    text-shadow: 1px 1px 0px rgba(0,0,0,0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 20px;
    text-align: center;
}

/* Special styling for the percentage display */
#worseThanBHPercentDisplay {
    color: #ff79c6; /* Bright magenta/pink for percentage */
    border-color: #ff79c6; /* Match border to text color */
    text-shadow: 2px 2px 0px #8b2a5b; /* Darker magenta shadow */
    background-color: #2c2c54; /* Keep same background */
}

/* Style for action buttons within modals, like the new Continue button */
/* This class is often used alongside .game-button, so it mainly overrides color if needed */
.modal-action-button {
    display: block;
    margin-left: auto;
    margin-right: auto;
    margin-top: 15px; /* Default top margin, can be overridden by inline styles */
    /* font-size, padding, color, border-radius, etc., are inherited from .game-button */
}

.modal-action-button:hover {
    /* background-color: #0056b3; */ /* Will inherit and be handled by specific color class or .game-button hover */
}

/* Name Input Area within Modal */
.name-input-container {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #555; /* Darker border for the name input section */
    border-radius: 8px;
    background-color: #2a2a2e; /* Slightly different background for contrast */
    text-align: center;
}

.name-input-container h3 {
    font-size: 1.2em;
    color: #e0e0e0; /* Light text for heading */
    margin-bottom: 10px;
    font-family: 'Press Start 2P', cursive; /* Consistent retro font */
}

.current-name-display {
    min-height: 30px; /* Ensure space even when empty */
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #444; /* Border for the name display */
    border-radius: 4px;
    background-color: #1c1c1e; /* Dark background for the display */
    color: #fff; /* White text for the name */
    font-size: 1.5em; /* Larger font for the name itself */
    letter-spacing: 2px; /* Spacing between characters */
    font-family: 'Press Start 2P', cursive;
    overflow-x: auto; /* In case name gets too long for small screens */
    white-space: nowrap;
}

.char-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); /* Adjust number of columns as needed */
    gap: 8px; /* Spacing between character buttons */
    margin-bottom: 15px;
}

.char-button {
    padding: 8px; /* Adjusted for smaller buttons */
    font-size: 0.9rem; /* Slightly smaller for grid */
    background-color: #4a4a4e; 
    color: #fff; 
    border: 1px solid #333; /* Darker border */
    border-radius: 3px; /* Slightly blocky */
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    font-family: 'Press Start 2P', cursive; 
    text-shadow: 1px 1px 0px rgba(0,0,0,0.5);
    box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
}

.char-button:hover,
.char-button.selected {
    background-color: #6a6a6e; 
    border-color: #555;
    transform: translateY(-1px) translateX(-1px);
    box-shadow: 3px 3px 0px rgba(0,0,0,0.4);
}
.char-button:active {
    transform: translateY(0px) translateX(0px);
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

.name-input-instructions {
    font-size: 0.9em;
    color: #bbb; /* Lighter text for instructions */
    margin-bottom: 15px;
}

.name-input-controls {
    display: flex;
    justify-content: center; /* Center DEL and END buttons */
    gap: 15px; /* Space between DEL and END buttons */
}

.name-input-button {
    padding: 10px 15px; /* Adjusted padding */
    font-size: 0.9rem; /* Adjusted for smaller buttons */
    /* background-color: #50fa7b; */ /* Color set by ID below */
    /* color: #000; */ /* Color set by ID below */
    border: 2px solid #000; /* Consistent border */
    border-radius: 4px; /* Consistent radius */
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    transition: all 0.1s ease-in-out; /* Consistent transition */
    text-transform: uppercase;
    text-shadow: 1px 1px 0px rgba(0,0,0,0.4); /* Text shadow for retro look */
    box-shadow: 3px 3px 0px rgba(0,0,0,0.3); /* Consistent shadow */
}

.name-input-button:hover {
    /* background-color: #8be9fd; */ /* Hover color specific to ID */
    transform: translateY(-2px) translateX(-2px);
    box-shadow: 5px 5px 0px rgba(0,0,0,0.4);
}
.name-input-button:active {
    transform: translateY(1px) translateX(1px);
    box-shadow: 1px 1px 0px rgba(0,0,0,0.2);
}

#backspaceButton {
    background-color: #ff5555; /* Reddish for DEL */
    color: #ffffff; /* White text */
}

#backspaceButton:hover {
    background-color: #dd4444; /* Darker Red */
}

/* Submit button (END) in name input */
#submitNameButton {
    background-color: #50fa7b; /* Greenish */
    color: #000000; /* Black text */
}
#submitNameButton:hover {
    background-color: #30e05f; /* Darker Greenish */
}

/* Style for keyboard navigation focus */
.char-button.keyboard-focused,
.name-input-button.keyboard-focused, /* For END button and other similar buttons */
#backspaceButton.keyboard-focused { /* Specific for DEL button */
    outline: 3px solid #ffc107; /* Bright yellow, consistent with game accents */
    outline-offset: 1px;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.7); /* Yellow glow for more emphasis */
}

/* Ensure modal content can scroll if name input makes it too tall */
.modal-game-over-content {
    max-height: 90vh; /* Max height for the modal content */
    overflow-y: auto; /* Allow vertical scrolling if content overflows */
} 