/**
 * INVEST-SIM Styles
 *
 * Mobile-first PWA styling
 * Modern CSS: Grid, Flex, Custom Properties, clamp()
 */

/* =============================================================================
   CSS CUSTOM PROPERTIES
   ============================================================================= */

:root {
    /* Colors */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-elevated: #1f2b4d;

    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));

    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono: 'SF Mono', Monaco, 'Courier New', monospace;

    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);

    /* Layout */
    --header-height: 60px;
    --nav-height: 70px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* =============================================================================
   RESET & BASE
   ============================================================================= */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
}

input, button, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* =============================================================================
   APP LAYOUT
   ============================================================================= */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-md);
    z-index: 100;
    padding-top: env(safe-area-inset-top, 0px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.app-title {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.session-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--success-bg);
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.lang-toggle {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-toggle:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

.lang-flag {
    font-size: 1.2rem;
    line-height: 1;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.header-info .label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.header-info .value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.app-main {
    flex: 1;
    padding: calc(var(--header-height) + var(--space-md)) var(--space-md) calc(var(--nav-height) + var(--safe-area-bottom) + var(--space-md));
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* =============================================================================
   BOTTOM NAVIGATION
   ============================================================================= */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
    min-width: 64px;
    min-height: 44px; /* Touch target */
}

.nav-item:active {
    transform: scale(0.95);
}

.nav-item.active {
    color: var(--accent-primary);
}

.nav-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.nav-label {
    font-size: 0.7rem;
    margin-top: 2px;
    font-weight: 500;
}

/* =============================================================================
   TAB CONTENT
   ============================================================================= */

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   CARDS
   ============================================================================= */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    color: var(--text-primary);
}

.card-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: calc(-1 * var(--space-sm));
    margin-bottom: var(--space-md);
}

/* =============================================================================
   FORMS
   ============================================================================= */

.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 44px; /* Touch target */
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-row .btn {
    align-self: end;
}

/* =============================================================================
   BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-sm) var(--space-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    min-height: 44px; /* Touch target */
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

/* =============================================================================
   SUMMARY CARD
   ============================================================================= */

.summary-card {
    background: var(--accent-gradient);
    color: white;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.summary-row .label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.summary-row .value {
    font-weight: 600;
}

.summary-row .value.large {
    font-size: 1.75rem;
}

.summary-row.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: var(--space-sm);
    padding-top: var(--space-md);
}

.summary-row.split > div {
    display: flex;
    flex-direction: column;
}

/* =============================================================================
   STATS GRID
   ============================================================================= */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
}

.stat {
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
}

/* =============================================================================
   POSITIONS LIST
   ============================================================================= */

.positions-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.position-item {
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
}

.position-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.position-header .symbol {
    font-weight: 700;
    font-size: 1.1rem;
}

.position-header .market-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

