/* ========================================
   KRUST - FPS Browser Game Styles
   ======================================== */

:root {
    --primary: #ff4444;
    --secondary: #44ff88;
    --accent: #44aaff;
    --bg-dark: #0a0a0f;
    --bg-overlay: rgba(10, 10, 15, 0.9);
    --text: #ffffff;
    --text-dim: #888899;
    --health-high: #44ff88;
    --health-mid: #ffaa44;
    --health-low: #ff4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: var(--bg-dark);
    font-family: 'Segoe UI', system-ui, sans-serif;
    color: var(--text);
    cursor: none;
}

/* ========================================
   GAME CANVAS
   ======================================== */

#game-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
}

/* ========================================
   HUD OVERLAY
   ======================================== */

.hud {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

.hud.hidden {
    display: none;
}

/* Crosshair */
.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.crosshair-dot {
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px var(--primary);
}

.crosshair-line {
    position: absolute;
    background: var(--text);
    opacity: 0.8;
}

.crosshair-line.top,
.crosshair-line.bottom {
    width: 2px;
    height: 10px;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair-line.top {
    bottom: 8px;
}

.crosshair-line.bottom {
    top: 8px;
}

.crosshair-line.left,
.crosshair-line.right {
    width: 10px;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.crosshair-line.left {
    right: 8px;
}

.crosshair-line.right {
    left: 8px;
}

/* Health Bar */
.health-container {
    position: absolute;
    bottom: 30px;
    left: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.health-icon {
    font-size: 24px;
}

.health-bar {
    width: 200px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.health-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--health-high), var(--secondary));
    transition: width 0.3s ease, background 0.3s ease;
    box-shadow: 0 0 10px var(--health-high);
}

.health-fill.mid {
    background: linear-gradient(90deg, var(--health-mid), #ffcc44);
    box-shadow: 0 0 10px var(--health-mid);
}

.health-fill.low {
    background: linear-gradient(90deg, var(--health-low), #ff6666);
    box-shadow: 0 0 10px var(--health-low);
    animation: pulse-low 0.5s ease-in-out infinite;
}

@keyframes pulse-low {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.health-text {
    font-size: 20px;
    font-weight: bold;
    min-width: 40px;
    text-align: right;
}

/* Ammo Counter */
.ammo-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    align-items: baseline;
    gap: 5px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ammo-icon {
    font-size: 24px;
    margin-right: 10px;
}

.ammo-current {
    font-size: 32px;
    font-weight: bold;
    color: var(--accent);
}

.ammo-separator {
    font-size: 20px;
    color: var(--text-dim);
}

.ammo-reserve {
    font-size: 20px;
    color: var(--text-dim);
}

/* Kill Feed */
.kill-feed {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.kill-entry {
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 14px;
    animation: slide-in 0.3s ease;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* FPS Counter */
.fps-counter {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 14px;
    font-family: monospace;
    color: var(--secondary);
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 10px;
    border-radius: 4px;
}

/* Minimap */
.minimap-container {
    position: absolute;
    top: 60px;
    right: 20px;
    width: 150px;
    height: 150px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    overflow: hidden;
}

#minimap {
    width: 100%;
    height: 100%;
}

.minimap-player {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px var(--primary);
    z-index: 10;
}

/* Street Name Display */
.street-name {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 25px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: bold;
    color: white;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ========================================
   OVERLAY SCREENS
   ======================================== */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    backdrop-filter: blur(10px);
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    overflow: hidden;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    /* Prevent browser gestures */
}

.overlay.hidden {
    display: none;
}

/* Start Screen */
.start-content {
    text-align: center;
}

.game-title {
    font-size: 120px;
    font-weight: 900;
    letter-spacing: 15px;
    margin-bottom: 10px;
    text-shadow: 0 0 30px rgba(255, 68, 68, 0.5);
}

.game-title span {
    display: inline-block;
    animation: title-float 3s ease-in-out infinite;
}

.title-k {
    color: #ff4444;
    animation-delay: 0s;
}

.title-r {
    color: #ff6644;
    animation-delay: 0.1s;
}

.title-u {
    color: #ff8844;
    animation-delay: 0.2s;
}

.title-s {
    color: #ffaa44;
    animation-delay: 0.3s;
}

.title-t {
    color: #ffcc44;
    animation-delay: 0.4s;
}

@keyframes title-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.subtitle {
    font-size: 18px;
    color: var(--text-dim);
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 40px;
}

.controls-info {
    background: rgba(255, 255, 255, 0.05);
    padding: 25px 40px;
    border-radius: 12px;
    margin-bottom: 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.controls-info h3 {
    margin-bottom: 15px;
    color: var(--accent);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.control-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 10px 0;
    color: var(--text-dim);
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 5px 10px;
    font-family: monospace;
    font-size: 14px;
    color: var(--text);
    min-width: 30px;
    text-align: center;
}

.start-button {
    position: relative;
    background: linear-gradient(135deg, var(--primary), #ff6644);
    border: none;
    padding: 20px 60px;
    font-size: 24px;
    font-weight: bold;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 5px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.start-button:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 40px rgba(255, 68, 68, 0.4);
}

.start-button:active {
    transform: scale(0.98);
}

.button-glow {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: button-shine 2s infinite;
}

@keyframes button-shine {
    0% {
        left: -100%;
    }

    50%,
    100% {
        left: 100%;
    }
}

/* Pause Screen */
.pause-content {
    text-align: center;
}

.pause-content h2 {
    font-size: 60px;
    margin-bottom: 20px;
    color: var(--accent);
}

.pause-content p {
    color: var(--text-dim);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .game-title {
        font-size: 60px;
        letter-spacing: 8px;
    }

    .controls-info {
        padding: 15px 20px;
        display: none;
        /* Hide on mobile - show touch controls instead */
    }

    .health-container,
    .ammo-container {
        padding: 8px 12px;
    }

    .health-bar {
        width: 120px;
    }

    /* Adjust HUD for mobile */
    /* Adjust HUD for mobile */
    .health-container {
        bottom: calc(240px + env(safe-area-inset-bottom));
        /* Lift well above controls */
        left: 15px;
        left: max(15px, env(safe-area-inset-left));
    }

    .ammo-container {
        bottom: calc(240px + env(safe-area-inset-bottom));
        /* Lift well above controls */
        right: 15px;
        right: max(15px, env(safe-area-inset-right));
    }

    body {
        cursor: default;
    }
}

/* ========================================
   TOUCH CONTROLS (Mobile)
   ======================================== */

/* Touch Controls (Mobile) */
#touch-controls {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1500;
}

/* Show ONLY when both is-mobile AND game-active are present */
body.is-mobile.game-active #touch-controls {
    display: block !important;
}

@media (pointer: coarse),
(max-width: 1024px) {
    #touch-controls {
        display: block;
    }
}

/* Joystick Area - Left side */
.joystick-area {
    position: absolute;
    bottom: calc(80px + env(safe-area-inset-bottom));
    /* Increased safe zone for Android Nav Bar */
    left: calc(40px + env(safe-area-inset-left));
    width: 180px;
    height: 180px;
    pointer-events: auto;
    touch-action: none;
}

/* Action Buttons - Right side */
.action-buttons {
    position: absolute;
    bottom: calc(80px + env(safe-area-inset-bottom));
    /* Increased safe zone for Android Nav Bar */
    right: calc(40px + env(safe-area-inset-right));
    display: flex;
    gap: 20px;
    pointer-events: auto;
    touch-action: none;
}

.joystick-base {
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    background: linear-gradient(135deg, var(--accent), #2288dd);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(68, 170, 255, 0.5);
    transition: transform 0.05s;
}

/* Look Area - Right side "Central Circle" */
.look-area {
    position: absolute;
    bottom: 40px;
    right: 40px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
}

/* Visual center dot for look area */
.look-area::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

/* Action Buttons - Positioned relative to screen, around the look circle */
.action-buttons {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through container */
}

.touch-btn {
    pointer-events: auto;
    /* Re-enable for buttons */
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.1s, background 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

/* Fire button - Left of look circle */
.fire-btn {
    bottom: 80px;
    right: 260px;
    /* Left of the 200px circle + spacing */
    width: 90px;
    height: 90px;
    background: rgba(255, 68, 68, 0.4);
    border-color: var(--primary);
    font-size: 32px;
}

.fire-btn:active {
    background: rgba(255, 68, 68, 0.7);
}

/* Jump button - Top-Right of look circle */
.jump-btn {
    bottom: 260px;
    /* Above circle */
    right: 100px;
    background: rgba(68, 255, 136, 0.3);
    border-color: var(--secondary);
}

.jump-btn:active {
    background: rgba(68, 255, 136, 0.6);
}

/* Reload button - Tiny, somewhere safe */
.reload-btn {
    top: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    font-size: 20px;
    opacity: 0.6;
}

/* Hide sprint button (Auto-run now) */
.sprint-btn {
    display: none !important;
}

@keyframes sprint-pulse {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(255, 170, 68, 0.3);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 170, 68, 0.6);
    }
}

/* Touch instruction on start screen (mobile) */
@media (pointer: coarse) {
    .controls-info {
        display: block;
    }

    .controls-info .control-row kbd {
        display: none;
    }

    .controls-info::after {
        content: 'Toque na tela para controlar';
        display: block;
        text-align: center;
        color: var(--accent);
        margin-top: 10px;
        font-size: 16px;
    }

    .start-button {
        padding: 25px 50px;
        font-size: 20px;
    }
}

/* ========================================
   LOADING & ERROR SCREENS
   ======================================== */

.loading-content {
    text-align: center;
    width: 300px;
}

.loading-content h2 {
    font-size: 24px;
    margin-bottom: 20px;
    letter-spacing: 5px;
    color: var(--text);
}

.progress-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--primary);
}

.loading-text {
    font-size: 14px;
    color: var(--text-dim);
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.5;
    }

    to {
        opacity: 1;
    }
}

.error-content {
    text-align: center;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.8);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--primary);
    box-shadow: 0 0 30px rgba(255, 68, 68, 0.2);
}

.error-content h2 {
    color: var(--primary);
    font-size: 32px;
    margin-bottom: 20px;
}

.error-message {
    color: var(--text);
    margin-bottom: 30px;
    line-height: 1.5;
}

.reload-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.2s;
}

.reload-button:hover {
    background: #ff6666;
    transform: scale(1.05);
}