body { 
    font-family: Arial, sans-serif; 
    margin: 10px; 
    padding: 0;
    box-sizing: border-box;
}

/* Make all elements respect box-sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Responsive image */
img {
    max-width: 100%;
    width: 100%;
    max-width: 500px; /* Default max size */
    height: auto;
    display: block;
    margin: 0 auto;
}

/* Adjust image size for larger screens */
@media (min-width: 1200px) {
    img {
        max-width: 600px;
    }
}

/* Center the main title */
h1 {
    text-align: center;
}

textarea { 
    width: 100%; 
    max-width: 600px;
    height: 120px;
    box-sizing: border-box;
    padding: 10px;
    font-size: 16px; /* Prevents zoom on iOS */
    display: block;
    margin: 0 auto;
}

button { 
    margin-top: 10px;
    padding: 12px 20px;
    font-size: 16px;
    border: none;
    background-color: #007cba;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: #005a87;
}

/* Responsive table */
table { 
    border-collapse: collapse; 
    width: 100%; 
    margin-top: 20px;
    font-size: 14px;
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

table thead, table tbody {
    display: table;
    width: 100%;
}

th, td { 
    border: 1px solid #ddd; 
    padding: 8px; 
    text-align: right;
    min-width: 80px;
}

th { 
    background-color: #f2f2f2; 
    text-align: left;
    font-weight: bold;
}

.total { 
    font-weight: bold; 
}

#totalGrown, #projectedPortfolio { 
    font-size: clamp(24px, 8vw, 48px); /* Responsive font size */
    font-weight: bold; 
    color: #2e7d32; 
    margin: 10px 0; 
    text-align: center;
    word-break: break-word;
}

.checkbox-container, .example-container, .projection-container { 
    margin-top: 15px;
}

.checkbox-container label, .example-container label, .projection-container label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 16px;
    justify-content: space-between;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.checkbox-container {
    text-align: center;
    margin-top: 15px;
}

.checkbox-container label {
    justify-content: flex-start;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    display: inline-block;
    margin-right: 20px;
}

.checkbox-container input[type="checkbox"] {
    margin-left: 8px;
    order: 2;
}

.example-container input, .projection-container input {
    width: 200px;
    padding: 8px;
    margin-left: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
}

.example-container select {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin-left: 10px;
    min-width: 200px;
}

.example-container select:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
}

.example-container small {
    display: block;
    margin-top: 5px;
    margin-bottom: 10px;
    color: #666;
    margin-left: 20px;
}

.example-container label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 16px;
    justify-content: space-between;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.example-container button {
    display: block;
    margin: 15px auto;
    padding: 10px 20px;
    font-size: 16px;
    border: none;
    background-color: #007cba;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}

.example-container button:hover {
    background-color: #005a87;
}

.centered-text { 
    text-align: center; 
}

.early-retirement-container {
    margin-top: 15px;
}

.early-retirement-container label {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 16px;
    justify-content: space-between;
    max-width: 450px;
    margin-left: auto;
    margin-right: auto;
    white-space: nowrap;
}

.early-retirement-container input {
    width: 200px;
    padding: 8px;
    margin-left: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-shrink: 0;
    min-width: 120px;
    max-width: 100%;
}

/* Mobile-specific override */
@media (max-width: 768px) {
    .early-retirement-container input {
        width: 120px; /* Reduce width on mobile */
        min-width: 100px;
        margin-left: 5px; /* Reduce margin */
    }
    
    .early-retirement-container label {
        max-width: 95%; /* Use more of the screen width */
        font-size: 14px; /* Slightly smaller text */
    }
}

@media (max-width: 480px) {
    .early-retirement-container input {
        width: 100px; /* Even smaller on very small screens */
        min-width: 80px;
        padding: 6px;
        font-size: 14px;
    }
}

.early-retirement-container input[type="checkbox"] {
    width: 20px;
    padding: 0;
    margin-left: 0;
}

.large-button {
    padding: 15px 25px;
    font-size: 18px;
    min-width: 150px;
    min-height: 60px;
    border-radius: 8px;
    display: block;
    margin: 20px auto;
    background-color: #28a745;
    color: white;
    border: none;
    cursor: pointer;
}

.large-button:hover {
    background-color: #218838;
}

/* Chart container */
.chart-container {
    display: flex; 
    justify-content: center; 
    align-items: center;
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
}

#comparisonChart {
    width: 100% !important;
    max-width: 800px !important;
    height: 400px !important;
}

#portfolioGrowthChart {
    width: 100% !important;
    max-width: 1200px !important;
    height: 450px !important;
    margin-top: 20px;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    body {
        margin: 5px;
        font-size: 16px;
    }
    
    h1 {
        font-size: 24px;
        text-align: center;
    }
    
    h2 {
        font-size: 20px;
        text-align: center;
    }
    
    textarea {
        height: 150px;
        font-size: 14px;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 6px 4px;
        min-width: 60px;
    }
    
    .large-button {
        font-size: 16px;
        min-height: 50px;
        padding: 12px 20px;
    }
    
    #comparisonChart {
        height: 300px !important;
    }
    
    .example-container, .projection-container {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {
    body {
        margin: 2px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    h2 {
        font-size: 18px;
    }
    
    textarea {
        height: 120px;
        font-size: 14px;
    }
    
    table {
        font-size: 11px;
    }
    
    th, td {
        padding: 4px 2px;
        min-width: 50px;
    }
    
    #comparisonChart {
        height: 250px !important;
    }
}

/* Table wrapper for horizontal scroll on mobile */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrapper table {
    display: table;
    white-space: nowrap;
    min-width: 100%;
}

/* Mobile-first approach for Social Security trust fund warning */
#ssaTrustFundWarning {
    max-width: 95%; /* Take up most of mobile screen */
    margin: 20px auto;
}

/* Desktop styles */
@media (min-width: 1080px) {
    #ssaTrustFundWarning {
        max-width: 40%; /* Keep current desktop behavior */
    }
}

/* Federal Income Tax Percentage Container */
#federalTaxPercentageContainer {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

#federalTaxPercentageContainer label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

#federalTaxPercentageContainer input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Personal Savings Container */
#personalSavingsContainer {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

#personalSavingsContainer label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

#personalSavingsContainer input {
    width: 80px;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Error message styles */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 15px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
}

/* Add a class for the wide input box */
.input-fields-box {
    margin: 30px auto;
    padding: 18px;
    background: #f5f5f5;
    border-radius: 10px;
    max-width: 600px;
    border: 1px solid #e0e0e0;
}

/* Make the input box wider on desktop screens */
@media (min-width: 1080px) {
    .input-fields-box {
        max-width: 900px;
    }
}