/* ============================================================
   Viber MMO Client — Master Stylesheet
   ============================================================ */

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

:root {
    --bg-dark:    #0d0f14;
    --bg-panel:   #161a23;
    --bg-input:   #1e2330;
    --bg-hover:   #252b3a;
    --border:     #2a303f;
    --text:       #d4d8e0;
    --text-dim:   #7a8299;
    --accent:     #5b8aff;
    --accent-dim: #3a5eb0;
    --hp:         #d04040;
    --hp-bg:      #3a1515;
    --mp:         #4080d0;
    --mp-bg:      #152040;
    --sp:         #40b060;
    --sp-bg:      #153020;
    --danger:     #d04040;
    --success:    #40b060;
    --warning:    #d0a040;

    /* Rarity colours */
    --rarity-standard: #a0a0a0;
    --rarity-forged:   #30c8b0;
    --rarity-imbued:   #4090e0;
    --rarity-pristine: #a050d0;
    --rarity-relic:    #d03030;

    --font: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Consolas', 'Courier New', monospace;
}

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

a { color: var(--accent); text-decoration: none; }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen { display: none; width: 100%; height: 100%; position: absolute; top: 0; left: 0; }
.screen.active { display: flex; }

/* =========================== LOGIN =========================== */
#screen-login {
    justify-content: center; align-items: center;
    background: linear-gradient(135deg, #0d0f14 0%, #1a1f2e 100%);
}
.login-container { width: 380px; text-align: center; }
.game-title {
    font-size: 56px; font-weight: 800; letter-spacing: 4px;
    color: #e0e4ec; margin-bottom: 4px;
}
.game-title .accent { color: var(--accent); }
.subtitle { color: var(--text-dim); margin-bottom: 32px; font-size: 15px; }

.form-panel {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 28px; text-align: left;
}
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.form-group input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg-input); color: var(--text);
    font-size: 14px; outline: none; transition: border .2s;
}
.form-group input:focus { border-color: var(--accent); }

.btn {
    display: inline-block; padding: 10px 20px; border: none; border-radius: 6px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: background .2s, transform .1s;
    text-align: center; width: 100%; margin-bottom: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4a76e0; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; width: auto; }
.btn-danger:hover { background: #b03030; }
.btn-small { padding: 4px 10px; width: auto; margin: 0; font-size: 12px; border-radius: 4px; }
.btn-close { background: transparent; color: var(--text-dim); border: none; font-size: 16px; }
.btn-close:hover { color: var(--text); }

.error-msg { margin-top: 12px; padding: 8px; background: rgba(208, 64, 64, .15); border: 1px solid var(--danger); border-radius: 6px; color: var(--danger); font-size: 13px; }

.connection-status { margin-top: 16px; font-size: 12px; color: var(--text-dim); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.dot.disconnected { background: var(--danger); }
.dot.connecting { background: var(--warning); }
.dot.connected { background: var(--success); }

/* Server address row on login screen */
.server-address-row {
    display: flex; align-items: center; justify-content: center;
    margin-top: 16px; gap: 6px; font-size: 12px; color: var(--text-dim);
}
.server-address-label { text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
.server-address-sep { color: var(--text-dim); }
.server-address-input {
    flex: 1; min-width: 0; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 5px;
    background: var(--bg-input); color: var(--text); font-size: 12px; outline: none;
    transition: border .2s;
}
.server-address-input:focus { border-color: var(--accent); }
.server-address-port {
    width: 62px; padding: 5px 8px;
    border: 1px solid var(--border); border-radius: 5px;
    background: var(--bg-input); color: var(--text); font-size: 12px; outline: none;
    transition: border .2s;
    /* Hide number spinner arrows */
    -moz-appearance: textfield;
}
.server-address-port::-webkit-inner-spin-button,
.server-address-port::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.server-address-port:focus { border-color: var(--accent); }

/* =========================== CHARACTER SELECT =========================== */
#screen-charselect {
    justify-content: center; align-items: center;
    background: linear-gradient(135deg, #0d0f14 0%, #1a1f2e 100%);
}
.charselect-container { width: 540px; }
.charselect-container h2 { text-align: center; margin-bottom: 20px; font-size: 28px; }

.character-list {
    max-height: 340px; overflow-y: auto;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 8px; margin-bottom: 16px;
}
.char-entry {
    display: flex; align-items: center; padding: 14px 18px;
    border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s;
}
.char-entry:last-child { border-bottom: none; }
.char-entry:hover { background: var(--bg-hover); }
.char-entry.selected { background: rgba(91, 138, 255, .12); border-left: 3px solid var(--accent); }
.char-entry .char-icon { font-size: 28px; margin-right: 14px; }
.char-entry .char-details { flex: 1; }
.char-entry .char-name { font-weight: 600; font-size: 16px; }
.char-entry .char-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }

.charselect-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.charselect-actions .btn { width: auto; flex: 1; min-width: 100px; }

/* ---------- Create Character Modal ---------- */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; justify-content: center; align-items: center;
    background: rgba(0,0,0,.6); z-index: 100;
}
.modal-content {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 28px; width: 460px; max-height: 80vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 18px; text-align: center; }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; }
.modal-actions .btn { flex: 1; }

