*, *::before, *::after {
    box-sizing: border-box;
}
/* --- Global Styles & Variables (2000s SAP Theme) --- */
:root {
    --bg-dark: #ECECEC; /* Main window background */
    --bg-light: #DFDFDF; /* Panel/header background */
    --border-color: #707070;
    --border-light: #FFFFFF;
    --border-dark: #4A4A4A;
    --text-primary: #000000;
    --text-secondary: #333333;
    
    /* Corporate Colors */
    --brand-blue: #00458C;
    --brand-blue-dark: #003366;
    --green-accent: #008000;
    --red-accent: #FF0000;
    
    /* Political Colors (POTUS Specific) */
    --dem-blue: #0000ff;
    --rep-red: #ff0803;
    --ind-gray: #B0B0B0;
    --btn-bg: #DFDFDF; /* Standard button background */
}

p {
  font-size:12px;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center; /* Center horizontally */
    margin: 0;
    min-width: 320px;
    min-height: 100vh; /* Use full viewport height */
    padding: 20px 10px; /* Reduced side padding for mobile */
    overflow-x: hidden; /* Prevent body-level horizontal scroll */
}

.footer {
    margin-top: 3rem;
    padding: 0rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    width: 100%;
    max-width: 800px;
    border-top: 1px solid var(--border-color);
}

.footer-nav {
    margin-bottom: 1rem;
}

.footer-nav a {
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: bold;
}

.footer-nav a:hover {
    text-decoration: underline;
}

.footer-divider {
    color: var(--border-color);
    margin: 0 0.5rem;
}

.footer-link {
    color: var(--brand-blue-dark);
    font-weight: bold;
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

/* Static Page Container (For About, Terms, Privacy) */
.static-page-container {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 2rem 3rem;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.1);
    max-width: 800px;
    width: 95%;
    margin-top: 2rem;
    text-align: left;
}

.static-page-container h1 {
    border-bottom: 2px solid var(--brand-blue);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.static-page-container h2 {
    font-size: 16px;
    color: var(--brand-blue-dark);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.static-page-container p {
    line-height: 1.6;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.static-page-container ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

/* --- Typography --- */
.header-1 {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-primary);
    text-align: center;
}
.header-2 {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
}
.header-3 {
    font-size: 16px;
    font-weight: bold;
    color: var(--text-primary);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}
.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
}
.subtitle-small {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* --- Startup Screen --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 10px; /* Prevent edge touching on mobile */
}

.modal-content {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 1.5rem; /* Reduced slightly */
    box-shadow: 4px 4px 10px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 700px;
    width: 100%; /* Now safe due to box-sizing */
    max-height: 90vh; 
    overflow-y: auto;
    margin: auto; /* Centers in flex overlay */
}

.startup-modal-content {
    text-align: left;
}
.section-header {
    text-align: left;
    margin-top: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.industry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.industry-card {
    background: var(--btn-bg);
    padding: 1rem;
    border-radius: 0;
    border: 1px solid var(--border-dark);
    border-style: outset;
    text-align: left;
    cursor: pointer;
}
.industry-card:hover { background: #EFEFEF; }
.industry-card.selected {
    background: #CACACA;
    border-style: inset;
}
.industry-card h4 {
    font-size: 16px;
    font-weight: bold;
    color: var(--brand-blue);
    margin: 0 0 0.5rem 0;
}
.industry-card p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

/* --- Toggle Switch --- */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 0; 
    justify-content: center;
}
.toggle-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
}

/* --- Main Game Layout --- */
#game-container {
    width: 100%;
    max-width: 1200px;
    /* FIX 1: Remove fixed height so body can scroll */
    height: auto;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    box-shadow: none;
    border-radius: 0;
    overflow: visible; /* Allow content to dictate height */
    border: 1px solid var(--border-color);
}

/* --- Header Bar --- */
#header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
    flex-wrap: wrap; /* Handle smaller screens gracefully */
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem; /* Space between stat boxes */
}

/* Ensure title doesn't break layout on mobile */
.header-2 {
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ratio-box {
    background: #fff;
    padding: 4px 8px;
    border: 1px solid var(--border-dark);
    border-radius: 0; /* Keep square aesthetic */
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.1);
}

