/**
 * Arena Survival - Game Styles
 * All visual elements can be dynamically updated by server
 */

/* CSS Variables - Server can override these */
:root {
    --primary-color: #ff6b35;
    --secondary-color: #4ecdc4;
    --danger-color: #ff3333;
    --success-color: #33ff57;
    --warning-color: #ffcc00;
    --bg-dark: #1a1a2e;
    --bg-darker: #0f0f1a;
    --bg-panel: rgba(20, 20, 40, 0.9);
    --text-primary: #ffffff;
    --text-secondary: #aaaaaa;
    --health-color: #ff4444;
    --shield-color: #44aaff;
    --stamina-color: #ffcc00;
    --zone-danger-color: rgba(255, 0, 0, 0.3);
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-display: 'Impact', 'Arial Black', sans-serif;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: var(--bg-darker);
    color: var(--text-primary);
    overflow: hidden;
    cursor: none;
    user-select: none;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 100;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Connect Screen */
#screen-connect {
    background: linear-gradient(135deg, var(--bg-darker) 0%, #16213e 100%);
}

.connect-box {
    background: var(--bg-panel);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 50px rgba(255, 107, 53, 0.3);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 50px rgba(255, 107, 53, 0.3); }
    50% { box-shadow: 0 0 80px rgba(255, 107, 53, 0.5); }
}

.connect-box h1 {
    font-family: var(--font-display);
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 0 0 20px var(--primary-color);
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.2em;
    margin-bottom: 30px;
}

.connect-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.connect-form input {
    padding: 15px 20px;
    font-size: 1.2em;
    border: 2px solid #444;
    border-radius: 10px;
    background: var(--bg-darker);
    color: var(--text-primary);
    text-align: center;
    transition: border-color 0.3s;
}

.connect-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn-primary, .btn-secondary {
    padding: 15px 40px;
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #ff8c5a 100%);
    color: white;
}

.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 107, 53, 0.5);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--text-secondary);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.status-message {
    min-height: 30px;
    color: var(--warning-color);
    font-size: 0.9em;
}

.game-info {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #333;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Game Screen */
#screen-game {
    display: none;
    background: var(--bg-darker);
}

#screen-game.active {
    display: block;
}

/* Game Canvas */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Top HUD */
#hud-top {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 30px;
    z-index: 50;
}

.hud-item {
    background: var(--bg-panel);
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid #444;
}

.hud-label {
    color: var(--text-secondary);
    margin-right: 5px;
}

#hud-zone-timer.danger {
    animation: zone-warning 0.5s infinite;
    border-color: var(--danger-color);
}

@keyframes zone-warning {
    0%, 100% { background: var(--bg-panel); }
    50% { background: rgba(255, 0, 0, 0.3); }
}

/* Left HUD - Player Stats */
#hud-left {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 50;
    width: 250px;
}

.stat-bar {
    position: relative;
    height: 30px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #444;
}

.stat-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.3s ease;
}

.health-fill {
    background: linear-gradient(90deg, #cc0000 0%, var(--health-color) 100%);
    width: 100%;
}

.shield-fill {
    background: linear-gradient(90deg, #0066cc 0%, var(--shield-color) 100%);
    width: 0%;
}

.stamina-fill {
    background: linear-gradient(90deg, #cc9900 0%, var(--stamina-color) 100%);
    width: 100%;
}

.stat-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    font-size: 0.9em;
}

/* Health bar effects */
.stat-bar.critical .health-fill {
    animation: health-critical 0.3s infinite;
}

@keyframes health-critical {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

/* Right HUD - Inventory */
#hud-right {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid #444;
    z-index: 50;
}

#inventory-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.8em;
    letter-spacing: 2px;
}

#inventory-slots {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-bottom: 15px;
}

.inventory-slot {
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #444;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.inventory-slot:hover {
    border-color: var(--primary-color);
}

.inventory-slot.selected {
    border-color: var(--secondary-color);
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
}

