/* ==========================================================================
   WILD WEST ZAPPER 84 - STYLESHEET
   Retro Arcade Aesthetics + Modern Responsive Touch & Desktop Controls
   ========================================================================== */

:root {
    --sand-bg: #e6b87d;
    --sky-day: #5db9f8;
    --sky-sunset: #f87d42;
    --wood-dark: #4a2810;
    --wood-med: #7c4820;
    --wood-light: #b3733b;
    --saloon-red: #8e2b24;
    --gold: #f9ca24;
    --crt-green: #2ecc71;
    --font-arcade: 'Courier New', Courier, monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a0f07;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
    touch-action: manipulation;
}

/* Master Game Container */
#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #2c1a0e 0%, #0d0603 100%);
    overflow: hidden;
}

/* Screen aspect ratio box (Responsive scaling) */
#screen-canvas-box {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 100%;
    max-height: 680px;
    background: linear-gradient(to bottom, #4ea3e8 0%, #f7a868 60%, #c4823f 100%);
    overflow: hidden;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0,0,0,0.5);
    border-radius: 12px;
    cursor: crosshair;
}

/* Desktop Custom Reticle */
@media (hover: hover) and (pointer: fine) {
    #screen-canvas-box {
        cursor: none; /* Hide default cursor to use custom crosshair */
    }
}

#custom-crosshair {
    position: absolute;
    width: 44px;
    height: 44px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 100;
    display: none;
    transition: transform 0.04s ease-out;
}

#custom-crosshair svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 4px rgba(0,0,0,0.8));
}

/* ==========================================================================
   SCENERY: SKY, CLOUDS, MOUNTAINS & SALOON
   ========================================================================== */

.sky-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 38%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1;
}

.mountain-range {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 80px;
    opacity: 0.75;
}

.cloud {
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    animation: floatCloud linear infinite;
}

@keyframes floatCloud {
    from { transform: translateX(-150px); }
    to { transform: translateX(950px); }
}

/* The Wooden Saloon Building */
#saloon-building {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 760px;
    height: 74%;
    background: linear-gradient(to right, #5c3214, #73401c 20%, #854b22 80%, #5c3214 100%);
    border: 6px solid #361b07;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 15px 35px rgba(0,0,0,0.7), inset 0 0 30px rgba(0,0,0,0.4);
    z-index: 5;
    display: flex;
    flex-direction: column;
}

/* Plank Texture lines */
#saloon-building::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 28px,
        rgba(30, 15, 5, 0.45) 28px,
        rgba(30, 15, 5, 0.45) 30px
    );
    pointer-events: none;
    opacity: 0.9;
}

/* Saloon Signboard on Roof */
.saloon-roof-sign {
    position: absolute;
    top: -46px;
    left: 50%;
    transform: translateX(-50%);
    background: #87231b;
    border: 4px solid #f9ca24;
    color: #f9ca24;
    padding: 6px 20px;
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    box-shadow: 0 6px 15px rgba(0,0,0,0.6);
    border-radius: 6px;
    white-space: nowrap;
    text-shadow: 2px 2px 0 #3a0d09;
    z-index: 10;
}

.roof-balcony {
    width: 100%;
    height: 18px;
    background: #3d1f0b;
    border-bottom: 3px solid #1f0f04;
}

/* Windows Grid (2 Floors, 3 Columns) */
.saloon-floors {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    padding: 10px 15px 20px 15px;
    z-index: 6;
}

.window-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}

/* Individual Window Cell */
.window-slot {
    position: relative;
    width: 25%;
    max-width: 140px;
    aspect-ratio: 1 / 1.15;
    background: #180c05;
    border: 5px solid #3d1f0b;
    border-radius: 8px 8px 3px 3px;
    box-shadow: inset 0 0 25px #000, 0 6px 10px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* Window Sill */
.window-slot::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: -10%;
    width: 120%;
    height: 10px;
    background: #5a2e10;
    border: 2px solid #291204;
    border-radius: 4px;
    z-index: 15;
}

/* Wooden Shutters (Left & Right) */
.shutter {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    background: repeating-linear-gradient(
        to bottom,
        #6d3815,
        #6d3815 10px,
        #442009 10px,
        #442009 13px
    );
    border: 2px solid #281204;
    z-index: 12;
    transition: transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-origin: left center;
}

.shutter.shutter-right {
    right: 0;
    transform-origin: right center;
}

