/* AI Whack-A-Mole Styles */

#game-container {
    position: relative;
    width: 100%;
    height: 600px;
    background: #050508;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), inset 0 0 100px rgba(139, 92, 246, 0.15);
    border: 2px solid rgba(139, 92, 246, 0.3);
}

#TEMPLATE-4weird-gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    /* Sledgehammer cursor (head = hotspot). Swung pose while pressed. */
    cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><line x1='20' y1='58' x2='42' y2='32' stroke='%23a06a35' stroke-width='9' stroke-linecap='round'/><line x1='20' y1='58' x2='42' y2='32' stroke='%235d3a17' stroke-width='9' stroke-linecap='round' stroke-dasharray='3 5' opacity='0.6'/><g transform='rotate(-35 45 25)'><rect x='31' y='17' width='28' height='16' rx='3' fill='%2394a3b8' stroke='%23334155' stroke-width='2'/><rect x='31' y='17' width='28' height='6' rx='3' fill='%23e2e8f0'/></g></svg>") 45 22, pointer;
}
#TEMPLATE-4weird-gameCanvas:active {
    cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='64'><g transform='rotate(28 20 58)'><line x1='20' y1='58' x2='42' y2='32' stroke='%23a06a35' stroke-width='9' stroke-linecap='round'/><line x1='20' y1='58' x2='42' y2='32' stroke='%235d3a17' stroke-width='9' stroke-linecap='round' stroke-dasharray='3 5' opacity='0.6'/><g transform='rotate(-35 45 25)'><rect x='31' y='17' width='28' height='16' rx='3' fill='%2394a3b8' stroke='%23334155' stroke-width='2'/><rect x='31' y='17' width='28' height='6' rx='3' fill='%23e2e8f0'/></g></g></svg>") 45 22, pointer;
}

/* Bubbles overlay container */
#bubbles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas for raycasting */
    overflow: hidden;
    z-index: 10;
}

/* Chat bubble style - must NOT be styled differently for good/bad */
.mole-bubble {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(18, 18, 26, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(139, 92, 246, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 0 15px rgba(139, 92, 246, 0.2);
    border-radius: 12px;
    padding: 8px 12px;
    color: #e5e7eb;
    font-family: 'Share Tech Mono', monospace;
    font-size: 11px;
    line-height: 1.4;
    max-width: 180px;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.15s ease-out, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: bubble-bounce 0.4s ease-out forwards;
    word-wrap: break-word;
}

.mole-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: rgba(18, 18, 26, 0.85) transparent;
    display: block;
    width: 0;
}

/* Tail hides when the bubble is clamped inside the frame (no mole to point at) */
.mole-bubble.clamped::after {
    display: none;
}

@keyframes bubble-bounce {
    0% {
        opacity: 0;
        transform: translate(-50%, -90%) scale(0.7);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -105%) scale(1);
    }
}

/* HUD Panel */
#game-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 15;
    font-family: 'Orbitron', sans-serif;
    color: #fff;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.hud-item {
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(139, 92, 246, 0.4);
    padding: 10px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-label {
    font-size: 10px;
    color: #a78bfa;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.hud-value {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    color: #22d3ee;
    text-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
}

/* Health Bar specific */
.health-container {
    flex: 1;
    max-width: 300px;
    margin: 0 20px;
}

.health-bar-bg {
    flex: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#hud-health-bar {
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #10b981);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    transition: width 0.3s ease-out;
}

/* Glow effects and screen designs */
.glow-text {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px rgba(139, 92, 246, 0.5));
    font-weight: 800;
}