.ratio-title {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
}

.ratio-value {
    font-size: 14px;
    font-family: "Courier New", Courier, monospace;
    color: var(--brand-blue-dark);
    background: none;
    border: none;
    padding: 0;
    min-width: auto;
}

/* Adjust button to fit header height */
#view-report-btn {
    margin: 0 !important; /* Override inline styles */
    height: 30px;
    padding: 0 12px;
    white-space: nowrap;
}

/* --- Main Content --- */
#main-content {
    flex-grow: 1;
    padding: 1rem;
    /* FIX 1: Allow main content to expand parent */
    overflow: visible; 
}

/* --- Dashboard Grid & Charts --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}
.full-width {
    grid-column: 1 / -1;
}

.chart-wrapper {
    background: var(--bg-light);
    padding: 1rem;
    border: 1px solid var(--border-color);
    overflow-x: hidden; 
}

/* Parliament Specifics */
.parliament-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}
.parliament-chart {
    width: 100%;
    /* Keep flexible height for d3 svg */
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
.parliament-chart-svg {
    width: 100%;
    height: auto;
    max-height: 200px;
    display: block; /* Removes bottom margin artifact */
}

.parliament-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0; /* Flexbox overflow fix */
}
.parliament-label {
    font-size: 14px;
    color: var(--text-primary);
    margin-top: -30px; /* Pull label up into the arch empty space */
    margin-bottom: 10px;
    z-index: 5;
}

/* Modal Charts */
.modal-chart-container {
    height: 300px;
    width: 100%;
    margin-bottom: 1rem;
    position: relative;
    border: 1px solid var(--border-color);
    background: #fff;
    padding: 10px;
    box-sizing: border-box; /* FIX 3: Keep padding inside width */
}

/* --- Cards --- */
.card-options-area {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
.decision-card {
    background: var(--bg-dark);
    padding: 0.75rem;
    border-radius: 0;
    border: 1px solid var(--border-color);
    box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: none;
    min-height: 120px; /* INCREASED HEIGHT */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    padding-top: 2.5rem; /* Space for badge */
    padding-bottom: 2.5rem; /* NEW: Space for PASSED/BLOCKED message */
    border-right-width: 2px;
    border-bottom-width: 2px;
}
.decision-card:hover {
    border-color: var(--brand-blue);
}
.decision-card.selected { 
    border: 3px solid var(--brand-blue);
    transform: none;
}
.card-type-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 0;
    text-transform: uppercase;
    color: white;
}

