:root {
    --bg-dark: #0b1120;
    --card-bg: #1e293b;
    --primary: #22c55e;
    --accent: #f59e0b;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
body { background-color: var(--bg-dark); color: var(--text-main); height: 100vh; width: 100vw; overflow: hidden; display: flex; flex-direction: column; }
.hidden { display: none !important; }

.clock-bar { background: #020617; border-bottom: 1px solid #334155; padding: 7px 10px; display: flex; justify-content: space-between; align-items: center; font-size: 0.73rem; z-index: 100; flex-shrink: 0; }
.country-tag { color: var(--accent); font-weight: 700; margin-right: 4px; }
.loan-timer { background: rgba(239, 68, 68, 0.2); color: #fca5a5; padding: 2px 6px; border-radius: 6px; border: 1px solid rgba(239, 68, 68, 0.4); font-weight: 600; }
.btn-accel { background: #3b82f6; color: white; border: none; padding: 3px 7px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; cursor: pointer; margin-left: 4px; }

.sale-toast {
    position: fixed; top: 44px; right: 12px; background: rgba(22, 163, 74, 0.95);
    color: white; padding: 6px 12px; border-radius: 20px; font-size: 0.78rem;
    font-weight: 800; z-index: 500; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.screen { display: none; width: 100%; flex: 1; overflow-y: auto; overflow-x: hidden; }
.screen.active { display: flex; flex-direction: column; }

#screen-cover { background: radial-gradient(circle at top, #1e3a8a 0%, #0b1120 100%); background-image: url('/cover.jpg'); background-repeat: no-repeat; background-position: center center; background-size: cover; }
.cover-overlay { background: linear-gradient(180deg, rgba(11,17,32,0.7) 0%, rgba(11,17,32,0.2) 50%, rgba(11,17,32,0.95) 100%); width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 24px; }
.logo-box { display: inline-flex; flex-direction: column; background: rgba(15, 23, 42, 0.85); padding: 10px 16px; border-radius: 12px; border: 1px solid rgba(245, 158, 11, 0.4); }
.logo-title { font-weight: 800; font-size: 1.2rem; color: var(--accent); }
.tg-badge { font-size: 0.75rem; background: #0088cc; color: white; padding: 2px 8px; border-radius: 6px; width: fit-content; margin-top: 4px; }

.btn-primary { width: 100%; padding: 14px; background-color: var(--primary); color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: bold; cursor: pointer; box-shadow: 0 4px 15px rgba(34, 197, 94, 0.35); }

#screen-auth { justify-content: center; padding: 20px; }
.auth-container { background: var(--card-bg); padding: 22px; border-radius: 16px; border: 1px solid #334155; width: 100%; max-width: 420px; margin: 0 auto; }
.auth-tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.tab-btn { flex: 1; padding: 10px; background: #0f172a; color: var(--text-muted); border: none; border-radius: 8px; font-weight: 600; }
.tab-btn.active { background: var(--accent); color: #000; }
.auth-form { display: none; }
.auth-form.active { display: block; }
.subtitle { color: var(--text-muted); font-size: 0.82rem; margin-bottom: 14px; }
.input-group { margin-bottom: 12px; }
.input-group label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 4px; }
.input-group input { width: 100%; padding: 11px; background: #0f172a; border: 1px solid #334155; border-radius: 8px; color: white; font-size: 0.95rem; }
.message-box { margin-top: 12px; text-align: center; font-size: 0.88rem; color: var(--accent); }

#screen-letter { padding: 20px; justify-content: center; }
.letter-paper { background: #fef3c7; color: #1e293b; padding: 20px; border-radius: 14px; border: 3px double #b45309; box-shadow: 0 10px 30px rgba(0,0,0,0.6); }
.bank-seal { text-align: center; font-weight: 800; color: #78350f; border-bottom: 2px solid #d97706; padding-bottom: 8px; margin-bottom: 12px; }
.letter-paper h3 { text-align: center; font-size: 1rem; margin-bottom: 10px; color: #92400e; }
.letter-paper p { font-size: 0.86rem; line-height: 1.45; margin-bottom: 10px; }
.loan-highlight { background: #fde68a; border-left: 4px solid #b45309; padding: 10px; border-radius: 6px; margin: 12px 0; font-size: 0.84rem; }

.map-header { padding: 12px 16px; background: #0f172a; border-bottom: 1px solid #334155; }
.map-header h2 { font-size: 1.05rem; color: var(--accent); }
.map-header p { font-size: 0.78rem; color: var(--text-muted); }
.map-frame { flex: 1; background-size: cover; background-position: center; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; }
.map-overlay-cards { display: flex; flex-direction: column; gap: 10px; }
.region-card { background: rgba(15, 23, 42, 0.92); border: 1px solid #475569; padding: 12px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; }
.region-card.available { border-color: var(--primary); }
.region-card h4 { font-size: 0.92rem; margin-bottom: 3px; }
.region-card p { font-size: 0.76rem; color: var(--text-muted); }
.btn-small-green { background: var(--primary); color: #fff; border: none; padding: 8px 11px; border-radius: 8px; font-weight: 700; cursor: pointer; white-space: nowrap; font-size: 0.78rem; }
.badge-port { background: #0284c7; color: white; font-size: 0.72rem; padding: 4px 8px; border-radius: 6px; }

.city-map-banner { width: 100%; height: 260px; background-size: cover; background-position: center; border-bottom: 2px solid var(--accent); flex-shrink: 0; }
.locations-container { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.loc-card { background: var(--card-bg); border: 1px solid #334155; border-radius: 12px; padding: 12px; }
.loc-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.loc-price { color: var(--accent); font-weight: 800; font-size: 1rem; }
.loc-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font-size: 0.72rem; }
.badge-vis { background: #1e3a8a; color: #93c5fd; padding: 3px 7px; border-radius: 6px; }
.badge-cond { background: #334155; color: #e2e8f0; padding: 3px 7px; border-radius: 6px; }

.dash-header { background: #0f172a; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #334155; flex-shrink: 0; }
.sub-badge { font-size: 0.72rem; color: var(--text-muted); }
.capital-box { text-align: right; }
.capital-amount { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
.debt-text { color: #fca5a5; font-size: 0.7rem; }
.gold-text { color: var(--accent); }

.dash-nav { display: flex; background: #1e293b; border-bottom: 1px solid #334155; flex-shrink: 0; }
.dash-tab { flex: 1; padding: 10px 4px; background: none; border: none; color: var(--text-muted); font-weight: 700; font-size: 0.78rem; cursor: pointer; }
.dash-tab.active { color: var(--accent); border-bottom: 3px solid var(--accent); }
.dash-view { display: none; padding: 12px; width: 100%; max-width: 540px; margin: 0 auto; }
.dash-view.active { display: block; }

/* ESCENA ANIMADA RESPONSIVA SIN DESBORDES */
.store-live-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--accent);
    margin-bottom: 10px;
    background: #0f172a;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.store-top-bar {
    background: #020617;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: #f8fafc;
    border-bottom: 1px solid #334155;
}

#store-live-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    cursor: pointer;
}

.store-live-footer {
    background: #020617;
    text-align: center;
    padding: 5px;
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
}

.strategy-bar {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    flex-wrap: wrap;
    gap: 6px;
}

.strategy-btns { display: flex; gap: 4px; }
.strat-btn {
    background: #1e293b; color: #94a3b8; border: 1px solid #334155;
    padding: 5px 8px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; cursor: pointer;
}
.strat-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }

.quest-banner { background: linear-gradient(90deg, #3b0764, #1e1b4b); border: 1px solid var(--accent); padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; }
.quest-banner h4 { font-size: 0.86rem; color: var(--accent); }
.quest-banner p { font-size: 0.78rem; margin-top: 3px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.stat-card { background: var(--card-bg); padding: 9px 11px; border-radius: 10px; border: 1px solid #334155; display: flex; flex-direction: column; }
.stat-card span { font-size: 0.7rem; color: var(--text-muted); }
.stat-card strong { font-size: 1rem; color: var(--accent); margin-top: 2px; }

.bank-pay-bar {
    background: #0f172a; border: 1px solid #334155; padding: 9px 10px;
    border-radius: 10px; display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 12px; font-size: 0.76rem; flex-wrap: wrap; gap: 6px;
}

.section-title { font-size: 0.9rem; margin-bottom: 8px; color: #e2e8f0; }
.muelle-visual-container { width: 100%; height: 180px; background-size: cover; background-position: center; border-radius: 10px; border: 1px solid var(--accent); }
.dock-banner { background: linear-gradient(90deg, #0c4a6e, #1e293b); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; border: 1px solid #0284c7; }
.dock-banner h3 { font-size: 0.9rem; margin-bottom: 3px; }
.dock-banner p { font-size: 0.75rem; color: #bae6fd; }

.ship-block { background: var(--card-bg); border: 1px solid #334155; border-radius: 12px; padding: 11px; margin-bottom: 12px; }
.ship-header { border-bottom: 1px solid #334155; padding-bottom: 6px; margin-bottom: 8px; }
.ship-origin { font-size: 0.72rem; color: var(--accent); display: block; margin-top: 2px; }
.prod-item { background: #0f172a; border: 1px solid #1e293b; border-radius: 10px; padding: 9px; margin-bottom: 8px; }
.prod-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; font-size: 0.7rem; }
.tag { padding: 2px 6px; border-radius: 4px; background: #1e293b; color: #cbd5e1; }
.tag.hot { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.tag.profit { background: rgba(34, 197, 94, 0.2); color: #86efac; }

.employee-hiring-card { background: var(--card-bg); border: 1px solid #334155; border-radius: 10px; padding: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.employee-hiring-card p { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }

.overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.85); z-index: 999; justify-content: center; align-items: center; padding: 14px; overflow-y: auto; }
.overlay.active { display: flex; }
.bargain-box, .event-box { background: var(--card-bg); border: 2px solid var(--accent); padding: 16px; border-radius: 14px; max-width: 430px; width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.8); }
.captain-profile { font-size: 0.74rem; color: #93c5fd; margin-bottom: 6px; }
.dialogue-bubble { background: #0f172a; border-left: 4px solid var(--accent); padding: 10px; border-radius: 8px; font-size: 0.82rem; line-height: 1.4; margin-bottom: 8px; color: #f1f5f9; }
.dialogue-choices { display: flex; flex-direction: column; gap: 7px; }
.choice-btn { background: #0f172a; color: #e2e8f0; border: 1px solid #475569; padding: 9px; border-radius: 8px; text-align: left; font-size: 0.78rem; line-height: 1.3; cursor: pointer; }
.choice-btn:active { background: #1e3a8a; border-color: var(--accent); }
.btn-cancel { background: #475569; width: 100%; border: none; padding: 10px; border-radius: 8px; color: white; margin-top: 8px; font-weight: 700; cursor: pointer; }

/* TABLA DE FINANZAS Y CONTROLES ACÁPITE POR ACÁPITE */
.finance-card {
    background: var(--card-bg);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

.finance-card h3 {
    font-size: 0.92rem;
    color: var(--accent);
    margin-bottom: 4px;
}

.fin-sub {
    font-size: 0.74rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.fin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    margin-top: 6px;
}

.fin-table td {
    padding: 6px 4px;
    border-bottom: 1px solid #0f172a;
}

.fin-table td:last-child {
    text-align: right;
    font-weight: 700;
}

.fin-neg { color: #f87171; }
.fin-pos { color: #4ade80; }
.fin-warn { color: #fbbf24; }

.fin-total-row td {
    border-top: 1px solid #475569;
    border-bottom: 1px solid #475569;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px 4px;
}

.fin-label {
    display: block;
    font-size: 0.76rem;
    color: #cbd5e1;
    margin: 10px 0 4px 0;
    font-weight: 600;
}

.fin-select {
    width: 100%;
    padding: 9px;
    background: #0f172a;
    border: 1px solid #475569;
    border-radius: 8px;
    color: #f8fafc;
    font-size: 0.78rem;
}

/* BARRAS DE PSICOLOGÍA (ESTRÉS, CALOR/ENVIDIA Y ESCASEZ) */
.psycho-hud-bar {
    background: #020617;
    border-bottom: 1px solid #334155;
    padding: 6px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    font-size: 0.72rem;
}

.psycho-meter {
    flex: 1;
    min-width: 115px;
}

.meter-bg {
    width: 100%;
    height: 6px;
    background: #1e293b;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2px;
}

.meter-fill.stress { background: linear-gradient(90deg, #38bdf8, #ef4444); }
.meter-fill.heat { background: linear-gradient(90deg, #f59e0b, #dc2626); }

.scarcity-pill {
    width: 100%;
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #fde68a;
    padding: 3px 8px;
    border-radius: 6px;
    text-align: center;
}

.loyalty-banner {
    background: linear-gradient(90deg, #1e1b4b, #0f172a);
    border: 1px solid #6366f1;
    padding: 10px 12px;
    border-radius: 10px;
    margin: 10px 0;
}

.inv-actions-row {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.btn-mini-action {
    flex: 1;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}