.inventory-slot .item-icon {
    font-size: 1.5em;
}

.inventory-slot .item-count {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.7em;
    font-weight: bold;
}

#equipped-weapon {
    padding-top: 10px;
    border-top: 1px solid #444;
    font-size: 0.9em;
}

.equipped-label {
    color: var(--text-secondary);
}

#weapon-name {
    color: var(--secondary-color);
    font-weight: bold;
}

#ammo-count {
    color: var(--warning-color);
    margin-left: 10px;
}

/* Bottom HUD - Hotbar */
#hud-bottom {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
}

#hotbar {
    display: flex;
    gap: 10px;
    background: var(--bg-panel);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #444;
}

.hotbar-slot {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #444;
    border-radius: 8px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.hotbar-slot:hover {
    border-color: var(--primary-color);
}

.hotbar-slot.active {
    border-color: var(--secondary-color);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.5);
}

.hotbar-key {
    position: absolute;
    top: 2px;
    left: 5px;
    font-size: 0.8em;
    color: var(--text-secondary);
}

.hotbar-item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
}

.hotbar-slot .item-cooldown {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s linear;
}

/* Minimap */
#minimap-container {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 180px;
    height: 180px;
    background: var(--bg-panel);
    border-radius: 10px;
    padding: 5px;
    border: 1px solid #444;
    z-index: 50;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    border-radius: 5px;
}

/* Kill Feed */
#kill-feed {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 300px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.kill-message {
    background: var(--bg-panel);
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 0.85em;
    animation: kill-feed-in 0.3s ease;
    border-left: 3px solid var(--danger-color);
}

@keyframes kill-feed-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.kill-message .killer {
    color: var(--primary-color);
    font-weight: bold;
}

.kill-message .victim {
    color: var(--secondary-color);
    font-weight: bold;
}

.kill-message .weapon {
    color: var(--text-secondary);
}

/* Chat */
#chat-container {
    position: absolute;
    bottom: 100px;
    left: 20px;
    width: 350px;
    z-index: 50;
}

#chat-messages {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
    scrollbar-width: thin;
    scrollbar-color: #444 transparent;
}

.chat-message {
    padding: 5px 10px;
    margin-bottom: 3px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    font-size: 0.9em;
    animation: chat-in 0.2s ease;
}

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

.chat-message .sender {
    color: var(--secondary-color);
    font-weight: bold;
}

.chat-message.system {
    color: var(--warning-color);
    font-style: italic;
}

#chat-input {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-panel);
    border: 1px solid #444;
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 0.9em;
    display: none;
}

#chat-input.active {
    display: block;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Server Alerts */
#server-alerts {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    text-align: center;
    pointer-events: none;
}

.server-alert {
    font-size: 2em;
    font-weight: bold;
    text-shadow: 0 0 20px black;
    margin-bottom: 10px;
    animation: alert-in 0.5s ease;
}

@keyframes alert-in {
    from {
        transform: scale(2);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.server-alert.danger {
    color: var(--danger-color);
}

.server-alert.warning {
    color: var(--warning-color);
}

.server-alert.info {
    color: var(--secondary-color);
}

.server-alert.success {
    color: var(--success-color);
}

/* Interaction Prompt */
#interaction-prompt {
    position: absolute;
    bottom: 200px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    padding: 10px 20px;
    border-radius: 5px;
    border: 1px solid var(--secondary-color);
    z-index: 50;
    animation: prompt-pulse 1s infinite;
}

@keyframes prompt-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Damage Indicators */
#damage-indicators {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 45;
}

.damage-indicator {
    position: absolute;
    font-weight: bold;
    font-size: 1.5em;
    text-shadow: 2px 2px 4px black;
    animation: damage-float 1s ease-out forwards;
    pointer-events: none;
}

.damage-indicator.damage {
    color: var(--danger-color);
}

.damage-indicator.heal {
    color: var(--success-color);
}

.damage-indicator.critical {
    font-size: 2em;
    color: #ff0000;
}

