* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 900px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-height: calc(100vh - 40px);
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.screen {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.screen.hidden {
    display: none;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2em;
}

h2 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.5em;
}

h3 {
    color: #34495e;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.instructions-panel {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 25px;
    margin-bottom: 30px;
    flex: 1;
}

.instructions-panel ul {
    list-style-position: inside;
    padding-left: 0;
}

.instructions-panel li {
    margin-bottom: 12px;
    color: #555;
}

.start-button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.1em;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s;
    align-self: center;
    margin-top: auto;
}

.start-button:hover {
    background-color: #2980b9;
}

.start-button:active {
    transform: scale(0.98);
}

.header-stats {
    display: flex;
    justify-content: space-around;
    background-color: #ecf0f1;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.portfolio-section-top {
    margin-left: auto;
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.portfolio-section-top h3 {
    margin-bottom: 10px;
    font-size: 1em;
    color: #34495e;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.9em;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #2c3e50;
}

.trading-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.equity-selector-section {
    margin-bottom: 20px;
    flex-shrink: 0;
}

.equity-selector-section label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.equity-select {
    width: 100%;
    padding: 10px;
    font-size: 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
}

.charts-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.chart-wrapper {
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
}

.chart-wrapper h3 {
    margin-bottom: 10px;
    text-align: center;
    font-size: 1em;
}

.chart-wrapper canvas {
    max-height: 200px;
}

.trading-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    flex-shrink: 0;
}

.quantity-control {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quantity-control label {
    color: #555;
    font-weight: 500;
}

.quantity-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.quantity-btn {
    background-color: #95a5a6;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.quantity-btn:hover {
    background-color: #7f8c8d;
}

#quantityInput {
    flex: 1;
    padding: 8px;
    font-size: 1em;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.trade-buttons {
    display: flex;
    gap: 10px;
}

.trade-btn {
    flex: 1;
    padding: 12px;
    font-size: 1em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.1s;
    font-weight: 600;
}

.buy-btn {
    background-color: #27ae60;
    color: white;
}

.buy-btn:hover {
    background-color: #229954;
}

.sell-btn {
    background-color: #e74c3c;
    color: white;
}

.sell-btn:hover {
    background-color: #c0392b;
}

.trade-btn:active {
    transform: scale(0.98);
}

.trade-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.portfolio-section {
    flex-shrink: 0;
    margin-top: auto;
}

.portfolio-section h3 {
    margin-bottom: 10px;
}

.portfolio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 2px solid #ddd;
    margin-bottom: 8px;
    gap: 15px;
}

.portfolio-header-label {
    font-weight: 600;
    font-size: 0.85em;
    color: #7f8c8d;
    text-transform: uppercase;
}

.portfolio-header-label:nth-child(1) {
    flex: 1;
    min-width: 150px;
}

.portfolio-header-label:nth-child(2) {
    min-width: 60px;
    text-align: right;
}

.portfolio-header-label:nth-child(3) {
    min-width: 80px;
    text-align: right;
}

.portfolio-header-label:nth-child(4) {
    min-width: 90px;
    text-align: right;
}

.portfolio-list {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.empty-portfolio {
    color: #95a5a6;
    text-align: center;
    font-style: italic;
}

.portfolio-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
    gap: 15px;
}

.portfolio-item:last-child {
    border-bottom: none;
}

.portfolio-ticker {
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
    min-width: 150px;
}

.portfolio-quantity {
    color: #555;
    font-weight: 500;
    min-width: 60px;
    text-align: right;
}

.portfolio-quantity.positive {
    color: #27ae60;
}

.portfolio-quantity.negative {
    color: #e74c3c;
}

.portfolio-value {
    font-weight: 600;
    min-width: 80px;
    text-align: right;
}

.portfolio-value.positive {
    color: #27ae60;
}

.portfolio-value.negative {
    color: #e74c3c;
}

.portfolio-gainloss {
    font-weight: 600;
    min-width: 90px;
    text-align: right;
}

.portfolio-gainloss.positive {
    color: #27ae60;
}

.portfolio-gainloss.negative {
    color: #e74c3c;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background-color: white;
    padding: 40px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
}

.overlay-content h2 {
    color: #e74c3c;
    margin-bottom: 30px;
}

.win-title {
    color: #27ae60 !important;
}

.win-message {
    color: #555;
    font-size: 1.1em;
    margin-bottom: 30px;
}

.app-footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 15px;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

@media (max-width: 768px) {
    .app-container {
        max-height: 100vh;
        min-height: 100vh;
        border-radius: 0;
    }

    body {
        padding: 0;
    }

    .screen {
        padding: 20px;
    }

    h1 {
        font-size: 1.5em;
    }

    .header-stats {
        flex-direction: column;
        gap: 10px;
    }

    .charts-container {
        gap: 15px;
    }

    .chart-wrapper canvas {
        max-height: 150px;
    }
}

