/**
 * Fireboy & Watergirl Online Co-op — In-Game Lobby & UI Styling
 * Authentic Oslo Albet Ancient Egyptian Sandstone & Temple Aesthetic
 * Pure CSS (Zero external image dependencies)
 */

:root {
    /* Oslo Albet Ancient Egyptian Temple Sandstone Palette */
    --fw-stone-darkest: #120e0a;
    --fw-stone-dark: #1f1812;
    --fw-stone-medium: #2f241a;
    --fw-stone-light: #443527;
    --fw-stone-carved: #5a4634;
    --fw-stone-highlight: #7a624a;

    /* Pharaoh Gold & Antique Bronze Accents */
    --fw-gold-deep: #7c5c1e;
    --fw-gold-base: #c59b27;
    --fw-gold-bright: #ffd700;
    --fw-gold-light: #ffeb85;
    --fw-gold-glow: rgba(255, 215, 0, 0.4);

    /* Elemental Fire Ruby (ولد النار) */
    --fw-fire-dark: #661800;
    --fw-fire-base: #ff5722;
    --fw-fire-bright: #ff7043;
    --fw-fire-glow: rgba(255, 87, 34, 0.55);

    /* Elemental Water Sapphire (بنت الماء) */
    --fw-water-dark: #003e5c;
    --fw-water-base: #03a9f4;
    --fw-water-bright: #4fc3f7;
    --fw-water-glow: rgba(3, 169, 244, 0.55);

    /* Typography & Contrast Colors */
    --fw-text-gold: #fde8a0;
    --fw-text-bright: #ffffff;
    --fw-text-muted: #c2b199;
    --fw-shadow-inset: inset 0 2px 4px rgba(255, 215, 0, 0.15), inset 0 -3px 6px rgba(0, 0, 0, 0.8);
    --fw-shadow-slab: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 30px rgba(0, 0, 0, 0.6);

    /* Font Stacks */
    --fw-font-en: 'Cinzel', 'Trajan Pro', Georgia, serif;
    --fw-font-ar: 'Cairo', 'Amiri', Tahoma, sans-serif;
}

/* Base Modal Overlay */
.fw-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 7, 5, 0.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 16px;
    box-sizing: border-box;
    font-family: var(--fw-font-en);
}

.fw-modal-overlay[dir="rtl"] {
    font-family: var(--fw-font-ar);
    direction: rtl;
}

.fw-modal-overlay[dir="ltr"] {
    font-family: var(--fw-font-en);
    direction: ltr;
}

.fw-modal-overlay.fw-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Master Oslo Albet Temple Sandstone Slab */
.fw-temple-slab {
    position: relative;
    width: 100%;
    max-width: 680px;
    min-width: 280px;
    background: radial-gradient(circle at 50% 20%, #3a2d21 0%, #241a13 60%, #150f0b 100%);
    border: 3px solid #5a4634;
    border-top-color: #7a624a; /* Carved top lighting bevel */
    border-bottom-color: #120e0a; /* Deep carved bottom shadow */
    border-radius: 14px;
    box-shadow:
        var(--fw-shadow-slab),
        inset 0 0 0 1px var(--fw-gold-deep),
        inset 0 2px 8px rgba(255, 235, 133, 0.2),
        inset 0 -4px 12px rgba(0, 0, 0, 0.85);
    padding: 24px;
    box-sizing: border-box;
    color: var(--fw-text-gold);
    transform: scale(1);
    transition: transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

/* Golden Egyptian Corner Brackets */
.fw-temple-slab::before,
.fw-temple-slab::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border: 3px solid var(--fw-gold-base);
    pointer-events: none;
    box-shadow: 0 0 6px var(--fw-gold-glow);
}

.fw-temple-slab::before {
    top: 6px;
    right: 6px;
    border-bottom: none;
    border-left: none;
}

.fw-temple-slab::after {
    bottom: 6px;
    left: 6px;
    border-top: none;
    border-right: none;
}

/* Header & Jewels */
.fw-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--fw-gold-deep);
    padding-bottom: 14px;
    margin-bottom: 20px;
    position: relative;
}