.header-fail {
    background: linear-gradient(135deg, #ef4444, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.5));
}

.hidden {
    display: none !important;
}

/* Whack particle effect */
.whack-score-popup {
    position: absolute;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    font-size: 20px;
    pointer-events: none;
    z-index: 20;
    animation: popup-float 0.8s ease-out forwards;
    text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.score-positive {
    color: #10b981;
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.score-negative {
    color: #ef4444;
    text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

/* Combo callouts: bigger, gold, extra punch */
.whack-score-popup.score-combo {
    color: #fbbf24;
    font-size: 26px;
    text-shadow: 0 0 12px rgba(251, 191, 36, 0.8), 0 2px 5px rgba(0,0,0,0.5);
}

/* Damage callouts when a bad AI escapes */
.whack-score-popup.score-damage {
    color: #f87171;
    font-size: 16px;
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.7);
}

/* Screen shake on impacts (re-triggered from JS by re-adding the class) */
#game-container.shake {
    animation: container-shake 0.22s linear;
}
#game-container.shake-big {
    animation: container-shake 0.38s linear;
}
@keyframes container-shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 3px); }
    40% { transform: translate(5px, -4px); }
    60% { transform: translate(-4px, -3px); }
    80% { transform: translate(3px, 2px); }
}

/* Expanding shockwave ring at the whack point */
.whack-shockwave {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid rgba(16, 185, 129, 0.9);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.7), inset 0 0 12px rgba(16, 185, 129, 0.5);
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 20;
    animation: shockwave-expand 0.45s ease-out forwards;
}
.whack-shockwave.bad-hit {
    border-color: rgba(251, 191, 36, 0.95);
    box-shadow: 0 0 22px rgba(251, 191, 36, 0.8), inset 0 0 12px rgba(251, 191, 36, 0.5);
}
@keyframes shockwave-expand {
    0% { opacity: 1; width: 24px; height: 24px; }
    100% { opacity: 0; width: 130px; height: 130px; }
}

/* Red flash vignette when integrity takes a hit */
#damage-flash {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 18;
    opacity: 0;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(239, 68, 68, 0.55) 100%);
}
#damage-flash.flash {
    animation: damage-flash-pulse 0.5s ease-out;
}
@keyframes damage-flash-pulse {
    0% { opacity: 0; }
    25% { opacity: 1; }
    100% { opacity: 0; }
}

/* Low-integrity heartbeat: pulsing red vignette + throbbing health bar */
#game-container.low-hp::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 17;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(239, 68, 68, 0.4) 100%);
    animation: low-hp-pulse 1s ease-in-out infinite;
}
@keyframes low-hp-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}
#game-container.low-hp #hud-health-bar {
    animation: low-hp-bar 0.8s ease-in-out infinite;
}
@keyframes low-hp-bar {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.8); }
}

/* 3-2-1-GO countdown overlay */
#countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: none;
    font-family: 'Orbitron', sans-serif;
    font-size: 110px;
    font-weight: 800;
    color: #22d3ee;
    text-shadow: 0 0 30px rgba(34, 211, 238, 0.8), 0 4px 10px rgba(0,0,0,0.6);
}
#countdown.go {
    color: #10b981;
    text-shadow: 0 0 34px rgba(16, 185, 129, 0.9), 0 4px 10px rgba(0,0,0,0.6);
}
#countdown.zoom {
    animation: countdown-zoom 0.55s ease-out;
}
@keyframes countdown-zoom {
    0% { opacity: 0; transform: scale(2.2); }
    30% { opacity: 1; transform: scale(1); }
    100% { opacity: 1; transform: scale(0.95); }
}

@keyframes popup-float {
    0% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -120%) scale(1.4);
    }
}

/* FW-ARCADE-A fullscreen: ⛶ overlay top-right, HUD stays visible. */
.fw-fs-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 50;
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
    line-height: 1;
    border-radius: 10px;
    border: 1px solid rgba(139, 92, 246, 0.5);
    background: rgba(10, 10, 18, 0.8);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(6px);
}
.fw-fs-btn:hover { border-color: rgba(34, 211, 238, 0.7); }
.fw-fs-btn:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
#game-container:fullscreen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
}
#game-container:fullscreen #TEMPLATE-4weird-gameCanvas {
    width: 100%;
    height: 100%;
}
#game-container:fullscreen #game-hud {
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
}

/* Adaptive mobile layout adjustments */
@media (max-width: 768px) {
    #game-container {
        height: 480px;
    }
    #game-hud {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    .hud-item {
        padding: 6px 10px;
    }
    .hud-value {
        font-size: 14px;
    }
    .health-container {
        margin: 0 5px;
    }
    .mole-bubble {
        max-width: 130px;
        font-size: 10px;
    }
}
