/* ==========================================================================
   Chrono Echo: Temporal Loop & Stasis (2026-08-11)
   Design System & Styling Rules
   ========================================================================== */

:root {
    --bg-dark: #070a14;
    --bg-card: rgba(15, 23, 42, 0.75);
    --border-glass: rgba(0, 240, 255, 0.25);
    --border-glass-hover: rgba(0, 240, 255, 0.6);
    
    --cyan-glow: #00f0ff;
    --amber-glow: #ffb700;
    --violet-glow: #e024ff;
    --emerald-glow: #10b981;
    --red-alert: #ff3366;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --font-heading: 'Orbitron', 'Outfit', 'Noto Sans SC', sans-serif;
    --font-body: 'Outfit', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    overflow-y: auto;
}

/* Background Ambient Lighting */
.chrono-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: 
        radial-gradient(circle at 20% 20%, rgba(0, 240, 255, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(224, 36, 255, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(255, 183, 0, 0.08) 0%, transparent 60%),
        #070a14;
    z-index: -3;
}

.time-warp-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: -2;
    transition: opacity 0.5s ease;
    opacity: 0;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.25) 0%, rgba(224, 36, 255, 0.1) 70%, transparent 100%);
}

.time-warp-overlay.active {
    opacity: 1;
    animation: timeWarpPulse 1.8s infinite alternate ease-in-out;
}

@keyframes timeWarpPulse {
    0% { transform: scale(1); filter: brightness(1); }
    100% { transform: scale(1.05); filter: brightness(1.3); }
}

.glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: -2;
}
.orb-cyan { top: -100px; left: -100px; width: 350px; height: 350px; background: rgba(0, 240, 255, 0.2); }
.orb-amber { bottom: -100px; right: -100px; width: 350px; height: 350px; background: rgba(255, 183, 0, 0.15); }
.orb-violet { top: 40%; left: 70%; width: 300px; height: 300px; background: rgba(224, 36, 255, 0.15); }

/* Layout App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* Header Navbar */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    margin-bottom: 16px;
}

.back-home-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.25s ease;
}

.back-home-btn:hover {
    color: var(--cyan-glow);
    border-color: var(--cyan-glow);
    background: rgba(0, 240, 255, 0.1);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.3);
}

.title-wrapper {
    text-align: center;
}

.main-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.sub-highlight {
    color: var(--cyan-glow);
    font-size: 1rem;
    display: inline-block;
    margin-left: 6px;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1.5px;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
}

.icon-btn:hover {
    border-color: var(--cyan-glow);
    background: rgba(0, 240, 255, 0.15);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.4);
}

/* Dashboard Cards */
.dashboard {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
}

.card-cyan .stat-value { color: var(--cyan-glow); text-shadow: 0 0 10px rgba(0, 240, 255, 0.5); }
.card-amber .stat-value { color: var(--amber-glow); text-shadow: 0 0 10px rgba(255, 183, 0, 0.5); }
.card-violet .stat-value { color: var(--violet-glow); text-shadow: 0 0 10px rgba(224, 36, 255, 0.5); }

/* Energy Bar */
.energy-card {
    grid-column: span 1;
}

.energy-bar-track {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(0, 240, 255, 0.3);
    margin-top: 4px;
    position: relative;
}

.energy-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--cyan-glow), var(--violet-glow));
    box-shadow: 0 0 10px var(--cyan-glow);
    border-radius: 6px;
    transition: width 0.25s linear;
}

.energy-bar-fill.full {
    background: linear-gradient(90deg, var(--amber-glow), var(--violet-glow));
    box-shadow: 0 0 14px var(--amber-glow);
    animation: barGlow 1s infinite alternate ease-in-out;
}

@keyframes barGlow {
    0% { filter: brightness(1); }
    100% { filter: brightness(1.4); }
}

/* Game Container & Canvas */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 580px;
    aspect-ratio: 1 / 1;
    background: rgba(11, 15, 25, 0.95);
    border: 2px solid var(--border-glass);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 240, 255, 0.15);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Stasis Overlay */
