/* Realm of Aldenmoor — emerald & gold on deep slate, high-fantasy serif display + clean sans */
@font-face {
  font-family: 'Cinzel';
  src: url('../fonts/cinzel-bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
:root {
  --slate-900: #0c1216;
  --slate-800: #121b21;
  --slate-700: #1a2630;
  --slate-600: #24333f;
  --emerald: #2fae6e;
  --emerald-bright: #4be08e;
  --emerald-dim: #1c7a4c;
  --gold: #d8b45a;
  --gold-bright: #f4d788;
  --parchment: #e8ddc0;
  --ink: #d5dde2;
  --danger: #c84b3c;
  --serif: 'Cinzel', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--slate-900); }
body { font-family: var(--sans); color: var(--ink); }
#game-root { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Loading ---------- */
#loading-overlay {
  position: absolute; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #16222b 0%, #0a0f13 80%);
}
.load-text { font-family: var(--serif); color: var(--gold); font-size: 20px; letter-spacing: 3px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .45; } 50% { opacity: 1; } }

/* ---------- Title screen ---------- */
#title-screen {
  position: absolute; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(9,14,18,.72) 0%, rgba(9,14,18,.45) 45%, rgba(9,14,18,.85) 100%);
}
.title-inner { text-align: center; padding: 34px 46px; }
.title-crest { font-size: 44px; color: var(--gold); text-shadow: 0 0 24px rgba(216,180,90,.5); }
.title-name {
  font-family: var(--serif); font-size: clamp(34px, 6vw, 62px); color: var(--gold-bright);
  letter-spacing: 4px; margin: 8px 0 4px;
  text-shadow: 0 2px 0 #6b5424, 0 0 34px rgba(216,180,90,.35);
}
.title-sub { font-size: 12px; letter-spacing: 5px; color: var(--emerald-bright); margin-bottom: 18px; }
.title-world-stats { font-size: 13px; color: var(--ink); opacity: .8; margin-bottom: 24px; line-height: 1.7; }
.btn-gold {
  font-family: var(--serif); font-size: 20px; letter-spacing: 2px; padding: 13px 44px;
  color: #1a1405; background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, #a8843a);
  border: 1px solid #6b5424; border-radius: 4px;
  box-shadow: 0 0 26px rgba(216,180,90,.35), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 0 40px rgba(216,180,90,.55), inset 0 1px 0 rgba(255,255,255,.6); }
.title-controls {
  margin-top: 26px; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 26px;
  font-size: 12.5px; color: var(--ink); opacity: .85; text-align: left; max-width: 560px;
}
.title-controls b { color: var(--gold); font-weight: 600; }

