/* Castla Game Client Styles */

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none;
}

/* Loading Screen */
#loading-screen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 4rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

#loading-text {
    font-size: 1.2rem;
    opacity: 0.8;
}

/* Login Screen */
#login-screen {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
}

.login-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-width: 400px;
}

.login-content h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.login-content p {
    margin-bottom: 2rem;
    opacity: 0.9;
    font-size: 1.1rem;
}

.input-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: #ffffff;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#join-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#join-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#join-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Game Screen */
#game-screen {
    display: block;
    padding: 0;
}

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

/* Game UI */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

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

/* Top Bar */
#top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#player-info {
    display: flex;
    gap: 20px;
    align-items: center;
}

#player-name-display {
    font-weight: bold;
    font-size: 1.1rem;
}

#server-info {
    font-size: 0.9rem;
    opacity: 0.8;
}

#connection-status {
    display: flex;
    gap: 10px;
    align-items: center;
}

#connection-indicator {
    font-size: 1.5rem;
}

#connection-indicator.connected {
    color: #4CAF50;
}

#connection-indicator.disconnected {
    color: #f44336;
}

#connection-indicator.connecting {
    color: #ff9800;
    animation: pulse 1s infinite;
}

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

/* Chat Panel */
#chat-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 350px;
    height: 250px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

#chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.4;
}

.chat-message {
    margin-bottom: 8px;
    word-wrap: break-word;
}

.chat-message .player-name {
    font-weight: bold;
    color: #4CAF50;
}

.chat-message .timestamp {
    font-size: 0.8rem;
    opacity: 0.6;
    margin-left: 8px;
}

#chat-input-container {
    display: flex;
    padding: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 0.9rem;
    margin-right: 10px;
}

#chat-input:focus {
    outline: none;
    border-color: #ffffff;
}

#chat-send {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
}

#chat-send:hover {
    background: #45a049;
}

/* Controls Info */
#controls-info {
    position: absolute;
    top: 100px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 200px;
}

#controls-info h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #4CAF50;
}

#controls-info ul {
    list-style: none;
}

#controls-info li {
    margin-bottom: 8px;
    font-size: 0.9rem;
    line-height: 1.3;
}

#controls-info strong {
    color: #ffffff;
}

/* Player List */
#player-list {
    position: absolute;
    top: 100px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
}

#player-list h3 {
    margin-bottom: 15px;
    font-size: 1.1rem;
    color: #4CAF50;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.9rem;
}

.player-item:last-child {
    border-bottom: none;
}

.player-name {
    font-weight: 500;
}

.player-ping {
    opacity: 0.7;
    font-size: 0.8rem;
}

/* Debug Info */
#debug-info {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    min-width: 200px;
}

#debug-info h4 {
    margin-bottom: 10px;
    color: #4CAF50;
}

#debug-content div {
    margin-bottom: 4px;
}

/* Error Handling */
.error-message {
    background: rgba(244, 67, 54, 0.9);
    color: white;
    padding: 12px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-size: 0.9rem;
}

/* Error Screen */
#error-screen {
    background: linear-gradient(135deg, #c62828 0%, #d32f2f 100%);
}

.error-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    min-width: 400px;
}

.error-content h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.error-content p {
    margin-bottom: 2rem;
    font-size: 1.1rem;
    opacity: 0.9;
}

#retry-btn {
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background 0.3s ease;
}

#retry-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-content {
        min-width: 90%;
        padding: 2rem;
    }
    
    #top-bar {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
    }
    
    #chat-panel {
        width: calc(100% - 40px);
        height: 200px;
    }
    
    #controls-info,
    #player-list {
        position: static;
        margin: 10px;
        max-height: none;
    }
}

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

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

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