:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --primary: #4CAF50; 
    --accent: #2196F3;
    --gold: #FFD700;
    --danger: #f44336;
    --warn: #FF9800;
    --text: #ffffff;
    --text-dim: #888888;
}

body {
    background-color: var(--bg-color);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto; 
}

.screen {
    display: none;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    min-height: 100vh; 
    padding-bottom: 50px; 
}

.screen.active { display: flex; }

/* Dashboard */
.dashboard-header { display: flex; align-items: center; gap: 15px; margin-bottom: 25px; padding-bottom: 15px; border-bottom: 1px solid #333; }
.rank-badge { font-size: 2.5rem; background: #252525; width: 60px; height: 60px; display: flex; justify-content: center; align-items: center; border-radius: 12px; border: 1px solid #444; }
.header-text { flex-grow: 1; }
.rank-label { font-size: 0.7rem; color: var(--gold); letter-spacing: 1px; font-weight: bold; }
#rank-title { margin: 0; font-size: 1.4rem; text-transform: uppercase; }
.streak-mini { font-size: 0.8rem; color: var(--text-dim); background: #252525; padding: 5px 10px; border-radius: 20px; }

/* Heatmap */
.heatmap-card { margin-bottom: 20px; }
.heatmap-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.heatmap-header h3 { font-size: 0.9rem; margin: 0; color: #ccc; }
.legend { font-size: 0.7rem; color: #666; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; margin-left: 8px; }
.dot.green { background: var(--primary); }
.dot.yellow { background: var(--warn); }
.dot.red { background: var(--danger); }
.heatmap-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10px, 1fr)); gap: 3px; max-width: 100%; overflow-x: auto; }
.heat-sq { width: 100%; aspect-ratio: 1; background: #252525; border-radius: 2px; }
.heat-sq.success { background: var(--primary); opacity: 0.8; }
.heat-sq.fail { background: var(--danger); opacity: 0.8; }
.heat-sq.skip { background: var(--warn); opacity: 0.6; }
.heat-sq.rest { background: #333; }

/* Mission Card */
.mission-card { background: linear-gradient(145deg, #1e1e1e, #252525); border: 1px solid #444; border-radius: 16px; padding: 20px; margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.mission-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mission-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; }
.phase-tag { background: var(--primary); color: #000; font-size: 0.7rem; font-weight: bold; padding: 2px 8px; border-radius: 4px; }
#phase-title-dash { margin: 5px 0; font-size: 1.5rem; }
#phase-desc-dash { margin: 0 0 20px; color: var(--text-dim); font-size: 0.9rem; font-style: italic; }
.bullet-tracker { 
    display: flex; 
    justify-content: space-between; 
    background: #111; 
    padding: 12px; 
    border-radius: 12px; 
    margin-bottom: 15px; 
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.5); 
    border: 1px solid #333; 
}

.bullet { 
    width: 14px; 
    height: 30px; 
    background: #2a2a2a; /* Empty state */
    border-radius: 4px; 
    position: relative; 
    overflow: hidden; 
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    border: 1px solid #444; 
}

/* 1. Green Fill (Default Success) */
.bullet.filled { 
    background: var(--primary); 
    border-color: #66bb6a; 
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.6); 
    transform: scale(1.1); 
}

/* 2. Red Fill (Fail) - Must come AFTER .filled */
.bullet.fail { 
    background: var(--danger) !important; 
    border-color: #d32f2f !important; 
    box-shadow: 0 0 10px rgba(244, 67, 54, 0.6) !important; 
}.mission-footer { display: flex; justify-content: space-between; align-items: center; }
.text-btn { background: none; border: none; color: var(--accent); font-size: 0.8rem; cursor: pointer; text-decoration: none; font-weight: bold; }

/* Actions */
.dashboard-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; }
.secondary-actions-row { display: flex; gap: 10px; }
.large-action { padding: 20px; font-size: 1.3rem; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; box-shadow: 0 0 20px rgba(76, 175, 80, 0.2); }

/* Settings (Clean) */
.accordion-card { background: #1e1e1e; border-radius: 8px; margin-bottom: 10px; overflow: hidden; border: 1px solid #333; }
.accordion-card summary { padding: 15px; cursor: pointer; font-weight: bold; color: #bbb; list-style: none; }
.accordion-content { padding: 20px; background: #181818; display: flex; flex-direction: column; gap: 20px; border-top: 1px solid #333; }
.setting-group { display: flex; flex-direction: column; gap: 10px; }
.setting-group.row-flex { flex-direction: row; justify-content: space-between; align-items: center; padding: 5px 0; }
.setting-row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.setting-label { font-size: 0.95rem; color: #ddd; font-weight: 500; }
.setting-value-badge { background: #333; color: var(--accent); padding: 2px 8px; border-radius: 4px; font-size: 0.85rem; font-weight: bold; }

/* Switch & Slider */
.styled-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; background: #333; border-radius: 5px; outline: none; transition: background 0.3s; }
.styled-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; background: var(--accent); border-radius: 50%; cursor: pointer; box-shadow: 0 0 10px rgba(33, 150, 243, 0.4); }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

/* Danger Button */
.danger-area { margin-top: 10px; padding-top: 15px; border-top: 1px solid #333; }
.danger-btn-modern { width: 100%; padding: 12px; background: rgba(244, 67, 54, 0.08); border: 1px solid var(--danger); color: var(--danger); font-weight: bold; border-radius: 8px; cursor: pointer; display: flex; justify-content: center; align-items: center; gap: 8px; transition: all 0.3s; }
.danger-btn-modern:hover { background: var(--danger); color: white; box-shadow: 0 5px 15px rgba(244, 67, 54, 0.4); transform: translateY(-1px); }

/* Session */
.session-header-row { display: flex; justify-content: flex-end; padding-bottom: 10px; }
.icon-btn { background: transparent; border: 1px solid #333; color: #666; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; }
.icon-btn.active { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px rgba(33, 150, 243, 0.3); }
#main-timer { font-size: 3.5rem; font-weight: bold; text-align: center; margin-bottom: 20px; font-variant-numeric: tabular-nums; transition: opacity 0.5s; }
.zen-active #main-timer { opacity: 0; }
.zen-active .top-bar { opacity: 0.2; }
.peak-button { flex-grow: 1; background: var(--card-bg); border: 2px solid var(--primary); border-radius: 20px; color: var(--primary); font-size: 1.5rem; display: flex; flex-direction: column; justify-content: center; align-items: center; touch-action: manipulation; margin-bottom: 20px; }
.peak-button:active { background: #2e3d2f; }
#rest-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--accent); color: white; display: flex; justify-content: center; align-items: center; text-align: center; z-index: 10; cursor: pointer; }
#rest-overlay.hidden { display: none; }
#rest-timer { font-size: 5rem; font-weight: bold; }
.tap-hint { margin-top: 30px; font-size: 0.9rem; opacity: 0.7; animation: pulse 2s infinite; }
.breath-container { height: 100px; display: flex; justify-content: center; align-items: center; margin-bottom: 20px; }
.breath-circle { width: 20px; height: 20px; background: var(--primary); border-radius: 50%; opacity: 0.6; animation: breathe 10s infinite ease-in-out; }
@keyframes breathe { 0% { transform: scale(1); } 40% { transform: scale(4); } 100% { transform: scale(1); } }

/* Logbook */
.log-header { text-align: center; margin-bottom: 20px; }
.log-header h2 { margin: 0; font-size: 2rem; color: var(--primary); }
.log-grid { display: flex; flex-direction: column; gap: 25px; }
.log-section label { display: block; margin-bottom: 10px; font-weight: bold; color: #bbb; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px; }
#journal-input { width: 100%; background: #252525; border: 1px solid #444; color: white; padding: 15px; border-radius: 8px; font-family: inherit; box-sizing: border-box; resize: none; }
.status-cards { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
}

.status-card { 
    background: #252525; 
    border: 2px solid #333; 
    border-radius: 12px; 
    padding: 20px 10px; /* More vertical padding */
    text-align: center; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    opacity: 0.7; 
}

.status-card .icon { 
    font-size: 2.2rem; 
    margin-bottom: 8px; 
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.status-card .text { 
    font-weight: 800; /* Extra Bold */
    font-size: 1.4rem; /* Larger text */
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
    color: #fff;
}

.status-card .sub { 
    font-size: 0.75rem; 
    color: #999; 
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Selected States */
.status-card.selected { 
    opacity: 1; 
    transform: translateY(-2px); 
    border-width: 2px;
}

.status-card.success.selected { 
    border-color: var(--primary); 
    background: rgba(76, 175, 80, 0.15); 
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.2);
}

.status-card.success.selected .text { color: var(--primary); }

.status-card.fail.selected { 
    border-color: var(--danger); 
    background: rgba(244, 67, 54, 0.15); 
    box-shadow: 0 4px 15px rgba(244, 67, 54, 0.2);
}

.status-card.fail.selected .text { color: var(--danger); }
.alert-box { background: rgba(244, 67, 54, 0.2); border-left: 4px solid var(--danger); color: #ffcccb; padding: 10px; margin-top: 15px; border-radius: 4px; font-size: 0.9rem; }
.slider-wrapper {
    display: flex;
    align-items: center;
    gap: 20px; /* Increased gap */
    background: #252525;
    padding: 25px 20px; /* More padding */
    border-radius: 16px;
}
#ehs-display-emoji {
    font-size: 5rem; /* Much bigger emoji */
    min-width: 80px;
    text-align: center;
    line-height: 1;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
}
.styled-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 16px;
    background: #444;
    border-radius: 10px;
    outline: none;
    transition: background 0.3s;
}
.styled-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;  /* Big touch target */
    height: 20px; /* Big touch target */
    background: var(--accent);
    border: 3px solid #fff; /* White border for contrast */
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    margin-top: -2px; /* Center alignment adjustment if needed */
}
.styled-slider::-webkit-slider-thumb:active {
    transform: scale(1.1);
    background: var(--primary); /* Changes color when dragging */
}
/* --- BIGGER SLIDER STYLES --- */

/* The Track */
#ehs-input {
    flex-grow: 1;
    -webkit-appearance: none; /* Override default look */
    appearance: none;
    height: 20px; /* Much thicker track */
    border-radius: 10px;
    background: #444;
    outline: none;
    transition: background 0.2s;
}

/* The Handle (Thumb) - Webkit (Chrome/Safari/Edge) */
#ehs-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;  /* Big, touch-friendly handle */
    height: 40px; 
    background: var(--accent);
    border: 4px solid #fff; /* White border to make it pop */
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}

/* The Handle (Thumb) - Firefox */
#ehs-input::-moz-range-thumb {
    width: 40px; 
    height: 40px; 
    background: var(--accent);
    border: 4px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    border: none; /* Remove default border */
}.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding: 0 10px;
}
#ehs-val-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
}
#ehs-text-desc {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent);
}
.chips-container { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { flex: 1; background: #2a2a2a; border: 1px solid #444; color: #bbb; padding: 12px; border-radius: 20px; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; white-space: nowrap; }
.chip.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Improved Graph Styles */
.chart-container { background: #1e1e1e; border: 1px solid #333; border-radius: 12px; padding: 15px; margin-bottom: 20px; }
.chart-label { display: block; font-size: 0.75rem; color: #888; margin-bottom: 10px; text-transform: uppercase; font-weight: bold; }
.graph-wrapper { width: 100%; height: 100px; position: relative; border-bottom: 1px solid #444; border-left: 1px solid #444; }
#stats-graph { width: 100%; height: 100%; }
.graph-line { fill: none; stroke: var(--primary); stroke-width: 3px; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 4px 6px rgba(76, 175, 80, 0.3)); }

/* History & Achievements */
.screen-header { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #333; }
.back-btn { background: none; border: none; color: #888; font-size: 1rem; cursor: pointer; }
.history-list { display: flex; flex-direction: column; gap: 15px; }
.history-card { background: #1e1e1e; border: 1px solid #333; padding: 15px; border-radius: 10px; }
.history-top { display: flex; justify-content: space-between; margin-bottom: 10px; font-size: 0.9rem; color: #888; }
.history-body { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.h-metric { text-align: center; }
.h-metric span { display: block; font-weight: bold; font-size: 1.1rem; color: #fff; }
.h-metric label { font-size: 0.65rem; color: #666; text-transform: uppercase; }
.history-note { background: #252525; padding: 10px; border-radius: 5px; font-size: 0.85rem; color: #ccc; font-style: italic; border-left: 2px solid var(--accent); }
.split-peaks { font-size: 0.7rem; color: #555; margin-top: 5px; }
.achievements-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.ach-card { background: #1e1e1e; border: 1px solid #333; padding: 15px; border-radius: 12px; text-align: center; opacity: 0.5; filter: grayscale(1); transition: all 0.3s; }
.ach-card.unlocked { opacity: 1; filter: grayscale(0); border-color: var(--gold); box-shadow: 0 0 10px rgba(255, 215, 0, 0.1); }
.ach-icon { font-size: 2.5rem; margin-bottom: 10px; }
.ach-title { font-weight: bold; font-size: 1rem; color: var(--gold); margin-bottom: 5px; }
.ach-desc { font-size: 0.75rem; color: #888; }

/* Buttons & Utils */
.primary-btn { background: var(--primary); color: white; border: none; padding: 15px; width: 100%; font-size: 1.2rem; border-radius: 8px; cursor: pointer; }
.secondary-btn { background: transparent; border: 1px solid #555; color: #ccc; padding: 12px; border-radius: 8px; cursor: pointer; flex: 1; }
.danger-btn-filled { background: var(--danger); color: white; border: none; padding: 12px; border-radius: 8px; cursor: pointer; flex: 1; }
.pulse-btn { animation: pulseBtn 2s infinite; }
.hidden { display: none !important; }
.link-btn { background: none; border: none; color: #666; cursor: pointer; text-decoration: underline; }

/* Skip Button & Text Buttons */
.skip-container { text-align: center; margin-bottom: 20px; }
.text-btn-sub { background: none; border: none; color: #888; font-size: 0.8rem; cursor: pointer; text-decoration: underline; }
.modal-actions-col { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; width: 100%; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.85); display: flex; justify-content: center; align-items: center; z-index: 100; backdrop-filter: blur(5px); }
.modal-card { background: #1e1e1e; border: 2px solid var(--gold); width: 85%; max-width: 400px; padding: 30px; border-radius: 20px; text-align: center; position: relative; box-shadow: 0 0 30px rgba(255, 215, 0, 0.2); animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.mini-modal { border-color: #444; box-shadow: 0 10px 25px rgba(0,0,0,0.5); padding: 25px; }
.modal-icon { font-size: 3rem; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 15px; margin-top: 20px; }
.intel-section { text-align: left; margin-bottom: 25px; }
.intel-section label { color: var(--text-dim); font-size: 0.7rem; font-weight: bold; letter-spacing: 1px; display: block; margin-bottom: 8px; }
.goals-list { padding-left: 20px; margin: 0; color: #ddd; font-size: 0.95rem; line-height: 1.5; }
.technique-box { background: #252525; padding: 15px; border-radius: 8px; border-left: 3px solid var(--primary); color: #fff; font-size: 1rem; line-height: 1.4; }

@keyframes pulseBtn { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7); } 70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(76, 175, 80, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); } }
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* --- CELEBRATION MODAL FIXES --- */

/* Center the content area */
.levelup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

/* Make the lock icon big and bouncy */
.lock-icon-large {
    font-size: 3.5rem;
    margin-bottom: 15px;
    animation: bounce 2s infinite;
}

/* The "UNLOCKED" text */
.unlock-label {
    display: block; /* Forces it to its own line */
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 2px;
    font-weight: bold;
    margin-bottom: 5px; /* Space between "UNLOCKED" and "PHASE 2" */
}

/* The "PHASE 2" text */
.phase-name-large {
    font-size: 1.8rem;
    color: var(--primary);
    margin: 0 0 15px 0; /* Space below the title */
    text-transform: uppercase;
}

/* Description Text */
.phase-preview-text {
    color: #ccc;
    font-style: italic;
    font-size: 1rem;
    margin: 0;
    max-width: 80%; /* Prevents text from hitting the edges */
    line-height: 1.4;
}

/* Optional: Simple Bounce Animation for the lock */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* --- FOOTER & SUPPORT --- */

.app-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #333;
    text-align: center;
    padding-bottom: 30px; /* Extra padding for bottom of mobile screen */
}

.footer-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: bold;
    margin-bottom: 15px;
}

.footer-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap; /* Wraps on very small screens */
}

.footer-btn {
    text-decoration: none;
    background: #252525;
    border: 1px solid #444;
    padding: 10px 20px;
    border-radius: 50px; /* Pill shape */
    color: #ccc;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.footer-btn span {
    font-size: 1.1rem;
}

/* Hover/Active States */
.footer-btn:active {
    transform: scale(0.95);
}

.footer-btn.coffee:hover {
    border-color: #FFDD00; /* Coffee yellow/gold */
    color: #fff;
    background: rgba(255, 221, 0, 0.1);
}

.footer-btn.gear:hover {
    border-color: var(--accent); /* Blue */
    color: #fff;
    background: rgba(33, 150, 243, 0.1);
}

.version-text {
    margin-top: 20px;
    font-size: 0.7rem;
    color: #444;
}