/* ---------- Unit frames ---------- */
.unit-frame {
  position: absolute; width: 240px; padding: 8px 10px;
  background: linear-gradient(180deg, rgba(18,27,33,.92), rgba(12,18,22,.88));
  border: 1px solid var(--slate-600); border-radius: 6px;
  box-shadow: 0 2px 12px rgba(0,0,0,.5);
}
#player-frame { top: 14px; left: 14px; }
#target-frame { top: 14px; left: 50%; transform: translateX(-50%); width: 260px; }
.uf-name { font-family: var(--serif); font-size: 14px; color: var(--parchment); margin-bottom: 5px; letter-spacing: 1px; }
.uf-name span { color: var(--gold); }
.uf-bar { position: relative; height: 15px; border-radius: 3px; background: #060a0c; border: 1px solid #000; overflow: hidden; margin-bottom: 4px; }
.uf-bar .fill { height: 100%; width: 100%; transition: width .18s ease; }
.uf-bar.hp .fill { background: linear-gradient(180deg, #57d98c, var(--emerald) 60%, var(--emerald-dim)); }
.uf-bar.hp.enemy .fill { background: linear-gradient(180deg, #e0705f, var(--danger) 60%, #8c2f24); }
.uf-bar.xp { height: 8px; }
.uf-bar.xp .fill { background: linear-gradient(180deg, var(--gold-bright), var(--gold)); width: 0%; }
.uf-bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600; color: #fff; text-shadow: 0 1px 2px #000;
}
.uf-buffs { display: flex; gap: 4px; min-height: 18px; margin-top: 3px; }
.uf-buffs .buff { width: 18px; height: 18px; border: 1px solid var(--gold); border-radius: 3px; font-size: 11px; display: flex; align-items: center; justify-content: center; background: rgba(216,180,90,.15); }

/* ---------- Minimap ---------- */
#minimap-wrap { position: absolute; top: 14px; right: 14px; width: 200px; text-align: center; }
#minimap {
  width: 196px; height: 196px; border-radius: 50%;
  border: 3px solid var(--slate-600); outline: 1px solid #000;
  box-shadow: 0 0 0 2px rgba(216,180,90,.25), 0 4px 18px rgba(0,0,0,.6);
  background: #0a0f13;
}
#minimap-zone { font-family: var(--serif); font-size: 13px; color: var(--gold); letter-spacing: 1px; margin-top: 6px; text-shadow: 0 1px 3px #000; }
#clock { font-size: 11px; color: var(--ink); opacity: .85; margin-top: 2px; text-shadow: 0 1px 2px #000; }

/* ---------- Quest tracker ---------- */
#quest-tracker {
  position: absolute; top: 240px; right: 14px; width: 230px; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.qt-quest {
  background: linear-gradient(180deg, rgba(18,27,33,.82), rgba(12,18,22,.78));
  border-left: 3px solid var(--gold); border-radius: 0 5px 5px 0; padding: 7px 10px;
}
.qt-quest.done { border-left-color: var(--emerald-bright); }
.qt-title { font-family: var(--serif); font-size: 12.5px; color: var(--gold-bright); letter-spacing: .5px; }
.qt-obj { font-size: 11.5px; color: var(--ink); margin-top: 3px; opacity: .9; }
.qt-obj.complete { color: var(--emerald-bright); }

/* ---------- Hotbar ---------- */
#hotbar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 7px;
  background: linear-gradient(180deg, rgba(18,27,33,.92), rgba(12,18,22,.9));
  border: 1px solid var(--slate-600); border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.55);
}
.hb-slot {
  position: relative; width: 52px; height: 52px; border-radius: 6px;
  background: linear-gradient(180deg, var(--slate-700), var(--slate-800));
  border: 1px solid var(--slate-600); display: flex; align-items: center; justify-content: center;
}
.hb-slot.active { border-color: var(--gold); box-shadow: 0 0 12px rgba(216,180,90,.4); }
.hb-ico { font-size: 24px; filter: drop-shadow(0 2px 2px #000); }
.hb-key {
  position: absolute; bottom: -1px; right: 2px; font-size: 9px; font-weight: 700; color: var(--gold);
  text-shadow: 0 1px 2px #000;
}
.hb-cd {
  position: absolute; inset: 0; border-radius: 6px; background: rgba(4,7,9,.78);
  transform-origin: bottom; transform: scaleY(0); pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: #fff;
}
.hb-count { position: absolute; top: 0; left: 3px; font-size: 10px; font-weight: 700; color: var(--emerald-bright); text-shadow: 0 1px 2px #000; }

/* ---------- Menu buttons ---------- */
#menu-buttons {
  position: absolute; bottom: 16px; right: 14px; display: flex; gap: 6px; align-items: center;
}
#menu-buttons button {
  width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--slate-600);
  background: linear-gradient(180deg, var(--slate-700), var(--slate-800)); color: var(--gold);
  font-family: var(--serif); font-size: 14px; font-weight: 700;
}
#menu-buttons button:hover { border-color: var(--gold); }
#gold-display {
  margin-left: 8px; padding: 6px 12px; border-radius: 6px; font-size: 14px;
  background: linear-gradient(180deg, rgba(18,27,33,.92), rgba(12,18,22,.9));
  border: 1px solid var(--slate-600); color: var(--gold-bright);
}

/* ---------- Interact prompt ---------- */
#interact-prompt {
  position: absolute; bottom: 108px; left: 50%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 6px; font-size: 14px;
  background: linear-gradient(180deg, rgba(18,27,33,.95), rgba(12,18,22,.92));
  border: 1px solid var(--gold); color: var(--parchment);
  box-shadow: 0 0 18px rgba(216,180,90,.25);
}
#interact-prompt b { color: var(--gold-bright); font-family: var(--serif); }