.fw-header-jewels {
    display: flex;
    align-items: center;
    gap: 12px;
}

.fw-jewel {
    display: inline-block;
    width: 14px;
    height: 14px;
    transform: rotate(45deg);
    border-radius: 2px;
}

.fw-jewel-fire {
    background: linear-gradient(135deg, #ff7043, #d90429);
    border: 1.5px solid #ffa07a;
    box-shadow: 0 0 10px #ff4500, inset 0 0 4px #ffffff;
}

.fw-jewel-water {
    background: linear-gradient(135deg, #4fc3f7, #0288d1);
    border: 1.5px solid #b3e5fc;
    box-shadow: 0 0 10px #00bcd4, inset 0 0 4px #ffffff;
}

.fw-temple-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--fw-text-gold);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px var(--fw-gold-glow);
    letter-spacing: 0.5px;
}

.fw-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fw-btn-lang {
    background: #2a2016;
    border: 1px solid var(--fw-gold-deep);
    color: var(--fw-text-gold);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.fw-btn-lang:hover {
    background: var(--fw-stone-carved);
    border-color: var(--fw-gold-bright);
    color: #ffffff;
    box-shadow: 0 0 8px var(--fw-gold-glow);
}

.fw-btn-close {
    background: #2a2016;
    border: 1px solid #5a4634;
    color: var(--fw-text-muted);
    font-size: 20px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.fw-btn-close:hover {
    background: #661800;
    border-color: #ff5722;
    color: #ffffff;
    box-shadow: 0 0 8px rgba(255, 87, 34, 0.6);
}

/* Views & Flow Cards */
.fw-view {
    display: block;
}

.fw-view.fw-hidden {
    display: none !important;
}

.fw-subtitle {
    margin: 0 0 18px 0;
    color: var(--fw-text-muted);
    font-size: 14px;
    text-align: center;
}

.fw-flow-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.fw-card {
    background: linear-gradient(180deg, #2a2017 0%, #1b140f 100%);
    border: 2px solid #4a3828;
    border-radius: 10px;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 235, 133, 0.1);
    position: relative;
    user-select: none;
}

.fw-card:hover {
    transform: translateY(-4px);
    border-color: var(--fw-gold-base);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7), 0 0 14px var(--fw-gold-glow);
}

.fw-card-featured {
    border-color: var(--fw-gold-base);
    background: radial-gradient(circle at 50% 0%, #3d2e1c 0%, #1e150f 100%);
}

.fw-card-featured::before {
    content: "★";
    position: absolute;
    top: -10px;
    background: var(--fw-gold-base);
    color: #120e0a;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.fw-card-icon {
    font-size: 32px;
    margin-bottom: 10px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.fw-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--fw-text-gold);
    margin-bottom: 6px;
}

.fw-card-desc {
    font-size: 12px;
    color: var(--fw-text-muted);
    line-height: 1.4;
    margin-bottom: 14px;
    flex-grow: 1;
}

/* Buttons */
.fw-btn {
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    user-select: none;
    font-family: inherit;
}

.fw-btn-gold {
    background: linear-gradient(180deg, #ffd700 0%, #c59b27 100%);
    color: #1a1208;
    border: 1px solid #ffeb85;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 1px #fff;
}

.fw-btn-gold:hover {
    background: linear-gradient(180deg, #ffeb85 0%, #ffd700 100%);
    box-shadow: 0 4px 14px var(--fw-gold-glow);
    transform: translateY(-1px);
}

.fw-btn-secondary {
    background: #2a2016;
    border: 1px solid #5a4634;
    color: var(--fw-text-gold);
}

.fw-btn-secondary:hover {
    background: #3e3022;
    border-color: var(--fw-gold-base);
    color: #ffffff;
}

/* Character Selector Cards */
.fw-char-selector {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin: 16px 0;
}

.fw-char-card {
    flex: 1;
    max-width: 220px;
    background: #1d1611;
    border: 2px solid #443527;
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    position: relative;
}

.fw-char-card.fw-char-fire {
    border-color: #661800;
}

.fw-char-card.fw-char-fire:hover,
.fw-char-card.fw-char-fire.fw-selected {
    border-color: var(--fw-fire-base);
    background: radial-gradient(circle at 50% 0%, #471304 0%, #1c0a04 100%);
    box-shadow: 0 0 16px var(--fw-fire-glow);
}

.fw-char-card.fw-char-water {
    border-color: #003e5c;
}

.fw-char-card.fw-char-water:hover,
.fw-char-card.fw-char-water.fw-selected {
    border-color: var(--fw-water-base);
    background: radial-gradient(circle at 50% 0%, #032b3e 0%, #02141d 100%);
    box-shadow: 0 0 16px var(--fw-water-glow);
}

.fw-char-badge {
    font-size: 24px;
    margin-bottom: 6px;
}

.fw-char-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--fw-text-bright);
}

.fw-char-controls {
    font-size: 11px;
    color: var(--fw-text-muted);
    margin-top: 4px;
}

/* Room Code Display & 1-Click Copy */
.fw-room-code-box {
    background: #140e0a;
    border: 2px solid var(--fw-gold-deep);
    border-radius: 8px;
    padding: 14px;
    text-align: center;
    margin: 16px 0;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
}

.fw-room-code-label {
    font-size: 12px;
    color: var(--fw-text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.fw-room-code-display {
    font-size: 32px;
    font-weight: 800;
    font-family: monospace;
    color: var(--fw-gold-bright);
    text-shadow: 0 0 12px var(--fw-gold-glow);
    letter-spacing: 4px;
    margin: 4px 0 12px 0;
}

.fw-code-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.fw-btn-copy {
    background: linear-gradient(180deg, #ffd700 0%, #c59b27 100%);
    color: #120e0a;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid #ffeb85;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.fw-btn-copy.fw-copied {
    background: linear-gradient(180deg, #4caf50 0%, #2e7d32 100%) !important;
    border-color: #81c784 !important;
    color: #ffffff !important;
    box-shadow: 0 0 14px rgba(76, 175, 80, 0.6) !important;
}

/* Waiting Indicator */
.fw-waiting-box {
    text-align: center;
    padding: 14px;
    color: var(--fw-text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.fw-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-top-color: var(--fw-gold-bright);
    border-radius: 50%;
    animation: fw-spin 0.8s linear infinite;
}

@keyframes fw-spin {
    to { transform: rotate(360deg); }
}

/* Join View Input */
.fw-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 20px 0;
}

.fw-input-label {
    font-size: 13px;
    color: var(--fw-text-gold);
    font-weight: 600;
}

.fw-input-code {
    background: #140e0a;
    border: 2px solid var(--fw-stone-carved);
    border-radius: 8px;
    color: var(--fw-gold-bright);
    font-size: 24px;
    font-weight: 700;
    font-family: monospace;
    padding: 12px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fw-input-code:focus {
    border-color: var(--fw-gold-base);
    box-shadow: 0 0 12px var(--fw-gold-glow);
}

.fw-input-nickname {
    background: #140e0a;
    border: 1px solid var(--fw-stone-carved);
    border-radius: 6px;
    color: #ffffff;
    font-size: 14px;
    padding: 8px 12px;
    outline: none;
    margin-bottom: 12px;
}

.fw-input-nickname:focus {
    border-color: var(--fw-gold-base);
}

/* Status Alert Badges */
.fw-status-badge {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
    margin: 12px 0;
    display: none;
}

.fw-status-badge.fw-active {
    display: block;
}

.fw-status-connecting {
    background: rgba(197, 155, 39, 0.15);
    border: 1px solid var(--fw-gold-base);
    color: var(--fw-gold-bright);
}

.fw-status-connected {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid #4caf50;
    color: #81c784;
}

.fw-status-error {
    background: rgba(217, 4, 41, 0.15);
    border: 1px solid #ff5722;
    color: #ff8a80;
}

/* =========================================================================
   In-Game Floating Pill Nameplates & Glowing Green Online Dot
   ========================================================================= */

.fw-floating-nameplate {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(18, 14, 10, 0.92);
    border: 1.5px solid var(--fw-gold-base);
    border-radius: 9999px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 6px rgba(197, 155, 39, 0.35);
    user-select: none;
    white-space: nowrap;
    transition: border-color 0.2s ease;
}

.fw-floating-nameplate[data-accent="fire"] {
    border-color: var(--fw-fire-base);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 8px var(--fw-fire-glow);
}

.fw-floating-nameplate[data-accent="water"] {
    border-color: var(--fw-water-base);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8), 0 0 8px var(--fw-water-glow);
}

.fw-online-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    filter: drop-shadow(0 0 4px #00e676);
    animation: fw-pulse-green 1.8s infinite ease-in-out;
}

@keyframes fw-pulse-green {
    0%, 100% { transform: scale(1); opacity: 1; filter: drop-shadow(0 0 4px #00e676); }
    50% { transform: scale(1.25); opacity: 0.85; filter: drop-shadow(0 0 8px #00e676); }
}

.fw-name {
    letter-spacing: 0.3px;
}

/* =========================================================================
   In-Game Minimalist HUD Overlay & Disconnect Dialog
   ========================================================================= */

.fw-hud-overlay {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(22, 16, 12, 0.88);
    border: 1.5px solid var(--fw-gold-deep);
    border-radius: 20px;
    padding: 4px 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    font-family: var(--fw-font-en);
}

.fw-hud-overlay[dir="rtl"] {
    right: auto;
    left: 12px;
    font-family: var(--fw-font-ar);
    direction: rtl;
}

.fw-hud-overlay.fw-hidden {
    display: none !important;
}

.fw-hud-badge {
    font-size: 12px;
    font-weight: 700;
    color: var(--fw-text-gold);
    display: flex;
    align-items: center;
    gap: 4px;
}

.fw-hud-ping {
    font-family: monospace;
    font-weight: 800;
}

.fw-hud-ping.fw-ping-excellent {
    color: #4caf50;
    text-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
}

.fw-hud-ping.fw-ping-good {
    color: #ffd700;
    text-shadow: 0 0 6px var(--fw-gold-glow);
}

.fw-hud-ping.fw-ping-poor {
    color: #ff5722;
    text-shadow: 0 0 6px rgba(255, 87, 34, 0.6);
}

.fw-hud-status {
    font-size: 11px;
    color: var(--fw-text-muted);
}

.fw-hud-btn {
    background: transparent;
    border: none;
    color: var(--fw-text-gold);
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.fw-hud-btn:hover {
    background: var(--fw-stone-carved);
}

/* Solo Floating Minimalist Toggle Button (re-open lobby anytime) */
.fw-solo-toggle-btn {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 9989;
    background: rgba(25, 18, 13, 0.9);
    border: 1.5px solid var(--fw-gold-base);
    color: var(--fw-text-gold);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
    font-size: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.fw-solo-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 12px var(--fw-gold-glow);
}

.fw-solo-toggle-btn[dir="rtl"] {
    right: auto;
    left: 12px;
}

/* Disconnect Modal Dialog */
.fw-disconnect-dialog {
    background: radial-gradient(circle at 50% 20%, #3a1c14 0%, #1c0e0a 100%);
    border-color: #8b2510;
    max-width: 460px;
    text-align: center;
}

.fw-disconnect-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.fw-disconnect-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Responsive Viewport Rules */
@media (max-width: 480px) {
    .fw-temple-slab {
        padding: 16px;
    }
    .fw-temple-title {
        font-size: 18px;
    }
    .fw-room-code-display {
        font-size: 24px;
    }
    .fw-flow-cards {
        grid-template-columns: 1fr;
    }
}