.stasis-overlay {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.stasis-overlay.active {
    opacity: 1;
}

.stasis-badge {
    background: rgba(224, 36, 255, 0.85);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 15px var(--violet-glow);
    animation: badgePulse 1.2s infinite alternate;
}

@keyframes badgePulse {
    0% { transform: scale(0.98); }
    100% { transform: scale(1.04); }
}

/* Overlay Screens (Start & GameOver) */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 10, 20, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
    text-align: center;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 240, 255, 0.2);
}

.chrono-icon-wrapper {
    margin-bottom: 12px;
    animation: chronoRotate 12s infinite linear;
}

@keyframes chronoRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.overlay-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--cyan-glow);
    text-shadow: 0 0 15px rgba(0, 240, 255, 0.6);
    margin-bottom: 4px;
}

.overlay-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.rules-summary {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.4;
}

.rule-icon {
    font-size: 1.1rem;
}

/* GameOver Specific */
.gameover-badge {
    display: inline-block;
    background: rgba(255, 51, 102, 0.2);
    color: var(--red-alert);
    border: 1px solid var(--red-alert);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
    margin-bottom: 10px;
}

.gameover-title {
    color: var(--red-alert);
    text-shadow: 0 0 15px rgba(255, 51, 102, 0.6);
}

.gameover-reason {
    font-size: 0.9rem;
    color: #e2e8f0;
    margin-bottom: 16px;
}

.final-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 20px;
}

.final-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.final-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.final-val {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    margin-top: 2px;
}

.neon-cyan { color: var(--cyan-glow); }
.neon-amber { color: var(--amber-glow); }
.neon-violet { color: var(--violet-glow); }

/* Buttons */
.btn {
    border: none;
    border-radius: 12px;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cyan-glow), #0077ff);
    color: #070a14;
    box-shadow: 0 4px 15px rgba(0, 240, 255, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.7);
    filter: brightness(1.1);
}

.btn-glow {
    animation: btnPulse 2s infinite alternate;
}

@keyframes btnPulse {
    0% { box-shadow: 0 0 10px rgba(0, 240, 255, 0.4); }
    100% { box-shadow: 0 0 25px rgba(0, 240, 255, 0.9); }
}

.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 580px;
    margin-top: 12px;
    gap: 12px;
}

.btn-skill {
    flex: 1;
    background: rgba(224, 36, 255, 0.2);
    border: 1px solid var(--violet-glow);
    color: #fff;
    padding: 10px 16px;
    font-size: 0.9rem;
    box-shadow: 0 0 10px rgba(224, 36, 255, 0.3);
}

.btn-skill:not(:disabled):hover {
    background: rgba(224, 36, 255, 0.4);
    box-shadow: 0 0 20px var(--violet-glow);
}

.btn-skill:disabled {
    opacity: 0.4;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: none;
    cursor: not-allowed;
}

.canvas-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px 14px;
    white-space: nowrap;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    margin-top: 16px;
    width: 100%;
    max-width: 320px;
    justify-content: center;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 60px);
    gap: 6px;
}

.dpad-btn {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-glass);
    border-radius: 14px;
    color: var(--cyan-glow);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: background 0.15s ease, transform 0.1s ease;
}

.dpad-btn:active {
    background: rgba(0, 240, 255, 0.3);
    transform: scale(0.92);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; color: var(--violet-glow); font-size: 1rem; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Modal Backdrop & Help */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(5, 8, 16, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--cyan-glow);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
}

.close-btn:hover { color: #fff; }

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.help-section h4 {
    color: var(--amber-glow);
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.help-section ul {
    list-style: none;
    padding-left: 4px;
}

.help-section li {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.dot-amber { background: var(--amber-glow); box-shadow: 0 0 6px var(--amber-glow); }
.dot-cyan { background: var(--cyan-glow); box-shadow: 0 0 6px var(--cyan-glow); }
.dot-violet { background: var(--violet-glow); box-shadow: 0 0 6px var(--violet-glow); }

.modal-footer {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

/* Footer */
.footer {
    text-align: center;
    padding: 16px 0;
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Mobile Responsiveness Media Queries */
@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .mobile-controls {
        display: flex;
    }
    
    .controls-bar {
        flex-direction: column;
        gap: 8px;
    }
    
    .canvas-status {
        width: 100%;
        text-align: center;
    }
    
    .main-title {
        font-size: 1.2rem;
    }
    
    .sub-highlight {
        font-size: 0.85rem;
    }
}