/* ---------- Combat text ---------- */
#combat-text-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ctext {
  position: absolute; font-weight: 800; font-size: 17px; color: #fff;
  text-shadow: 0 0 4px #000, 0 2px 3px #000; pointer-events: none;
  transition: none; font-family: var(--sans); will-change: transform, opacity;
}
.ctext.crit { color: var(--gold-bright); font-size: 23px; font-family: var(--serif); }
.ctext.player-hit { color: #ff7d6b; }
.ctext.heal { color: var(--emerald-bright); }
.ctext.xp { color: #b9a7ff; font-size: 13px; }
.ctext.info { color: var(--parchment); font-size: 13px; }

/* ---------- Toasts ---------- */
#toast-layer {
  position: absolute; bottom: 92px; right: 14px; display: flex; flex-direction: column-reverse; gap: 6px;
  pointer-events: none; max-width: 280px;
}
.toast {
  padding: 8px 12px; border-radius: 6px; font-size: 13px;
  background: linear-gradient(180deg, rgba(26,38,48,.96), rgba(18,27,33,.94));
  border: 1px solid var(--slate-600); border-left: 3px solid var(--gold);
  animation: toast-in .25s ease; box-shadow: 0 3px 14px rgba(0,0,0,.5);
}
.toast.loot { border-left-color: var(--gold); }
.toast.quest { border-left-color: var(--emerald-bright); }
.toast.system { border-left-color: #7d6bb8; }
.toast b { color: var(--gold-bright); }
@keyframes toast-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.fade { opacity: 0; transition: opacity .4s ease; }

/* ---------- Level up ---------- */
#levelup-banner {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%,-50%);
  text-align: center; pointer-events: none; animation: lu-pop 3s ease forwards;
}
.lu-title {
  font-family: var(--serif); font-size: 54px; color: var(--gold-bright); letter-spacing: 6px;
  text-shadow: 0 0 40px rgba(216,180,90,.8), 0 3px 0 #6b5424;
}
.lu-sub { font-size: 15px; color: var(--emerald-bright); letter-spacing: 2px; margin-top: 6px; }
@keyframes lu-pop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.6); }
  12% { opacity: 1; transform: translate(-50%,-50%) scale(1.06); }
  20% { transform: translate(-50%,-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Zone announce ---------- */
#zone-announce {
  position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  text-align: center; pointer-events: none; animation: zone-in 3.4s ease forwards;
}
#zone-announce .z-name { font-family: var(--serif); font-size: 34px; color: var(--parchment); letter-spacing: 5px; text-shadow: 0 0 26px rgba(0,0,0,.9), 0 2px 4px #000; }
#zone-announce .z-sub { font-size: 12px; color: var(--gold); letter-spacing: 3px; margin-top: 4px; }
#zone-announce.danger .z-name { color: #ff8f7d; }
@keyframes zone-in {
  0% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
  12% { opacity: 1; transform: translateX(-50%) translateY(0); }
  82% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Hurt vignette ---------- */
#hurt-vignette {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(160,30,20,.5) 100%);
  transition: opacity .3s ease;
}

/* ---------- Panels ---------- */
#panel-backdrop {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(5,8,10,.45); backdrop-filter: blur(2px);
}
.panel {
  width: min(440px, 92vw); max-height: 78vh; overflow-y: auto;
  background: linear-gradient(180deg, #16212a 0%, #10181f 100%);
  border: 1px solid var(--slate-600); border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(216,180,90,.15), 0 14px 50px rgba(0,0,0,.7);
  padding: 0 0 14px;
}
.panel.wide { width: min(700px, 94vw); }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--slate-600);
  background: linear-gradient(180deg, rgba(216,180,90,.1), transparent);
  position: sticky; top: 0; z-index: 2;
}
.panel-head h2 { font-family: var(--serif); font-size: 18px; color: var(--gold); letter-spacing: 2px; }
.panel-close {
  background: none; border: 1px solid var(--slate-600); color: var(--ink); border-radius: 4px;
  width: 26px; height: 26px; font-size: 12px;
}
.panel-close:hover { border-color: var(--danger); color: #ff9d8c; }

/* quests */
#quest-list { padding: 10px 14px; display: flex; flex-direction: column; gap: 10px; }
.q-entry { border: 1px solid var(--slate-600); border-radius: 7px; padding: 10px 12px; background: rgba(12,18,22,.5); }
.q-entry.done { border-color: var(--emerald-dim); }
.q-entry h3 { font-family: var(--serif); font-size: 14.5px; color: var(--gold-bright); letter-spacing: .5px; }
.q-entry.done h3 { color: var(--emerald-bright); }
.q-giver { font-size: 11px; color: var(--ink); opacity: .65; margin: 2px 0 6px; }
.q-desc { font-size: 12.5px; line-height: 1.55; opacity: .92; margin-bottom: 7px; }
.q-obj { font-size: 12.5px; margin: 2px 0; }
.q-obj::before { content: '◈ '; color: var(--gold); }
.q-obj.complete { color: var(--emerald-bright); }
.q-obj.complete::before { content: '✔ '; color: var(--emerald-bright); }
.q-reward { font-size: 11.5px; color: var(--gold); margin-top: 6px; opacity: .9; }
.q-empty { text-align: center; padding: 26px; opacity: .6; font-size: 13px; }

/* character sheet */
#character-sheet { padding: 12px 16px; }
.cs-row { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid rgba(36,51,63,.6); font-size: 13.5px; }
.cs-row b { color: var(--gold-bright); font-weight: 600; }
.cs-sec { font-family: var(--serif); color: var(--emerald-bright); font-size: 13px; letter-spacing: 2px; margin: 14px 0 4px; }
.cs-equip { display: flex; gap: 8px; margin-top: 6px; }
.cs-equip .eq-slot { flex: 1; border: 1px solid var(--slate-600); border-radius: 6px; padding: 8px; text-align: center; font-size: 12px; background: rgba(12,18,22,.5); }
.cs-equip .eq-slot .eq-ico { font-size: 20px; }

/* inventory */
#inventory-grid { padding: 12px 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.inv-slot {
  aspect-ratio: 1; border: 1px solid var(--slate-600); border-radius: 6px;
  background: rgba(12,18,22,.55); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 22px; position: relative; cursor: default;
}
.inv-slot .inv-count { position: absolute; bottom: 2px; right: 4px; font-size: 10px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000; }
.inv-slot .inv-name { font-size: 8.5px; opacity: .8; margin-top: 2px; text-align: center; line-height: 1.1; }
.inv-slot.usable { cursor: pointer; }
.inv-slot.usable:hover { border-color: var(--emerald-bright); }
.inv-slot.equipped { border-color: var(--gold); box-shadow: 0 0 10px rgba(216,180,90,.3); }