@keyframes damage-float {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-50px);
    }
}

/* Crosshair */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    pointer-events: none;
}

.crosshair-line {
    position: absolute;
    background: rgba(255, 255, 255, 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;
}

.crosshair-dot {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#crosshair.spread .crosshair-line.top { transform: translateX(-50%) translateY(-5px); }
#crosshair.spread .crosshair-line.bottom { transform: translateX(-50%) translateY(5px); }
#crosshair.spread .crosshair-line.left { transform: translateY(-50%) translateX(-5px); }
#crosshair.spread .crosshair-line.right { transform: translateY(-50%) translateX(5px); }

#crosshair.hit .crosshair-line,
#crosshair.hit .crosshair-dot {
    background: var(--danger-color);
}

/* Death Screen */
#screen-death {
    background: rgba(100, 0, 0, 0.8);
}

.death-box {
    background: var(--bg-panel);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid var(--danger-color);
}

.death-box h2 {
    font-family: var(--font-display);
    font-size: 3em;
    color: var(--danger-color);
    margin-bottom: 30px;
    animation: death-shake 0.5s ease;
}

@keyframes death-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

#death-stats {
    margin-bottom: 30px;
}

#death-stats p {
    margin: 10px 0;
    font-size: 1.1em;
}

#death-stats span {
    color: var(--secondary-color);
    font-weight: bold;
}

.death-box button {
    margin: 10px;
}

/* Victory Screen */
#screen-victory {
    background: rgba(0, 50, 0, 0.8);
}

.victory-box {
    background: var(--bg-panel);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    border: 2px solid var(--success-color);
    animation: victory-glow 1s infinite;
}

@keyframes victory-glow {
    0%, 100% { box-shadow: 0 0 50px rgba(51, 255, 87, 0.3); }
    50% { box-shadow: 0 0 100px rgba(51, 255, 87, 0.6); }
}

.victory-box h2 {
    font-family: var(--font-display);
    font-size: 3em;
    color: var(--success-color);
    margin-bottom: 30px;
}

#victory-stats {
    margin-bottom: 30px;
}

#victory-stats p {
    margin: 10px 0;
    font-size: 1.1em;
}

#victory-stats span {
    color: var(--secondary-color);
    font-weight: bold;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loader {
    width: 60px;
    height: 60px;
    border: 4px solid #333;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Dynamic UI Container */
#dynamic-ui-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 80;
}

#dynamic-ui-container > * {
    pointer-events: auto;
}

/* Server-injected modal */
.server-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-panel);
    padding: 30px;
    border-radius: 15px;
    border: 2px solid var(--primary-color);
    max-width: 500px;
    text-align: center;
}

.server-modal-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.server-modal-content {
    margin-bottom: 20px;
}

.server-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Screen edge damage vignette */
.damage-vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
    box-shadow: inset 0 0 100px 50px rgba(255, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s;
}

.damage-vignette.active {
    opacity: 1;
    animation: vignette-pulse 0.2s ease;
}

@keyframes vignette-pulse {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Low health warning */
.low-health-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 39;
    box-shadow: inset 0 0 150px 50px rgba(255, 0, 0, 0.3);
    animation: low-health-pulse 1s infinite;
}

@keyframes low-health-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Zone warning overlay */
.zone-warning-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 38;
    background: var(--zone-danger-color);
    animation: zone-pulse 0.5s infinite;
}

@keyframes zone-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    #hud-right {
        width: 150px;
    }

    #inventory-slots {
        grid-template-columns: repeat(3, 1fr);
    }

    #minimap-container {
        width: 140px;
        height: 140px;
    }
}

@media (max-width: 900px) {
    #hud-left {
        width: 180px;
    }

    #hud-right {
        display: none;
    }

    .hotbar-slot {
        width: 50px;
        height: 50px;
    }

    #chat-container {
        width: 280px;
    }

    #kill-feed {
        width: 250px;
    }
}
