/* ============ Embervale UI ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --gold: #e8b84a; --gold-dim: #b8863a;
  --parchment: #e8dcc0; --ink: #2a2018;
  --panel: rgba(24, 20, 16, 0.92); --panel-border: #6a5638;
  --hp: #d84a3a; --mp: #4a8ad8; --sp: #6ab84a;
  --accent: #ff7a3a;
}
html, body { height: 100%; overflow: hidden; background: #0a0806; font-family: 'Segoe UI', system-ui, sans-serif; color: #e8e0d0; }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }

/* ============ LANDING ============ */
#landing, #charselect { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50; overflow-y: auto; }
.land-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 20% 100%, rgba(255, 122, 58, 0.25), transparent 55%),
    radial-gradient(ellipse at 80% 0%, rgba(74, 138, 216, 0.18), transparent 55%),
    linear-gradient(180deg, #141a28 0%, #1c1610 60%, #241a10 100%);
}
.land-bg::after { content: ''; position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 200, 120, 0.35) 1px, transparent 1.5px); background-size: 90px 110px; animation: emberdrift 30s linear infinite; opacity: 0.5; }
@keyframes emberdrift { from { background-position: 0 100vh; } to { background-position: 40px 0; } }
.land-inner { position: relative; text-align: center; padding: 40px 16px; max-width: 560px; width: 100%; }
.logo { font-size: clamp(52px, 9vw, 88px); letter-spacing: 0.08em; font-weight: 900; color: var(--parchment); text-shadow: 0 4px 24px rgba(255, 122, 58, 0.55), 0 2px 0 #000; }
.logo span { color: var(--accent); }
.tagline { margin: 6px 0 26px; color: #c9b89a; font-style: italic; letter-spacing: 0.04em; }
.land-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; padding: 22px; margin: 0 auto; max-width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,0.6); }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tab { flex: 1; padding: 9px; background: transparent; border: 1px solid var(--panel-border); color: #b8a888; border-radius: 8px; font-size: 14px; }
.tab.active { background: var(--gold-dim); color: #fff; border-color: var(--gold); }
#auth-form input, #char-create input[type="text"] { width: 100%; padding: 11px 12px; margin-bottom: 10px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); border-radius: 8px; color: #fff; font-size: 15px; outline: none; }
#auth-form input:focus { border-color: var(--gold); }
.btn-primary { width: 100%; padding: 12px; background: linear-gradient(180deg, var(--accent), #c9541e); border: none; border-radius: 8px; color: #fff; font-weight: 700; font-size: 16px; letter-spacing: 0.03em; box-shadow: 0 4px 14px rgba(255, 122, 58, 0.35); transition: transform 0.1s; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { margin-top: 18px; background: none; border: 1px solid var(--panel-border); color: #b8a888; padding: 8px 22px; border-radius: 8px; }
.err { color: #ff8a7a; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.motd { margin-top: 12px; font-size: 12px; color: #9a8a6a; font-style: italic; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 26px; font-size: 13px; color: #c9b89a; }
.features div { background: rgba(0,0,0,0.3); border: 1px solid rgba(106, 86, 56, 0.5); border-radius: 8px; padding: 10px; }

/* char select */
.cs-title { font-size: 34px; color: var(--parchment); margin-bottom: 18px; text-shadow: 0 2px 12px rgba(255,122,58,0.4); }
.char-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.char-card { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; padding: 12px 16px; }
.char-card .cc-name { font-weight: 700; color: var(--gold); font-size: 17px; }
.char-card .cc-sub { font-size: 12px; color: #9a8a6a; }
.char-card button { padding: 8px 18px; border-radius: 8px; border: none; }
.cc-play { background: var(--gold-dim); color: #fff; font-weight: 700; }
.cc-del { background: none; border: 1px solid #6a3a2a !important; color: #c96a4a; margin-left: 8px; }
#char-create h3 { margin-bottom: 10px; color: var(--parchment); }
.appearance-row { display: flex; gap: 10px; justify-content: center; margin: 8px 0 12px; flex-wrap: wrap; }
.appearance-row label { font-size: 12px; color: #b8a888; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.appearance-row input[type="color"] { width: 44px; height: 30px; border: 1px solid var(--panel-border); border-radius: 6px; background: none; }

/* ============ GAME HUD ============ */
#game { position: fixed; inset: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 16px; align-items: center; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 999px; padding: 6px 20px; font-size: 14px; z-index: 5; }
#loc-name { color: var(--gold); font-weight: 700; letter-spacing: 0.04em; }
#online-count { color: #8ab86a; font-size: 12px; }
#minimap-wrap { position: absolute; top: 12px; right: 12px; border: 2px solid var(--panel-border); border-radius: 50%; overflow: hidden; box-shadow: 0 6px 20px rgba(0,0,0,0.5); z-index: 5; }
#minimap { display: block; }

#vitals { position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%); width: 340px; display: flex; flex-direction: column; gap: 4px; z-index: 5; }
.bar { position: relative; height: 16px; background: rgba(0,0,0,0.55); border: 1px solid rgba(255,255,255,0.15); border-radius: 8px; overflow: hidden; }
.bar div { height: 100%; width: 100%; transition: width 0.15s; border-radius: 7px; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; color: #fff; text-shadow: 0 1px 2px #000; }
.bar.hp div { background: linear-gradient(180deg, #ff6a5a, var(--hp)); }
.bar.mp div { background: linear-gradient(180deg, #6aa8ff, var(--mp)); }
.bar.sp div { background: linear-gradient(180deg, #8ad86a, var(--sp)); }

#hotbar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 8px; z-index: 5; }
.hb-slot { width: 56px; height: 56px; background: var(--panel); border: 2px solid var(--panel-border); border-radius: 10px; position: relative; display: flex; align-items: center; justify-content: center; font-size: 26px; user-select: none; }
.hb-slot .key { position: absolute; top: 2px; left: 5px; font-size: 10px; color: #9a8a6a; }
.hb-slot .cd { position: absolute; inset: 0; background: rgba(0,0,0,0.65); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 15px; color: #fff; }
.hb-slot:hover { border-color: var(--gold); }
#buffbar { position: absolute; left: 50%; bottom: 145px; transform: translateX(-50%); display: flex; gap: 6px; z-index: 5; }
.buff { background: var(--panel); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 3px 8px; font-size: 12px; }

#chatbox { position: absolute; left: 12px; bottom: 12px; width: 360px; z-index: 5; }
#chatlog { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; font-size: 13px; padding: 8px; background: rgba(10, 8, 6, 0.55); border-radius: 10px; scrollbar-width: thin; }
#chatlog .warn { color: #ff9a7a; }
#chatlog .quest { color: #e8c84a; }
#chatlog .level { color: #8ae8a8; }
#chatlog .chat-name { color: #8ab8e8; font-weight: 700; }
#chatlog .chat-admin { color: #ff8a5a; font-weight: 700; }
#chatlog .sys { color: #9a8a7a; font-style: italic; }
#chat-input { width: 100%; margin-top: 4px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 8px; color: #fff; outline: none; }

#interact-prompt { position: absolute; left: 50%; bottom: 175px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: 6px 16px; font-size: 14px; z-index: 5; }
#interact-prompt b { color: var(--gold); }
#motd-banner { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--gold); color: var(--gold); border-radius: 8px; padding: 8px 20px; z-index: 20; }

#menubar { position: absolute; right: 12px; top: 210px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#menubar button { width: 46px; height: 46px; font-size: 22px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 10px; }
#menubar button:hover { border-color: var(--gold); }

/* ============ PANELS ============ */
.panel { position: absolute; top: 60px; right: 70px; width: 420px; max-width: calc(100vw - 90px); max-height: calc(100vh - 140px); background: var(--panel); border: 1px solid var(--panel-border); border-radius: 14px; z-index: 10; display: flex; flex-direction: column; box-shadow: 0 16px 50px rgba(0,0,0,0.6); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--panel-border); }
.panel-head h3 { color: var(--gold); font-size: 17px; letter-spacing: 0.03em; }
.panel-close { background: none; border: none; color: #b8a888; font-size: 20px; }
.panel-body { padding: 12px 16px; overflow-y: auto; scrollbar-width: thin; }

/* inventory */
.inv-gold { color: var(--gold); font-weight: 700; margin-bottom: 8px; }
.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.inv-slot { aspect-ratio: 1; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 22px; position: relative; cursor: pointer; }
.inv-slot:hover { border-color: var(--gold); }
.inv-slot .qty { position: absolute; bottom: 1px; right: 4px; font-size: 10px; color: #e8e0d0; text-shadow: 0 1px 2px #000; }
.inv-slot.fine { border-color: #6ab8e8; }
.inv-slot.master { border-color: #c98aff; }
.inv-slot.ench { box-shadow: inset 0 0 8px rgba(200, 138, 255, 0.5); }
.equip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.equip-slot { aspect-ratio: 1; background: rgba(40, 32, 20, 0.5); border: 1px dashed var(--panel-border); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 20px; cursor: pointer; }
.equip-slot small { font-size: 8px; color: #9a8a6a; }
.equip-slot.filled { border-style: solid; }

/* tooltip */
#tooltip { position: fixed; pointer-events: none; background: rgba(14, 11, 8, 0.97); border: 1px solid var(--gold-dim); border-radius: 8px; padding: 10px 12px; font-size: 12px; max-width: 260px; z-index: 100; }
#tooltip h4 { color: var(--gold); font-size: 14px; margin-bottom: 4px; }
#tooltip .tt-type { color: #9a8a6a; font-style: italic; margin-bottom: 4px; }
#tooltip .tt-stat { color: #8ab8e8; }
#tooltip .tt-ench { color: #c98aff; }

/* skills */
.skill-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px solid rgba(106, 86, 56, 0.3); cursor: pointer; }
.skill-row .si { font-size: 20px; width: 28px; }
.skill-row .sn { flex: 1; }
.skill-row .sl { color: var(--gold); font-weight: 700; }
.skill-xpbar { height: 5px; background: rgba(0,0,0,0.5); border-radius: 3px; margin-top: 3px; }
.skill-xpbar div { height: 100%; background: var(--gold-dim); border-radius: 3px; }
.perk-tag { font-size: 10px; background: rgba(200, 138, 255, 0.2); color: #c98aff; border-radius: 4px; padding: 1px 5px; margin-left: 4px; }

/* quests */
.quest-item { padding: 10px; border: 1px solid var(--panel-border); border-radius: 10px; margin-bottom: 8px; }
.quest-item h4 { color: var(--gold); }
.quest-item .q-desc { font-size: 12px; color: #c9b89a; margin: 4px 0; }
.quest-item .q-obj { font-size: 12px; color: #8ab8e8; }
.quest-item.done h4 { color: #8ae8a8; }

/* crafting */
.craft-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.craft-tabs button { padding: 5px 12px; font-size: 12px; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border); color: #c9b89a; border-radius: 6px; }
.craft-tabs button.active { border-color: var(--gold); color: var(--gold); }
.recipe { display: flex; justify-content: space-between; align-items: center; padding: 7px 6px; border-bottom: 1px solid rgba(106, 86, 56, 0.3); font-size: 13px; }
.recipe .r-in { font-size: 11px; color: #9a8a6a; }
.recipe button { padding: 5px 14px; background: var(--gold-dim); border: none; border-radius: 6px; color: #fff; font-weight: 600; }
.recipe button:disabled { background: #4a4038; color: #7a6a5a; cursor: default; }
.recipe.locked { opacity: 0.45; }

/* dialogue */
#dialogue { position: absolute; left: 50%; bottom: 160px; transform: translateX(-50%); width: 520px; max-width: 92vw; background: var(--panel); border: 2px solid var(--gold-dim); border-radius: 14px; padding: 16px 20px; z-index: 15; }
#dlg-name { color: var(--gold); font-weight: 800; font-size: 16px; margin-bottom: 6px; }
#dlg-text { font-size: 14px; line-height: 1.5; color: #e8dcc0; margin-bottom: 12px; }
#dlg-options { display: flex; flex-direction: column; gap: 6px; }
#dlg-options button { text-align: left; padding: 8px 12px; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 8px; color: #c9d8e8; font-size: 13px; }
#dlg-options button:hover { border-color: var(--gold); color: #fff; }

/* shop */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-col h4 { color: var(--gold); font-size: 13px; margin-bottom: 6px; }
.shop-row { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 4px 2px; border-bottom: 1px solid rgba(106, 86, 56, 0.25); }
.shop-row button { padding: 3px 10px; font-size: 11px; background: var(--gold-dim); border: none; border-radius: 5px; color: #fff; }

/* settings */
.set-group { margin-bottom: 14px; }
.set-group h4 { color: var(--gold); font-size: 13px; margin-bottom: 8px; }
.set-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.set-row input[type="range"] { width: 140px; accent-color: var(--accent); }
.keybind-btn { min-width: 90px; padding: 4px 10px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); border-radius: 6px; color: var(--gold); font-size: 12px; }
.keybind-btn.listening { border-color: var(--accent); color: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* perk modal */
#perk-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 60; }
.perk-card { background: var(--panel); border: 2px solid var(--gold); border-radius: 16px; padding: 26px; width: 480px; max-width: 92vw; text-align: center; }
.perk-card h3 { color: var(--gold); margin-bottom: 4px; }
.perk-card p.sub { color: #9a8a6a; font-size: 13px; margin-bottom: 16px; }
.perk-opts { display: flex; gap: 12px; }
.perk-opt { flex: 1; background: rgba(0,0,0,0.35); border: 1px solid var(--panel-border); border-radius: 12px; padding: 16px 12px; cursor: pointer; transition: all 0.15s; }
.perk-opt:hover { border-color: var(--gold); transform: translateY(-3px); }
.perk-opt h4 { color: #c98aff; margin-bottom: 6px; }
.perk-opt div { font-size: 12px; color: #c9b89a; }

/* admin */
#panel-admin { width: 480px; }
.adm-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.adm-tabs button { padding: 5px 10px; font-size: 12px; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border); color: #c9b89a; border-radius: 6px; }
.adm-tabs button.active { border-color: var(--accent); color: var(--accent); }
.adm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.adm-item { padding: 8px 6px; font-size: 12px; background: rgba(0,0,0,0.3); border: 1px solid var(--panel-border); border-radius: 8px; color: #e8e0d0; text-align: center; cursor: pointer; }
.adm-item:hover, .adm-item.active { border-color: var(--accent); color: var(--accent); }
.adm-row { display: flex; gap: 6px; margin: 8px 0; align-items: center; flex-wrap: wrap; }
.adm-row input, .adm-row select { padding: 6px 8px; background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border); border-radius: 6px; color: #fff; font-size: 12px; flex: 1; min-width: 60px; }
.adm-row button, .adm-action { padding: 7px 12px; background: #7a3a2a; border: 1px solid var(--accent); border-radius: 6px; color: #fff; font-size: 12px; }
.adm-note { font-size: 11px; color: #9a8a6a; font-style: italic; margin-top: 6px; }
#admin-placing-banner { position: absolute; top: 100px; left: 50%; transform: translateX(-50%); background: #7a3a2a; border: 1px solid var(--accent); border-radius: 8px; padding: 8px 18px; z-index: 30; }

#death-flash { position: absolute; inset: 0; background: radial-gradient(ellipse, transparent 40%, rgba(160, 20, 20, 0.5)); opacity: 0; pointer-events: none; transition: opacity 0.4s; z-index: 40; }

@media (max-width: 720px) {
  #chatbox { width: 60vw; }
  .panel { right: 8px; width: calc(100vw - 70px); }
}
