:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

body.dark-mode {
    --bg: #020617;
    /* Slate 950 - Much darker */
    --card-bg: #0f172a;
    /* Slate 900 - Dark contrast */
    --text: #e2e8f0;
    /* Slate 200 - High legibility */
    --text-light: #94a3b8;
    /* Slate 400 */
    --border: #1e293b;
    /* Slate 800 */
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.7), 0 2px 4px -2px rgb(0 0 0 / 0.5);
    --primary: #3b82f6;
    /* Brighter blue for dark background */
}

#reset-life-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 10px;
}

#reset-life-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

body.dark-mode #reset-life-btn {
    background: #dc2626;
}

body.dark-mode #reset-life-btn:hover {
    background: #b91c1c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

body.dark-mode .shop-btn {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

body.dark-mode .shop-btn:hover {
    background: #334155;
    border-color: #475569;
}

body.dark-mode .event-box {
    background: #0f172a;
    color: #e2e8f0;
    border-color: var(--primary);
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.8);
}

#theme-toggle {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text);
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    margin-right: 1rem;
    transition: all 0.2s;
}

#theme-toggle:hover {
    background: var(--card-bg);
    transform: scale(1.1);
}

#reset-life-btn:hover {
    background: #dc2626;
    transform: translateY(-2px);
}

body.dark-mode #reset-life-btn {
    background: #dc2626;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

body.dark-mode #reset-life-btn:hover {
    background: #b91c1c;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

#app {
    width: 100%;
    max-width: 1300px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-bar {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.price-info {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

#savings-account {
    color: #059669;
    /* Green for growth */
}

.stat {
    font-weight: 600;
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat span {
    color: var(--primary);
}

#happiness {
    color: #db2777;
    /* Pink for health/happiness */
}

#stock-price {
    color: #0891b2;
    /* Cyan for stocks */
}

main {
    display: grid;
    grid-template-columns: 250px 250px 1fr;
    gap: 1.5rem;
}

#education-panel {
    max-height: 500px;
    overflow-y: auto;
    font-size: 0.8rem;
    padding: 1rem;
}

#education-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: var(--primary);
}

#tip-text {
    line-height: 1.4;
    color: var(--text);
}

#education-panel hr {
    margin: 1rem 0;
}

#about-alphabet {
    font-size: 0.75rem !important;
}

.character-stat,
.character-feature {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

#character-sidebar .label {
    color: var(--text-light);
    font-weight: 600;
}

.perk-badge {
    padding: 0.4rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #f1f5f9;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.dark-mode .perk-badge {
    background: #1e293b;
    border-color: #334155;
}

.perk-badge.positive {
    border-left: 4px solid #10b981;
    color: #059669;
}

.perk-badge.negative {
    border-left: 4px solid #ef4444;
    color: #dc2626;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

#status-card h2 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

#shop-card {
    border-color: var(--border);
    background: #f1f5f9;
}

#settings-card {
    border-color: var(--border);
    background: #f8fafc;
}

#relationship-card {
    border-color: #ec4899;
    background: #fff1f2;
}

#business-manager {
    border-color: #3b82f6;
    background: #eff6ff;
}

/* Dark Mode Overrides */
body.dark-mode #shop-card,
body.dark-mode #settings-card,
body.dark-mode #business-manager {
    background: #0f172a;
    border-color: #1e293b;
}

body.dark-mode #relationship-card {
    background: #1e1b4b;
    /* Deep Indigo/Pink mix for queer dark mode */
    border-color: #a21caf;
}

body.dark-mode .sub-card {
    background: #111827 !important;
    border-color: #374151 !important;
}

body.dark-mode #budget-container {
    background: #030712 !important;
    border-color: #1f2937 !important;
}

#budget-list {
    list-style: none;
    margin-bottom: 1rem;
}

#budget-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-weight: 500;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.total {
    font-weight: 800;
    font-size: 1.2rem;
    display: flex;
    justify-content: space-between;
}

#actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.action-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.action-btn.primary {
    background: var(--primary);
    color: white;
}

.action-btn.secondary {
    background: var(--success);
    color: white;
}

