        :root {
            --coral: #FF7F50;
            --coral-dark: #e5673a;
            --sun-yellow: #FFD700;
            --turquoise: #40E0D0;
            --turquoise-dark: #36c7b8;
            --sky-blue-start: #87CEEB;
            --sky-blue-end: #ADD8E6;
            --sand: #F4A460;
            --green: #2E8B57;
            --dark-bg: #1a1a2e;
            --light-text: #f0f0f0;

            /* New Style Palette from Image */
            --card-bg-dark-blue: rgba(13, 27, 69, 0.9);
            --card-border-blue: #61d5f5;
            --card-glow-blue: rgba(97, 213, 245, 0.5);
            --card-bg-interactive: rgba(23, 41, 99, 0.8);
        }

        body {
            font-family: 'Inter', sans-serif;
            overflow: hidden;
            height: 100vh;
            width: 100vw;
            background-color: var(--dark-bg);
            color: var(--light-text);
            margin: 0;
            padding: 0;
        }

        #three-canvas-container {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }

        .game-screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: none;
            opacity: 0;
            transition: opacity 0.5s ease-in-out;
            box-sizing: border-box;
            z-index: 10;
            pointer-events: none;
        }

        .game-screen.active {
            display: flex;
            opacity: 1;
        }

        .overlay-center {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            pointer-events: all;
            padding: 1rem;
        }       


        /* --- Splash Screen --- */
        #splash-screen {
            background-color: var(--dark-bg);
            justify-content: center;
            align-items: center;
            flex-direction: column;
            pointer-events: all;
        }
        #typewriter-text { font-size: 3rem; font-weight: 900; text-align: center; white-space: pre-wrap; }
        #typewriter-text .cursor { display: inline-block; background-color: var(--light-text); width: 4px; animation: blink 1s step-end infinite; }
        @keyframes blink { from, to { background-color: transparent } 50% { background-color: var(--light-text); } }

        #play-button {
            margin-top: 2rem;
            width: 80px;
            height: 80px;
            background: linear-gradient(145deg, #ff8b61, #e66a41);
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            transform: scale(0);
            transition: transform 0.3s ease-in-out, box-shadow 0.2s ease;
            box-shadow: 0 5px 15px rgba(255, 127, 80, 0.4), inset 0 -4px 0 rgba(0,0,0,0.2);
            animation: pulse 2s infinite;
        }
        #play-button:hover {
            animation-play-state: paused;
            box-shadow: 0 8px 20px rgba(255, 127, 80, 0.6), inset 0 -4px 0 rgba(0,0,0,0.2);
        }
        #play-button:active {
            transform: scale(0.95) !important;
            box-shadow: 0 2px 10px rgba(255, 127, 80, 0.4), inset 0 2px 0 rgba(0,0,0,0.2);
        }
        #play-button svg { width: 40px; height: 40px; fill: white; margin-left: 5px; filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3)); }

        @keyframes pulse {
            0% { transform: scale(1); }
            50% { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* --- Screens --- */
        #profiling-screen, #quest-screen, #recap-screen, #insurance-modal, #casino-modal, #store-modal, #pfm-modal, #formations-modal, #insurance-story-modal {
            background: transparent;
        }

        .content-panel {
            background: var(--card-bg-dark-blue);
            backdrop-filter: blur(10px);
            border: 2px solid var(--card-border-blue);
            border-radius: 20px;
            padding: 2rem;
            width: 90%;
            max-width: 700px;
            box-shadow: 0 0 25px var(--card-glow-blue), 0 8px 32px 0 rgba(0, 0, 0, 0.5);
            color: var(--light-text);
        }

        .coach-bubble {
            background: linear-gradient(145deg, #ffffff, #e6e6e6);
            color: #333;
            padding: 1.5rem;
            border-radius: 20px;
            margin-bottom: 2rem;
            width: 100%;
            box-shadow: 0 5px 10px rgba(0,0,0,0.2), inset 0 2px 4px rgba(0,0,0,0.1);
            text-align: center;
            font-size: 1.25rem;
            font-weight: 500;
            border: 2px solid white;
        }

        .card-container { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

        .profiling-card {
            background: var(--card-bg-interactive);
            border: 2px solid var(--card-border-blue);
            border-radius: 16px;
            padding: 1rem;
            text-align: center;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
            backdrop-filter: blur(5px);
            color: var(--light-text);
        }
        .profiling-card:hover {
            transform: translateY(-5px) scale(1.02);
            box-shadow: 0 0 20px var(--card-border-blue);
        }
        .profiling-card.selected {
            box-shadow: 0 0 25px var(--card-border-blue), inset 0 0 15px var(--card-glow-blue);
            transform: scale(1.05);
        }
        .profiling-card img { width: 100px; height: 100px; border-radius: 50%; margin-bottom: 0.5rem; object-fit: cover; border: 3px solid var(--card-border-blue); }

        .horizontal-cards {
            flex-direction: column;
            width: 100%;
            max-width: 500px;
        }

        .horizontal-cards .profiling-card {
            text-align: center;
            padding: 1.5rem;
            width: 100%;
            font-size: 1.1rem;
        }

        .quest-card-select {
            width: calc(50% - 0.75rem);
            min-height: 160px;
            padding: 1rem;
        }
        .quest-card-select.disabled {
            filter: grayscale(1);
            cursor: not-allowed;
            opacity: 0.6;
        }
        .quest-card-select .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
        .quest-card-select h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.5rem; }

        #choose-quest-btn, #start-life-btn {
            margin-top: 2rem;
        }
        #choose-quest-btn { display: none; }

        /* --- Main Game Screen --- */
        #main-game-screen {
            background: transparent;
            display: block;
        }
        #main-game-screen.modal-open {
            pointer-events: none;
        }
        .ui-panel {
            position: absolute;
            background: linear-gradient(160deg, rgba(40, 40, 70, 0.8), rgba(20, 20, 45, 0.9));
            backdrop-filter: blur(8px);
            border-radius: 15px;
            border: 1px solid rgba(97, 213, 245, 0.5);
            padding: 1rem;
            pointer-events: all;
            box-shadow: 0 4px 15px rgba(0,0,0,0.4);
            z-index: 5;
        }

        #top-left-ui { top: 20px; left: 20px; width: 260px; }
        .player-info-container { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
        .player-avatar { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--card-border-blue); }
        #player-name { font-size: 1.2rem; font-weight: bold; }
        .age-container {
            position: absolute;
            top: -10px;
            right: -10px;
            width: 60px;
            height: 60px;
        }

        .age-circle {
            width: 100%;
            height: 100%;
            background: var(--coral);
            border-radius: 50%;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 1.5rem;
            font-weight: bold;
            border: 3px solid white;
            box-shadow: 0 0 10px var(--coral);
            animation: pulse-age 2s infinite;
        }

        @keyframes pulse-age {
            0% {
                transform: scale(1);
                box-shadow: 0 0 10px var(--coral);
            }
            50% {
                transform: scale(1.1);
                box-shadow: 0 0 20px var(--coral);
            }
            100% {
                transform: scale(1);
                box-shadow: 0 0 10px var(--coral);
            }
        }

        .age-increment-animation {
            position: absolute;
            top: 50%;
            left: 100%;
            transform: translateY(-50%);
            font-size: 2rem;
            font-weight: 900;
            color: var(--sun-yellow);
            text-shadow: 0 0 10px var(--sun-yellow), 0 0 20px white;
            pointer-events: none;
            z-index: 10;
            white-space: nowrap;
        }

        #top-right-ui { top: 20px; right: 20px; display: flex; flex-direction: column; gap: 0.75rem; width: 240px; }
        #bottom-left-ui { bottom: 20px; left: 20px; width: 260px; }
        #bottom-right-ui { bottom: 20px; right: 20px; display: flex; gap: 0.5rem; flex-direction: column; align-items: center; width: 240px; }

        #top-center-ui {
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            width: auto;
            padding: 0.5rem;
        }

        #money-change-anim, #salary-change-anim, #score-change-anim {
            position: absolute;
            font-weight: 900; /* Made text bolder */
            font-size: 1.2rem; /* Made text bigger */
            text-shadow: 1px 1px 2px black;
            pointer-events: none;
            opacity: 0;
            z-index: 20;
        }
        .money-gain { color: #2ecc71; }
        .money-loss { color: #e74c3c; }
        .score-gain { color: #f1c40f; }

        .stat-gauge-container { display: flex; align-items: center; gap: 0.75rem; }
        .stat-gauge-label { font-size: 1.5rem; }
        .stat-gauge-bar-bg { flex-grow: 1; height: 18px; background: rgba(0,0,0,0.3); border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,0.2); }
        .stat-gauge-bar { height: 100%; border-radius: 10px; transition: width 0.5s ease-out; }
        #health-bar { background: linear-gradient(90deg, #e74c3c, #c0392b); }
        #financial-bar { background: linear-gradient(90deg, #f1c40f, #f39c12); }
        #social-bar { background: linear-gradient(90deg, #3498db, #2980b9); }
        #stress-bar { background: linear-gradient(90deg, #8e44ad, #9b59b6); }
        .stat-value { font-weight: bold; font-size: 0.9rem; min-width: 35px; text-align: right; }

        #bottom-center-ui {
            position: absolute;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            align-items: flex-end;
            gap: 1rem;
            width: 90%;
            max-width: 700px;
            background: none;
            pointer-events: all;
        }

        .narrator-container {
            position: relative;
            width: 100%;
            transition: opacity 0.3s, transform 0.3s ease-out;
            pointer-events: all;
        }
        .narrator-container.hidden {
            opacity: 0;
            transform: translateY(100%);
            pointer-events: none;
        }
        .narrator-bubble-main {
            background: var(--card-bg-dark-blue);
            color: var(--light-text);
            padding: 1.5rem;
            border-radius: 20px;
            box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
            min-height: 225px;
            display: flex;
            flex-direction: column;
            border: 3px solid var(--card-border-blue);
            position: relative;
            transition: border-color 0.5s ease;
        }
        .event-type-question { background-color: rgba(52, 152, 219, 0.2); border-color: #3498db; }
        .event-type-life_event { background-color: rgba(241, 196, 15, 0.2); border-color: #f1c40f; }
        .event-type-hint { background-color: rgba(26, 188, 156, 0.2); border-color: #1abc9c; }
        .event-type-career { background-color: rgba(155, 89, 182, 0.2); border-color: #9b59b6; }
        .event-type-finance { background-color: rgba(46, 204, 113, 0.2); border-color: #2ecc71; }

        .narrator-icon {
            position: absolute;
            top: -15px;
            right: -15px;
            background-color: var(--card-border-blue);
            border-radius: 20px;
            padding: 5px 10px;
            font-size: 0.9rem;
            font-weight: bold;
            color: white;
            box-shadow: 0 0 10px var(--card-glow-blue);
        }
        .event-icon-text {
            display: block;
        }
        #narrator-text { flex-grow: 1; overflow-y: auto; margin-bottom: 1rem; max-height: 120px; }
        #narrator-options { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

        .narrator-option {
            padding: 0.75rem 1.5rem;
            background: var(--card-bg-interactive);
            color: white;
            border-radius: 12px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            border: 2px solid var(--card-border-blue);
            font-weight: 700;
            flex-grow: 1;
        }
        .narrator-option:hover {
            background: #172a5a;
            box-shadow: 0 0 10px var(--card-glow-blue);
        }
        .game-button:disabled {
            background: #555 !important;
            cursor: not-allowed !important;
            border-color: #777 !important;
            opacity: 0.6;
            box-shadow: none !important;
        }
        .narrator-option.disabled {
            background: #555 !important;
            cursor: not-allowed !important;
            border-color: #777 !important;
            opacity: 0.6;
            box-shadow: none !important;
        }

        .game-button {
            padding: 0.75rem 1.5rem;
            background: var(--card-bg-interactive);
            color: white;
            border-radius: 12px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            border: 2px solid var(--card-border-blue);
            font-weight: 700;
        }
        .game-button:hover {
            background: #172a5a;
            box-shadow: 0 0 10px var(--card-glow-blue);
        }
        .game-button.disabled {
            background: #555 !important;
            cursor: not-allowed !important;
            border-color: #777 !important;
            opacity: 0.6;
            box-shadow: none !important;
        }
        .game-button.glow {
            animation: pulse-glow 2s infinite;
        }

        @keyframes pulse-glow {
            0% { box-shadow: 0 0 5px var(--card-glow-blue); }
            50% { box-shadow: 0 0 15px 5px var(--card-glow-blue); }
            100% { box-shadow: 0 0 5px var(--card-glow-blue); }
        }

        .quest-progress .label { font-weight: bold; margin-bottom: 0.5rem; }
        .progress-bar-container { width: 100%; height: 15px; background-color: rgba(0,0,0,0.3); border-radius: 10px; overflow: hidden;}
        .progress-bar { height: 100%; background: linear-gradient(90deg, var(--sun-yellow), #ffc371); transition: width 0.5s ease; border-radius: 10px; }

        .insurance-list-icons {
            display: flex;
            justify-content: space-around;
            align-items: center;
        }
        .insurance-item-icon {
            position: relative;
            cursor: pointer;
            font-size: 1.5rem;
            color: #ccc;
            transition: color 0.3s;
        }
        .insurance-item-icon:hover {
            color: var(--sun-yellow);
        }
        .insurance-item-icon .status-dot {
            position: absolute;
            bottom: -5px;
            right: -5px;
            width: 12px;
            height: 12px;
            border: 2px solid var(--dark-bg);
        }
        .status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; transition: background-color 0.3s; }
        .status-dot.inactive { background-color: #666; }
        .status-dot.active { background-color: #2ecc71; box-shadow: 0 0 5px #2ecc71; }

        #settings-modal, #insurance-modal, #casino-modal, #formation-unlocked-modal, #badge-unlocked-modal, #store-modal, #pfm-modal, #insurance-story-modal {
            background: rgba(0,0,0,0.7);
            backdrop-filter: blur(5px);
        }
        .setting-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
        #close-settings-btn { margin-top: 1.5rem; }
        .insurance-modal-actions {
            display: flex;
            justify-content: space-around;
            margin-top: 1.5rem;
            gap: 1rem;
        }

        #badges-ui { margin-top: 1rem; }
        #badge-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
            gap: 0.5rem;
            padding: 0.75rem;
            background: rgba(20, 20, 45, 0.7);
            border-radius: 15px;
            border: 1px solid rgba(97, 213, 245, 0.3);
        }
        .badge, .formation-card {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            width: 80px;
            height: 80px;
            background: rgba(23, 41, 99, 0.6);
            border-radius: 10px;
            border: 1px solid var(--turquoise);
            transition: opacity 0.5s, transform 0.5s, filter 0.3s;
            position: relative; /* For tooltip */
            cursor: pointer;
        }
        .badge.locked, .formation-card.locked {
            filter: grayscale(1) brightness(0.5);
            opacity: 0.6;
        }
        .badge.unlocked, .formation-card.unlocked {
            filter: grayscale(0) brightness(1);
            opacity: 1;
            transform: scale(1);
            animation: badge-pop 0.5s ease-out forwards;
        }
        @keyframes badge-pop {
            0% { transform: scale(0.5); }
            70% { transform: scale(1.1); }
            100% { transform: scale(1); }
        }
        .badge .icon, .formation-card .icon { font-size: 2rem; }
        .badge .name, .formation-card .name { font-size: 0.6rem; font-weight: bold; margin-top: 0.25rem; text-align: center; line-height: 1.1; word-break: break-word; }
        .badge .tooltip, .formation-card .tooltip {
            visibility: hidden;
            width: 140px;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px 0;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -70px;
            opacity: 0;
            transition: opacity 0.3s;
        }
        .badge:hover .tooltip, .formation-card:hover .tooltip {
            visibility: visible;
            opacity: 1;
        }

/* Heartbeat animation for health icon */
.heartbeat {
    animation: heartbeat 1.5s ease-in-out;
}

@keyframes heartbeat {
    0% {
        transform: scale(1);
    }
    10% {
        transform: scale(1.3);
    }
    20% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.3);
    }
    40% {
        transform: scale(1);
    }
    100% {
        transform: scale(1);
    }
}

/* Blackjack Styles */
#blackjack-screen {
    z-index: 11;
}

#blackjack-table {
    background-color: #0a4723; /* Green felt color */
    border-radius: 10px;
    padding: 1rem;
    margin: 1rem 0;
    border: 5px solid #5d4037;
}

.blackjack-area {
    margin-bottom: 1rem;
}

.card-hand {
    display: flex;
    justify-content: center;
    gap: 10px;
    min-height: 95px; /* Standard card height */
}

.card {
    width: 65px;
    height: 95px;
    border: 1px solid #000;
    border-radius: 5px;
    background-color: white;
    color: black;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 5px;
    font-size: 1.2rem;
    font-weight: bold;
    position: relative;
}

.card.red {
    color: #b71c1c;
}

.card .suit {
    font-size: 1.5rem;
    line-height: 1;
}

.card .rank-top {
    align-self: flex-start;
}

.card .rank-bottom {
    align-self: flex-end;
    transform: rotate(180deg);
}

#blackjack-betting-controls, #blackjack-action-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    align-items: center;
}

        #formation-unlocked-modal .content-panel, #badge-unlocked-modal .content-panel {
            text-align: center;
        }
        #formation-unlocked-badge, #badge-unlocked-badge {
            margin: 1rem auto;
            width: 150px;
            height: 150px;
            font-size: 1.5rem;
            animation: badge-pop 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
        }
        #formation-unlocked-badge .icon, #badge-unlocked-badge .icon { font-size: 5rem; }

        #fortune-wheel-canvas-container {
            position: relative;
            width: 350px;
            height: 350px;
            margin: 1rem auto;
        }
        #fortune-wheel-canvas {
            width: 100%;
            height: 100%;
        }
        #wheel-pointer {
            position: absolute;
            top: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 0;
            height: 0;
            border-left: 20px solid transparent;
            border-right: 20px solid transparent;
            border-top: 30px solid var(--coral);
            z-index: 12;
        }

        .store-item-grid, .pfm-tab-content {
            max-height: 400px;
            overflow-y: auto;
            padding: 0.5rem;
        }
        .store-item {
            display: flex;
            align-items: center;
            background: rgba(23, 41, 99, 0.7);
            padding: 1rem;
            border-radius: 12px;
            margin-bottom: 0.75rem;
            border: 1px solid var(--card-border-blue);
        }
        .store-item .icon { font-size: 2.5rem; margin-right: 1rem; }
        .store-item .info { flex-grow: 1; }
        .pfm-tabs { display: flex; border-bottom: 2px solid var(--card-border-blue); margin-bottom: 1rem; }
        .pfm-tab { padding: 0.5rem 1rem; cursor: pointer; }
        .pfm-tab.active { background: var(--card-border-blue); color: var(--dark-bg); border-radius: 8px 8px 0 0; }
        .pfm-section { margin-bottom: 1rem; }

        #pfm-expense-list li {
            padding: 0.5rem;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            display: flex;
            justify-content: space-between;
        }
        #pfm-expense-list li:last-child { border-bottom: none; }


        #tutorial-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 998;
            pointer-events: all;
            display: none; /* Hidden by default */
        }
        #tutorial-highlight {
            position: absolute;
            border-radius: 15px;
            box-shadow: 0 0 0 9999px rgba(0,0,0,0.7), 0 0 20px 5px var(--sun-yellow);
            transition: all 0.5s ease-in-out;
            pointer-events: none;
        }
        #tutorial-box {
            position: absolute;
            background: var(--card-bg-dark-blue);
            border: 2px solid var(--card-border-blue);
            border-radius: 15px;
            padding: 1.5rem;
            max-width: 400px;
            z-index: 999;
            transition: all 0.5s ease-in-out;
            margin-bottom: 0; /* Remove margin since controls are separate */
        }
        #tutorial-controls {
            position: fixed;
            bottom: 30px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 300px;
            padding: 1rem;
            background: var(--card-bg-dark-blue);
            border: 2px solid var(--card-border-blue);
            border-radius: 20px;
            z-index: 1000;
            box-shadow: 0 0 25px var(--card-glow-blue);
        }
        .tutorial-icon-btn {
            position: relative;
            cursor: pointer;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background: var(--card-bg-interactive);
            border: 2px solid var(--card-border-blue);
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }
        .tutorial-icon-btn:hover {
            background: #172a5a;
            box-shadow: 0 0 10px var(--card-glow-blue);
        }
        .tutorial-icon-btn.disabled {
            filter: grayscale(1);
            opacity: 0.5;
            pointer-events: none;
            box-shadow: none;
        }
        .tutorial-icon-btn svg { width: 24px; height: 24px; }
        .tutorial-icon-btn .tooltip {
            visibility: hidden;
            width: 140px;
            background-color: #333;
            color: #fff;
            text-align: center;
            border-radius: 6px;
            padding: 5px 0;
            position: absolute;
            z-index: 1;
            bottom: 125%;
            left: 50%;
            margin-left: -70px;
            opacity: 0;
            transition: opacity 0.3s;
        }
        .tutorial-icon-btn:hover .tooltip {
            opacity: 1;
            visibility: visible;
        }
        .tutorial-controls-group {
            display: flex;
            gap: 1rem;
        }

        #end-screen {
            background: transparent;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            text-align: center;
            pointer-events:all;
        }
        #confetti-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 11;}
        .end-title { font-size: 3rem; font-weight: 900; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
        .end-summary { margin-top: 1rem; background: var(--card-bg-dark-blue); backdrop-filter: blur(10px); padding: 1.5rem; border-radius: 20px; color: white; max-width: 800px; max-height: 80vh; overflow-y: auto; }
        #final-decisions-summary { max-height: 200px; overflow-y: auto; text-align: left; margin-top: 1rem; padding-right: 1rem; }
        #insurance-recap { margin-top: 1rem; border-top: 1px solid var(--card-border-blue); padding-top: 1rem; }
        .insurance-fiche { background: rgba(0,0,0,0.2); padding: 0.5rem; border-radius: 8px; margin-bottom: 0.5rem; text-align: left;}
        #replay-options { margin-top: 1.5rem; display: flex; gap: 1rem; justify-content: center; }

        .custom-alert {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) scale(0.9);
            opacity: 0;
            transition: transform 0.3s ease-out, opacity 0.3s ease-out;
            pointer-events: none;
            z-index: 200;
        }
        .custom-alert.visible {
            transform: translate(-50%, -50%) scale(1);
            opacity: 1;
            pointer-events: all;
        }

        #formation-unlocked-modal, #badge-unlocked-modal { z-index: 100; }

        #formation-unlocked-badge, #badge-unlocked-badge {
            margin: 1rem auto;
            width: 150px;
            height: 150px;
            font-size: 1.5rem;
            animation: badge-pop 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
        }
        #formation-unlocked-badge .icon, #badge-unlocked-badge .icon { font-size: 5rem; }

        /* --- Responsive Design for Mobile --- */
        @media (max-width: 768px) {
            body {
                overflow-y: auto; /* Allow scrolling on mobile */
            }

            .overlay-center {
                padding: 0.5rem;
                justify-content: flex-start;
                padding-top: 2rem;
            }

            #typewriter-text { font-size: 1.8rem; }
            .end-title { font-size: 1.8rem; }

            .content-panel {
                width: 100%;
                padding: 1rem;
                margin-bottom: 1rem;
            }

            .coach-bubble {
                font-size: 1rem;
                padding: 1rem;
                margin-bottom: 1rem;
            }

            .card-container {
                flex-direction: column;
                gap: 0.5rem;
            }
            .profiling-card, .quest-card-select {
                width: 100%;
            }

            #main-game-screen {
                overflow-y: auto;
                display: block; /* Allow content to flow and scroll */
                padding: 10px;
            }

            .ui-panel {
                position: relative; /* Change from absolute to relative */
                width: 100% !important; /* Override fixed widths */
                top: auto !important;
                left: auto !important;
                right: auto !important;
                bottom: auto !important;
                margin: 0 auto 10px auto; /* Center panels and add space */
                transform: none !important;
                max-width: 450px;
            }

            #bottom-center-ui {
                position: fixed; /* Narrator stays at the bottom */
                bottom: 0;
                left: 0;
                right: 0;
                width: 100%;
                max-width: 100%;
                border-radius: 15px 15px 0 0;
                z-index: 20;
                box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
            }
            .narrator-container.hidden {
                transform: translateY(110%); /* Slide down when hidden */
            }
            .narrator-container {
                transform: translateY(0); /* Slide up when shown */
            }
            .narrator-bubble-main {
                min-height: auto;
                padding: 1rem;
            }
            #narrator-options {
                flex-direction: column;
            }

            .player-avatar { width: 40px; height: 40px; }
            #player-name { font-size: 1rem; }
            .stat-gauge-label { font-size: 1rem; }
            .stat-gauge-bar-bg { height: 16px; }

            .insurance-list { grid-template-columns: repeat(2, 1fr); }
            #badge-container { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
            .badge, .formation-card { width: 70px; height: 70px; }

            #fortune-wheel-canvas-container { width: 300px; height: 300px; }
            #fortune-wheel-canvas { width: 300px; height: 300px; }

            .setting-row { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
            #age-increment-options { margin-top: 0.5rem; }

            #end-screen .overlay-center {
                justify-content: center;
            }
            .end-summary {
                padding: 1rem;
            }
            #replay-options {
                flex-direction: column;
                align-items: center;
            }
        }

