/* Zero Protocol Reloaded Styles */

/* Base Atmosphere */
body.zero-mode {
    --z-pri: #30D5C8;
    --z-warn: #ff4d4f;
    --z-dark: #000000;
    --z-bg: radial-gradient(circle at center, #1f1f3a, #000);
    
    background: var(--z-bg) !important;
    font-family: 'Segoe UI', monospace;
}

/* Immunity Shield Effect */
body.immune-active .game-container {
    box-shadow: inset 0 0 50px #52c41a;
    transition: box-shadow 0.5s;
}
body.immune-active .zero-top-bar {
    background: linear-gradient(to bottom, rgba(82, 196, 26, 0.3), transparent);
}

/* Hide standard time bar in Zero Mode */
body.zero-mode #time-bar {
    display: none !important;
}
body.zero-mode #time-text {
    display: none !important;
}

/* Zero HUD V2 */
.zero-hud-v2 {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none; /* Let clicks pass through to board */
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    width: 100%; /* Ensure it fits container */
    height: 100%;
}

/* Top Bar: Stability & Rupture */
.zero-top-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    pointer-events: auto;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
    padding: 20px;
}

.stability-container {
    flex: 1;
    max-width: 400px;
    margin-right: 20px;
}

.stability-container .label {
    color: #fff;
    font-size: 12px;
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-shadow: 0 0 5px var(--z-pri);
}

.stability-container .bar-bg {
    height: 12px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    overflow: hidden;
}

.stability-container .bar-fill {
    height: 100%;
    width: 100%;
    background: var(--z-pri);
    box-shadow: 0 0 10px var(--z-pri);
    transition: width 0.3s, background-color 0.3s;
}

.rupture-badge {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    border: 2px solid #fff;
    padding: 5px 15px;
    border-radius: 4px;
    background: rgba(0,0,0,0.5);
    text-shadow: 0 0 10px #fff;
}

/* Bottom Bar: XP & Skills */
.zero-bottom-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    padding: 20px;
}

.xp-container {
    width: 60%;
    height: 8px;
    background: #333;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1890ff, #722ed1);
    transition: width 0.2s;
}

.xp-markers .marker {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: #fff;
    opacity: 0.5;
}

.skill-dock {
    display: flex;
    gap: 15px;
}

.z-btn {
    background: rgba(0,0,0,0.6);
    border: 1px solid var(--z-pri);
    color: var(--z-pri);
    padding: 8px 16px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    transition: all 0.2s;
    border-radius: 4px;
}

.z-btn:hover:not(:disabled) {
    background: var(--z-pri);
    color: #000;
    box-shadow: 0 0 15px var(--z-pri);
}

.z-btn.danger {
    border-color: var(--z-warn);
    color: var(--z-warn);
}
.z-btn.danger:hover:not(:disabled) {
    background: var(--z-warn);
    color: #fff;
    box-shadow: 0 0 15px var(--z-warn);
}

.fragment-counter {
    color: #ffd700;
    font-weight: bold;
    font-size: 18px;
    text-shadow: 0 0 5px #ffd700;
}

/* Board Wrapper Centering */
.board-wrapper {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex: 1; /* Use flex grow instead of calc height */
    width: 100%;
    margin-top: 60px; /* Reduced top margin */
    position: relative;
    z-index: 10;
    overflow: visible !important; /* Allow explosions to overflow */
}

/* Ensure board stays centered */
#game-board {
    position: relative;
    margin: 0 auto;
    transform-origin: center center;
}

