/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

/* Base Styles & Theme Colors */
:root {
    --body-bg: #f0f2f5; /* Light grey body background */
    --container-bg: #ffffff; /* White main container */
    --header-bg: #2c3e50; /* Dark blue */
    --header-accent: #f1c40f; /* Yellow */
    --header-text: #ffffff;
    --indices-bg: #ecf0f1; /* Light grey */
    --index-bg: #ffffff;
    --index-border: #bdc3c7; /* Slightly darker grey border */
    --status-bg: #e8eef1; /* Slightly different light grey */
    --tweet-area-bg: #f9f9f9; /* Very light grey */
    --tweet-feed-bg: #ffffff;
    --tweet-border: #eaeaea;
    --text-primary: #34495e; /* Darker grey/blue text */
    --text-secondary: #7f8c8d; /* Medium grey text */
    --text-rule-highlight: #2980b9; /* Blue for rule highlights */
    --text-intro: #333; /* Dark text for intro */
    --positive-change: #27ae60; /* Green */
    --negative-change: #c0392b; /* Red */
    --button-continue-bg: #27ae60; /* Same as start */
    --button-continue-hover: #229954;
    --button-start-bg: #27ae60;
    --button-start-hover: #229954;
    --button-tweet-bg: #3498db; /* Twitter blue */
    --button-tweet-hover: #2980b9;
    --button-restart-bg: #e74c3c;
    --button-restart-hover: #c0392b;
    --button-close-bg: #ecf0f1;
    --button-close-hover: #bdc3c7;
    --loading-color: var(--negative-change); /* Red for loading text */
    --font-family: 'Noto Sans SC', sans-serif;
    /* --intro-bg: #eaf0f4;  REMOVED - Intro screen will use container-bg */
    --intro-image-bg: #e4d7b1;
}

body {
    font-family: var(--font-family);
    background-color: var(--body-bg);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
}

.game-wrapper { width: 100%; display: flex; justify-content: center; }