.action-btn.danger {
    background: #fee2e2;
    color: var(--danger);
}

.action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.shop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.shop-btn {
    padding: 0.6rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.shop-btn:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.shop-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e2e8f0;
}

#education-panel {
    background: #eff6ff;
    border-color: #bfdbfe;
}

body.dark-mode #education-panel {
    background: #1e3a5f;
    border-color: #3b82f6;
}

#education-panel h3 {
    color: var(--primary);
    margin-bottom: 0.5rem;
}

body.dark-mode #education-panel h3 {
    color: #60a5fa;
}

#education-panel p {
    font-size: 0.95rem;
    color: #475569;
}

body.dark-mode #education-panel p {
    color: #cbd5e1;
}

/* Dark mode for Settings & Tools */
/* Dark mode for Settings & Tools */
body.dark-mode #settings-card {
    background: #1e293b;
    border-color: #475569;
}

body.dark-mode #settings-card .shop-btn,
body.dark-mode #settings-card input {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode #settings-card .shop-btn:hover {
    background: #475569;
    border-color: #64748b;
}

body.dark-mode #settings-card h2 {
    color: #e2e8f0;
}

body.dark-mode #settings-card h3 {
    color: #cbd5e1;
}

/* Dark mode for Career Upgrades & Start A Business */
body.dark-mode #shop-card {
    background: #1e293b;
    border-color: #475569;
}

body.dark-mode #shop-card .shop-btn {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode #shop-card .shop-btn:hover {
    background: #475569;
    border-color: #64748b;
}

body.dark-mode #shop-card h2 {
    color: #e2e8f0;
}

/* Dark mode overrides for other cards */
body.dark-mode #relationship-card,
body.dark-mode #business-manager {
    background: #1e293b;
    /*Keep original border colors or override if needed*/
}

footer {
    display: flex;
    justify-content: flex-end;
}


#next-month-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    position: fixed;
    bottom: 30px;
    right: 30px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#next-month-btn:hover {
    transform: translateY(-2px);
    background: var(--primary-hover);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.outlook-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.outlook-label {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-light);
}

.gauge-bg {
    background: #e2e8f0;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
}

#sentiment-gauge {
    height: 100%;
    width: 50%;
    background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
    transition: width 0.5s;
}

#valuation-gauge {
    height: 100%;
    width: 50%;
    transition: width 0.5s;
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    margin-top: 0.25rem;
    color: var(--text-light);
    font-weight: 600;
}

.sparkline {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 30px;
}

.spark-bar {
    flex: 1;
    background: #cbd5e1;
    border-radius: 2px 2px 0 0;
}

.hidden {
    display: none !important;
}

.event-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    align-items: center;
    z-index: 100;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    pointer-events: none;
    padding: 2rem;
}

.event-box {
    position: relative;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    z-index: 101;
    max-width: 320px;
    border: 3px solid var(--primary);
    text-align: center;
    pointer-events: auto;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-origin {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    font-weight: 800;
}

.event-box h2 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.event-box p {
    margin-bottom: 1.5rem;
}


.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

#job-offers-modal,
#bankrupt-modal,
#vet-modal,
#difficulty-modal,
#victory-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--card-bg);
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

#job-offers-modal.hidden,
#bankrupt-modal.hidden,
#vet-modal.hidden,
#difficulty-modal.hidden,
#victory-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: block !important;
    /* Keep in flow for centering calculations */
}

/* Ensure the .hidden utility elsewhere still works for non-modals */
.hidden {
    display: none !important;
}

.achievement-card {
    padding: 0.75rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

body.dark-mode .achievement-card {
    background: #1e293b;
}

.achievement-card.locked {
    opacity: 0.8;
    filter: grayscale(1);
    background: #f1f5f9;
}

.achievement-card.unlocked {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#education-panel {
    font-size: 0.8rem;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

#education-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}



body.dark-mode .achievement-card.unlocked {
    background: #312e81;
}

.achievement-icon {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.achievement-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text);
}

.achievement-desc {
    font-size: 0.65rem;
    color: var(--text-light);
    line-height: 1.2;
}

/* --- New UI Refinements --- */

/* Character Sidebar Box Styling */
.character-stat,
.character-feature {
    background: #f1f5f9;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border: 1px solid var(--border);
    align-items: center;
}

body.dark-mode .character-stat,
body.dark-mode .character-feature {
    background: #1e293b;
    border-color: #334155;
}

/* Dashboard Centering */
#actions {
    justify-content: center;
    flex-wrap: wrap;
}