/* Water Effect Cursor */
body.water-active .game-container {
    cursor: crosshair; /* Indicate targeting */
    box-shadow: inset 0 0 30px #1890ff;
}
body.water-active .tile:hover {
    box-shadow: 0 0 15px #1890ff;
    border-color: #1890ff;
}
/* Fragment Visuals */
.tile.fragment-container {
    box-shadow: 0 0 20px #00ffff, inset 0 0 10px #00ffff !important;
    border: 2px solid #fff !important;
    animation: pulse-fragment 1s infinite alternate;
    z-index: 10;
}
.fragment-icon {
    position: absolute;
    top: -15px; left: 50%; transform: translateX(-50%);
    font-size: 24px;
    filter: drop-shadow(0 0 5px #00ffff);
    animation: float-icon 1.5s infinite ease-in-out;
    pointer-events: none;
}
@keyframes pulse-fragment { 0% { border-color: #fff; } 100% { border-color: #00ffff; } }
@keyframes float-icon { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -10px); } }

/* Element Trait Indicators */
.tile.trait-fire::after { content: '🔥'; position: absolute; top: -5px; right: -5px; font-size: 12px; }
.tile.trait-water::after { content: '💧'; position: absolute; top: -5px; right: -5px; font-size: 12px; }
.tile.trait-wind::after { content: '🍃'; position: absolute; top: -5px; right: -5px; font-size: 12px; }
.tile.trait-earth::after { content: '🛡️'; position: absolute; top: -5px; right: -5px; font-size: 12px; }
.tile.trait-light::after { content: '✨'; position: absolute; top: -5px; right: -5px; font-size: 12px; }
.tile.trait-dark::after { content: '🌑'; position: absolute; top: -5px; right: -5px; font-size: 12px; }

/* Floating Energy Text */
.energy-float {
    position: absolute;
    color: #ffd700;
    font-weight: bold;
    font-size: 20px;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    z-index: 200;
    text-shadow: 0 0 5px #000;
}
@keyframes float-up {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

/* Event Notification Banner */
.zero-event-banner {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #ff4d4f;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    border: 2px solid #ff4d4f;
    box-shadow: 0 0 20px rgba(255, 77, 79, 0.5);
    z-index: 500;
    pointer-events: none;
    animation: banner-pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes banner-pop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Tutorial Overlay */
.zero-tutorial {
    position: absolute;
    top: 50px; left: 20px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    font-size: 12px;
    pointer-events: none;
    z-index: 200;
    max-width: 200px;
}
.zero-tutorial h4 { margin: 0 0 5px 0; color: var(--z-pri); }
.zero-tutorial ul { padding-left: 15px; margin: 0; }

/* Existing Styles... */
.tile.trait-fire { box-shadow: 0 0 8px #ff4d4f; border: 1px solid #ff4d4f; }
.tile.trait-water { box-shadow: 0 0 8px #1890ff; border: 1px solid #1890ff; }
.tile.trait-wind { box-shadow: 0 0 8px #52c41a; animation: spin-slow 3s infinite linear; }
.tile.trait-light { box-shadow: 0 0 15px #fff; background: rgba(255,255,255,0.2); }
.tile.trait-dark { filter: brightness(0.5); border: 1px dashed #666; }

.tile.infected {
    border: 2px solid #52c41a !important;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 5px, rgba(82, 196, 26, 0.3) 5px, rgba(82, 196, 26, 0.3) 10px);
}

.tile.darkened {
    background: #000 !important;
    color: transparent !important;
    border: 1px solid #333;
}

.tile.in-tide {
    background: rgba(24, 144, 255, 0.5) !important;
    pointer-events: none;
    transform: translateY(2px);
}

.tile.wormhole {
    border-radius: 50%;
    animation: pulse-spin 2s infinite linear;
}

/* Immunity Buff */
body.immune-active .game-container {
    box-shadow: inset 0 0 50px gold;
    border: 2px solid gold;
    transition: all 0.5s;
}

/* Zero Markers (Wormholes, Tides) */
.zero-marker {
    position: absolute;
    pointer-events: none;
    z-index: 5; /* Below tiles (z-index 10 usually) but above board bg */
    box-sizing: border-box;
}

.wormhole-marker {
    width: 48px; /* TILE_SIZE */
    height: 48px;
    border: 2px dashed #bd93f9;
    border-radius: 50%;
    animation: pulse-spin 3s infinite linear;
    background: rgba(189, 147, 249, 0.2);
    box-shadow: 0 0 10px #bd93f9;
}

.tide-row-marker {
    background: rgba(24, 144, 255, 0.3);
    border-top: 1px solid #1890ff;
    border-bottom: 1px solid #1890ff;
    animation: tide-surge 2s infinite alternate;
}
@keyframes tide-surge { from {opacity: 0.3;} to {opacity: 0.6;} }

/* Animations */
@keyframes spin-slow { from {transform: rotate(0deg);} to {transform: rotate(360deg);} }
@keyframes pulse-spin { 
    0% {transform: rotate(0deg) scale(1);} 
    50% {transform: rotate(180deg) scale(1.1);} 
    100% {transform: rotate(360deg) scale(1);} 
}

.shake-horizontal { animation: shake 0.3s; }
@keyframes shake { 0%, 100% {transform: translateX(0);} 25% {transform: translateX(-5px);} 75% {transform: translateX(5px);} }

.screen-shake { animation: big-shake 0.5s; }
@keyframes big-shake { 
    0% {transform: translate(0,0);} 
    20% {transform: translate(-10px, 5px);} 
    40% {transform: translate(10px, -5px);} 
    60% {transform: translate(-5px, 10px);} 
    80% {transform: translate(5px, -10px);} 
    100% {transform: translate(0,0);} 
}

body.zero-recoil .game-container {
    filter: contrast(1.2) hue-rotate(90deg);
    animation: recoil-jitter 0.1s infinite;
}
@keyframes recoil-jitter {
    0% {transform: translate(1px, 1px);}
    100% {transform: translate(-1px, -1px);}
}