.game-container {
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    padding: 0;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

/* --- Intro Screen Styles --- */
.intro-screen {
    padding: 0; /* No padding on the main screen container */
    /* background-color: var(--intro-bg); REMOVED - Use main container bg */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.intro-content {
    display: flex;
    width: 100%;
    min-height: 400px;
    background-color: var(--container-bg); /* Ensure content area is white */
}
.intro-text {
    flex: 1;
    padding: 40px 35px;
    color: var(--text-intro);
    font-size: 1.05em;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: var(--container-bg); /* Explicitly white */
}
.intro-text p { margin: 0 0 18px 0; }
.intro-text p:last-child { margin-bottom: 0; }

.intro-image-container {
    flex-basis: 40%;
    background-color: var(--intro-image-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}
.intro-image { max-width: 100%; max-height: 100%; height: auto; object-fit: contain; }

.button-continue { /* Button is now OUTSIDE intro-content, directly in intro-screen */
    background-color: var(--button-continue-bg); color: white; border: none; padding: 12px 28px; border-radius: 6px; font-size: 1.1em; font-weight: 700; cursor: pointer; transition: background-color 0.2s ease;
    margin: 30px 0; /* Positioned below the intro-content */
}
.button-continue:hover { background-color: var(--button-continue-hover); }


/* --- Start Screen (Rules) Styles --- */
.start-screen { display: flex; flex-direction: column; align-items: center; padding: 40px 30px; text-align: center; /* display: none; Set by JS initially */ }
.trump-avatar-large { width: 120px; height: 120px; border-radius: 50%; border: 4px solid var(--negative-change); margin-bottom: 20px; }
.start-screen h1 { font-size: 1.9em; color: var(--text-primary); margin-bottom: 25px; font-weight: 700; }
.rules { background-color: #fff; border: 1px solid #dce4e8; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border-radius: 6px; padding: 25px 30px; margin-bottom: 30px; text-align: left; display: block; max-width: 650px; width: 100%; box-sizing: border-box; margin-left: auto; margin-right: auto; }
.rules h2 { font-size: 1.4em; color: var(--negative-change); margin-top: 0; margin-bottom: 15px; text-align: center; font-weight: 700; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.rules h2:first-of-type { margin-top: 0; }
.rules p { font-size: 1em; color: var(--text-primary); line-height: 1.6; margin-bottom: 15px; text-align: center;}
.rules ul { list-style: none; margin: 0; padding: 0 0 0 10px; margin-bottom: 20px; }
.rules li { font-size: 1.05em; margin-bottom: 12px; line-height: 1.5; position: relative; padding-left: 25px; }
.rules li::before { content: '🎯'; position: absolute; left: 0; top: 2px; font-size: 1em; }
.rules strong { font-weight: 700; color: var(--text-rule-highlight); }
.rules .maga-text { text-align: center; font-weight: 700; color: var(--text-primary); margin-top: 25px; font-size: 1.1em; }
.button-start { background-color: var(--button-start-bg); color: white; border: none; padding: 14px 30px; border-radius: 6px; font-size: 1.15em; font-weight: 700; cursor: pointer; transition: background-color 0.2s ease; }
.button-start:hover { background-color: var(--button-start-hover); }


/* --- Main Game Area Styles --- (Unchanged from previous version) */
.main-game { padding: 0; }
.header { background-color: var(--header-bg); color: var(--header-text); padding: 10px 25px 10px 115px; position: relative; min-height: 60px; display: flex; align-items: center; }
.header-accent { position: absolute; top: 0; left: 0; width: 100%; height: 5px; background-color: var(--header-accent); }
.header-title { color: var(--header-text); margin: 0; font-size: 1.4em; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; text-align: center; flex-grow: 1; padding: 0 85px 0 0; }
.trump-avatar { width: 65px; height: 65px; border-radius: 50%; border: 3px solid #fff; position: absolute; top: 50%; left: 25px; transform: translateY(-50%); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.button-restart { position: absolute; top: 50%; right: 25px; transform: translateY(-50%); background-color: var(--button-restart-bg); color: white; border: none; border-radius: 5px; padding: 6px 12px; font-size: 0.85em; font-weight: 500; cursor: pointer; transition: background-color 0.2s ease; }
.button-restart:hover { background-color: var(--button-restart-hover); }

.market-indices, .game-status, .tweet-area, .tweet-feed { padding: 20px 25px; }
.market-indices { background-color: var(--indices-bg); display: flex; flex-wrap: wrap; justify-content: space-around; border-bottom: 1px solid #dce4e8; }
.index { background-color: var(--index-bg); border: 1px solid var(--index-border); border-radius: 4px; padding: 10px 15px; margin: 6px; min-width: 120px; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,0.05); transition: background-color 0.3s, transform 0.1s; }
.index-name { font-size: 0.8em; color: var(--text-secondary); margin-bottom: 5px; font-weight: 700; text-transform: uppercase; }
.index-change { font-size: 1.4em; font-weight: 700; transition: color 0.3s; letter-spacing: 0.5px; }
.index-change.positive { color: var(--positive-change); }
.index-change.negative { color: var(--negative-change); }
.index-change.positive::before { content: '▲ '; }
.index-change.negative::before { content: '▼ '; }
.index.volatile-up { animation: pulse-up 0.5s ease-out; }
.index.volatile-down { animation: pulse-down 0.5s ease-out; }
@keyframes pulse-up { 0% { transform: scale(1); background-color: #fff;} 50% { transform: scale(1.08); background-color: #dff0d8; } 100% { transform: scale(1); background-color: #fff; } }
@keyframes pulse-down { 0% { transform: scale(1); background-color: #fff;} 50% { transform: scale(1.08); background-color: #f2dede; } 100% { transform: scale(1); background-color: #fff; } }

.game-status { background-color: var(--status-bg); display: flex; justify-content: space-around; border-radius: 0; border-bottom: 1px solid #dce4e8; font-size: 0.95em; padding: 12px 25px; }
.game-status p { margin: 0 10px; color: var(--text-primary); }
.game-status span { font-weight: 700; color: var(--button-tweet-bg); }

.loading-indicator { text-align: center; padding: 15px; color: var(--loading-color); font-weight: 700; font-size: 1.05em; background-color: #fff; border-bottom: 1px solid #dce4e8; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 3px solid rgba(192, 57, 43, 0.2); border-radius: 50%; border-top-color: var(--loading-color); animation: spin 1s linear infinite; margin-left: 8px; vertical-align: -3px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.tweet-area { background-color: var(--tweet-area-bg); border-bottom: 1px solid #dce4e8; }
.tweet-area h2 { margin-top: 0; margin-bottom: 15px; font-size: 1.2em; color: var(--text-primary); font-weight: 700; }
#tweet-input { width: calc(100% - 22px); height: 65px; padding: 10px; border: 1px solid #ccc; border-radius: 4px; margin-bottom: 10px; font-family: var(--font-family); font-size: 1em; resize: vertical; background-color: #fff; }
.tweet-controls { display: flex; justify-content: space-between; align-items: center; }
#char-count { font-size: 0.85em; color: var(--text-secondary); }
.button-tweet { background-color: var(--button-tweet-bg); color: white; border: none; padding: 9px 20px; border-radius: 20px; font-weight: 700; cursor: pointer; transition: background-color 0.2s ease; font-size: 1em; }
.button-tweet:hover { background-color: var(--button-tweet-hover); }
.button-tweet:disabled { background-color: #a0d3f0; cursor: not-allowed; }

.tweet-feed { background-color: var(--container-bg); padding-bottom: 10px; }
.tweet-feed h2 { font-size: 1.2em; margin-top: 0; margin-bottom: 15px; color: var(--text-primary); font-weight: 700; }
#feed-list { list-style: none; padding: 0; margin: 0; max-height: 350px; overflow-y: auto; border: 1px solid var(--tweet-border); border-radius: 4px; background-color: var(--tweet-feed-bg); }
#feed-list li { padding: 15px; border-bottom: 1px solid var(--tweet-border); background-color: transparent; }
#feed-list li:last-child { border-bottom: none; }
.tweet-content-wrapper { display: flex; align-items: flex-start; margin-bottom: 10px; }
.tweet-avatar { width: 48px; height: 48px; border-radius: 50%; margin-right: 12px; flex-shrink: 0; }
.tweet-text-area { flex-grow: 1; }
.tweet-text-area strong { color: var(--text-primary); font-size: 1.05em; font-weight: 700; }
.tweet-text-area .tweet-text { margin: 5px 0 8px 0; font-size: 1em; line-height: 1.5; word-wrap: break-word; color: var(--text-primary); }
.tweet-text-area .tweet-time { font-size: 0.8em; color: var(--text-secondary); display: block; }
.tweet-stats { display: flex; justify-content: space-around; padding-top: 10px; border-top: 1px solid var(--tweet-border); max-width: 320px; margin-left: 60px; }
.tweet-stats .stat { font-size: 0.9em; color: var(--text-secondary); display: flex; align-items: center; }
.tweet-stats .stat .count { margin-left: 5px; font-weight: 700; min-width: 25px; display: inline-block; text-align: right; color: var(--text-primary); }

/* --- Game Over Screen Styles --- (Unchanged) */
.game-over-screen { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); justify-content: center; align-items: center; z-index: 1000; }
.game-over-content { background-color: white; padding: 35px 45px; border-radius: 8px; text-align: center; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2); animation: fade-in 0.4s ease-out; max-width: 550px; width: 90%; position: relative; border-top: 5px solid var(--header-accent); }
.button-close { position: absolute; top: 12px; right: 12px; background: var(--button-close-bg); border: none; border-radius: 50%; width: 30px; height: 30px; font-size: 22px; line-height: 28px; text-align: center; cursor: pointer; color: #888; transition: background-color 0.2s, color 0.2s; }
.button-close:hover { background: var(--button-close-hover); color: #555; }
.game-over-content h2 { margin-top: 10px; margin-bottom: 20px; font-size: 1.7em; font-weight: 700; color: var(--text-primary); }
.final-summary-box { margin-bottom: 15px; text-align: left; font-size: 0.95em; max-height: 160px; overflow-y: auto; border: 1px solid #eee; padding: 12px 15px; border-radius: 4px; background: var(--status-bg); }
.final-summary-box p { margin: 3px 0; font-size: 1em; }
.final-summary-box h4 { margin-top: 0; margin-bottom: 10px; font-size: 1.1em; color: var(--text-primary); font-weight: 700; }
.final-summary-box .positive { color: var(--positive-change); font-weight: 700; }
.final-summary-box .negative { color: var(--negative-change); font-weight: 700; }
.goal-summary-box { margin-top: 20px; margin-bottom: 25px; font-size: 1em; color: var(--text-primary); border-top: 1px dashed #ccc; padding-top: 15px; }
.goal-summary-box p { margin: 6px 0; }
.goal-summary-box span { font-weight: 700; }
.goal-summary-box .goal-met { color: var(--positive-change); }
.goal-summary-box .goal-not-met { color: var(--negative-change); }
.button-play-again { background-color: var(--button-start-bg); color: white; border: none; padding: 12px 25px; border-radius: 6px; font-size: 1.1em; cursor: pointer; font-weight: 700; transition: background-color 0.2s ease; }
.button-play-again:hover { background-color: var(--button-start-hover); }

@keyframes fade-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* --- Responsive Adjustments --- (Unchanged) */
@media (max-width: 900px) { .intro-content { flex-direction: column; } .intro-image-container { flex-basis: auto; height: 300px; order: -1; } .intro-text { padding: 30px 25px; font-size: 1em; } }
@media (max-width: 700px) { .header { padding: 8px 15px 8px 90px; min-height: 50px; } .header-title { font-size: 1.1em; padding: 0 50px 0 0; } .trump-avatar { width: 55px; height: 55px; left: 15px; } .button-restart { font-size: 0.7em; padding: 4px 8px; right: 10px; } .index { min-width: 95px; padding: 8px 10px; margin: 4px; } }
@media (max-width: 600px) { body { padding: 10px; } .game-container { padding: 0; } .header { padding: 8px 15px 8px 70px; } .trump-avatar { width: 45px; height: 45px; left: 10px; } .market-indices, .game-status, .tweet-area, .tweet-feed { padding: 15px; } .market-indices { justify-content: center; } .index-change { font-size: 1.1em; } .game-status { flex-direction: column; align-items: center; padding: 10px; } .game-status p { margin: 4px 0; } .tweet-area h2, .tweet-feed h2 { font-size: 1.1em; margin-bottom: 12px; } #feed-list { max-height: 250px; } .tweet-avatar { width: 40px; height: 40px; margin-right: 10px;} .tweet-stats { margin-left: 50px; } .start-screen { padding: 25px 15px; } .trump-avatar-large { width: 100px; height: 100px; } .start-screen h1 { font-size: 1.6em; } .rules { padding: 15px; margin-left: auto; margin-right: auto; } .rules h2 { font-size: 1.1em; margin-bottom: 12px; } .rules p, .rules li { font-size: 0.9em; } .game-over-content { padding: 25px 20px; } .game-over-content h2 { font-size: 1.4em; margin-bottom: 15px; } .button-close { width: 26px; height: 26px; font-size: 18px; line-height: 24px; top: 8px; right: 8px;} .final-summary-box, .goal-summary-box { font-size: 0.9em; } }