/* Family Unit Cards */
.family-unit-card {
    font-size: 0.75rem;
    background: #fff;
    padding: 0.5rem;
    border-radius: 6px;
    border: 1px solid #fed7aa;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.family-unit-card.away {
    background: #f1f5f9;
    border-color: #cbd5e1;
    opacity: 0.7;
}

.family-unit-card.injured {
    border-color: #fca5a5;
    background: #fef2f2;
}

.family-unit-card.pet {
    background: #fdf2f8;
    border-color: #f9a8d4;
}

/* Dark Mode Family Cards */
body.dark-mode .family-unit-card {
    background: #1e293b;
    border-color: #9a3412;
    /* Dark Orange */
    color: #e2e8f0;
}

body.dark-mode .family-unit-card.away {
    background: #0f172a;
    border-color: #334155;
}

body.dark-mode .family-unit-card.injured {
    background: #450a0a;
    border-color: #7f1d1d;
}

body.dark-mode .family-unit-card.pet {
    background: #3c0820;
    /* Dark Pink */
    border-color: #831843;
}

/* New Status Badges */
.status-badge {
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 4px;
    background: #e2e8f0;
    color: #475569;
}

.status-badge.alert {
    background: #fee2e2;
    color: #ef4444;
}

/* Personality Tag */
.personality-tag {
    color: #9d174d;
    font-weight: 600;
}

body.dark-mode .personality-tag {
    color: #f472b6;
}

/* Happiness Track */
.happiness-track {
    width: 100%;
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 6px;
    overflow: hidden;
}

body.dark-mode .happiness-track {
    background: #334155;
}

.happiness-bar {
    height: 100%;
    transition: width 0.3s;
}

/* Widened Layout */
#app {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
}

main#game-main {
    display: grid;
    grid-template-columns: 250px 250px 1fr;
    gap: 1.5rem;
}

/* Economy Meter */
.meter-container {
    background: #e2e8f0;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 5px;
}

.meter-fill {
    height: 100%;
    transition: width 0.5s;
}

/* Social Section */
.social-meter-box {
    margin-bottom: 1rem;
}

/* Bond Cards */
.bond-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

#bonds-holdings {
    margin-bottom: 1rem;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 6px;
    border: 1px solid #bfdbfe;
}

body.dark-mode #bonds-holdings {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

body.dark-mode .bond-card {
    background: #1e293b;
    border-color: #334155;
}

.bond-rating {
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.rating-aaa {
    background: #dcfce7;
    color: #166534;
}

.rating-aa {
    background: #dcfce7;
    color: #15803d;
}

.rating-a {
    background: #f0fdf4;
    color: #16a34a;
}

.rating-bbb {
    background: #fef9c3;
    color: #854d0e;
}

.rating-cc {
    background: #fee2e2;
    color: #991b1b;
}

/* Timer */
#play-timer {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-left: 1rem;
}

/* Neuro Perks */
.symptom-tag {
    background: #fef9c3;
    color: #854d0e;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 12px;
    display: inline-block;
    margin-top: 4px;
}

body.dark-mode .symptom-tag {
    background: #422006;
    color: #fde047;
}

/* Dark Mode Overrides for new elements */
body.dark-mode .bond-card {
    background: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark-mode .bond-card span {
    color: #f1f5f9 !important;
}

body.dark-mode #budget-container {
    background: #0f172a !important;
    border-color: #334155 !important;
}

body.dark-mode #budget-table td {
    border-bottom-color: #334155 !important;
    color: #cbd5e1 !important;
}

/* Budget Table */
#budget-table tr:last-child {
    border-bottom: none;
}

#budget-table td {
    padding: 6px 0;
}

footer {
    display: none;
    /* Hide default footer if any, we use settings footer */
}