/* --- 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;
    --brand-blue: #00458C;
    --brand-blue-dark: #003366;
    --green-accent: #008000;
    --red-accent: #FF0000;
    --btn-bg: #DFDFDF; /* Standard button background */
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    min-width: 320px; /* Changed from 1000px */
    font-size: 14px;
}

/* --- Typography --- */
.header-1 {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}
.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-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;
}
.modal-content {
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    border-radius: 0;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 700px;
    max-height: 90vh; 
    overflow-y: auto;
}
.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;
}

.startup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.startup-card {
    background: var(--btn-bg);
    padding: 1rem;
    border-radius: 0;
    border: 1px solid var(--border-dark);
    border-style: outset;
    transition: none;
    cursor: pointer;
}
.startup-card:hover {
    background: #EFEFEF;
}
.startup-card.selected {
    background: #CACACA;
    border-style: inset;
}
.startup-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-blue);
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.startup-card p {
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.4;
    font-size: 12px;
}
.startup-card .effect-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    font-style: italic;
}

/* --- Main Game Layout --- */
#game-container {
    width: 100%;
    max-width: 1200px;
    height: 90vh; /* Use viewport height */
    max-height: 800px;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-dark);
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* --- Header Bar --- */
#header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.turn-counter {
    font-size: 14px;
    font-weight: bold;
    color: var(--brand-blue);
}
.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.ratio-box {
    background: none;
    padding: 0;
    border: none;
    width: auto;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ratio-title {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
    text-transform: none;
}
.ratio-value {
    font-size: 14px;
    font-weight: normal;
    font-family: "Courier New", Courier, monospace;
    color: var(--text-primary);
    background: white;
    border: 1px solid var(--border-color);
    border-style: inset;
    padding: 2px 5px;
    min-width: 80px;
    text-align: right;
}
#ratio-cash { font-weight: bold; }


/* --- Main Content --- */
#main-content {
    flex-grow: 1;
    padding: 1rem;
    overflow-y: auto;
}

/* --- Game View (Card Choices) --- */
.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: 80px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    padding-top: 2rem; /* Space for badge */
    border-right-width: 2px;
    border-bottom-width: 2px;
}
.decision-card:hover {
    border-color: var(--brand-blue);
    transform: none;
}
.decision-card.selected { /* This will flash briefly */
    border: 2px solid var(--brand-blue);
    transform: none;
    box-shadow: 0 0 5px var(--brand-blue);
}
.card-type-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.type-operations { background-color: var(--brand-blue); color: white; }
.type-investing { background-color: var(--green-accent); color: white; }
.type-financing { background-color: #A0A0A0; color: white; }
.decision-card .card-content { 
    flex-grow: 1; 
    display: flex;
    flex-direction: column;
}
.decision-card .card-content { flex-grow: 1; }
.decision-card h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.5rem 0;
    padding-top: 0.5rem;
}
.decision-card p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 0.5rem 0;
    line-height: 1.5;
    flex-grow: 1;
}
.decision-card .effect-text {
    font-size: 11px;
    color: #444;
    font-style: italic;
    margin: 0;
    line-height: 1.4;
}
.effect-text.pro-mode-hidden { display: none; }
.footer-link {
    color: inherit; /* Uses the same color as the surrounding text */
    text-decoration: none; /* Removes the default underline */
    font-weight: 600; /* Makes it slightly bolder (optional) */
    transition: opacity 0.3s ease; /* Smooth transition for hover effect */
}

.footer-link:hover {
    opacity: 0.7; /* Slightly fades the text when hovered */
    text-decoration: underline; /* Optional: adds underline only on hover */
    cursor: pointer;
}
.startup-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.startup-footer a {
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: bold;
}
.startup-footer a:hover {
    text-decoration: underline;
}
/* --- Pro Mode Checkbox --- */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}
.toggle-label {
    font-size: 12px;
    font-weight: bold;
    color: var(--text-primary);
    cursor: pointer;
}
.sap-checkbox {
    margin: 0;
    width: 13px;
    height: 13px;
}

/* --- Buttons --- */
.btn {
    padding: 0.5rem 1rem;
    font-size: 14px;
    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:hover {
    color: var(--text-primary);
    background: #EFEFEF;
}
.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 {
    padding: 1rem;
    display: none;
    overflow-y: auto;
    flex-grow: 1;
}
.tab-content.active { display: block; }
.statements-placeholder { display: none; }

/* --- Statement Table Styling --- */
.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 .indent {
    padding-left: 1.5rem;
    color: var(--text-secondary);
}
.statement-table .indent-less { padding-left: 0.5rem; }
.statement-table .text-right {
    text-align: right;
    font-family: "Courier New", Courier, monospace;
}
.statement-table .total-row {
    background-color: var(--bg-light);
    font-weight: bold;
}
.statement-table .net-income-row {
    background-color: #D6E6F5;
    font-weight: bold;
    color: var(--brand-blue);
    border-top: 1px solid var(--brand-blue);
}
.statement-table .final-total-row {
    background-color: #D6E6F5;
    font-weight: bold;
    color: var(--brand-blue);
    border-top: 1px solid var(--brand-blue);
}
.statement-table .category-header {
    background-color: var(--bg-light);
    font-weight: bold;
    font-size: 14px;
    padding-top: 1rem;
}
.statement-table .subcategory-header {
    font-weight: bold;
    padding-top: 0.75rem;
}
.year-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}

