/* /style.css */
:root {
    --bg-color: #1a1a1a;
    --ui-bg: rgba(0, 0, 0, 0.85);
    --text-color: #ffffff;
    --accent-red: #ff3333;
    --accent-orange: #ff9900;
    --accent-blue: #00aaff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-color);
}

/* Orientation Warning */
#orientation-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    text-align: center;
    padding: 20px;
    color: #ff3333;
}

#orientation-warning .icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: rotate-phone 2s infinite ease-in-out;
}

@keyframes rotate-phone {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}

@media screen and (orientation: portrait) {
    #orientation-warning {
        display: flex;
    }
    #game-container {
        display: none;
    }
}

/* Game Container */
#game-container {
    position: relative;
    width: 100vw;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#building-view {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#building-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Firetruck */
#firetruck-container {
    position: absolute;
    bottom: 5%;
    left: 50%;
    width: 28%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 55;
}

#firetruck-img {
    width: 100%;
    display: block;
}

#firetruck-nozzle {
    position: absolute;
    /* Initial position based on NOZZLE config in JS */
    width: 20px;
    height: 5px;
    background: #444;
    border-radius: 2px;
    transform-origin: left center;
    z-index: 56;
    display: none; /* We will show it and position via JS */
}

#fire-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#fx-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 100;
}

.hud-group h1 {
    font-size: 1.2rem;
    letter-spacing: 2px;
    color: var(--accent-red);
    text-transform: uppercase;
}

.hud-group p {
    font-size: 1rem;
    font-weight: bold;
}

#timer {
    font-size: 2.5rem;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    line-height: 1;
}

#timer-bar-container {
    width: 150px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    margin-top: 5px;
    float: right;
    overflow: hidden;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background: var(--accent-red);
    transition: width 0.1s linear;
}

#timer.warning {
    color: var(--accent-red);
    animation: pulse-emergency 0.5s infinite alternate;
}

@keyframes pulse-emergency {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.8; transform: scale(1.05); }
}

/* Fire Element */
.fire {
    position: absolute;
    width: 60px;
    height: 60px;
    pointer-events: auto;
    cursor: pointer;
    z-index: 50;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.fire-visual {
    width: 90%;
    height: 90%;
    background: radial-gradient(ellipse at center, #fff 0%, #ff0 20%, #f90 50%, #f30 80%, transparent 100%);
    border-radius: 50% 50% 20% 20%;
    filter: blur(2px) drop-shadow(0 0 15px rgba(255, 100, 0, 0.8));
    animation: flicker 0.1s infinite alternate;
    position: relative;
}

.fire-visual::before {
    content: '';
    position: absolute;
    top: -20%; left: 10%; right: 10%; bottom: 0;
    background: inherit;
    filter: blur(4px);
    opacity: 0.6;
    animation: flicker 0.15s infinite alternate-reverse;
}

@keyframes flicker {
    0% { transform: scale(1) skewX(-2deg); opacity: 0.9; }
    100% { transform: scale(1.1) skewX(2deg); opacity: 1; }
}

/* Water Stream (handled by Canvas) */
.water-impact-flash {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #fff 0%, rgba(255,255,255,0) 70%);
    pointer-events: none;
    z-index: 70;
    transform: translate(-50%, -50%);
    animation: flash-out 0.3s ease-out forwards;
}

@keyframes flash-out {
    from { opacity: 0.8; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* Smoke particles handled by Canvas */

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
    text-align: center;
    color: #fff;
    transition: background 0.5s;
}

#game-over-screen {
    background: radial-gradient(circle, rgba(150, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.9) 100%);
}

.hidden { display: none !important; }

button {
    background: transparent;
    color: #fff;
    border: 2px solid #fff;
    padding: 12px 40px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 30px;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.3s;
}

button:hover, button:active {
    background: #fff;
    color: #000;
}

h2 {
    font-size: 3.5rem;
    margin-bottom: 5px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.stats {
    font-size: 1.1rem;
    margin: 15px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

/* Celebration Characters */
.celebration-chars {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 70%;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 20px;
    z-index: -1; /* Behind the text */
}

.char-wrapper {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    width: 35%;
}

.char-arkadii, .char-boria {
    height: 80%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(0, 170, 255, 0.4));
}

.bubble {
    background: #fff;
    color: #000;
    padding: 8px 12px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 10px;
    position: relative;
    opacity: 0;
    white-space: nowrap;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #fff transparent;
}

.bubble-left::after { left: 20%; }
.bubble-right::after { right: 20%; }

#win-screen:not(.hidden) .bubble {
    animation: fade-in-bubble 0.5s forwards 1.2s;
}

@keyframes fade-in-bubble {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#win-screen:not(.hidden) .char-arkadii {
    animation: bounce-in-left 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

#win-screen:not(.hidden) .char-boria {
    animation: bounce-in-right 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

@keyframes bounce-in-left {
    0% { transform: translateX(-100%) rotate(-10deg); opacity: 0; }
    100% { transform: translateX(0) rotate(0); opacity: 1; }
}

@keyframes bounce-in-right {
    0% { transform: translateX(100%) rotate(10deg); opacity: 0; }
    100% { transform: translateX(0) rotate(0); opacity: 1; }
}