.class-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.class-option {
    flex: 1 1 calc(50% - 8px); min-width: 130px;
    padding: 12px; background: var(--bg-input); border: 2px solid var(--border);
    border-radius: 8px; cursor: pointer; text-align: center; transition: border .2s, background .2s;
}
.class-option:hover { background: var(--bg-hover); }
.class-option.selected { border-color: var(--accent); background: rgba(91, 138, 255, .08); }
.class-icon { font-size: 28px; margin-bottom: 4px; }
.class-option span { display: block; font-weight: 600; }
.class-option small { display: block; color: var(--text-dim); font-size: 11px; margin-top: 2px; }

/* =========================== GAME SCREEN =========================== */
#screen-game { display: none; position: relative; }
#screen-game.active { display: block; }

/* Canvas container — Three.js appends its own <canvas> inside */
#game-canvas-container {
    width: 100%; height: 100%; position: absolute; top: 0; left: 0;
    overflow: hidden; background: #1a2020;
}
#game-canvas-container canvas { display: block; width: 100%; height: 100%; }

/* ---------- HUD Top ---------- */
.hud-top {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 16px; background: rgba(13, 15, 20, .75);
    pointer-events: none; z-index: 10;
}
.player-info, .zone-info { pointer-events: auto; }
.hud-name { font-weight: 700; margin-right: 8px; }
.hud-level { color: var(--accent); margin-right: 8px; }
.hud-class { color: var(--text-dim); font-size: 12px; }
.zone-info { color: var(--text-dim); font-size: 13px; }

