:root {
    --primary: #1a1a1a;
    --accent: #2980b9;
    --bg: #f4f7f6;
    --panel: #ffffff;
    --text-muted: #444444;
    
    /* Status Colors */
    --safe: #27ae60;
    --warn: #f39c12;
    --danger: #c0392b;
    
    /* Materials */
    --human-color: #e74c3c; 
    --run-fill: rgba(52, 152, 219, 0.6);
    --run-stroke: #2980b9;
    --land-fill: #bdc3c7;
    --land-stroke: #7f8c8d;

    /* UX: Standard Gray for inactive icons */
    --gray-icon: #aaaaaa;
}

/* --- TRAIN MODE (DARK THEME) VARIABLES --- */
body.train-mode {
    --primary: #ffffff;
    --accent: #00e5ff; /* Neon Cyan */
    --bg: #0d0d0d;
    --panel: #141414;
    --text-muted: #a0a0a0;
    --safe: #00e5ff; 
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: var(--bg); color: var(--primary); 
    margin: 0; padding: 0; 
    min-height: 100vh; display: flex; flex-direction: column; 
    -webkit-font-smoothing: antialiased;
    padding-bottom: 40px; 
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* LAYOUT */
.page-layout { 
    display: flex; 
    padding: 20px; 
    justify-content: center; 
    flex: 1; 
}

.main-wrapper {
    flex: 1; max-width: 900px; width: 100%;
    background: var(--panel); border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    display: flex; flex-direction: column; overflow: hidden;
    transition: background-color 0.3s ease;
}

/* HEADER & BRANDING */
.header { background: var(--panel); padding: 1.5rem 1rem 0.5rem 1rem; text-align: center; border-bottom: 1px solid #eee; transition: background-color 0.3s ease; }
body.train-mode .header { border-bottom: 1px solid #222; }

/* --- HEADER TOP (ICONS + LOGO + TOGGLE) --- */
.header-top {
    display: flex;
    justify-content: center; 
    align-items: flex-end; 
    gap: 40px; 
    margin-bottom: 15px; 
    padding: 0 15px;
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-branding {
    text-align: center;
    cursor: pointer;
    user-select: none;
    margin: 0 10px 15px 10px; 
}

.brand-top { font-size: 1.4rem; font-weight: 800; color: var(--primary); display: block; line-height: 1.2; letter-spacing: 1px; transition: color 0.3s ease; }
.brand-bottom { font-size: 1.8rem; font-weight: 900; color: var(--safe); display: block; line-height: 1; letter-spacing: 1px; transition: color 0.3s ease; }

/* Train Mode Specific Branding Colors */
body.train-mode .brand-top { color: #00e5ff; }
body.train-mode .brand-bottom { color: #ff66b2; } /* Neon Pink */

/* --- UX: MODE BUTTONS STYLING --- */
.mode-icon-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    outline: none;
    flex-shrink: 0;
    background-color: transparent; 
}

.btn-work svg { width: 30px; height: 30px; transition: fill 0.3s ease; }
.btn-train svg { width: 40px; height: 40px; transition: fill 0.3s ease; }

/* PULSE ANIMATIONS (Standard Hover) */
@keyframes pulseWork { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes pulseTrain { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* CONTINUOUS BREATHING ANIMATIONS (Color + Scale for Home Screens) */
@keyframes breatheTrainColor {
    0%, 100% { transform: scale(1); border-color: rgba(128, 128, 128, 0.3); }
    50% { transform: scale(1.05); border-color: #00d1e8; box-shadow: 0 0 10px rgba(0, 209, 232, 0.2); }
}
@keyframes breatheTrainSvg { 0%, 100% { fill: var(--gray-icon); } 50% { fill: #00d1e8; } }

@keyframes breatheWorkColor {
    0%, 100% { transform: scale(1); border-color: rgba(255, 255, 255, 0.2); }
    50% { transform: scale(1.05); border-color: #27ae60; box-shadow: 0 0 10px rgba(39, 174, 96, 0.2); }
}
@keyframes breatheWorkSvg { 0%, 100% { fill: var(--gray-icon); } 50% { fill: #27ae60; } }

/* =======================================
   LIGHT THEME (Work Mode Active)
   ======================================= */
body:not(.train-mode) .btn-work { border: 2.5px solid var(--primary); cursor: default; }
body:not(.train-mode) .btn-work svg { fill: var(--primary); }
body:not(.train-mode) .btn-train { border: 1px solid rgba(128, 128, 128, 0.3); cursor: pointer; }
body:not(.train-mode) .btn-train svg { fill: var(--gray-icon); }

/* Standard Hover (Fast Pulse) */
body:not(.train-mode) .btn-train:hover { border-color: #00d1e8; animation: pulseTrain 1.5s infinite ease-in-out; }
body:not(.train-mode) .btn-train:hover svg { fill: #00d1e8; }

/* Home Screen Breathing (Slow Pulse with Color) */
body.on-home:not(.train-mode) .btn-train { animation: breatheTrainColor 2.5s infinite ease-in-out; }
body.on-home:not(.train-mode) .btn-train svg { animation: breatheTrainSvg 2.5s infinite ease-in-out; }

/* Override breathing when actually hovering on Home screen */
body.on-home:not(.train-mode) .btn-train:hover { animation: pulseTrain 1.5s infinite ease-in-out; border-color: #00d1e8; }
body.on-home:not(.train-mode) .btn-train:hover svg { animation: none; fill: #00d1e8; }


/* =======================================
   DARK THEME (Train Mode Active)
   ======================================= */
body.train-mode .btn-train { border: 2.5px solid #ffffff; cursor: default; }
body.train-mode .btn-train svg { fill: #ffffff; }
body.train-mode .btn-work { border: 1px solid rgba(255, 255, 255, 0.2); cursor: pointer; }
body.train-mode .btn-work svg { fill: var(--gray-icon); }

/* Standard Hover (Fast Pulse) */
body.train-mode .btn-work:hover { border-color: #27ae60; animation: pulseWork 1.5s infinite ease-in-out; }
body.train-mode .btn-work:hover svg { fill: #27ae60; }

/* Home Screen Breathing (Slow Pulse with Color) */
body.on-home.train-mode .btn-work { animation: breatheWorkColor 2.5s infinite ease-in-out; }
body.on-home.train-mode .btn-work svg { animation: breatheWorkSvg 2.5s infinite ease-in-out; }

/* Override breathing when actually hovering on Home screen */
body.on-home.train-mode .btn-work:hover { animation: pulseWork 1.5s infinite ease-in-out; border-color: #27ae60; }
body.on-home.train-mode .btn-work:hover svg { animation: none; fill: #27ae60; }

/* HIDE TABS ON HOME SCREEN */
body.on-home .tabs { display: none !important; }

/* TOP CONTROLS */
.top-controls { display: flex; justify-content: center; width: 100%; margin-bottom: 0; }
.unit-toggle-container { display: flex; justify-content: center; align-items: center; gap: 10px; font-weight: 600; font-size: 0.9rem; color: var(--text-muted); }
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(24px); }

/* TABS */
.tabs { display: flex; background: rgba(0,0,0,0.05); padding: 5px; justify-content: center; gap: 5px; flex-wrap: wrap; }
body.train-mode .tabs { background: rgba(255,255,255,0.05); }
.tab-btn { padding: 12px 15px; border: none; background: transparent; cursor: pointer; font-weight: 600; color: var(--text-muted); border-bottom: 3px solid transparent; transition: 0.2s; font-size: 0.95rem; }
.tab-btn:hover { background: rgba(128,128,128,0.1); }
.tab-btn.active { background: var(--panel); color: var(--accent); border-bottom-color: var(--accent); }

.content-area { display: none; padding: 20px; background: var(--panel); animation: fadeIn 0.3s ease; }
.content-area.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* HOME HUB STYLES */
.hero-section { text-align: center; padding: 30px 10px 10px 10px; margin-bottom: 10px; }
.intro-text { max-width: 700px; margin: 0 auto 30px auto; text-align: center; color: var(--text-muted); line-height: 1.6; font-size: 1rem; }

.about-section { margin-top: 40px; padding: 25px; background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.05); border-radius: 8px; text-align: left; }
body.train-mode .about-section { background: rgba(255,255,255,0.03); border-color: rgba(255,255,255,0.1); }
.about-title { font-size: 1.2rem; font-weight: 700; color: var(--primary); margin-bottom: 10px; }
.about-content { font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; }

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; padding: 10px; }
.tool-card { background: var(--panel); border: 1px solid rgba(128,128,128,0.2); border-radius: 10px; padding: 20px; text-align: center; transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tool-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.08); border-color: var(--accent); }
body.train-mode .tool-card:hover { box-shadow: 0 10px 20px rgba(0, 229, 255, 0.1); }
.card-icon { width: 50px; height: 50px; margin-bottom: 15px; fill: var(--accent); opacity: 0.9; }
.card-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; color: var(--primary); }
.card-desc { font-size: 0.9rem; color: var(--text-muted); line-height: 1.4; }

/* SUGGEST CARD */
.tool-card-suggest { border: 2px dashed #bdc3c7; background: transparent; }
body.train-mode .tool-card-suggest { border-color: #444; }
.tool-card-suggest .card-icon { fill: #95a5a6; }
.tool-card-suggest:hover { border-color: var(--accent); background: rgba(128,128,128,0.05); }
.tool-card-suggest:hover .card-icon { fill: #f1c40f; }

/* SUGGEST PAGE */
.suggest-container { text-align: center; padding: 40px 20px; max-width: 600px; margin: 0 auto; }
.suggest-title { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin-bottom: 20px; }
.suggest-text { font-size: 1.1rem; color: var(--text-muted); line-height: 1.8; margin-bottom: 30px; }
.btn-linkedin { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: #0077b5; color: white; padding: 10px 28px; border-radius: 50px; text-decoration: none; font-weight: 600; font-size: 0.95rem; letter-spacing: 0.5px; box-shadow: 0 2px 8px rgba(0,119,181,0.15); transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); margin-top: 25px; }
.btn-linkedin:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,119,181,0.25); background: #005e93; }
.signature-text { font-weight: 500; color: #95a5a6; margin-top: 45px; font-size: 0.95rem; letter-spacing: 0.5px; text-transform: uppercase; }

/* INPUTS & UTILS */
.eng-notes { margin-top: 30px; padding: 20px; background: rgba(0,0,0,0.02); border-top: 1px solid rgba(128,128,128,0.2); font-size: 0.95rem; color: var(--text-muted); line-height: 1.6; }
.eng-notes h3 { margin-top: 0; color: var(--primary); font-size: 1.1rem; font-weight: 700; margin-bottom: 15px; }
.eng-notes h4 { margin: 15px 0 5px 0; font-size: 0.95rem; color: var(--accent); font-weight: 600; }
.eng-notes code { background: rgba(128,128,128,0.1); padding: 2px 5px; border-radius: 4px; font-family: monospace; color: #c0392b; }
body.train-mode .eng-notes code { color: #ff66b2; }

.legend-box { display: flex; flex-direction: column; border: 1px solid rgba(128,128,128,0.2); border-radius: 8px; overflow: hidden; margin-top: 20px; margin-bottom: 20px; }
.legend-item { display: flex; border-bottom: 1px solid rgba(128,128,128,0.2); background: transparent; align-items: stretch; }
.legend-item:last-child { border-bottom: none; }
.legend-color { width: 6px; flex-shrink: 0; }
.legend-content { padding: 12px 15px; flex: 1; }
.legend-range { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; display: block; }
.legend-desc { font-size: 0.95rem; color: var(--text-muted); line-height: 1.4; }

.visualizer { width: 100%; height: 400px; background: rgba(0,0,0,0.03); border: 1px solid rgba(128,128,128,0.2); border-radius: 8px; margin-bottom: 20px; overflow: hidden; display: flex; justify-content: center; align-items: center; }
body.train-mode .visualizer { background: #1a1a1a; border-color: #333; }
svg { width: 100%; height: 100%; display: block; }

.input-row { display: flex; gap: 15px; margin-bottom: 15px; flex-wrap: wrap; }
.input-group { flex: 1; min-width: 140px; display: flex; flex-direction: column; }
label { font-size: 0.85rem; font-weight: 700; margin-bottom: 5px; color: var(--primary); }
input, select { padding: 10px; border: 1px solid rgba(128,128,128,0.4); border-radius: 6px; font-size: 1rem; color: #000; background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type=range] { margin-top: 10px; }

.unit-group { display: flex; border: 1px solid rgba(128,128,128,0.4); border-radius: 6px; overflow: hidden; }
.unit-group input { border: none; flex: 2; border-radius: 0; min-width: 50px; }
.unit-group select { border: none; background: #eee; flex: 1; border-left: 1px solid rgba(128,128,128,0.4); border-radius: 0; }

.btn-container { text-align: center; margin-top: 20px; display: flex; justify-content: center; gap: 10px; }
.btn-clear { background: #95a5a6; color: white; border: none; padding: 10px 30px; border-radius: 6px; cursor: pointer; font-size: 1rem; }
.btn-calc { background: var(--safe); color: white; border: none; padding: 10px 30px; border-radius: 6px; cursor: pointer; font-size: 1rem; }
.btn-clear:hover, .btn-calc:hover { opacity: 0.9; }

.status-box { background: rgba(0,0,0,0.03); padding: 15px; border-radius: 8px; border-left: 5px solid var(--accent); margin-top: 20px; }
body.train-mode .status-box { background: #1a1a1a; }
.status-item { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed rgba(128,128,128,0.4); }
.status-val { font-weight: bold; color: var(--primary); }
.val-warn { color: var(--warn); }
.val-valid { color: var(--safe); }

/* --- FLOATING SHARE BUTTON INSIDE VISUALIZER --- */
.visualizer {
    position: relative; 
}

.share-floating-btn {
    position: absolute;
    top: 12px;
    right: 12px; 
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s ease;
    z-index: 10;
    backdrop-filter: blur(4px); 
}

.share-floating-btn:hover {
    background: var(--panel);
    transform: scale(1.1);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* FOOTER */
.app-footer { padding: 25px 20px; background: var(--panel); border-top: 1px solid rgba(128,128,128,0.2); text-align: center; display: flex; flex-direction: column; gap: 15px; align-items: center; }
.credit-box { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.credit-link { color: var(--accent); text-decoration: none; font-weight: 700; transition: color 0.2s; }
.credit-link:hover { text-decoration: underline; }
.separator { margin: 0 4px; color: #ccc; }

.btn-share { background: #2c3e50; color: white; border: none; padding: 12px 30px; border-radius: 8px; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; gap: 10px; font-weight: 600; transition: 0.2s; }
.btn-share:hover { background: #34495e; transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
body.train-mode .btn-share { display:none !important; }

.footer-disclaimer { font-size: 0.75rem; color: #7f8c8d; margin: 0 auto 15px auto; max-width: 700px; line-height: 1.5; }
.footer-version { font-family: 'Courier New', monospace; font-size: 0.7rem; color: #bdc3c7; margin-top: 15px; letter-spacing: 1px; opacity: 0.8; }

/* GRAPHICS */
text { font-family: monospace; font-size: 14px; fill: var(--primary); font-weight: bold; }
body.train-mode text { fill: #ccc; }
.dim-line { stroke: var(--primary); stroke-width: 1; }
body.train-mode .dim-line { stroke: #ccc; }
.dim-text { text-anchor: middle; dominant-baseline: middle; }
.dim-text.white { fill: white; }
.dim-line.white { stroke: white; }
.run-fill { fill: var(--run-fill); stroke: var(--run-stroke); stroke-width: 1; }
.run-fill.danger { fill: rgba(192, 57, 43, 0.4); stroke: var(--danger); }
.land-fill { fill: var(--land-fill); stroke: var(--land-stroke); stroke-width: 1; }
.handrail { stroke: #2c3e50; stroke-width: 2; fill: none; stroke-linecap: round; }
body.train-mode .handrail { stroke: #7f8c8d; }
.human-body { fill: var(--human-color); stroke: none; }
.human-head { fill: var(--human-color); stroke: none; }
.slope-fill { fill-opacity: 0.6; stroke-width: 2; }
.channel-water { fill: rgba(52, 152, 219, 0.5); stroke: #2980b9; stroke-width: 1; }
.plant-outer { fill: rgba(46, 204, 113, 0.3); stroke: #27ae60; stroke-width: 1; vector-effect: non-scaling-stroke; }
.plant-center { fill: #145a32; stroke: none; }
.gauge-border { fill: none; stroke: var(--primary); stroke-width: 2; }
.gauge-water { fill: rgba(52, 152, 219, 0.8); stroke: none; transition: height 0.5s; }
.crown-line { stroke: #e74c3c; stroke-width: 2; stroke-dasharray: 5,5; }
.contour-line { stroke: var(--primary); stroke-width: 2.5; fill: none; stroke-dasharray: 8,4; }
body.train-mode .contour-line { stroke: #888; }
.path-bg { fill: #e0e0e0; stroke: #333; stroke-width: 2; }
body.train-mode .path-bg { fill: #222; stroke: #555; }
.helper-line { stroke: #999; stroke-width: 1; stroke-dasharray: 4,2; }

/* AD CONTAINERS */
.ad-placeholder-inline, .ad-placeholder-sticky {
    display: flex; justify-content: center; align-items: center;
    width: 100%; max-width: 728px; margin: 15px auto; 
    border: 1px dashed #ccc; color: #aaa; font-family: sans-serif; font-size: 14px;
    background-color: transparent; box-sizing: border-box; height: 90px;
}
.ad-sticky-container {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%; z-index: 9999;
    background-color: rgba(255, 255, 255, 0.95); border-top: 1px solid #eee; 
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05); justify-content: center; padding: 10px 0;
}
body.train-mode .ad-sticky-container { display: none !important; }

/* =========================================================
   TRAIN MODE OVERRIDES (GENERAL)
   ========================================================= */

/* Fullscreen App-Feel respecting the Mobile Browser Bar */
body.train-mode {
    margin: 0 !important;
    padding: 0 !important;
    height: 100vh !important; 
    height: 100svh !important; 
    overflow: hidden !important; 
}

body.train-mode .page-layout { 
    padding: 0 !important; 
    margin: 0 !important;
    height: 100% !important; 
    box-sizing: border-box; 
}

body.train-mode .main-wrapper { 
    height: 100% !important; 
    max-height: 100% !important;
    border-radius: 0 !important; 
    box-sizing: border-box; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden !important; /* CRITICAL: Prevents any content from stretching the screen */
}

/* Hide footer and About section */
body.train-mode .app-footer,
body.train-mode .about-section { display: none !important; }

/* Visual Anchor at bottom of Arena grid */
body.train-mode .home-grid::after {
    content: "PLANCALC // ARENA_MODE_ACTIVE";
    display: block; grid-column: 1 / -1; text-align: center;
    margin-top: 40px; padding-top: 20px;
    border-top: 1px solid rgba(0, 229, 255, 0.15); 
    color: rgba(255, 255, 255, 0.2); font-family: monospace;
    font-size: 11px; letter-spacing: 4px; width: 100%;
}


/* =========================================================
   ARENA GAMES: SCALE SPRINT MODULE STYLES
   ========================================================= */

#train-scale { position: relative; overflow: hidden; display: none; flex-direction: column; align-items: center; background: transparent; padding: 0; flex: 1; }
#train-scale.active { display: flex; } 

.ss-fx-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; }

.ss-game-container { 
    width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; 
    gap: 15px; flex: 1; position: relative; z-index: 10; padding: 20px 0; box-sizing: border-box;
}

/* --- Top Navigation Bar --- */
.ss-top-bar { display: flex; justify-content: space-between; align-items: center; width: 100%; margin-bottom: 5px; }
.ss-header-info { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ss-score { font-size: 18px; color: #00e5ff; font-weight: bold; margin-bottom: 2px;} 
.ss-question-counter { color: #888; font-size: 15px; }
.ss-nav-btn { background: transparent; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 50%; width: 45px; height: 45px; display: flex; justify-content: center; align-items: center; color: #888; cursor: pointer; transition: 0.2s; padding: 10px; }
.ss-nav-btn:hover { border-color: #00e5ff; color: #00e5ff; transform: scale(1.05); }
.ss-nav-btn svg { width: 100%; height: 100%; fill: currentColor; }

/* --- Start Screen & Timer --- */
#ss-start-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; width: 100%; height: 100%; min-height: 150px; }
.ss-start-title { color: #00e5ff; font-size: 28px; font-weight: 900; letter-spacing: 2px; }
.ss-start-desc { color: #888; font-size: 14px; margin-bottom: 10px; text-align: center; }
.ss-unit-toggle { display: flex; justify-content: center; align-items: center; gap: 12px; font-weight: 600; font-size: 14px; color: #aaa; }

.ss-timer-wrapper { display: flex; align-items: center; width: 100%; gap: 10px; }
.ss-hourglass-icon { font-size: 18px; animation: ss-tilt 2s infinite ease-in-out; }
@keyframes ss-tilt { 0% { transform: rotate(0deg); } 50% { transform: rotate(15deg); } 100% { transform: rotate(0deg); } }
.ss-progress-bar-container { flex-grow: 1; height: 8px; background-color: #333; border-radius: 4px; overflow: hidden; }
.ss-progress-bar { height: 100%; width: 100%; background-color: #ff66b2; transition: width 0.1s linear; }

/* --- Display Area & Text Styling --- */
.ss-display-area { 
    background: #000; border: 2px solid #333; border-radius: 12px; padding: 15px; text-align: center; 
    box-shadow: inset 0 0 20px rgba(0,0,0,0.8); 
    display: flex; flex-direction: column; justify-content: center; align-items: center; 
    flex-grow: 1; min-height: 180px; height: auto; box-sizing: border-box; 
}
#ss-game-screen { display: flex; flex-direction: column; justify-content: center; align-items: center; width: 100%; gap: 6px; }

/* Rescued Text Styles! */
.ss-q-scale { color: #00e5ff; font-weight: bold; letter-spacing: 1px; font-size: 13px; margin: 0; }
.ss-q-task { color: #888; font-size: 14px; text-transform: uppercase; margin: 0; }
.ss-q-value { font-size: 26px; color: #ddd; font-weight: 500; margin: 0; }
.ss-answer-input { font-size: 38px; font-weight: bold; color: #ffffff; height: 40px; display: flex; align-items: center; justify-content: center; letter-spacing: 2px; overflow: hidden; margin: 0; }
.ss-answer-input.feedback-mode { font-size: 18px; }
.ss-formula-display { font-size: 14px; color: #aaa; height: 24px; display: flex; align-items: center; justify-content: center; font-family: monospace; background: rgba(255,255,255,0.05); padding: 0 6px; border-radius: 6px; opacity: 0; transition: opacity 0.3s; margin: 0; }

/* --- Numpad & Game Over --- */
.ss-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 0; }
.ss-num-btn { background-color: #222; color: #fff; border: 1px solid #333; border-radius: 10px; height: 60px; font-size: 24px; font-weight: 600; cursor: pointer; transition: 0.1s; }
.ss-num-btn:active { background-color: #444; transform: scale(0.95); }
.ss-btn-delete { background-color: #222; color: #ff66b2; border-color: #ff66b2; }
.ss-btn-enter { background-color: #00e5ff; color: #000; grid-column: span 3; font-size: 20px; font-weight: 800; letter-spacing: 2px; border:none; }
.ss-btn-enter.continue-mode { background-color: #ff66b2; color: #fff; }

.ss-game-over-screen { display: none; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ss-action-buttons { width: 100%; display: flex; flex-direction: column; gap: 15px; margin-top: 20px; }
.ss-share-btn { display: flex; align-items: center; justify-content: center; gap: 12px; background-color: transparent; color: #00e5ff; border: 2px solid #00e5ff; grid-column: span 3; font-size: 18px; }
.ss-share-btn:active { background-color: rgba(0, 229, 255, 0.1); }
.ss-share-icon { width: 22px; height: 22px; fill: currentColor; }


/* =========================================================
   MOBILE RESPONSIVENESS & FIXES
   ========================================================= */

@media (max-width: 1000px) {
    .page-layout { padding: 10px; }
    .visualizer { height: 220px !important; }
    .home-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 768px) {
    .ad-placeholder-inline, .ad-placeholder-sticky { height: 60px; max-width: 320px; font-size: 12px; }
    .ad-sticky-container { display: flex; padding: 5px 0; }
    body { padding-bottom: 80px; }
}

@media (max-width: 600px) {
    /* Main Header Fixes */
    .header-top { gap: 15px; margin-bottom: 10px; padding: 0 5px; }
    .mode-icon-btn { width: 45px; height: 45px; }
    body:not(.train-mode) .btn-work, body.train-mode .btn-train { border-width: 2px; }
    .btn-work svg { width: 20px; height: 20px; }
    .btn-train svg { width: 28px; height: 28px; }
    .site-branding { margin: 0 5px 10px 5px; }
    .brand-top { font-size: 1rem; letter-spacing: 0.5px; }
    .brand-bottom { font-size: 1.3rem; }
    
    /* Mobile App Grid 3x3 */
    .home-grid { 
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important; 
        gap: 20px 5px !important; padding: 10px 5px !important; border: none !important;
    }
    .tool-card { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; justify-content: flex-start !important; box-sizing: border-box !important; }
    .card-icon { width: 26px !important; height: 26px !important; background: var(--panel) !important; padding: 16px !important; border-radius: 22% !important; box-shadow: 0 4px 10px rgba(0,0,0,0.08) !important; margin-bottom: 8px !important; }
    body.train-mode .card-icon { background: #222 !important; box-shadow: 0 4px 10px rgba(0,0,0,0.4) !important;}
    .card-title { font-size: 0.75rem !important; line-height: 1.1 !important; font-weight: 600 !important; text-align: center !important; margin-bottom: 0 !important; }
    .card-desc { display: none !important; }
    
    .tool-card-suggest .card-icon { background: rgba(0,0,0,0.02) !important; border: 2px dashed #b6bbb1 !important; box-shadow: none !important; }
    body.train-mode .tool-card-suggest .card-icon { border-color: #444 !important; background: rgba(255,255,255,0.02) !important; }
    .tool-card-suggest .card-icon path { fill: #95a5a6 !important; }

/* --- ARENA MOBILE FIXES (JS CONTROLLED) --- */
    
    #train-scale { min-height: 0 !important; }

    /* Container becomes a simple flex column */
    .ss-game-container { 
        display: flex; flex-direction: column; width: 100%;
        padding: 5px !important; gap: 8px; 
        box-sizing: border-box !important; margin: 0 !important;
    }

    .ss-top-bar, .ss-timer-wrapper { 
        margin-bottom: 0; flex: 0 0 auto !important; 
    }
    
    .ss-hourglass-icon { font-size: 14px; } 

    /* JS will control the height of this box. No fake padding/margins! */
    .ss-display-area { 
        margin: 0 !important; padding: 15px 5px; 
        box-sizing: border-box; overflow-y: auto; 
    }
    
    .ss-q-scale { font-size: 14px; letter-spacing: 1.5px; margin: 0; } 
    .ss-q-task { font-size: 13px; margin: 0; } 
    .ss-q-value { font-size: 26px; font-weight: 600; margin: 5px 0; } 
    .ss-answer-input { font-size: 42px; height: 46px; margin: 0; } 
    .ss-formula-display { font-size: 13px; height: 18px; padding: 0 6px; margin: 0; }
    
    /* Numpad sits naturally in the column, no absolute positioning */
    .ss-numpad { 
        position: static !important; flex: 0 0 auto !important;
        margin: 0 !important; gap: 6px !important; padding: 0 !important; 
        box-sizing: border-box !important;
    }
    
    .ss-num-btn, .ss-btn-enter, .ss-share-btn { 
        height: 48px; font-size: 22px; border-radius: 8px; 
        box-sizing: border-box; margin: 0;
    }

    .ss-game-over-screen { padding-bottom: 15px !important; }
    .ss-action-buttons {
        position: static !important; margin-top: 20px !important;
        padding: 0 !important; box-sizing: border-box !important;
    }
}