.position-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.position-price {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.position-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.position-actions {
    display: flex;
    gap: var(--space-xs);
}

.btn-quick-sell {
    font-size: 0.7rem;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.btn-quick-sell:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.btn-quick-sell-all:hover {
    background: var(--danger);
    color: white;
}

.btn-quick-sell.confirm {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

/* =============================================================================
   PORTFOLIO ANALYSIS
   ============================================================================= */

.analysis-section {
    margin-bottom: var(--space-lg);
}

.analysis-section:last-child {
    margin-bottom: 0;
}

.analysis-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sector-chart {
    display: flex;
    height: 24px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: var(--space-sm);
}

.sector-bar {
    height: 100%;
    transition: opacity 0.2s;
}

.sector-bar:hover {
    opacity: 0.8;
}

.sector-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.metric-item {
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

.metric-value.good {
    color: var(--success);
}

.metric-value.warning {
    color: var(--warning);
}

.metric-value.bad {
    color: var(--danger);
}

/* =============================================================================
   QUICK STOCK SELECTION
   ============================================================================= */

.quick-stocks {
    margin-bottom: var(--space-md);
}

.quick-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.stock-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.stock-chip {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-full);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px; /* Touch target */
}

.stock-chip:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.stock-chip:active {
    transform: scale(0.95);
}

.stock-chip.selected {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.stock-chip.etf {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.stock-chip.etf:hover {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.stock-chip.commodity {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--warning);
}

.stock-chip.commodity:hover {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

/* Stock chip tooltip styling */
.stock-chip[title] {
    position: relative;
}

.symbol-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    min-height: 1em;
}

.symbol-hint strong {
    color: var(--accent-primary);
}

/* =============================================================================
   PRICE DISPLAY & ORDER ESTIMATE
   ============================================================================= */

.price-display {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
}

.price-display:empty {
    display: none;
}

.current-price-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.current-price-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.price-loading {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.price-error {
    font-size: 0.8rem;
    color: var(--danger);
}

.amount-input-group {
    margin-bottom: var(--space-md);
}

.amount-input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.amount-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.amount-prefix {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    color: var(--text-muted);
    font-weight: 600;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.amount-input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 1rem;
    min-height: 44px;
}

.amount-input-wrapper input:focus {
    outline: none;
}

.amount-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.order-estimate {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.order-estimate:empty {
    display: none;
}

.estimate-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.estimate-value {
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.estimate-value.over-budget {
    color: var(--danger);
}

.estimate-warning {
    font-size: 0.7rem;
    color: var(--danger);
    background: var(--danger-bg);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    width: 100%;
    text-align: center;
    margin-top: var(--space-xs);
}

/* =============================================================================
   SCENARIOS
   ============================================================================= */

.scenarios-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.scenario-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
}

.scenario-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.scenario-card:active {
    transform: scale(0.98);
}

.scenario-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.scenario-content {
    flex: 1;
    min-width: 0;
}

.scenario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xs);
}

.scenario-name {
    font-weight: 600;
    font-size: 1rem;
}

.scenario-difficulty {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
}

.difficulty-easy {
    background: var(--success-bg);
    color: var(--success);
}

.difficulty-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.difficulty-hard {
    background: var(--danger-bg);
    color: var(--danger);
}

.scenario-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.scenario-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

.divider-text {
    display: flex;
    align-items: center;
    margin: var(--space-lg) 0;
    color: var(--text-muted);
}

.divider-text::before,
.divider-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.divider-text span {
    padding: 0 var(--space-md);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* =============================================================================
   STEP CONTROLS
   ============================================================================= */

.step-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

/* =============================================================================
   EVENTS FEED
   ============================================================================= */

.events-feed {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    max-height: 300px;
    overflow-y: auto;
}

.event-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    border-left: 3px solid var(--text-muted);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.event-item.new {
    background: var(--bg-card);
    border-left-color: var(--accent-primary);
}

.event-item.crash {
    border-left-color: var(--danger);
}

.event-item.recovery {
    border-left-color: var(--success);
}

.event-item.milestone {
    border-left-color: var(--warning);
}

.event-item.volatile {
    border-left-color: var(--accent-secondary);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-xs);
}

.event-title {
    font-weight: 600;
    font-size: 0.9rem;
    flex: 1;
}

.event-impact {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
    margin-left: var(--space-sm);
}

.event-impact.critical {
    background: var(--danger-bg);
    color: var(--danger);
}

.event-impact.major {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.event-impact.minor {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.event-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Event Toast (special notification) */
.toast-event {
    border-left: 3px solid var(--warning);
    background: var(--bg-card);
}

.toast-event .event-icon {
    font-size: 1.2rem;
    margin-right: var(--space-sm);
}

/* =============================================================================
   CHARTS
   ============================================================================= */

.chart-container {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: var(--space-md);
    min-height: 250px;
    height: 280px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-container .empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 0;
}

.chart-container svg {
    max-width: 100%;
    height: auto;
}

/* Chart Symbol Input */
.chart-symbol-input {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.chart-symbol-input input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    min-height: 44px;
    text-transform: uppercase;
}

.chart-symbol-input input::placeholder {
    text-transform: none;
    color: var(--text-muted);
}

.chart-symbol-input input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.chart-symbol-input .btn {
    padding: var(--space-sm) var(--space-lg);
    min-width: 80px;
    white-space: nowrap;
}

/* =============================================================================
   QUESTS
   ============================================================================= */

.quest-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.quest-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-elevated);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    transition: transform 0.2s;
}

.quest-item:active {
    transform: scale(0.98);
}

.quest-icon {
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.quest-info {
    flex: 1;
}

.quest-info h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.quest-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.quest-badge {
    font-size: 0.75rem;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-weight: 600;
}

.quest-badge.pending {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.quest-badge.done {
    background: var(--success-bg);
    color: var(--success);
}

/* =============================================================================
   TRADE HISTORY
   ============================================================================= */

.trade-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 300px;
    overflow-y: auto;
}

.trade-item {
    background: var(--bg-elevated);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trade-item.buy {
    border-left: 3px solid var(--success);
}

.trade-item.sell {
    border-left: 3px solid var(--danger);
}

.trade-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.trade-type {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.trade-item.buy .trade-type {
    background: var(--success-bg);
    color: var(--success);
}

.trade-item.sell .trade-type {
    background: var(--danger-bg);
    color: var(--danger);
}

.trade-symbol {
    font-weight: 600;
}

.trade-details {
    text-align: right;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.trade-date {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* =============================================================================
   EMPTY STATE
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* =============================================================================
   USER AUTH AREA
   ============================================================================= */

.user-area {
    display: flex;
    align-items: center;
}

.btn-login {
    background: var(--accent-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    background: var(--accent-secondary);
}

.user-logged-in {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-logout-small {
    background: var(--bg-elevated);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout-small:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

/* =============================================================================
   AUTH MODAL
   ============================================================================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-md);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.auth-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.auth-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--accent-primary);
    color: white;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-error {
    background: var(--danger-bg);
    color: var(--danger);
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: var(--space-md);
    display: none;
}

.auth-error.show {
    display: block;
}

/* =============================================================================
   GAME MODES & LEADERBOARD
   ============================================================================= */

.game-modes {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.game-mode-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.mode-icon {
    font-size: 2rem;
    width: 50px;
    text-align: center;
}

.mode-info {
    flex: 1;
}

.mode-info h3 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.mode-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-start-game {
    padding: 8px 16px;
    font-size: 0.85rem;
}

.active-game-status {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--accent-bg);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    margin-top: var(--space-md);
    text-align: center;
}

.game-info-row {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    font-size: 0.9rem;
}

.game-mode-label {
    color: var(--accent-primary);
    font-weight: 600;
}

.game-cash-label {
    color: var(--success);
    font-weight: 600;
}

.game-timer {
    display: flex;
    flex-direction: column;
}

.timer-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.timer-value {
    font-size: 2rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.game-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 0;
}

.btn-warning {
    background: var(--warning);
    color: #000;
}

.btn-warning:hover {
    background: #d97706;
}

/* Leaderboard */
.leaderboard-tabs {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-md);
}

.leaderboard-tab {
    flex: 1;
    padding: var(--space-sm);
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-tab.active {
    background: var(--accent-primary);
    color: white;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
}

.leaderboard-rank {
    font-size: 1.1rem;
    font-weight: 700;
    width: 32px;
    text-align: center;
}

.leaderboard-rank.gold { color: #ffd700; }
.leaderboard-rank.silver { color: #c0c0c0; }
.leaderboard-rank.bronze { color: #cd7f32; }

.leaderboard-player {
    flex: 1;
}

.leaderboard-player-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.leaderboard-player-games {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.leaderboard-return {
    font-weight: 700;
    font-family: var(--font-mono);
}

/* Live Games */
.live-games-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.live-game-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--danger);
}

.live-indicator {
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.live-game-info {
    flex: 1;
}

.live-game-player {
    font-weight: 600;
    font-size: 0.9rem;
}

.live-game-mode {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.live-game-time {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* =============================================================================
   DISCLAIMER
   ============================================================================= */

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    margin-top: var(--space-md);
    line-height: 1.6;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

#toast-container {
    position: fixed;
    top: calc(var(--header-height) + var(--space-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    width: calc(100% - var(--space-lg) * 2);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: var(--space-md);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: auto;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-left: 3px solid var(--success);
}

.toast-error {
    border-left: 3px solid var(--danger);
}

.toast-info {
    border-left: 3px solid var(--accent-primary);
}

/* Trade Toast (special styling for buy/sell confirmations) */
.toast-trade {
    padding: var(--space-md);
}

.toast-trade.buy {
    border-left: 4px solid var(--success);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(16, 185, 129, 0.1) 100%);
}

.toast-trade.sell {
    border-left: 4px solid var(--danger);
    background: linear-gradient(135deg, var(--bg-elevated) 0%, rgba(239, 68, 68, 0.1) 100%);
}

.trade-toast-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.trade-toast-icon {
    font-size: 1rem;
}

.trade-toast-type {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toast-trade.buy .trade-toast-type {
    color: var(--success);
}

.toast-trade.sell .trade-toast-type {
    color: var(--danger);
}

.trade-toast-body {
    font-size: 0.95rem;
}

.trade-toast-total {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

/* =============================================================================
   LOADING OVERLAY
   ============================================================================= */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 26, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.2s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================================================
   SKELETON LOADING
   ============================================================================= */

.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-card) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* =============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================= */

@media (min-width: 768px) {
    .app-main {
        padding-left: var(--space-xl);
        padding-right: var(--space-xl);
    }

    .card {
        padding: var(--space-xl);
    }
}

@media (max-width: 360px) {
    :root {
        --space-md: 12px;
        --space-lg: 16px;
    }

    .summary-row .value.large {
        font-size: 1.5rem;
    }
}

/* Dark mode is default, but support light preference */
@media (prefers-color-scheme: light) {
    /* Could add light theme here if wanted */
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =============================================================================
   ROOM LOBBY STYLES
   ============================================================================= */

/* Play Mode Tabs */
.play-mode-tabs {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    padding: var(--space-xs);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.play-mode-tab {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.play-mode-tab.active {
    background: var(--accent-primary);
    color: white;
}

.play-mode-tab:hover:not(.active) {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.play-mode-content {
    display: none;
}

.play-mode-content.active {
    display: block;
}

.mode-description {
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
}

/* Room Sections */
.join-room-section,
.create-room-section,
.public-rooms-section {
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.join-room-section h3,
.create-room-section h3,
.public-rooms-section h3 {
    margin-bottom: var(--space-sm);
    font-size: 1rem;
    color: var(--text-primary);
}

.join-room-form {
    display: flex;
    gap: var(--space-sm);
}

.join-room-form input {
    flex: 1;
    text-transform: uppercase;
}

.create-room-options {
    display: flex;
    gap: var(--space-sm);
}

.create-room-options select {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.public-rooms-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.public-room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.public-room-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.public-room-code {
    font-weight: 700;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.public-room-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn-refresh {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: var(--space-xs);
    vertical-align: middle;
}

.btn-refresh:hover {
    transform: rotate(180deg);
    transition: transform 0.3s;
}

/* Room Lobby */
.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.room-header h2 {
    margin: 0;
}

#room-code {
    font-family: var(--font-mono);
    color: var(--accent-primary);
    letter-spacing: 2px;
}

.room-mode {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

.room-players {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.player-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    transition: all 0.2s;
}

.player-card.ready {
    border-color: var(--success);
    background: var(--success-bg);
}

.player-card.host {
    border-color: var(--warning);
}

.player-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    text-align: center;
}

.player-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.player-status.ready {
    color: var(--success);
}

.room-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    margin-bottom: var(--space-md);
}

.room-hint {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Room Game Active */
.room-standings {
    margin: var(--space-md) 0;
}

.standing-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-xs);
}

.standing-item.me {
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid var(--accent-primary);
}

.standing-rank {
    font-weight: 700;
    width: 30px;
}

.standing-name {
    flex: 1;
    padding-left: var(--space-sm);
}

.standing-return {
    font-weight: 600;
    font-family: var(--font-mono);
}

.standing-return.positive {
    color: var(--success);
}

.standing-return.negative {
    color: var(--danger);
}

/* Button small variant */
.btn-small {
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.8rem;
    min-height: auto;
}