/* Open Shutters State */
.window-slot.open .shutter.shutter-left {
    transform: perspective(400px) rotateY(-110deg);
}

.window-slot.open .shutter.shutter-right {
    transform: perspective(400px) rotateY(110deg);
}

/* Target Area inside Window */
.target-stage {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 8;
    overflow: hidden;
}

/* Ground / Dusty Street */
#ground-street {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 46px;
    background: linear-gradient(to bottom, #9b6127, #6e4014);
    border-top: 5px solid #4a270a;
    z-index: 6;
}

/* Tumbleweed */
.tumbleweed {
    position: absolute;
    bottom: 12px;
    width: 32px;
    height: 32px;
    animation: rollWeed 8s linear infinite;
    pointer-events: none;
    opacity: 0.85;
}

@keyframes rollWeed {
    0% { left: -50px; transform: rotate(0deg); }
    100% { left: 950px; transform: rotate(1080deg); }
}

/* Flying Duck Container */
#duck-sky-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50%;
    pointer-events: auto;
    z-index: 20;
    overflow: hidden;
}

/* ==========================================================================
   CHARACTERS & ANIMATIONS
   ========================================================================== */

/* General Character Sprite inside window */
.character-actor {
    position: absolute;
    bottom: -150px;
    width: 90%;
    max-width: 115px;
    height: 92%;
    transition: bottom 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    cursor: pointer;
}

.character-actor.active {
    bottom: 0px;
}

/* Bandit Reaction Countdown Alert Bubble */
.speech-alert {
    position: absolute;
    top: -24px;
    background: #fff;
    color: #d63031;
    font-weight: 900;
    font-size: 0.85rem;
    padding: 2px 7px;
    border-radius: 12px;
    border: 2px solid #000;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    white-space: nowrap;
    animation: popBounce 0.2s ease-out;
}

@keyframes popBounce {
    0% { transform: scale(0); }
    80% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Comic Hit Animations */
.hat-fly-off {
    animation: hatFly 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes hatFly {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-40px) rotate(25deg) scale(1.1); }
    100% { transform: translateY(-70px) rotate(60deg) scale(0.9); opacity: 0; }
}

.mustache-spin {
    animation: spinMustache 0.4s linear infinite;
    transform-origin: 50px 60px;
}

@keyframes spinMustache {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(180deg) scale(1.2); }
    100% { transform: rotate(360deg); }
}

/* Flying Duck */
.flying-duck {
    position: absolute;
    width: 65px;
    height: 55px;
    cursor: pointer;
    z-index: 25;
    transition: transform 0.08s ease;
}

/* Flying Slipper (Terlik!) */
.flying-slipper {
    position: absolute;
    width: 110px;
    height: 110px;
    pointer-events: none;
    z-index: 80;
    animation: slipperThrow 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes slipperThrow {
    0% {
        transform: scale(0.2) rotate(0deg);
        opacity: 0.8;
    }
    70% {
        transform: scale(1.6) rotate(540deg);
        opacity: 1;
    }
    100% {
        transform: scale(2.4) rotate(720deg);
        opacity: 0;
    }
}

/* Bullet Holes */
.bullet-hole {
    position: absolute;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #0a0a0a 35%, #42210b 70%, transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 30;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px #000;
    animation: smokeFade 1.2s forwards;
}

@keyframes smokeFade {
    0% { filter: drop-shadow(0 -5px 6px rgba(255, 255, 255, 0.7)); }
    100% { filter: none; opacity: 0.8; }
}

/* Floating Points text (+100, KAFADAN! etc) */
.floating-text {
    position: absolute;
    color: #f9ca24;
    font-weight: 900;
    font-size: 1.2rem;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    pointer-events: none;
    z-index: 90;
    transform: translate(-50%, -50%);
    animation: floatUp 0.8s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translate(-50%, -20%) scale(0.6); opacity: 0; }
    30% { transform: translate(-50%, -60%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* Screen Shake effect */
.screen-shake {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-4px, 0, 0); }
    20%, 80% { transform: translate3d(6px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
    40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* CRT Flash Effect (Retro 1984 Zapper) */
#crt-flash-overlay {
    position: absolute;
    inset: 0;
    background: #000;
    z-index: 120;
    pointer-events: none;
    opacity: 0;
}

#crt-flash-overlay.active {
    opacity: 1;
}

/* CRT Scanlines Overlay */
.crt-scanlines {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0px,
        rgba(0, 0, 0, 0) 2px,
        rgba(0, 0, 0, 0.25) 2px,
        rgba(0, 0, 0, 0.25) 4px
    );
    pointer-events: none;
    z-index: 70;
    opacity: 0.6;
}

/* ==========================================================================
   HEADS-UP DISPLAY (HUD)
   ========================================================================== */

#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 60;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0) 100%);
    font-family: 'Courier New', Courier, monospace;
}

