:root {
  --bg: #05070b;
  --panel: rgba(10, 17, 29, 0.76);
  --panel-strong: rgba(13, 24, 38, 0.92);
  --line: rgba(255, 255, 255, 0.16);
  --line-bright: rgba(255, 255, 255, 0.34);
  --text: #eef6ff;
  --muted: #9db2c5;
  --gold: #eac768;
  --cyan: #69d7ff;
  --green: #70f0a6;
  --red: #ff6b7a;
  --purple: #b690ff;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.55);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button { font: inherit; color: inherit; }
code { color: var(--cyan); }

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

#loading-screen {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: radial-gradient(circle at center, rgba(105, 215, 255, 0.12), rgba(5, 7, 11, 0.98) 55%);
  transition: opacity .7s ease, visibility .7s ease;
}
#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-card { width: min(460px, 92vw); padding: 34px; text-align: center; border: 1px solid var(--line); border-radius: 28px; background: var(--panel-strong); box-shadow: var(--shadow); backdrop-filter: blur(20px); }
.loading-card h1 { margin: 8px 0 4px; letter-spacing: .08em; text-transform: uppercase; font-size: 1.35rem; }
.loading-card p { color: var(--muted); margin: 0 0 24px; }
.sigil { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto; border-radius: 18px; color: var(--gold); border: 1px solid rgba(234, 199, 104, .36); background: rgba(234, 199, 104, .08); }
.loading-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.loading-bar span { display: block; height: 100%; width: 55%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--gold)); animation: loadPulse 1.3s ease-in-out infinite alternate; }
@keyframes loadPulse { to { transform: translateX(82%); } }