/* --- Buttons --- */
.btn {
    padding: 0.5rem 0.5rem;
    font-size: 12px;
    font-weight: normal;
    border-radius: 0;
    border: 1px solid var(--border-dark);
    border-style: outset;
    background: var(--btn-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: none;
}
.btn:hover { background: #EFEFEF; }
.btn:active { border-style: inset; }
.btn-primary {
    background-color: var(--brand-blue);
    color: white;
    font-weight: bold;
}
.btn-primary:hover { background-color: var(--brand-blue-dark); }
.btn:disabled {
    background-color: #BFBFBF;
    color: var(--border-color);
    border-style: inset;
    cursor: not-allowed;
}

/* --- Report View (Statements) --- */
.statements-view {
    background-color: var(--bg-dark);
    border-radius: 0;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.tab-header {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    padding: 0;
    background: var(--bg-light);
}
.tab-btn {
    padding: 0.5rem 1rem;
    font-size: 12px;
    font-weight: bold;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    background: var(--btn-bg);
    border-radius: 0;
    cursor: pointer;
    margin-bottom: -2px;
    border-bottom: none;
    border-right: 1px solid var(--border-color);
}
.tab-btn.active {
    color: var(--text-primary);
    font-weight: bold;
    border-color: var(--border-color);
    background: var(--bg-dark);
    border-bottom: 2px solid var(--bg-dark);
}
.tab-content {
    display: none;
    overflow-y: auto;
    flex-grow: 1;
}

/* --- Tables --- */
.statement-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.statement-table tr { border-bottom: 1px solid var(--border-color); }
.statement-table td { padding: 0.5rem; }
.statement-table .text-right {
    text-align: right;
    font-family: "Courier New", Courier, monospace;
}
.category-header {
    background-color: var(--bg-light);
    font-weight: bold;
}

/* --- Mission Brief --- */
.mission-brief {
    max-width: 550px;
    margin: 0 auto 1.5rem auto;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: inset 1px 1px 0px #fff;
    text-align: left;
}
.mission-header {
    font-family: monospace;
    font-size: 14px;
    color: var(--brand-blue);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}
.mission-lead {
    font-size: 13px;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.4;
}

/* --- Message Modal --- */
#message-modal .modal-content {
    border: 2px solid var(--brand-blue);
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

/* --- Responsive Adjustments --- */

/* Tablet & Mobile Header/Layout */
/* style.css - Update Media Query section */
@media (max-width: 768px) {
    #header-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
    }

    .dashboard-grid {
        display: flex; /* Switch grid to flex column for better control */
        flex-direction: column;
        gap: 1rem;
    }

    .chart-wrapper.full-width {
        flex-direction: column; /* Stack parliament charts vertically */
        gap: 1.5rem;
    }
    
    .legacy-grid {
        grid-template-columns: 1fr; /* Stack legacy stats */
    }
    
    /* Ensure tables can scroll internally if needed */
    .tab-content {
        width: 100%;
        overflow-x: auto;
    }
    
    .header-left {
        justify-content: space-between;
        width: 100%;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Make stats 50% width on mobile so they stack cleanly */
    .ratio-box {
        flex: 1 1 45%; 
        justify-content: center;
    }
    
    .header-right {
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid #e0e0e0; /* Visual separator */
        padding-top: 0.5rem;
    }
    
    .chart-wrapper.full-width {
        flex-direction: column; /* Stack parliament charts */
    }
    
    .modal-content {
        width: 100%;
        margin: 0 auto;
        padding: 1rem;
        max-height: 95vh; /* Ensure it doesn't touch edges */
    }
}

/* --- End Game / Presidential Library Styles --- */
.legacy-container {
    background-color: #f9f9f9;
    border: 1px solid #ccc;
    padding: 20px;
    margin-top: 1rem;
    text-align: left;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.05);
}

.legacy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--brand-blue);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.legacy-grade {
    font-size: 42px;
    font-weight: bold;
    color: var(--brand-blue-dark);
    font-family: "Georgia", serif;
}

.legacy-title {
    font-size: 18px;
    font-weight: bold;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.legacy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.legacy-stat-box {
    background: #fff;
    border: 1px solid var(--border-color);
    padding: 10px;
}

.legacy-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 5px;
}

.legacy-stat-value {
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.historian-verdict {
    margin-top: 20px;
    font-style: italic;
    color: #444;
    border-top: 1px solid #eee;
    padding-top: 15px;
    font-size: 14px;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .legacy-grid {
        grid-template-columns: 1fr;
    }
    .legacy-header {
        flex-direction: column;
        text-align: center;
    }
    #game-container {
        border: none;
    }
    
    /* Stack Dashboard & Cards */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .industry-grid, .card-options-area {
        grid-template-columns: 1fr;
    }
    
    /* Header Tweaks for small screens */
    .ratio-value { font-size: 16px; font-weight: bold; }
    #view-report-btn { width: 100% !important; margin-top: 5px !important; }

    /* Footer Mobile Optimization */
    .footer {
        margin-top: 1rem;
    }
    .footer-nav {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .footer-divider { display: none; } /* Hide pipes */
    
    /* Report Modal Mobile Optimization */
    .tab-header {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling iOS */
        padding-bottom: 5px; /* Space for scrollbar */
    }
    .tab-btn {
        padding: 0.75rem 1rem; /* Bigger touch targets */
        flex: 0 0 auto; /* Don't shrink buttons */
    }
    
    .modal-chart-container {
        height: 220px; /* Smaller height for mobile landscape */
        padding: 5px;
    }
    
    .parliament-chart {
        height: 120px;
    }
    .tab-btn {
        padding: 0.5rem 0.5rem;
        font-size: 10px;
        font-weight: bold;
        color: var(--text-secondary);
        border: 1px solid var(--border-color);
        background: var(--btn-bg);
        border-radius: 0;
        cursor: pointer;
        margin-bottom: -2px;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
    }
}