/* ---------- Vitals ---------- */
.hud-vitals {
    position: absolute; top: 40px; left: 16px; width: 260px; z-index: 10;
    pointer-events: none;
}
.vital-bar { display: flex; align-items: center; margin-bottom: 4px; }
.vital-label { width: 24px; font-size: 11px; font-weight: 700; text-align: center; }
.vital-track { flex: 1; height: 14px; border-radius: 3px; overflow: hidden; margin: 0 6px; }
.hp-track   { background: var(--hp-bg); }
.mp-track   { background: var(--mp-bg); }
.sp-track   { background: var(--sp-bg); }
.xp-track   { background: #1a1a2e; }
.vital-fill { height: 100%; border-radius: 3px; transition: width .2s; }
.hp-fill    { background: var(--hp); }
.mp-fill    { background: var(--mp); }
.sp-fill    { background: var(--sp); }
.xp-fill    { background: #8855cc; }
.vital-text { font-size: 11px; width: 60px; text-align: right; color: var(--text-dim); }

/* ---------- Target ---------- */
.hud-target {
    position: absolute; top: 40px; left: 50%; transform: translateX(-50%);
    background: rgba(13, 15, 20, .8); border: 1px solid var(--border);
    border-radius: 6px; padding: 8px 14px; width: 240px; z-index: 10; text-align: center;
    pointer-events: none;
}
.target-name { font-weight: 600; margin-right: 8px; }
.target-level { color: var(--accent); font-size: 12px; }
.target-hp-track { margin-top: 6px; }

/* ---------- Level-Up Overlay ---------- */
.level-up-overlay {
    position: absolute; top: 25%; left: 50%; transform: translate(-50%, -50%);
    z-index: 200; text-align: center; pointer-events: none;
    animation: levelUpFadeIn 0.5s ease-out;
}
.level-up-overlay.hidden { display: none; }
.level-up-text {
    font-size: 48px; font-weight: 900; color: #ffcc00;
    text-shadow: 0 0 20px rgba(255, 200, 0, 0.8), 0 0 40px rgba(255, 150, 0, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    letter-spacing: 4px;
    animation: levelUpPulse 0.6s ease-out;
}
.level-up-detail {
    font-size: 28px; font-weight: 700; color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 2px 2px 4px rgba(0,0,0,0.8);
    margin-top: 8px;
}
@keyframes levelUpPulse {
    0%   { transform: scale(0.5); opacity: 0; }
    60%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1.0); opacity: 1; }
}
@keyframes levelUpFadeIn {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

/* ---------- Action Bar ---------- */
.action-bar {
    position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 4px; z-index: 10;
}
.action-slot {
    width: 52px; height: 52px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 6px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; cursor: pointer;
    position: relative; transition: border .15s;
}
.action-slot:hover { border-color: var(--accent); }
.action-slot.on-cooldown { opacity: .5; }
.action-slot.skill-drag-over { border-color: var(--success); background: rgba(64, 176, 96, .15); box-shadow: 0 0 8px rgba(64,176,96,.4); }
.action-slot.autoattack-active {
    border-color: #ff6633;
    box-shadow: 0 0 10px rgba(255, 100, 50, 0.7), inset 0 0 6px rgba(255, 100, 50, 0.25);
    animation: autoAttackPulse 1.1s ease-in-out infinite;
}
@keyframes autoAttackPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(255, 100, 50, 0.6), inset 0 0 4px rgba(255, 100, 50, 0.2); }
    50%       { box-shadow: 0 0 16px rgba(255, 100, 50, 1.0), inset 0 0 8px rgba(255, 100, 50, 0.4); }
}
@keyframes skillActivateFlash {
    0%   { box-shadow: 0 0 18px rgba(255, 230, 80, 1.0), inset 0 0 12px rgba(255, 230, 80, 0.5); background: rgba(255, 230, 80, 0.3); }
    100% { box-shadow: none; background: var(--bg-panel); }
}
.action-slot.skill-flash {
    animation: skillActivateFlash 0.35s ease-out forwards;
}
.action-key { position: absolute; top: 2px; left: 4px; font-size: 10px; color: var(--text-dim); }
.action-icon { font-size: 20px; }
.action-name {
    font-size: 7px; color: var(--text-dim); white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 48px;
    text-align: center; margin-top: 1px;
}
.cooldown-overlay {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; background: rgba(0,0,0,.6); border-radius: 6px;
    font-size: 14px; font-weight: bold; color: #fff;
}
.cooldown-overlay.hidden { display: none; }

/* ---------- Cast Bar ---------- */
.cast-bar {
    position: absolute; bottom: 124px; left: 50%; transform: translateX(-50%);
    width: 260px; height: 22px; background: rgba(13,15,20,.85);
    border: 1px solid var(--border); border-radius: 4px;
    overflow: hidden; z-index: 11;
}
.cast-bar.hidden { display: none; }
.cast-bar-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, #f0b232, #e68a00);
    transition: width 0.05s linear; border-radius: 3px;
}
.cast-bar-text {
    position: absolute; inset: 0; display: flex; align-items: center;
    justify-content: center; font-size: 11px; color: #fff;
    text-shadow: 1px 1px 2px rgba(0,0,0,.9);
}