.hud-layer { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.glass-panel { border: 1px solid var(--line); background: linear-gradient(145deg, rgba(14, 24, 39, .78), rgba(6, 10, 18, .58)); box-shadow: 0 14px 42px rgba(0,0,0,.32); backdrop-filter: blur(16px); }
.character-frame { position: absolute; left: 24px; top: 24px; width: 355px; min-height: 120px; border-radius: 24px; padding: 16px; display: flex; gap: 14px; align-items: center; }
.portrait-orb { width: 74px; height: 74px; border-radius: 26px; border: 1px solid rgba(105, 215, 255, .32); background: radial-gradient(circle at 35% 25%, rgba(105, 215, 255, .38), rgba(105, 215, 255, .04) 70%); display: grid; place-items: center; font-weight: 900; letter-spacing: .08em; color: var(--cyan); }
.vitals { flex: 1; }
.name-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; color: #fff; }
.name-row span { color: var(--gold); font-size: .85rem; }
.bar { position: relative; height: 18px; margin: 7px 0; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 100%; border-radius: inherit; transition: width .2s ease; }
.bar b { position: absolute; inset: 0; display: grid; place-items: center; font-size: .68rem; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.health span { background: linear-gradient(90deg, #bd2335, var(--red)); }
.stamina span { background: linear-gradient(90deg, #2faf6a, var(--green)); }
.mana span { background: linear-gradient(90deg, #336bff, var(--cyan)); }

.quest-tracker { position: absolute; top: 24px; right: 24px; width: 300px; padding: 16px; border-radius: 22px; }
.quest-tracker h3 { margin: 0 0 7px; color: var(--gold); text-transform: uppercase; font-size: .78rem; letter-spacing: .14em; }
.quest-tracker p { margin: 0 0 12px; color: var(--muted); font-size: .88rem; line-height: 1.4; }
#objective-progress { padding: 10px 12px; border-radius: 14px; background: rgba(234, 199, 104, .08); color: var(--gold); border: 1px solid rgba(234, 199, 104, .22); }

.minimap { position: absolute; right: 24px; bottom: 24px; width: 176px; padding: 12px; border-radius: 24px; text-align: center; }
.minimap canvas { width: 150px; height: 150px; border-radius: 18px; display: block; margin: 0 auto 8px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.11); }
.minimap span { color: var(--muted); font-size: .68rem; letter-spacing: .14em; }

.interaction-prompt { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); border-radius: 18px; padding: 12px 18px; color: #fff; transition: opacity .18s ease, transform .18s ease; }
.interaction-prompt b { color: var(--gold); }
.interaction-prompt.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); }

.hotbar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; grid-template-columns: repeat(8, 58px); gap: 10px; pointer-events: auto; }
.hotbar-slot { height: 58px; border-radius: 18px; border: 1px solid rgba(255,255,255,.18); background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.025)); display: grid; place-items: center; position: relative; box-shadow: 0 12px 32px rgba(0,0,0,.28); }
.hotbar-slot strong { font-size: 1.2rem; }
.hotbar-slot span { position: absolute; left: 7px; top: 5px; color: var(--muted); font-size: .68rem; }
.hotbar-slot small { position: absolute; bottom: 5px; right: 7px; color: var(--gold); font-size: .62rem; }

.chat-box { position: absolute; left: 24px; bottom: 24px; width: 380px; min-height: 108px; border-radius: 22px; padding: 12px; font-size: .82rem; color: var(--muted); }
.chat-line { margin-bottom: 7px; }
.chat-line.system { color: var(--cyan); }
.chat-line.zone { color: var(--gold); }

.controls { position: absolute; left: 24px; top: 160px; width: 178px; border-radius: 20px; padding: 13px; display: grid; gap: 5px; color: var(--muted); font-size: .78rem; }
.controls b { color: #fff; margin-bottom: 4px; }

.window { position: fixed; z-index: 20; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(1100px, calc(100vw - 48px)); max-height: min(760px, calc(100vh - 48px)); border-radius: 30px; overflow: hidden; pointer-events: auto; }
.window.hidden { display: none; }
.window-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.035); }
.window-header h2 { margin: 0; font-size: 1.4rem; letter-spacing: .04em; }
.window-header p { margin: 4px 0 0; color: var(--muted); }
.close-btn { width: 42px; height: 42px; border: 1px solid var(--line); background: rgba(255,255,255,.06); border-radius: 14px; cursor: pointer; font-size: 1.5rem; }
.close-btn:hover { border-color: var(--line-bright); background: rgba(255,255,255,.12); }
.tabs { display: flex; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.tab { border: 1px solid transparent; padding: 10px 16px; border-radius: 14px; background: transparent; color: var(--muted); cursor: pointer; }
.tab:hover, .tab.active { color: #fff; border-color: rgba(105, 215, 255, .25); background: rgba(105, 215, 255, .08); }
.window-body { padding: 20px; overflow: auto; max-height: 584px; }
.tab-page { display: none; }
.tab-page.active { display: block; }
.inventory-layout { display: grid; grid-template-columns: 210px minmax(420px, 1fr) 260px; gap: 18px; }
.paper-doll, .bag-section, .item-inspector, .avatar-card, .systems-copy { border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 24px; padding: 16px; }
.doll-title { color: var(--gold); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; margin-bottom: 10px; }
.equipment-slot { min-height: 66px; margin-bottom: 10px; border-radius: 18px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.16); padding: 11px; cursor: pointer; }
.equipment-slot small { display: block; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .62rem; margin-bottom: 5px; }
.equipment-slot strong { font-size: .86rem; }
.equipment-slot.filled { border-color: rgba(234, 199, 104, .32); background: rgba(234, 199, 104, .07); }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-heading h3 { margin: 0; }
.section-heading span { color: var(--muted); }
.inventory-grid { display: grid; grid-template-columns: repeat(6, minmax(66px, 1fr)); gap: 10px; }
.item-tile { min-height: 78px; border-radius: 18px; border: 1px solid rgba(255,255,255,.12); background: rgba(0,0,0,.18); padding: 10px; cursor: pointer; display: grid; gap: 6px; align-content: center; transition: transform .14s ease, border-color .14s ease, background .14s ease; }
.item-tile:hover, .item-tile.selected { transform: translateY(-2px); border-color: rgba(105, 215, 255, .45); background: rgba(105, 215, 255, .07); }
.item-tile.empty { cursor: default; opacity: .35; }
.item-tile.empty:hover { transform: none; border-color: rgba(255,255,255,.12); background: rgba(0,0,0,.18); }
.item-icon { font-size: 1.35rem; }
.item-name { font-size: .72rem; line-height: 1.15; color: #fff; }
.item-type { color: var(--muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; }
.rarity-common { box-shadow: inset 0 0 0 1px rgba(255,255,255,.03); }
.rarity-uncommon { box-shadow: inset 0 0 0 1px rgba(112, 240, 166,.26); }
.rarity-rare { box-shadow: inset 0 0 0 1px rgba(105, 215, 255,.30); }
.rarity-epic { box-shadow: inset 0 0 0 1px rgba(182, 144, 255,.34); }
.item-inspector h3 { margin-top: 0; }
.item-inspector p { color: var(--muted); line-height: 1.45; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.action-btn { border: 1px solid rgba(105, 215, 255, .28); background: rgba(105, 215, 255, .08); color: #fff; border-radius: 14px; padding: 9px 12px; cursor: pointer; }
.action-btn:hover { background: rgba(105, 215, 255, .16); }
.hint { color: var(--muted); margin-bottom: 0; font-size: .82rem; }
.equipment-overview { display: grid; grid-template-columns: 260px 1fr; gap: 18px; }
.avatar-card { display: grid; place-items: center; text-align: center; min-height: 330px; }
.avatar-ring { width: 134px; height: 134px; border-radius: 44px; display: grid; place-items: center; font-size: 2.4rem; color: var(--gold); border: 1px solid rgba(234,199,104,.28); background: radial-gradient(circle, rgba(234,199,104,.17), transparent 72%); }
.summary-grid, .stats-layout, .system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.summary-item, .stat-card, .system-grid article { border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 20px; padding: 16px; }
.summary-item span, .stat-card span, .system-grid article span { display: block; color: var(--muted); font-size: .82rem; margin-top: 6px; line-height: 1.4; }
.stat-card strong { display: block; font-size: 1.7rem; margin-top: 6px; color: var(--gold); }
.systems-copy h3 { margin-top: 0; }

#toast-stack { position: fixed; z-index: 50; left: 50%; top: 20px; transform: translateX(-50%); display: grid; gap: 10px; pointer-events: none; }
.toast { min-width: 260px; max-width: 520px; border: 1px solid rgba(255,255,255,.16); background: rgba(8, 14, 24, .92); border-radius: 18px; padding: 12px 16px; box-shadow: 0 18px 48px rgba(0,0,0,.32); animation: toastIn .28s ease forwards; color: #fff; }
.toast small { display: block; color: var(--muted); margin-top: 3px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 900px) {
  .character-frame, .quest-tracker, .chat-box, .controls { transform: scale(.84); transform-origin: top left; }
  .quest-tracker { transform-origin: top right; }
  .chat-box { transform-origin: bottom left; }
  .inventory-layout, .equipment-overview { grid-template-columns: 1fr; }
  .inventory-grid { grid-template-columns: repeat(4, 1fr); }
  .hotbar { grid-template-columns: repeat(4, 58px); }
}