.hud-panel {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hud-item {
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.65rem;
    color: #e0a96d;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hud-val {
    font-size: 1.25rem;
    color: #fff;
    font-weight: 900;
    text-shadow: 1px 1px 2px #000;
}

/* Sheriff Badges (Lives) */
.hearts-container {
    display: flex;
    gap: 5px;
    align-items: center;
}

.sheriff-badge {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
    transition: transform 0.2s, opacity 0.2s;
}

.sheriff-badge.lost {
    opacity: 0.2;
    transform: scale(0.8);
    filter: grayscale(1);
}

/* Ammo & Revolver Drum Bottom HUD */
#bottom-hud {
    position: absolute;
    bottom: 6px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 60;
    pointer-events: none;
}

/* Revolver Cylinder */
.revolver-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(20, 10, 5, 0.88);
    padding: 6px 14px;
    border-radius: 30px;
    border: 2px solid #b3733b;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    transition: transform 0.15s;
}

.revolver-box:hover {
    transform: scale(1.04);
}

.cylinder-drum {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #333;
    border: 3px solid #777;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bullets-row {
    display: flex;
    gap: 5px;
}

.bullet-icon {
    width: 14px;
    height: 26px;
    transition: opacity 0.15s, transform 0.15s;
}

.bullet-icon.spent {
    opacity: 0.2;
    transform: translateY(4px);
    filter: grayscale(1);
}

/* Reload Button for Touch / Mobile */
.reload-btn-touch {
    background: linear-gradient(135deg, #e67e22, #d35400);
    border: 3px solid #f39c12;
    color: #fff;
    font-weight: 900;
    font-size: 0.95rem;
    padding: 10px 18px;
    border-radius: 24px;
    pointer-events: auto;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 1px;
    transition: transform 0.1s, background 0.2s;
}

.reload-btn-touch:active {
    transform: scale(0.92);
    background: #b94600;
}

/* Audio & Settings Buttons */
.hud-btn {
    background: rgba(0,0,0,0.6);
    border: 1px solid #7c4820;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.2s, transform 0.1s;
}

.hud-btn:active {
    transform: scale(0.9);
}

/* ==========================================================================
   MODAL / OVERLAY SCREENS (START, GAME OVER, LEVEL CLEARED)
   ========================================================================== */

.game-modal {
    position: absolute;
    inset: 0;
    background: rgba(14, 7, 3, 0.92);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 110;
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(4px);
}

.game-modal.hidden {
    display: none;
}

.modal-title {
    font-size: 2.2rem;
    color: #f9ca24;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 3px 3px 0 #8e2b24, 5px 5px 0 #000;
    margin-bottom: 12px;
}

.modal-subtitle {
    font-size: 1.05rem;
    color: #f0dfc8;
    max-width: 520px;
    margin-bottom: 22px;
    line-height: 1.5;
}

.guide-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 560px;
    margin-bottom: 25px;
}

.chip-item {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid #7c4820;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-arcade-action {
    background: linear-gradient(to bottom, #f39c12, #d35400);
    border: 4px solid #f1c40f;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 900;
    padding: 14px 38px;
    border-radius: 35px;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(230, 126, 34, 0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.btn-arcade-action:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(243, 156, 18, 0.8);
}

.btn-arcade-action:active {
    transform: scale(0.96);
}

/* Control Hint at bottom */
.device-hints {
    margin-top: 20px;
    font-size: 0.8rem;
    color: #a89078;
}

/* Responsive queries */
@media (max-width: 600px) {
    .modal-title { font-size: 1.6rem; }
    .modal-subtitle { font-size: 0.9rem; }
    .hud-val { font-size: 1rem; }
    .saloon-roof-sign { font-size: 0.85rem; top: -38px; }
    .revolver-box { padding: 4px 10px; }
    .reload-btn-touch { padding: 8px 14px; font-size: 0.85rem; }
}
