/* Aetheria Online — ProjectW — HUD & UI styling */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #05060a; }
body {
  font-family: "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #eef1f6; user-select: none; -webkit-user-select: none; touch-action: none;
}
:root {
  --panel: rgba(14, 18, 30, 0.86);
  --panel-line: rgba(255, 255, 255, 0.14);
  --gold: #e8c878;
  --gold-deep: #b8923a;
}
#game-root { position: fixed; inset: 0; }
#game-root canvas { display: block; }
button { font-family: inherit; cursor: pointer; }

/* ───────── HUD ───────── */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud input { pointer-events: auto; }

/* bars */
.bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18); overflow: hidden; margin-top: 5px; }
.bar .fill { position: absolute; inset: 0; width: 0%; border-radius: 8px 0 0 8px; transition: width .18s ease; }
.bar.hp .fill { background: linear-gradient(#6ee07a, #3aa84a); }
.bar.mp .fill { background: linear-gradient(#6fb8ff, #2f7fe0); }
.bar.xp { height: 8px; }
.bar.xp .fill { background: linear-gradient(#ffe08a, #e0a832); }
.bar.thp .fill { background: linear-gradient(#ff8a8a, #d83a3a); }
.bar-text { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; text-shadow: 0 1px 2px #000; letter-spacing: .3px; }

/* player frame */
#player-frame { position: absolute; top: 14px; left: 14px; width: 232px;
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px;
  padding: 10px 12px; backdrop-filter: blur(6px); }
.pf-top { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; }
.pf-top #pf-name { color: var(--gold); font-size: 15px; }
.pf-lv { font-size: 12px; color: #cdd6e6; }
.pf-lv b { color: #fff; }
.pf-gold { margin-top: 6px; font-size: 12px; color: #ffe08a; }

/* target frame */
#target-frame { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  width: 240px; background: var(--panel); border: 1px solid rgba(216,58,58,0.4); border-radius: 12px;
  padding: 8px 12px; opacity: 0; transition: opacity .15s; }
#target-frame.show { opacity: 1; }
.tf-top { display: flex; justify-content: space-between; font-weight: 700; font-size: 13px; }
.tf-top #tf-name { color: #ff9a9a; }
#tf-level { color: #cdd6e6; font-size: 11px; }

/* top-right cluster */
#top-right { position: absolute; top: 14px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#clock { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 18px;
  padding: 4px 14px; font-size: 13px; font-weight: 700; }
#minimap { width: 150px; height: 150px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--gold-deep); box-shadow: 0 0 12px rgba(0,0,0,0.5); background: #14201a; }
#menu-buttons { display: flex; gap: 6px; }
#menu-buttons button { width: 40px; height: 40px; font-size: 18px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--panel-line); color: #fff; }
#menu-buttons button:hover { border-color: var(--gold); }

/* quest tracker */
#quest-tracker { position: absolute; top: 218px; right: 14px; width: 230px;
  background: var(--panel); border: 1px solid var(--panel-line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 9px 11px; font-size: 12px; line-height: 1.5; }
.qt-title { color: var(--gold); font-weight: 700; margin-bottom: 3px; }
.qt-obj { color: #c4cce0; font-size: 11px; }
.qt-prog { margin-top: 4px; color: #ffd23f; font-weight: 600; }
.qt-prog.done { color: #6ee07a; }

/* chat */
#chat { position: absolute; bottom: 14px; left: 14px; width: 320px; max-width: 42vw; }
#chat-log { height: 132px; overflow-y: auto; background: rgba(8,10,18,0.55); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; line-height: 1.5; scrollbar-width: thin; }
#chat-log::-webkit-scrollbar { width: 5px; }
#chat-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
.chat-line { margin-bottom: 2px; word-break: break-word; }
.chat-line .sys { color: #9fb0c8; }
.chat-line .sys b { color: var(--gold); }
.rar-common { color: #cfd2d6 !important; } .rar-uncommon { color: #5fd06a !important; }
.rar-rare { color: #4d9bff !important; } .rar-epic { color: #c06bff !important; }
#chat-input { width: 100%; margin-top: 5px; padding: 6px 10px; font-size: 12px;
  background: rgba(8,10,18,0.8); border: 1px solid var(--panel-line); border-radius: 8px; color: #fff; }
#chat-input:focus { outline: none; border-color: var(--gold); }

/* hotbar */
#hotbar { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; pointer-events: auto; }
.slot { position: relative; width: 56px; height: 56px; border-radius: 11px;
  background: var(--panel); border: 1px solid var(--panel-line); overflow: hidden;
  display: flex; align-items: center; justify-content: center; }
.slot .ic { font-size: 26px; }
.slot .key { position: absolute; top: 2px; left: 5px; font-size: 10px; color: #9fb0c8; font-weight: 700; }
.slot .nm { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 9px; color: #c4cce0; }
.slot .cnt { position: absolute; bottom: 2px; right: 4px; font-size: 11px; font-weight: 700; color: #ffe08a; }
.slot .cd { position: absolute; top: 0; left: 0; right: 0; height: 0%; background: rgba(0,0,0,0.66); }
.slot.ready { border-color: var(--gold); box-shadow: 0 0 8px rgba(232,200,120,0.35); }
.slot.nomp { filter: grayscale(0.6) brightness(0.7); }
.slot:active { transform: scale(0.94); }

/* mobile buttons */
#mobile-buttons { position: absolute; right: 18px; bottom: 92px; display: none; flex-direction: column; gap: 10px; }
#mobile-buttons button { width: 54px; height: 54px; font-size: 22px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--panel-line); color: #fff; }
body.touch #mobile-buttons { display: flex; }

/* joystick (touch only) */
#joystick { position: fixed; left: 22px; bottom: 26px; width: 124px; height: 124px; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: 2px solid rgba(255,255,255,0.18); z-index: 15; display: none; touch-action: none; }
#joyknob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: rgba(232,200,120,0.55); border: 2px solid rgba(255,255,255,0.5); }
body.touch #joystick { display: block; }

/* toast */
#toast { position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  background: rgba(8,10,18,0.9); border: 1px solid var(--gold-deep); border-radius: 20px;
  padding: 7px 18px; font-size: 13px; font-weight: 600; opacity: 0; transition: opacity .25s; }
#toast.show { opacity: 1; }

/* ───────── nameplates (CSS2D) ───────── */
.nameplate, .float-text { pointer-events: none; }
.nameplate { text-align: center; transform: translateZ(0); white-space: nowrap;
  font-size: 11px; text-shadow: 0 1px 3px #000, 0 0 4px #000; transition: transform .1s; }
.nameplate.hit { transform: scale(1.18); }
.np-name { font-weight: 700; }
.nameplate.mob .np-name { color: #ff9a9a; }
.nameplate.npc .np-name { color: #ffd23f; }
.nameplate.bot .np-name { color: #7ec8ff; }
.np-lv { color: #cdd6e6; font-weight: 500; }
.np-sub { font-size: 9px; color: #b8c2d6; }
.np-bar { width: 56px; height: 5px; margin: 2px auto 0; background: rgba(0,0,0,0.6);
  border: 1px solid rgba(0,0,0,0.8); border-radius: 3px; overflow: hidden; }
.np-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(#ff7a7a, #d83a3a); }
.quest-marker { font-weight: 900; font-size: 16px; line-height: 1;
  animation: bob 1.1s ease-in-out infinite; }
.quest-marker.available { color: #ffd23f; }
.quest-marker.complete { color: #ffd23f; }
.quest-marker.progress { color: #b8c2d6; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* floating combat text */
.float-text { font-weight: 800; font-size: 14px; text-shadow: 0 1px 3px #000, 0 0 4px #000; white-space: nowrap; }
.float-text.big { font-size: 20px; }

/* ───────── panels ───────── */
.panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -46%) scale(0.96);
  width: min(440px, 92vw); max-height: 80vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--gold-deep); border-radius: 16px;
  padding: 16px; z-index: 30; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.panel.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.panel-head { display: flex; justify-content: space-between; align-items: center;
  font-size: 17px; font-weight: 700; color: var(--gold); margin-bottom: 12px;
  border-bottom: 1px solid var(--panel-line); padding-bottom: 8px; }
.panel-head .x { background: none; border: none; color: #cdd6e6; font-size: 16px; }
.panel-head .x:hover { color: #fff; }
.panel-hint { margin-top: 10px; font-size: 11px; color: #9fb0c8; text-align: center; }

.inv-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.inv-grid .empty { grid-column: 1 / -1; text-align: center; color: #9fb0c8; padding: 24px; }
.item { position: relative; aspect-ratio: 1; border-radius: 9px; background: rgba(0,0,0,0.35);
  border: 2px solid #555; display: flex; align-items: center; justify-content: center; }
.item:hover { filter: brightness(1.2); }
.item .ic { font-size: 22px; }
.item .ct { position: absolute; bottom: 1px; right: 4px; font-size: 11px; font-weight: 700; }
.item .eq { position: absolute; top: 1px; left: 3px; font-size: 9px; font-weight: 800; color: #6ee07a; }
.item.equipped { box-shadow: 0 0 8px rgba(110,224,122,0.6); }
.item.rar-common { border-color: #888; } .item.rar-uncommon { border-color: #4caf50; }
.item.rar-rare { border-color: #2f80ed; } .item.rar-epic { border-color: #b15bff; box-shadow: 0 0 8px rgba(177,91,255,0.5); }
.inv-equip { margin-top: 12px; font-size: 12px; color: #c4cce0; text-align: center; }
.inv-equip b { color: var(--gold); }

#char-body .char-head { font-size: 15px; color: var(--gold); margin-bottom: 10px; }
#char-body table { width: 100%; font-size: 13px; border-collapse: collapse; }
#char-body td { padding: 5px 4px; border-bottom: 1px solid rgba(255,255,255,0.08); }
#char-body td:first-child { color: #9fb0c8; } #char-body td:last-child { text-align: right; font-weight: 600; }
#char-body .plus { color: #6ee07a; font-size: 11px; }

#quest-body .q-row { border-left: 3px solid #555; padding: 8px 11px; margin-bottom: 8px; border-radius: 6px; background: rgba(0,0,0,0.25); }
.q-row.done { border-color: #4caf50; opacity: 0.7; } .q-row.active { border-color: var(--gold); }
.q-row.avail { border-color: #2f80ed; } .q-row.locked { opacity: 0.45; }
.q-tt { font-weight: 700; } .q-ds { font-size: 11px; color: #c4cce0; margin: 2px 0; } .q-st { font-size: 11px; color: #ffd23f; }

/* dialogue */
#dialogue { position: fixed; bottom: 96px; left: 50%; transform: translate(-50%, 12px);
  width: min(520px, 92vw); background: var(--panel); border: 1px solid var(--gold-deep);
  border-radius: 14px; padding: 16px 18px; z-index: 32; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
#dialogue.open { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#dlg-title { color: var(--gold); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
#dlg-body { font-size: 13px; line-height: 1.6; color: #e4e9f2; }
.dlg-reward { margin-top: 8px; font-size: 12px; color: #ffd23f; }
#dlg-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: flex-end; }
#dlg-actions button { padding: 8px 18px; border-radius: 9px; border: 1px solid var(--gold-deep);
  background: linear-gradient(#3a3320, #221d10); color: var(--gold); font-weight: 700; font-size: 13px; }
#dlg-actions #dlg-close { color: #cdd6e6; border-color: var(--panel-line); background: rgba(255,255,255,0.05); }
#dlg-actions button:hover { filter: brightness(1.2); }

/* level up */
#levelup { position: fixed; top: 32%; left: 50%; transform: translateX(-50%); text-align: center;
  z-index: 28; opacity: 0; pointer-events: none; }
#levelup.show { animation: lvlpop 2.2s ease-out forwards; }
.lvl-big { font-size: 46px; font-weight: 900; color: var(--gold); text-shadow: 0 0 20px rgba(232,200,120,0.8), 0 2px 6px #000; letter-spacing: 2px; }
.lvl-sub { font-size: 15px; color: #fff; text-shadow: 0 2px 4px #000; margin-top: 4px; }
@keyframes lvlpop { 0% { opacity: 0; transform: translateX(-50%) scale(0.6); } 18% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  30% { transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }

/* hurt vignette */
#hurt { position: fixed; inset: 0; z-index: 18; pointer-events: none; opacity: 0;
  box-shadow: inset 0 0 140px 40px rgba(200,0,0,0.6); }
#hurt.show { animation: hurt .4s ease-out; }
@keyframes hurt { 0% { opacity: 1; } 100% { opacity: 0; } }

/* death */
#death { position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center;
  background: rgba(20,0,0,0.7); backdrop-filter: blur(3px); }
#death.show { display: flex; }
.death-box { text-align: center; background: var(--panel); border: 1px solid #803030; border-radius: 16px; padding: 32px 40px; }
.death-box h2 { font-size: 30px; margin-bottom: 8px; }
.death-box p { color: #c4cce0; font-size: 13px; margin-bottom: 18px; }
#respawn-btn { padding: 11px 26px; border-radius: 10px; border: 1px solid var(--gold-deep);
  background: linear-gradient(#3a3320, #221d10); color: var(--gold); font-weight: 700; font-size: 15px; }
#respawn-btn:hover { filter: brightness(1.2); }

/* ───────── start menu ───────── */
#start { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(20,30,60,0.55), rgba(4,6,12,0.92));
  overflow-y: auto; transition: opacity .5s; }
#start.hidden { opacity: 0; pointer-events: none; }
.start-inner { text-align: center; padding: 30px 20px; max-width: 760px; }
.start-inner h1 { font-size: clamp(40px, 9vw, 76px); font-weight: 900; letter-spacing: 3px;
  color: var(--gold); text-shadow: 0 0 30px rgba(232,200,120,0.5), 0 4px 10px #000; line-height: 1; }
.start-inner h1 span { display: block; font-size: 0.4em; letter-spacing: 12px; color: #cdd6e6; margin-top: 6px; }
.tagline { color: #b8c2d6; margin-top: 12px; font-size: 14px; }
.class-grid { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 28px 0 20px; }
.class-card { width: 190px; padding: 20px 14px; border-radius: 16px; cursor: pointer;
  background: rgba(14,18,30,0.7); border: 2px solid var(--panel-line); transition: all .2s; }
.class-card:hover { transform: translateY(-4px); border-color: rgba(232,200,120,0.6); }
.class-card.sel { border-color: var(--gold); background: rgba(40,34,18,0.7); box-shadow: 0 0 18px rgba(232,200,120,0.35); }
.cc-icon { font-size: 44px; } .cc-name { font-size: 19px; font-weight: 700; margin: 6px 0; color: var(--gold); }
.cc-desc { font-size: 12px; color: #b8c2d6; line-height: 1.5; }
#name-input { display: block; margin: 0 auto 14px; width: min(300px, 80vw); padding: 11px 16px; text-align: center;
  font-size: 15px; border-radius: 10px; border: 1px solid var(--panel-line); background: rgba(8,10,18,0.85); color: #fff; }
#name-input:focus { outline: none; border-color: var(--gold); }
#enter-btn { padding: 13px 44px; font-size: 17px; font-weight: 800; border-radius: 12px; border: none;
  background: linear-gradient(#e8c878, #b8923a); color: #2a2110; box-shadow: 0 6px 18px rgba(232,200,120,0.35); }
#enter-btn:hover { filter: brightness(1.08); transform: translateY(-2px); }
.controls { margin-top: 24px; font-size: 12px; color: #9fb0c8; line-height: 2; max-width: 620px; margin-left: auto; margin-right: auto; }
.controls b { color: var(--gold); }
.controls kbd { background: rgba(255,255,255,0.1); border: 1px solid var(--panel-line); border-radius: 4px;
  padding: 1px 6px; font-size: 11px; margin: 0 1px; }
.mobile-note { margin-top: 8px; color: #7e8aa0; }

/* fatal */
#fatal { position: fixed; inset: 0; z-index: 60; display: none; align-items: center; justify-content: center; background: rgba(4,6,12,0.95); }
.fatal-box { max-width: 560px; padding: 30px; text-align: center; }
.fatal-box h2 { color: #ff7a7a; margin-bottom: 10px; }
.fatal-box p { color: #c4cce0; font-size: 13px; margin-bottom: 14px; }
.fatal-box pre { text-align: left; font-size: 11px; color: #9fb0c8; background: rgba(0,0,0,0.5);
  padding: 12px; border-radius: 8px; overflow: auto; max-height: 200px; }

@media (max-width: 640px) {
  #player-frame { width: 190px; } #chat { width: 60vw; } #chat-log { height: 88px; }
  #minimap { width: 116px; height: 116px; } #quest-tracker { top: 180px; width: 180px; font-size: 11px; }
  .slot { width: 48px; height: 48px; } .slot .ic { font-size: 22px; }
  #target-frame { width: 200px; }
}