@keyframes shake {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(3px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(3px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(1px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
  animation: shake 0.5s;
  animation-iteration-count: 1;
}

.stat-change-animation {
    position: absolute;
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    pointer-events: none;
    opacity: 0;
}

.stat-bar-flash-gain {
    animation: flash-gain 0.5s;
}

.stat-bar-flash-loss {
    animation: flash-loss 0.5s;
}

@keyframes flash-gain {
    0% { background-color: #2ecc71 !important; }
    100% { /* The original color will be restored by the JS */ }
}

@keyframes flash-loss {
    0% { background-color: #e74c3c !important; }
    100% { /* The original color will be restored by the JS */ }
}

.flash-green {
    animation: flash-green 1s;
}

@keyframes flash-green {
    0% { background-color: #2ecc71; }
    100% { /* The original color will be restored by the JS */ }
}


#iframe-container.active {
    pointer-events: all;
}

#iframe-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    z-index: 99;
    justify-content: center;
    align-items: center;
}

#game-iframe {
    width: 80vw;
    height: 80vh;
    border: none;
    border-radius: 15px;
}

#close-iframe-btn {
    position: absolute;
    top: 20px;
    right: 20px;
}

#score-animation-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    color: #fff;
    font-size: 2em;
    font-weight: bold;
    text-shadow: 2px 2px 4px #000;
}