/* ==============================================================================
   استایل تم قرون‌وسطایی و گیمینگ جنگ‌های صلیبی HD تحت وب
   ============================================================================== */

:root {
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --gold-dark: #8c6f1a;
    --red-crusader: #b91c1c;
    --red-hover: #dc2626;
    --bg-dark: #0c0f14;
    --panel-bg: rgba(20, 24, 33, 0.92);
    --panel-border: #3b4252;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --font-family: 'Vazirmatn', Tahoma, sans-serif;
}

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

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-family);
    direction: rtl;
}

/* تصویر پس‌زمینه قلعه و صحرای صلیبی */
.bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(12, 15, 20, 0.8) 0%, #080a0e 100%),
                url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.03"><rect width="100" height="100" fill="%23d4af37"/></svg>');
    z-index: 1;
}

/* کانتینر اصلی اپلیکیشن */
#app-container {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* هدر بالا */
header {
    height: 60px;
    background: rgba(14, 18, 26, 0.95);
    border-bottom: 2px solid var(--gold-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
}

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

.brand-icon {
    font-size: 26px;
    color: var(--gold);
    filter: drop-shadow(0 0 6px var(--gold-glow));
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 0.5px;
}

.brand-subtitle {
    font-size: 11px;
    background: var(--red-crusader);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: bold;
}

.network-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--panel-border);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.status-dot.relay {
    background-color: #eab308;
    box-shadow: 0 0 8px #eab308;
}

.status-dot.offline {
    background-color: #ef4444;
    box-shadow: 0 0 8px #ef4444;
}

/* نمای لابی */
#lobby-view {
    flex: 1;
    display: flex;
    gap: 24px;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.right-panel {
    flex: 1.4;
    display: flex;
    flex-direction: column;
}

.panel-header {
    font-size: 17px;
    font-weight: bold;
    color: var(--gold);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    padding-bottom: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* فرم‌ها و اینپوت‌ها */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}

label {
    font-size: 13px;
    color: var(--text-muted);
}

input[type="text"] {
    background: rgba(10, 13, 18, 0.8);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

/* دکمه‌های حماسی */
.btn {
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #111;
    box-shadow: 0 4px 15px var(--gold-glow);
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(30, 38, 52, 0.8);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(45, 55, 72, 0.9);
    border-color: var(--gold-dark);
}

.btn-crusader {
    background: linear-gradient(135deg, var(--red-hover) 0%, var(--red-crusader) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(185, 28, 28, 0.4);
}

.btn-crusader:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

/* جدول اتاق‌های فعال */
.rooms-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-card {
    background: rgba(12, 16, 23, 0.7);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: border-color 0.2s;
}

.room-card:hover {
    border-color: var(--gold);
}

.room-info-title {
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 4px;
}

.room-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* نمای اتاق بعد از ورود / ساخت */
#room-view {
    display: none;
    flex: 1;
    flex-direction: column;
    max-width: 900px;
    margin: 20px auto;
    width: 100%;
    padding: 0 20px;
}

.room-players-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 14px;
}

.room-players-table th, .room-players-table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid var(--panel-border);
    font-size: 14px;
}

.room-players-table th {
    color: var(--gold);
    background: rgba(0,0,0,0.2);
}

.virtual-ip-badge {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
    direction: ltr;
    display: inline-block;
}

/* پنجره مدال دانلود دیتای بازی با پروگرس بار */
#download-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--panel-bg);
    border: 2px solid var(--gold);
    border-radius: 14px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    margin: 20px 0 10px 0;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold));
    transition: width 0.3s ease;
}

/* ناحیه بازی شبیه‌ساز (Canvas تمام صفحه) */
#game-view {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: black;
    z-index: 50;
}

#crusader-canvas {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* ==============================================================================
   لایه رابط کاربری لمسی موبایل (Mobile Touch Overlay)
   ============================================================================== */
#touch-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 60;
    display: none;
}

/* جوی‌استیک مجازی اسکرول صفحه (سمت چپ) */
.virtual-joystick-zone {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 50%;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.virtual-joystick-nipple {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, var(--gold) 0%, var(--gold-dark) 100%);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--gold-glow);
    transition: transform 0.05s ease;
}

/* دکمه‌های اکشن سمت راست */
.action-buttons-zone {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    pointer-events: auto;
}

.touch-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(14, 18, 26, 0.85);
    border: 2px solid var(--gold);
    color: var(--gold);
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    touch-action: none;
}

.touch-btn.active {
    background: var(--red-crusader);
    color: white;
    border-color: #f87171;
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.8);
}

/* تول‌بار هات‌کی‌های سریع بالا */
.top-hotkeys-zone {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(14, 18, 26, 0.85);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 6px 16px;
    pointer-events: auto;
}

.hotkey-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--text-main);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
}

.hotkey-btn:active {
    background: var(--gold);
    color: black;
}
