:root {
    --bg-dark: #0d1117;
    --panel-bg: rgba(16, 24, 38, 0.88);
    --panel-border: rgba(197, 160, 89, 0.45);
    --gold: #d4af37;
    --gold-bright: #ffd700;
    --gold-glow: rgba(212, 175, 55, 0.5);
    --hp-red: #e63946;
    --hp-gradient: linear-gradient(180deg, #ff6b6b 0%, #c92a2a 100%);
    --mp-blue: #1d72b8;
    --mp-gradient: linear-gradient(180deg, #4dabf7 0%, #1864ab 100%);
    --exp-gold: #f59f00;
    --text-main: #f1f3f5;
    --text-muted: #adb5bd;
    --font-heading: 'Cinzel', serif;
    --font-ui: 'Nunito', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
}

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

#game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at center, #1a2332 0%, #080d14 100%);
}

/* GLASS PANEL UTILITY - WUXIA ORNAMENTAL STYLE */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(8px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(212, 175, 55, 0.08);
    border-radius: 8px;
    position: relative;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 9px;
    height: 9px;
    border-top: 2px solid var(--gold-bright);
    border-left: 2px solid var(--gold-bright);
    pointer-events: none;
    border-top-left-radius: 4px;
}

.glass-panel::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 9px;
    height: 9px;
    border-bottom: 2px solid var(--gold-bright);
    border-right: 2px solid var(--gold-bright);
    pointer-events: none;
    border-bottom-right-radius: 4px;
}

/* TOP HEADER HUD */
#top-hud {
    height: 90px;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    z-index: 20;
}

#player-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    min-width: 330px;
}

.avatar-box {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    box-shadow: 0 0 10px var(--gold-glow);
    background: radial-gradient(circle, #2b3a4a 0%, #121820 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="48" fill="%230e1726" stroke="%23d4af37" stroke-width="2"/><path d="M40 30 Q26 44 18 64" stroke="%23e03131" stroke-width="3" fill="none" stroke-linecap="round"/><path d="M60 30 Q74 44 82 64" stroke="%23e03131" stroke-width="3" fill="none" stroke-linecap="round"/><path d="M22 88 Q50 68 78 88 L78 98 L22 98 Z" fill="%231c7ed6" stroke="%23ffd700" stroke-width="1.5"/><path d="M40 76 L50 90 L60 76 Z" fill="%23ffffff"/><circle cx="50" cy="48" r="21" fill="%23111823"/><ellipse cx="50" cy="50" rx="14" ry="16" fill="%23ffe8d6"/><path d="M36 44 Q50 36 64 44 Q50 48 36 44 Z" fill="%23111823"/><ellipse cx="44" cy="50" rx="2.5" ry="1.5" fill="%23111823"/><ellipse cx="56" cy="50" rx="2.5" ry="1.5" fill="%23111823"/><path d="M41 46 Q45 44 48 47" stroke="%23111823" stroke-width="1.5" fill="none"/><path d="M59 46 Q55 44 52 47" stroke="%23111823" stroke-width="1.5" fill="none"/><ellipse cx="50" cy="30" rx="7" ry="6" fill="%23111823"/><rect x="43" y="27" width="14" height="4" rx="2" fill="%23ffd700"/><circle cx="50" cy="29" r="2" fill="%23e03131"/></svg>');
}

.level-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: #e67e22;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1px solid var(--gold-bright);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.player-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 15px;
    color: var(--gold-bright);
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.title-tag {
    font-size: 11px;
    color: #74c0fc;
    font-weight: 600;
}

.bar-container {
    width: 100%;
    height: 12px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.bar-fill {
    height: 100%;
    transition: width 0.3s ease;
}

.bar-fill.hp {
    background: var(--hp-gradient);
    box-shadow: 0 0 8px rgba(230, 57, 70, 0.6);
}

.bar-fill.mp {
    background: var(--mp-gradient);
    box-shadow: 0 0 8px rgba(29, 114, 184, 0.6);
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 1px 2px #000;
    letter-spacing: 0.5px;
    pointer-events: none;
}

.currency-row {
    font-size: 11px;
    color: #ffe066;
    font-weight: 700;
}

/* HEADER CENTER - GAME TITLE */
.header-center {
    padding: 8px 24px;
    text-align: center;
}

.game-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(180deg, #fff 0%, var(--gold-bright) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 8px var(--gold-glow);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    color: #a9e34b;
    margin-top: 2px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background: #51cf66;
    border-radius: 50%;
    box-shadow: 0 0 8px #51cf66;
}

.pulse {
    animation: dotPulse 1.8s infinite;
}

@keyframes dotPulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* TOP RIGHT - MINIMAP */
#minimap-panel {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
}

.map-header {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.zone-name {
    font-weight: 800;
    font-size: 13px;
    color: var(--gold-bright);
}

.zone-coords {
    font-size: 11px;
    color: #74c0fc;
    font-family: monospace;
}

.radar-box {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--gold);
    overflow: hidden;
    background: #09121d;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8);
}

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

.radar-cross {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 6px;
    transform: translate(-50%, -50%);
    background: #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 6px #fff;
}

.hud-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.icon-btn, .hud-btn {
    background: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    border: 1px solid var(--gold);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 700;
    font-size: 11px;
    transition: all 0.2s;
}

.icon-btn:hover, .hud-btn:hover {
    background: var(--gold);
    color: #000;
    box-shadow: 0 0 10px var(--gold-glow);
}

.hud-btn.highlight {
    background: linear-gradient(180deg, #f39c12 0%, #d35400 100%);
    border-color: #ffd700;
}

/* MAIN VIEWPORT */
#viewport-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    background: #111;
}

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

/* ACTION BAR (FLOATING RIGHT) */
#action-bar {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    z-index: 10;
}