/* ---------- Chat ---------- */
.chat-panel {
    position: absolute; bottom: 64px; left: 12px; width: 360px;
    background: rgba(13, 15, 20, .8); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; z-index: 10;
    display: flex; flex-direction: column; max-height: 260px;
}
.chat-tabs {
    display: flex; gap: 0; background: var(--bg-panel); overflow-x: auto;
    border-bottom: 1px solid var(--border);
}
.chat-tab {
    padding: 6px 12px; font-size: 12px; background: transparent;
    border: none; color: var(--text-dim); cursor: pointer; white-space: nowrap;
}
.chat-tab:hover { color: var(--text); }
.chat-tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); }
.chat-messages {
    flex: 1; overflow-y: auto; padding: 8px 10px; min-height: 100px; max-height: 180px;
    font-size: 13px; line-height: 1.5;
}
.chat-messages .msg { margin-bottom: 2px; }
.chat-messages .msg-system { color: var(--warning); font-style: italic; }
.chat-messages .msg-say .msg-sender { color: #fff; }
.chat-messages .msg-yell .msg-sender { color: #e0c040; }
.chat-messages .msg-whisper { color: #d080d0; }
.chat-messages .msg-party .msg-sender { color: #60a0ff; }
.chat-messages .msg-guild .msg-sender { color: #40c080; }
.chat-messages .msg-world .msg-sender { color: #c0c0c0; }
.msg-sender { font-weight: 600; }
.chat-input-row { display: flex; border-top: 1px solid var(--border); }
.chat-input {
    flex: 1; padding: 8px 10px; background: var(--bg-input); border: none;
    color: var(--text); font-size: 13px; outline: none;
}

/* ---------- Minimap ---------- */
.minimap {
    position: absolute; top: 40px; right: 12px;
    width: 184px; height: 184px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; z-index: 10;
    pointer-events: none;
}
#minimap-canvas { width: 100%; height: 100%; }

/* ---------- Side Panels (Inventory / Equipment) ---------- */
.side-panel {
    position: absolute; top: 60px; right: 204px; width: 340px;
    background: rgba(22, 26, 35, .95); border: 1px solid var(--border);
    border-radius: 8px; z-index: 20; padding: 12px; max-height: calc(100vh - 140px);
    overflow-y: auto;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-header h3 { font-size: 16px; }
.panel-actions { display: flex; gap: 4px; }

.currency-display { font-size: 13px; margin-bottom: 8px; color: var(--warning); }

.inventory-grid {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
}
.inv-slot {
    aspect-ratio: 1; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 4px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; cursor: pointer;
    font-size: 11px; position: relative; transition: border .15s;
    overflow: hidden; padding: 2px;
}
.inv-slot:hover { border-color: var(--accent); }
.inv-slot.occupied { }
.inv-slot .item-qty { position: absolute; bottom: 1px; right: 3px; font-size: 9px; color: var(--text-dim); z-index: 2; }
.inv-slot .item-name { font-size: 9px; text-align: center; word-break: break-all; line-height: 1.1; z-index: 2; position: relative; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
.inv-slot .item-icon { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; border-radius: 3px; z-index: 1; }
.inv-slot.dragging { opacity: .4; }
.inv-slot.drag-over { border-color: var(--success); background: rgba(64, 176, 96, .1); }

/* Rarity border colours */
.inv-slot.rarity-1 { border-color: var(--rarity-standard); }
.inv-slot.rarity-2 { border-color: var(--rarity-forged); }
.inv-slot.rarity-3 { border-color: var(--rarity-imbued); }
.inv-slot.rarity-4 { border-color: var(--rarity-pristine); }
.inv-slot.rarity-5 { border-color: var(--rarity-relic); }

/* ---------- Equipment ---------- */
.equipment-slots {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.equip-slot {
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px; padding: 10px 8px; text-align: center; cursor: pointer;
    transition: border .15s; min-height: 60px;
}
.equip-slot:hover { border-color: var(--accent); }
.equip-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.equip-item-name { font-size: 12px; font-weight: 600; margin-top: 4px; }

/* ---------- Equipment — Character Stats ---------- */
.equip-stats-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.equip-stats-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.equip-derived-title { margin-top: 10px; }
.equip-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
}
.equip-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    padding: 2px 0;
}
.equip-stat-label { color: var(--text-dim); }
.equip-stat-value { font-weight: 600; color: var(--text); white-space: nowrap; }
.equip-stat-bonus { color: var(--success); font-size: 11px; margin-left: 2px; }

/* ---------- NPC Dialogue ---------- */
.npc-dialogue {
    position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
    width: 420px; background: rgba(22, 26, 35, .95); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px; z-index: 25;
}
.dialogue-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.dialogue-header span { font-weight: 700; font-size: 16px; }
#dialogue-text { margin-bottom: 12px; line-height: 1.5; color: var(--text); }
.dialogue-options { display: flex; flex-direction: column; gap: 6px; }
.dialogue-option {
    padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px; cursor: pointer; transition: background .15s;
}
.dialogue-option:hover { background: var(--bg-hover); }

/* ---------- NPC Trade ---------- */
.npc-trade {
    position: absolute; top: 60px; left: 50%; transform: translateX(-50%);
    width: 440px; background: rgba(22, 26, 35, .95); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px; z-index: 25; max-height: 60vh; overflow-y: auto;
}
.trade-items { display: flex; flex-direction: column; gap: 6px; }
.trade-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px;
}
.trade-item-info { flex: 1; }
.trade-item-name { font-weight: 600; }
.trade-item-price { color: var(--warning); font-size: 13px; }
.trade-item-stock { font-size: 12px; color: var(--text-dim); }
.trade-actions { display: flex; gap: 4px; }

/* ---------- Death Overlay ---------- */
.death-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(80, 0, 0, .6); display: flex; flex-direction: column;
    justify-content: center; align-items: center; z-index: 50;
}
.death-overlay h2 { font-size: 48px; color: #ff4040; margin-bottom: 16px; }
.death-overlay p { color: var(--text); margin-bottom: 24px; }
.death-overlay .btn { width: auto; }

/* ---------- Toolbar ---------- */
.toolbar {
    position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 6px; z-index: 10;
}
.toolbar-btn {
    width: 44px; height: 44px;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 6px; font-size: 20px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: border .15s;
}
.toolbar-btn:hover { border-color: var(--accent); }
.toolbar-btn.active { border-color: var(--accent); background: rgba(91, 138, 255, .1); }

/* ---------- Tooltip ---------- */
.item-tooltip {
    position: absolute; z-index: 100; width: 220px;
    background: rgba(22, 26, 35, .97); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px; pointer-events: none;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.tooltip-name { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.tooltip-type { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
.tooltip-stats { font-size: 12px; line-height: 1.6; white-space: pre-line; }

/* ---------- Context Menu ---------- */
.context-menu {
    position: absolute; z-index: 100;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: 6px; overflow: hidden; min-width: 140px;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.context-menu ul { list-style: none; }
.context-menu li {
    padding: 8px 14px; cursor: pointer; font-size: 13px; transition: background .15s;
}
.context-menu li:hover { background: var(--bg-hover); }
.context-menu li.danger { color: var(--danger); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================================
   Skillbook Panel
   ============================================================ */

.skillbook-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(960px, 95vw);
    height: min(640px, 90vh);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.7);
}
.skillbook-panel.hidden { display: none; }

.skillbook-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.skillbook-title-row {
    display: flex;
    align-items: baseline;
    gap: 16px;
}
.skillbook-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
}
.skillbook-points {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.skillbook-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left: scrollable graph area */
.skillbook-graph-wrap {
    flex: 1;
    overflow: auto;
    padding: 8px;
    border-right: 1px solid var(--border);
}
.skillbook-graph {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

/* Branch label */
.skillbook-branch-label {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-bottom: 2px solid;
    pointer-events: none;
    white-space: nowrap;
}

/* Skill nodes */
.skillbook-node {
    position: absolute;
    width: 82px;
    height: 82px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color .2s, box-shadow .2s, background .2s;
    user-select: none;
}
.skillbook-node:hover { background: var(--bg-hover); }
.skillbook-node--selected { outline: 2px solid var(--accent); outline-offset: 2px; }
.skillbook-node--locked-prereq, .skillbook-node--locked-level, .skillbook-node--locked {
    opacity: .45;
    cursor: default;
}
.skillbook-node--learned { cursor: grab; }
.skillbook-node--learned:active { cursor: grabbing; }
.skillbook-node--dragging { opacity: .45; }

.skillbook-node-icon {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-dim);
    line-height: 1;
}
.skillbook-node-name {
    font-size: 10px;
    color: var(--text-dim);
    margin-top: 4px;
    text-align: center;
    line-height: 1.2;
    max-width: 74px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.skillbook-node-lvl {
    font-size: 9px;
    color: var(--text-dim);
    margin-top: 2px;
}
.skillbook-node-tick {
    position: absolute;
    top: 3px;
    right: 5px;
    font-size: 11px;
    font-weight: 700;
}

/* Pulse animation for available nodes */
@keyframes skillbook-pulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50%       { box-shadow: 0 0 10px 3px rgba(91,138,255,.35); }
}

/* Right: detail panel */
.skillbook-detail {
    width: 240px;
    flex-shrink: 0;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}
.skillbook-detail-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.skillbook-detail-desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.5;
}
.skillbook-detail-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.sb-stat {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
}
.sb-stat--wide {
    flex-direction: column;
    gap: 2px;
}
.sb-stat-k { color: var(--text-dim); }
.sb-stat-v { color: var(--text); font-weight: 500; }

.skillbook-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

/* ============================================================
   Party Frame & Party Panel
   ============================================================ */

/* Left-side party frame — shown below #hud-vitals when in a party */
.party-frame {
    position: absolute;
    top: 180px; /* below the vitals bars */
    left: 16px;
    width: 260px;
    z-index: 10;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.party-member {
    background: rgba(13, 15, 20, .75);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 5px 8px;
    cursor: pointer;
    transition: border-color .15s;
}
.party-member:hover { border-color: var(--accent); }
.party-member-dead { opacity: .5; }

.party-member-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 3px;
}
.party-member-level { color: var(--accent); font-weight: 400; }

.party-member-hp-track {
    position: relative;
    height: 10px;
    background: var(--hp-bg);
    border-radius: 3px;
    overflow: hidden;
}
.party-member-hp-fill {
    height: 100%;
    background: var(--hp);
    border-radius: 3px;
    transition: width .2s;
}
.party-member-hp-text {
    position: absolute;
    right: 3px; top: 0;
    font-size: 9px;
    line-height: 10px;
    color: #eee;
    text-shadow: 0 0 3px #000;
}

/* Party panel (side panel) */
.party-panel-members {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.party-panel-member {
    font-size: 13px;
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
}
.party-panel-name { font-weight: 600; }
.party-panel-hp-track {
    margin-top: 4px;
    height: 8px;
    background: var(--hp-bg);
    border-radius: 3px;
    overflow: hidden;
}
.party-panel-hp-fill {
    height: 100%;
    background: var(--hp);
    border-radius: 3px;
    transition: width .2s;
}
.party-empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
.party-panel-actions { border-top: 1px solid var(--border); padding-top: 8px; }

/* Invite banner */
#party-invite-banner {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(22, 26, 35, .96);
    border: 1px solid var(--accent-dim);
    border-radius: 6px;
    padding: 10px 16px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
}
#party-invite-banner button {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    border: none;
}
#btn-party-accept  { background: var(--success, #40b060); color: #fff; }
#btn-party-decline { background: var(--danger, #b04040);  color: #fff; }

.btn-danger {
    background: var(--danger, #b04040);
    color: #fff;
    border: none;
}
.btn-danger:hover { background: #c05050; }

/* ============================================================
   Options Panel
   ============================================================ */

.options-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, 94vw);
    max-height: min(600px, 90vh);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 40px rgba(0,0,0,.7);
}
.options-panel.hidden { display: none; }

/* Header */
.options-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.options-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

/* Tab bar */
.options-tabs {
    display: flex;
    gap: 2px;
    padding: 8px 16px 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.options-tab {
    padding: 6px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: color .15s, background .15s;
    position: relative;
    bottom: -1px;
}
.options-tab:hover { color: var(--text); background: var(--bg-hover); }
.options-tab.active {
    color: var(--text);
    background: var(--bg-panel);
    border-color: var(--border);
    border-bottom-color: var(--bg-panel);
}

/* Body / scrollable area */
.options-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Hotkeys page */
.options-hint {
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 12px;
    line-height: 1.5;
}
.options-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 11px;
    font-family: var(--font-mono);
}

.options-hotkey-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.options-hotkey-table thead th {
    text-align: left;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
}
.options-hotkey-table tbody tr:hover { background: rgba(255,255,255,.03); }
.options-hotkey-table td { padding: 6px 8px; vertical-align: middle; }
.options-slot-num  { color: var(--text-dim); width: 28px; }
.options-slot-name { color: var(--text); }
.options-slot-key  { width: 70px; }
.options-slot-actions { white-space: nowrap; }

.options-key-badge {
    display: inline-block;
    min-width: 32px;
    padding: 2px 7px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    text-align: center;
    color: var(--text);
}
.options-key-badge.rebinding {
    border-color: var(--accent);
    color: var(--accent);
    animation: options-blink .7s step-start infinite;
}
@keyframes options-blink {
    50% { opacity: .4; }
}

/* Graphics page */
.options-graphics-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.options-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s;
    gap: 12px;
}
.options-toggle-row:hover { background: var(--bg-hover); }
.options-toggle-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.options-toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.options-toggle-desc {
    font-size: 11px;
    color: var(--text-dim);
}

/* Toggle switch */
.options-toggle-switch {
    position: relative;
    flex-shrink: 0;
}
.options-toggle-cb {
    position: absolute;
    opacity: 0;
    width: 0; height: 0;
}
.options-toggle-track {
    display: block;
    width: 40px;
    height: 22px;
    background: var(--border);
    border-radius: 11px;
    transition: background .2s;
    cursor: pointer;
}
.options-toggle-track::after {
    content: '';
    display: block;
    width: 16px;
    height: 16px;
    background: var(--text-dim);
    border-radius: 50%;
    margin: 3px;
    transition: transform .2s, background .2s;
}
.options-toggle-cb:checked + .options-toggle-track {
    background: var(--accent);
}
.options-toggle-cb:checked + .options-toggle-track::after {
    transform: translateX(18px);
    background: #fff;
}
