        :root {
            --bg-dark: #0f0518;
            --primary: #c084fc;
            --accent: #e879f9;
            --success: #4ade80;
            --danger: #fb7185;
            --warning: #facc15;
            --text: #fff;
            --dim: #94a3b8;
            
            /* JRPG Box Colors (Purple Theme) */
            --box-bg-top: #2e1065;
            --box-bg-bottom: #4c1d95;
            --box-border: #fff;
            --box-shadow: inset 0 0 0 3px rgba(255,255,255,0.4), 0 10px 20px rgba(0,0,0,0.8);
        }

        * { box-sizing: border-box; }
        body {
            margin: 0; background: var(--bg-dark); color: var(--text);
            font-family: 'Press Start 2P', monospace; font-size: 12px; line-height: 1.8;
            height: 100vh; overflow: hidden; display: flex; flex-direction: column;
            user-select: none;
        }

        /* CRT SCANLINE OVERLAY */
        body::after {
            content: " "; display: block; position: absolute; top: 0; left: 0; bottom: 0; right: 0;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
            z-index: 999; background-size: 100% 2px, 3px 100%; pointer-events: none;
        }
        body.no-crt::after { display: none; }

        /* SHAKE ANIMATION */
        @keyframes shake {
            0% { transform: translate(2px, 1px) rotate(0deg); }
            10% { transform: translate(-1px, -2px) rotate(-1deg); }
            20% { transform: translate(-3px, 0px) rotate(1deg); }
            30% { transform: translate(0px, 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(2px, 1px) rotate(-1deg); }
            80% { transform: translate(-1px, -1px) rotate(1deg); }
            90% { transform: translate(2px, 2px) rotate(0deg); }
            100% { transform: translate(0px, 0px) rotate(0deg); }
        }
        .shake { animation: shake 0.4s cubic-bezier(.36,.07,.19,.97); }

        /* JRPG DIALOG BOX */
        .ff-box {
            background: linear-gradient(180deg, var(--box-bg-top) 0%, var(--box-bg-bottom) 100%);
            border: 4px solid var(--box-border);
            border-radius: 8px;
            box-shadow: var(--box-shadow);
            padding: 20px;
            position: relative;
        }

        h1, h2, h3 { color: var(--warning); text-shadow: 2px 2px 0 #000; margin-top: 0; line-height: 1.4; }
        p { font-family: 'JetBrains Mono', monospace; font-size: 14px; }

        /* TOP HUD */
        #top-hud {
            display: flex; justify-content: space-between; align-items: center;
            padding: 10px 20px; z-index: 100; margin: 10px;
        }
        .hud-stats { display: flex; gap: 20px; align-items: center; }
        .hud-item { display: flex; flex-direction: column; gap: 5px; }

        /* HP & LIMIT BARS */
        .bar-bg { width: 150px; height: 12px; background: #222; border: 2px solid #fff; border-radius: 4px; overflow: hidden; }
        .hp-fill { height: 100%; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width 0.3s; }
        .hp-fill.danger { background: linear-gradient(90deg, #ef4444, #f87171); }
        .limit-fill { height: 100%; background: linear-gradient(90deg, #eab308, #fef08a); transition: width 0.3s; width: 0%; }

        /* MAIN SCREENS */
        main { flex: 1; position: relative; padding: 10px; overflow-y: auto; overflow-x: hidden; }
        .screen { display: none; height: 100%; max-width: 1000px; margin: 0 auto; position: relative; }
        .screen.active { display: block; animation: fadeIn 0.3s; }
        @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

        /* BUTTONS */
        button {
            background: transparent; border: none; color: #fff; font-family: 'Press Start 2P', monospace;
            font-size: 12px; cursor: pointer; text-align: left; padding: 10px;
            position: relative; line-height: 1.5; text-shadow: 1px 1px 0 #000;
        }
        button:hover:not(:disabled) { color: var(--warning); }
        button:hover:not(:disabled)::before { content: '▶'; position: absolute; left: -15px; color: #fff; animation: blink 1s infinite; }
        button:disabled { opacity: 0.4; cursor: not-allowed; }
        @keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

        .btn-solid { background: rgba(255,255,255,0.2); border: 2px solid #fff; padding: 15px; text-align: center; border-radius: 8px; }
        .btn-solid:hover:not(:disabled)::before { display: none; }
        .btn-solid:hover:not(:disabled) { background: var(--primary); color: #000; text-shadow: none; }

        /* MAP PATHS */
        .map-container { position: relative; width: 100%; height: calc(100vh - 110px); max-width: 1200px; margin: 0 auto; padding: 0; }
        .node-wrapper { position: absolute; z-index: 10; }
        .map-node { 
            width: 400px; cursor: pointer; transition: transform 0.2s, background 0.2s, backdrop-filter 0.2s; position: relative; top: 0;
            animation: lightBounce 4s ease-in-out infinite;
            background: none !important;
            border: none !important;
            box-shadow: none !important;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }
        .map-node:hover { 
            animation-play-state: paused; z-index: 20;
            background: rgba(0,0,0,0.1) !important;
            backdrop-filter: blur(8px);
        }
        .map-node h3 {
            font-size: 24px;
            letter-spacing: 2px;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
            margin: 0;
            transition: transform 0.2s;
            transform-origin: left center;
        }
        .map-node:hover h3 {
            transform: scale(1.1);
        }
        .lore-dropdown {
            max-height: 0;
            opacity: 0;
            overflow: hidden;
            transition: max-height 0.4s ease, opacity 0.4s ease, padding 0.4s ease;
            background: rgba(15, 5, 24, 0.8);
            padding: 0 15px;
            margin-top: 5px;
            width: 100%;
        }
        .map-node:hover .lore-dropdown {
            max-height: 300px;
            opacity: 1;
            padding: 15px;
        }
        .node-locked { filter: grayscale(100%); opacity: 0.6; }
        .node-cleared h3 { text-shadow: 0 0 15px var(--success), 2px 2px 4px rgba(0,0,0,0.8) !important; }

        /* REALM HUB */
        .realm-hub { min-height: 100%; overflow-y: auto; }
        .realm-accent { height: 6px; margin: -20px -20px 18px; border-radius: 4px 4px 0 0; background: var(--primary); box-shadow: 0 0 18px currentColor; }
        .realm-briefing { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; border-bottom: 2px solid rgba(255,255,255,0.22); padding-bottom: 18px; }
        .realm-briefing h1 { margin: 0 0 12px; }
        .realm-danger { display: inline-block; color: #000; background: var(--warning); padding: 6px 10px; border-radius: 6px; font-size: 9px; margin-bottom: 12px; box-shadow: 3px 3px 0 #000; }
        .realm-mastery { min-width: 150px; text-align: center; border: 2px solid rgba(255,255,255,0.35); border-radius: 8px; padding: 14px; background: rgba(0,0,0,0.28); }
        .realm-mastery span { display: block; color: var(--dim); font-size: 9px; margin-bottom: 8px; }
        .realm-mastery strong { display: block; color: var(--warning); font-size: 26px; line-height: 1; }
        .realm-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 22px 0; }
        .realm-step { border: 2px solid rgba(255,255,255,0.22); border-radius: 8px; padding: 12px 8px; text-align: center; color: var(--dim); background: rgba(0,0,0,0.22); font-size: 8px; min-height: 58px; display: flex; align-items: center; justify-content: center; }
        .realm-step.done { border-color: var(--success); color: var(--success); background: rgba(74,222,128,0.12); }
        .realm-step.active { border-color: var(--warning); color: var(--warning); background: rgba(250,204,21,0.13); box-shadow: 0 0 18px rgba(250,204,21,0.25); }
        .realm-step.locked { opacity: 0.45; }
        .realm-brief-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
        .realm-brief-card { border: 2px solid rgba(255,255,255,0.18); border-radius: 8px; padding: 14px; background: rgba(0,0,0,0.25); }
        .realm-brief-card h3 { font-size: 10px; margin-bottom: 8px; color: var(--primary); }
        .realm-brief-card p { margin: 0; font-size: 12px; line-height: 1.7; }
        .realm-status { min-height: 48px; margin: 20px auto 0; max-width: 760px; border-left: 4px solid var(--primary); background: rgba(0,0,0,0.28); padding: 12px 14px; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text); }
        .realm-action-grid { display: grid; grid-template-columns: 1fr; gap: 16px; max-width: 470px; margin: 22px auto 0; }
        #hub-boss-btn { border-color: var(--danger); color: var(--danger); }
        #hub-boss-btn.ready { border-color: var(--warning); color: var(--warning); box-shadow: 0 0 20px rgba(250,204,21,0.2); }

        /* CODEX TRAINING */
        .codex-panel { height: 100%; overflow-y: auto; }
        .codex-intro { text-align: center; max-width: 760px; margin: 0 auto 20px; color: var(--primary); }
        .codex-training-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
        .codex-card { border: 2px solid rgba(255,255,255,0.18); border-radius: 8px; padding: 16px; background: rgba(0,0,0,0.26); min-height: 230px; display: flex; flex-direction: column; gap: 10px; }
        .codex-card h3 { font-size: 11px; margin-bottom: 0; color: var(--warning); }
        .codex-card p { font-size: 12px; line-height: 1.7; margin: 0; }
        .codex-check { margin-top: auto; border-top: 1px solid rgba(255,255,255,0.16); padding-top: 10px; }
        .codex-check-label { color: var(--primary); font-family: 'JetBrains Mono', monospace; font-size: 12px; margin-bottom: 8px; }
        .codex-options { display: grid; gap: 8px; }
        .codex-options button { font-size: 9px; padding: 10px; text-align: center; border: 2px solid rgba(255,255,255,0.35); border-radius: 6px; background: rgba(255,255,255,0.08); }
        .codex-options button.correct { background: var(--success); border-color: var(--success); color: #000; text-shadow: none; }
        .codex-options button.wrong { background: rgba(251,113,133,0.35); border-color: var(--danger); color: #fff; }
        .codex-complete-note { margin-top: 18px; padding: 12px; text-align: center; color: var(--success); border: 2px solid var(--success); border-radius: 8px; background: rgba(74,222,128,0.12); }

        /* BOSS REWARD */
        .boss-reward-panel { min-height: 100%; display: flex; flex-direction: column; justify-content: center; text-align: center; overflow-y: auto; }
        .boss-reward-kicker { color: var(--success); letter-spacing: 4px; font-size: 9px; margin-bottom: 12px; animation: victoryFadeIn 0.5s both; }
        .boss-reward-panel h1 { font-size: 30px; animation: victoryGlow 1.4s ease-in-out infinite alternate; }
        .boss-reward-panel p { max-width: 720px; margin: 0 auto 20px; color: var(--primary); }
        .boss-reward-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 720px; width: 100%; margin: 0 auto; }
        .boss-reward-stat { border: 2px solid rgba(255,255,255,0.22); border-radius: 8px; background: rgba(0,0,0,0.28); padding: 16px; }
        .boss-reward-stat strong { display: block; color: var(--warning); font-size: 20px; margin-bottom: 8px; }
        
        /* EMERGENCY DISPATCH ANIMATION */
        @keyframes emergencyPulse {
            0%, 100% { background-color: var(--danger); box-shadow: 0 0 10px var(--danger); color: #fff; }
            50% { background-color: rgba(239, 68, 68, 0.3); box-shadow: 0 0 30px var(--danger); color: #fff; }
        }
        .emergency-active {
            animation: emergencyPulse 0.8s infinite !important;
            border-color: var(--danger) !important;
        }

        /* BATTLE ARENA */
        .battle-scene { height: calc(100% - 260px); position: relative; overflow: hidden; border-radius: 8px; }
        #battle-bg { position: absolute; inset: 0; background-size: cover; background-position: center top; opacity: 0.55; z-index: 0; transition: background-image 0.4s, opacity 0.8s; }
        #battle-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.5) 100%); }
        .boss-mechanic-panel { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 3; min-width: 280px; max-width: 520px; padding: 10px 14px; border: 2px solid rgba(255,255,255,0.45); border-radius: 8px; background: rgba(0,0,0,0.62); text-align: center; font-size: 9px; color: var(--warning); box-shadow: 0 8px 24px rgba(0,0,0,0.55); }
        .boss-mechanic-panel strong { color: #fff; display: block; margin-bottom: 3px; }
        .boss-mechanic-panel.alert { border-color: var(--danger); color: var(--danger); animation: pulse-glow 1.2s infinite; }
        .boss-station { position: absolute; top: 20px; right: 10%; text-align: right; display: flex; flex-direction: column; align-items: flex-end; z-index: 1; }
        .boss-sprite { width: 280px; height: 280px; animation: float 3s infinite ease-in-out; margin-top: 40px; }
        .player-station { position: absolute; bottom: 20px; left: 10%; display: flex; flex-direction: column; align-items: flex-start; z-index: 1; }
        .player-sprite { width: 220px; height: 220px; margin-top: 40px; }

        .stat-box { padding: 10px 20px; display: inline-block; text-align: left; z-index: 10; }
        
        .command-window { height: 240px; width: 100%; position: absolute; bottom: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; }
        .dialogue-text { font-size: 14px; line-height: 2; border-right: 2px solid rgba(255,255,255,0.2); padding-right: 20px; align-self: start; }
        .command-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: center; width: 100%; height: 100%; }
        .command-options button { border: 2px solid transparent; padding: 12px 15px; font-size: 11px; }

        .floating { animation: float 3s ease-in-out infinite; }
        @keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
        @keyframes lightBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

        /* FLOATING COMBAT TEXT */
        .floating-text { position: absolute; font-size: 24px; font-weight: bold; text-shadow: 2px 2px 0 #000; z-index: 1000; pointer-events: none; animation: floatUp 1s ease-out forwards; top: 0; left: 50%; transform: translateX(-50%); }
        .floating-text.dmg { color: var(--danger); }
        .floating-text.heal { color: var(--success); }
        @keyframes floatUp { 0% { opacity: 1; margin-top: 0; } 100% { opacity: 0; margin-top: -80px; } }

        /* BATTLE HIT ANIMATIONS */
        @keyframes hitFlash { 0%,100%{opacity:1;} 25%{opacity:0.15; filter:brightness(8) saturate(0);} 75%{opacity:0.85;} }
        .hit-flash { animation: hitFlash 0.5s ease-out forwards; }
        @keyframes damageFlash { 0%,100%{filter:none;} 40%{filter:drop-shadow(0 0 25px var(--danger)) brightness(1.5);} }
        .damage-flash { animation: damageFlash 0.5s ease-out forwards; }
        @keyframes screenFlashAnim { 0%{opacity:0.8;} 100%{opacity:0;} }
        #screen-flash { position:fixed; inset:0; pointer-events:none; z-index:9997; opacity:0; }
        .screen-flash-active { animation: screenFlashAnim 0.6s ease-out forwards; }

        /* FULL SCREEN OVERLAY MENU */
        #menu-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 500; display: none; padding: 40px; }
        .menu-grid { display: grid; grid-template-columns: 250px 1fr; gap: 30px; height: 100%; }
        
        /* OTHER ELEMENTS */
        .creator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
        .origin-card { border: 2px solid rgba(255,255,255,0.15); border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; background: rgba(0,0,0,0.4); display: flex; flex-direction: column; }
        .origin-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
        .origin-card.selected { box-shadow: 0 0 28px rgba(192,132,252,0.5); }
        .class-card { border: 2px solid rgba(255,255,255,0.12); border-radius: 10px; overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; background: rgba(0,0,0,0.35); }
        .class-card:hover { transform: translateY(-3px); }
        .class-card.selected { transform: translateY(-2px); }
        .class-card-header { display:flex; align-items:center; gap:9px; margin-bottom:7px; min-height:54px; }
        .class-emblem { width:52px; height:52px; flex:0 0 52px; background-image:url('../Game Characters/Class Emblem Icons.png'); background-size:200% 200%; background-repeat:no-repeat; filter:drop-shadow(0 4px 8px rgba(0,0,0,0.65)); }
        .emblem-knight { background-position:0 0; }
        .emblem-mage { background-position:100% 0; }
        .emblem-rogue { background-position:0 100%; }
        .emblem-sage { background-position:100% 100%; }
        .stat-fill { transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1); }
        input[type="text"] { background: #000; border: 2px solid #fff; color: #fff; font-family: 'Press Start 2P'; padding: 15px; width: 100%; }

        @media (max-width: 820px) {
            .realm-briefing, .realm-brief-grid, .codex-training-grid { grid-template-columns: 1fr; }
            .realm-progress { grid-template-columns: repeat(2, 1fr); }
            .realm-mastery { width: 100%; }
            .boss-reward-stats { grid-template-columns: 1fr; }
            .mission-slot-grid, .mission-choice-grid, .mission-report-grid { grid-template-columns: 1fr; }
        }
        
        .pulse { animation: pulse-glow 1.5s infinite; color: var(--warning) !important; }
        @keyframes pulse-glow { 0%, 100% { text-shadow: 0 0 5px var(--warning); } 50% { text-shadow: 0 0 20px var(--warning), 0 0 10px #fff; } }

        /* Mission Mini-games */
        .mission-arena { position: relative; height: 300px; background: #000; border: 2px solid #fff; overflow: hidden; margin-top: 20px;}
        .molecule { position: absolute; width: 40px; height: 40px; background: var(--accent); border: 2px solid #fff; cursor: crosshair; animation: riseMolecule 4s infinite linear; }
        @keyframes riseMolecule { from { transform: translateY(350px); } to { transform: translateY(-50px); } }
        
        .slot { border: 2px dashed #888; padding: 20px; text-align: center; }
        .part { background: var(--box-bg-bottom); border: 2px solid #fff; padding: 15px; cursor: grab; margin-bottom: 10px; }
        .mission-header { text-align: center; border-bottom: 2px solid rgba(255,255,255,0.18); margin-bottom: 18px; padding-bottom: 14px; }
        .mission-header h1 { margin-bottom: 8px; }
        .mission-kicker { color: var(--success); font-size: 9px; letter-spacing: 3px; text-transform: uppercase; margin-bottom: 8px; }
        .mission-bank { display:flex; gap:10px; margin-bottom:20px; min-height:82px; padding:10px; flex-wrap:wrap; justify-content:center; }
        .mission-slot-grid { display:grid; grid-template-columns: repeat(4, 1fr); gap:10px; }
        .mission-slot-grid span { display:block; color:var(--warning); text-align:center; margin-bottom:5px; }
        .mission-panel { margin-top:20px; padding:16px; border:2px solid rgba(255,255,255,0.22); border-radius:8px; background:rgba(0,0,0,0.26); }
        .mission-choice-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap:10px; margin-top:12px; }
        .mission-choice-grid button.correct, .codex-options button.correct { background: var(--success); border-color: var(--success); color:#000; text-shadow:none; }
        .mission-choice-grid button.wrong, #safety-steps button.wrong { background: rgba(251,113,133,0.35); border-color: var(--danger); color:#fff; }
        .mission-meter { height:18px; border:2px solid #fff; border-radius:8px; background:#111; overflow:hidden; margin:16px 0 8px; }
        #vacuum-meter-fill { height:100%; width:100%; background:var(--warning); transition:width 0.25s, background 0.25s; }
        .mission-readout { text-align:center; color:var(--warning); font-family:'JetBrains Mono', monospace; margin-bottom:12px; }
        .mission-report { min-height:520px; display:flex; flex-direction:column; justify-content:center; text-align:center; }
        .mission-report-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:12px; margin-top:12px; }
        .mission-report-grid div { border:2px solid rgba(255,255,255,0.22); border-radius:8px; background:rgba(0,0,0,0.28); padding:14px; }
        .mission-report-grid strong { display:block; color:var(--warning); margin-bottom:6px; }
        .mission-report-grid span { font-family:'JetBrains Mono', monospace; font-size:12px; color:var(--text); }

        /* Dynamic Fullscreen World Map Background */
        body.map-bg-active {
            background-color: var(--bg-dark);
            background-image: linear-gradient(rgba(15, 5, 24, 0.4), rgba(15, 5, 24, 0.95)), url('../Game Characters/Game Map.png');
            background-position: center center;
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-size: cover;
        }
        
        #screen-map, #screen-start, #screen-victory { background: transparent; box-shadow: none; border: none; overflow: hidden; }
        @keyframes badgeDrop { from { transform: translateY(-180px) scale(0.4); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
        @keyframes certRise { from { transform: translateY(80px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
        @keyframes victoryFadeIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
        @keyframes victoryGlow { from { text-shadow: 0 0 20px rgba(255,215,0,0.4); } to { text-shadow: 0 0 50px rgba(255,215,0,1), 0 0 100px rgba(255,215,0,0.4); } }
        
        /* CALLBACK OVERLAY */
        #callback-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(251, 113, 133, 0.15); z-index: 2000; display: none; place-items: center; backdrop-filter: blur(4px); }