.act-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #1f2d42 0%, #121c2b 100%);
    border: 1.5px solid var(--gold);
    color: #ffd700;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6), inset 0 0 8px rgba(212, 175, 55, 0.15);
}

.act-btn:hover {
    background: linear-gradient(180deg, #2c4263 0%, #1b293d 100%);
    border-color: #ffe066;
    color: #ffffff;
    transform: translateX(-4px) scale(1.02);
    box-shadow: 0 4px 16px rgba(212, 175, 55, 0.4);
}

.act-btn.danger {
    border-color: #ff6b6b;
    color: #ff8787;
}

.act-btn.danger:hover {
    background: linear-gradient(180deg, #8a1f26 0%, #491216 100%);
    border-color: #ff8787;
    color: #fff;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

.btn-icon {
    font-size: 16px;
}

/* VIRTUAL DPAD (BOTTOM LEFT VIEWPORT) */
#virtual-dpad {
    position: absolute;
    left: 20px;
    bottom: 20px;
    width: 110px;
    height: 110px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 4px;
    z-index: 10;
    opacity: 0.75;
    transition: opacity 0.2s;
}

#virtual-dpad:hover {
    opacity: 1;
}

.dpad-btn {
    background: rgba(16, 24, 38, 0.85);
    border: 1px solid var(--gold);
    color: var(--gold-bright);
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active {
    background: var(--gold);
    color: #000;
}

.dpad-btn.up { grid-column: 2; grid-row: 1; }
.dpad-btn.left { grid-column: 1; grid-row: 2; }
.dpad-btn.center { grid-column: 2; grid-row: 2; background: rgba(0,0,0,0.5); pointer-events: none; font-size: 8px; color: #888; }
.dpad-btn.right { grid-column: 3; grid-row: 2; }
.dpad-btn.down { grid-column: 2; grid-row: 3; }

/* HINT BUBBLE */
.hint-toast {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 15, 25, 0.85);
    border: 1px solid var(--gold);
    color: #ffd8a8;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.6);
    z-index: 10;
}

/* BOTTOM CHAT SYSTEM */
#chat-dock {
    height: 210px;
    margin: 8px 16px 12px 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 20;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(10, 16, 26, 0.8);
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.chat-tabs {
    display: flex;
    gap: 4px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--gold-bright);
    background: rgba(212, 175, 55, 0.15);
    border-bottom: 2px solid var(--gold-bright);
}

.chat-tool-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.chat-tool-btn:hover {
    opacity: 1;
}

.chat-log {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.chat-log::-webkit-scrollbar {
    width: 6px;
}

.chat-log::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

.chat-msg {
    display: flex;
    align-items: baseline;
    gap: 6px;
    word-break: break-word;
}

.badge {
    font-size: 11px;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.badge-world { background: #b25e00; color: #ffe066; }
.badge-local { background: #343a40; color: #f8f9fa; }
.badge-guild { background: #2b8a3e; color: #b2f2bb; }
.badge-team  { background: #1971c2; color: #a5d8ff; }
.badge-system { background: #c92a2a; color: #ffc9c9; }

.chat-msg.world .msg-text { color: #ffe066; }
.chat-msg.local .msg-text { color: #f1f3f5; }
.chat-msg.guild .msg-text { color: #b2f2bb; }
.chat-msg.team .msg-text  { color: #a5d8ff; }
.chat-msg.system .msg-text { color: #ffa8a8; font-style: italic; }

.sender-name {
    font-weight: 700;
    color: #74c0fc;
    cursor: pointer;
}

.sender-name:hover {
    text-decoration: underline;
}

.chat-input-bar {
    display: flex;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(10, 16, 26, 0.95);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
}

.channel-dropdown {
    background: #141f2e;
    border: 1px solid var(--gold);
    color: var(--gold-bright);
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    cursor: pointer;
}

#chat-input {
    flex-grow: 1;
    background: #0b121b;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    font-family: var(--font-ui);
}

#chat-input:focus {
    border-color: var(--gold-bright);
    box-shadow: 0 0 8px var(--gold-glow);
}

.send-btn {
    background: linear-gradient(180deg, #f59f00 0%, #e67700 100%);
    border: 1px solid var(--gold-bright);
    color: #000;
    font-weight: 900;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 10px var(--gold-glow);
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    width: 580px;
    max-width: 90vw;
    padding: 20px;
    border: 2px solid var(--gold);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-family: var(--font-heading);
    color: var(--gold-bright);
    font-size: 18px;
}

.close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.modal-intro {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.role-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.role-card:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--gold-bright);
    transform: translateY(-2px);
}

.role-card.active {
    border: 2px solid var(--gold-bright);
    background: rgba(212, 175, 55, 0.25);
    box-shadow: 0 0 10px var(--gold-glow);
}

.role-card-name {
    font-weight: 800;
    font-size: 14px;
    color: var(--gold-bright);
}

.role-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.custom-login-box {
    border-top: 1px solid rgba(212, 175, 55, 0.3);
    padding-top: 14px;
}

.custom-login-box h3 {
    font-size: 13px;
    color: var(--gold-bright);
    margin-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 8px;
}

.form-row input {
    flex-grow: 1;
    background: #0b121b;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
}