/* --- Ratio Flashing Animations --- */
.flash-green { animation: flash-green 1s ease-out; }
.flash-red { animation: flash-red 1s ease-out; }
@keyframes flash-green {
    0%, 100% { color: var(--text-primary); }
    50% { color: var(--green-accent); font-weight: 700; }
}
@keyframes flash-red {
    0%, 100% { color: var(--text-primary); }
    50% { color: var(--red-accent); font-weight: 700; }
}

/* --- Error Text --- */
.error-text { color: var(--red-accent); font-weight: bold; }
.placeholder-text {
    text-align: center;
    color: var(--text-secondary);
    margin-top: 2rem;
}

/* --- NEW: Mobile Responsive Styles --- */
@media (max-width: 768px) {
    body {
        /* Allow scrolling */
        height: auto;
        min-height: 100vh;
    }

    #game-container {
        /* Fill the screen */
        width: 100%;
        min-width: 0;
        height: 100vh; /* Use full viewport height */
        max-height: none;
        border: none; /* No border on mobile */
    }

    #main-content {
        padding: 0.75rem; /* Reduce padding */
    }

    /* --- Modals --- */
    .modal-content {
        width: 95%;
        max-width: 95vw;
        padding: 1rem;
        max-height: 90vh; /* Ensure modal is scrollable */
    }

    /* --- Grids (stack them) --- */
    .industry-grid,
    .startup-grid,
    .card-options-area {
        grid-template-columns: 1fr;
    }
    
    .decision-card {
        min-height: 120px; /* Slightly smaller min-height */
    }

    /* --- Header --- */
    #header-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    .header-right {
        width: 100%;
        justify-content: flex-end; /* Push ratio box to the right */
    }
    .ratio-value {
        min-width: 100px; /* Ensure cash is visible */
    }

    /* --- Tables --- */
    .tab-content {
        /* Make tables horizontally scrollable */
        overflow-x: auto; 
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 0.5rem;
    }
    
    .statement-table {
        font-size: 11px; /* Slightly smaller font to fit */
        white-space: nowrap; /* Prevent ugly wrapping in tables */
    }
    
    /* Make SE table headers stack for readability */
    #tab-content-se .statement-table th,
    #tab-content-se .statement-table td {
        padding: 0.5rem 0.75rem; /* Adjust padding */
    }

    /* --- Tabs --- */
    .tab-header {
        /* Allow tabs to scroll horizontally */
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .tab-btn {
        flex-shrink: 0; /* Prevent tabs from shrinking */
    }

    /* --- Charts --- */
    #performance-chart-area {
        margin-top: 1.5rem;
    }
    #chart-container-revenue,
    #chart-container-net-income,
    #chart-container-eps {
        height: 200px; /* Reduce chart height */
    }

    .header-right {
        width: 100%;
        display: flex;
        flex-direction: column; /* Stack items vertically */
        align-items: stretch;   /* Make items span the full width */
        gap: 0.5rem;            /* Add space between the boxes */
        margin-top: 0.5rem;
    }

    .ratio-box {
        justify-content: space-between; /* Push Label to left, Value to right */
        border: 1px solid var(--border-color); /* Add border to container for clarity */
        padding: 0.5rem;
        background: var(--bg-light);
    }
    .end-game-modal-content {
        max-width: 800px; 
    }

    #end-game-screen .statement-table {
        margin-top: 0.5rem;
        width: 100%;
        
        /* --- NEW: Make tables scrollable on mobile --- */
        display: block;           /* Allows the table element to act as a container */
        overflow-x: auto;         /* Enables horizontal scrolling */
        white-space: nowrap;      /* Prevents cells from wrapping awkwardly */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling for iOS */
        /* --------------------------------------------- */
    }

    #end-game-screen .statement-table td {
        padding: 0.6rem 0.75rem; 
        font-size: 14px;
    }
}
.chart-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    font-style: italic;
    /* Use a light background to look like an empty panel */
    background-color: var(--bg-light); 
    z-index: 10; /* Make sure it's on top of the canvas */
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--border-color);
    margin: 0; /* Reset default p margin */
}

/* --- End Game Screen Improvements --- */
.end-game-modal-content {
    max-width: 800px; /* Wider modal for tables */
}

#end-game-screen .statement-table {
    margin-top: 0.5rem;
    width: 100%;
}

#end-game-screen .statement-table td {
    padding: 0.6rem 0.75rem; /* More padding */
    font-size: 14px;
}

#end-game-screen .statement-table .metric-title {
    font-weight: bold;
    color: var(--text-primary);
}

.text-red {
    color: var(--red-accent);
    font-weight: 700;
}

#bankrupt-cash-final {
    font-size: 16px;
    font-weight: bold;
    color: var(--red-accent);
    text-align: center;
    margin: 0.5rem 0;
}