/* big map */
#bigmap { display: block; margin: 12px auto; border: 1px solid var(--slate-600); border-radius: 6px; max-width: 92%; height: auto; }

/* dialog */
#dialog-body { padding: 14px 18px; }
.dlg-text { font-size: 14px; line-height: 1.65; color: var(--parchment); margin-bottom: 14px; }
.dlg-opt {
  display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px 12px;
  border: 1px solid var(--slate-600); border-radius: 6px; background: rgba(12,18,22,.5);
  color: var(--ink); font-size: 13.5px; transition: border-color .12s ease;
}
.dlg-opt:hover { border-color: var(--gold); }
.dlg-opt b { color: var(--gold-bright); }
.dlg-opt .opt-reward { float: right; color: var(--gold); font-size: 12px; }
.dlg-opt.complete-opt { border-color: var(--emerald-dim); }
.dlg-opt.complete-opt b { color: var(--emerald-bright); }

/* vendor */
#vendor-body { padding: 12px 16px; }
.v-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 6px 0;
  border: 1px solid var(--slate-600); border-radius: 6px; background: rgba(12,18,22,.5);
}
.v-row .v-ico { font-size: 22px; }
.v-row .v-info { flex: 1; }
.v-row .v-name { font-size: 13.5px; color: var(--parchment); }
.v-row .v-desc { font-size: 11px; opacity: .7; }
.v-row button {
  padding: 6px 12px; border-radius: 5px; border: 1px solid var(--gold); font-size: 12.5px; font-weight: 600;
  background: linear-gradient(180deg, rgba(216,180,90,.2), rgba(216,180,90,.08)); color: var(--gold-bright);
}
.v-row button:disabled { opacity: .4; cursor: not-allowed; border-color: var(--slate-600); color: var(--ink); }
.v-row .owned-tag { font-size: 11px; color: var(--emerald-bright); }
.v-gold { text-align: right; font-size: 13px; color: var(--gold-bright); padding: 4px 6px; }

/* ---------- Touch UI ---------- */
#touch-ui { position: absolute; inset: 0; pointer-events: none; z-index: 30; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 55%; pointer-events: auto; }
#stick-base {
  position: absolute; left: 60px; bottom: 90px; width: 110px; height: 110px; border-radius: 50%;
  border: 2px solid rgba(216,180,90,.4); background: rgba(12,18,22,.4); display: none;
}
#stick-nub {
  position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; border-radius: 50%;
  background: rgba(216,180,90,.55); transform: translate(-50%,-50%);
}
#touch-buttons { position: absolute; right: 16px; bottom: 100px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; pointer-events: auto; }
.tbtn {
  width: 58px; height: 58px; border-radius: 50%; font-size: 22px;
  border: 2px solid rgba(216,180,90,.5); background: rgba(12,18,22,.55); color: var(--gold-bright);
}
.tbtn:active { background: rgba(216,180,90,.4); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .unit-frame { width: 170px; padding: 6px 8px; }
  #minimap-wrap { width: 130px; }
  #minimap { width: 126px; height: 126px; }
  #quest-tracker { width: 170px; top: 165px; }
  .qt-quest { padding: 5px 8px; }
  .hb-slot { width: 42px; height: 42px; }
  .hb-ico { font-size: 19px; }
  #menu-buttons button { width: 30px; height: 30px; }
  #toast-layer { bottom: 160px; }
}
@media (max-width: 600px) {
  #quest-tracker { display: none; }
  #player-frame { top: 8px; left: 8px; }
  #minimap-wrap { top: 8px; right: 8px; }
  #hotbar { bottom: 8px; padding: 5px; gap: 4px; }
  .hb-slot { width: 38px; height: 38px; }
  #menu-buttons { bottom: auto; top: 148px; right: 8px; flex-direction: column; }
  #gold-display { margin-left: 0; margin-top: 4px; font-size: 12px; padding: 4px 8px; }
  .lu-title { font-size: 34px; }
  .title-inner { padding: 20px; }
  .title-controls { grid-template-columns: 1fr; }
}
