:root {
  --panel: rgba(16, 20, 18, 0.82);
  --border: rgba(255, 255, 255, 0.12);
  --text: #f1eee6;
  --muted: #b3ada0;
  --gold: #ffd36b;
  --hp: #d8343c;
  --hp-back: #3a1517;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #18201a;
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* The 3D view, under the game canvas (shown only where there's 3D scenery). */
canvas#game3d {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- HUD ---------- */

#hud { position: fixed; inset: 0; pointer-events: none; }

.topbar {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px #000;
}

.tag {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-left: 6px;
}

.stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.stats span {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
}

.stats span:empty { display: none; }

#log {
  position: absolute;
  left: 16px;
  bottom: 96px;
  width: min(360px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#log .line {
  font-size: 13px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(10, 12, 11, 0.55);
  text-shadow: 0 1px 2px #000;
  animation: fade 10s forwards;
}

@keyframes fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

.bottom {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  pointer-events: auto;
}

.char { width: min(260px, 46vw); }

.char-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hpbar {
  position: relative;
  height: 20px;
  border-radius: 5px;
  background: var(--hp-back);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.5);
}

#hp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(#e85a60, var(--hp));
  transition: width 0.15s;
}

#hp-text {
  position: relative;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  text-shadow: 0 1px 2px #000;
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  overflow: hidden;
  color: var(--text);
}

.slot svg { width: 34px; height: 34px; margin-top: 4px; }
.slot:active { transform: scale(0.95); }
#potion-slot.empty svg { opacity: 0.55; filter: grayscale(1) brightness(1.6); }
#jump-slot.active { border-color: var(--gold); background: rgba(255, 211, 107, 0.22); }

#potion-count {
  position: absolute;
  right: 4px;
  bottom: 2px;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
}

.slot .key {
  position: absolute;
  left: 4px;
  top: 2px;
  font-size: 10px;
  color: var(--muted);
}

#potion-cd {
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  background: rgba(0, 0, 0, 0.55);
}

.help {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  text-shadow: 0 1px 2px #000;
  padding: 0 16px;
}

kbd {
  font: inherit;
  padding: 0 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(8, 10, 9, 0.55);
}

.overlay.passive { pointer-events: none; background: rgba(40, 0, 0, 0.25); }

.panel {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.panel h1 {
  margin: 0 0 4px;
  font-size: 30px;
  letter-spacing: 0.06em;
  color: var(--gold);
}

.panel h2 { margin: 0 0 8px; font-size: 22px; }
.panel p { margin: 0 0 16px; }

.panel label {
  display: block;
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.panel input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.panel input:focus { border-color: var(--gold); }

.panel button {
  width: 100%;
  padding: 11px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: #1b1408;
  background: var(--gold);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.panel button:disabled { opacity: 0.6; cursor: default; }

.error { color: #ff8a80; font-size: 13px; min-height: 1em; margin: 10px 0 0 !important; }

#death .panel { background: rgba(30, 8, 8, 0.8); }

@media (max-width: 600px) {
  .help { display: none; }
  .bottom { bottom: 12px; }
  #log { bottom: 86px; }
}

/* ---------- v0.2 additions ---------- */

.xpbar {
  position: relative;
  height: 10px;
  margin-top: 4px;
  border-radius: 4px;
  background: #241a33;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.5);
}

#xp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(#b48cff, #7a4fd6);
  transition: width 0.3s;
}

#xp-text {
  position: relative;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 9px;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 2px #000;
}

.bottom.levelup { animation: levelflash 1.2s; }

@keyframes levelflash {
  0% { box-shadow: 0 0 0 0 rgba(255, 211, 107, 0.9); border-color: var(--gold); }
  100% { box-shadow: 0 0 0 18px rgba(255, 211, 107, 0); }
}

#minimap {
  position: absolute;
  top: 46px;
  right: 16px;
  border-radius: 8px;
  background: rgba(10, 14, 12, 0.6);
  border: 1px solid var(--border);
  padding: 4px;
  box-sizing: content-box;
}

#boss-bar {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  width: min(380px, calc(100vw - 32px));
  text-align: center;
}

.boss-name {
  font-weight: 700;
  font-size: 14px;
  color: #ffb39a;
  text-shadow: 0 1px 3px #000;
  margin-bottom: 4px;
}

.boss-track {
  position: relative;
  height: 14px;
  border-radius: 4px;
  background: rgba(40, 8, 8, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#boss-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(#e0603e, #a3301f);
  transition: width 0.2s;
}

#boss-text {
  position: relative;
  font-size: 10px;
  font-weight: 700;
  line-height: 12px;
  text-shadow: 0 1px 2px #000;
}

.panel .label {
  text-align: left;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.classes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.class-card {
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px 10px;
  margin: 0 !important;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  text-align: center !important;
  color: var(--muted) !important;
}

.class-card input { position: absolute; opacity: 0; pointer-events: none; }
.bodies .class-card { padding: 8px; }
.class-card svg { width: 28px; height: 28px; color: var(--text); }
.class-card .title { font-size: 14px; font-weight: 700; color: var(--text); }
.class-card .desc { font-size: 11px; line-height: 1.3; }
.class-card:has(input:checked) { border-color: var(--gold); background: rgba(255, 211, 107, 0.12); }
.class-card:has(input:checked) svg { color: var(--gold); }
.class-card:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

.stats span { white-space: nowrap; }

@media (max-width: 600px) {
  #minimap { display: none; }
  .tag, #ping { display: none; }
  #boss-bar { top: 44px; }
}

#error-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(120, 20, 20, 0.92);
  border: 1px solid rgba(255, 160, 160, 0.5);
  color: #fff;
  font-size: 13px;
  z-index: 10;
}

/* ---------- login ---------- */

.panel.auth { margin: auto; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin: 4px 0 16px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
}

.panel .tab {
  padding: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border-radius: 7px;
}

.panel .tab.active {
  color: #1b1408;
  background: var(--gold);
}

#auth-status {
  margin: 16px 0 4px;
  font-size: 15px;
}

.fineprint {
  margin: 12px 0 0 !important;
  font-size: 11px;
  color: var(--muted);
}

#logout {
  pointer-events: auto;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}

#logout:hover { color: var(--text); }

/* ---------- special attack counter ---------- */

.char-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.char-top .char-name { margin-bottom: 0; }

.special {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.pips { display: flex; gap: 3px; }

.pips i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid rgba(255, 211, 107, 0.7);
}

.pips i.on { background: var(--gold); }
.special.ready { color: var(--gold); }
.special.ready .pips i { box-shadow: 0 0 6px var(--gold); }

/* ---------- character window ---------- */

.window {
  position: absolute;
  top: 46px;
  right: 16px;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100vh - 170px);
  overflow-y: auto;
  padding: 14px;
  border-radius: 12px;
  background: rgba(16, 20, 18, 0.94);
  border: 1px solid var(--border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 5;
}

.win-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.win-title { font-size: 17px; font-weight: 700; color: var(--gold); }
.win-sub { font-size: 12px; color: var(--muted); }

.win-close {
  font: inherit;
  font-size: 20px;
  line-height: 1;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  cursor: pointer;
}

.cw-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 6px;
}

.cw-equip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cw-bag {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.item-slot {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
  color: var(--muted);
}

.item-slot svg { width: 72%; height: 72%; }
.item-slot.selected { outline: 2px solid var(--gold); outline-offset: 1px; }
.item-slot.cant-use svg { opacity: 0.45; }
.item-slot.cant-use::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(200, 40, 40, 0.18);
}

.slot-label { font-size: 10px; }

.cw-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
}

.cw-stats .stat { display: flex; justify-content: space-between; gap: 6px; }
.cw-stats .stat:last-child { grid-column: 1 / -1; }
.cw-stats span { color: var(--muted); }

.cw-belt { font-size: 12px; margin-top: 8px; }

.cw-details {
  margin-top: 12px;
  padding: 10px;
  min-height: 64px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
}

.cw-details p { margin: 0; }
.item-name { font-size: 14px; font-weight: 700; }
.item-sub { color: var(--muted); margin: 2px 0 6px; }
.item-stats { font-weight: 600; }
.item-compare { color: #b9e6a8; margin-top: 4px; }
.item-problem { color: #ff8a80; margin-top: 4px; }
.item-actions { display: flex; gap: 8px; margin-top: 10px; }

.item-actions button {
  flex: 1;
  padding: 8px;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 7px;
  color: #1b1408;
  background: var(--gold);
  cursor: pointer;
}

.item-actions button.secondary { color: var(--text); background: rgba(255, 255, 255, 0.12); }
.item-actions button:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 600px) {
  .window { top: 40px; right: 16px; max-height: calc(100vh - 150px); }
  .special span:first-child { display: none; }
}

/* ---------- gear level badges ---------- */

.item-slot { position: relative; }
.item-level {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: #f1eee6;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
  pointer-events: none;
}
.item-slot.cant-use .item-level { color: #ff8a7a; }

/* ---------- minimap and the big map ---------- */

#minimap { cursor: pointer; pointer-events: auto; }

#bigmap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
  pointer-events: auto;
}

.bm-panel {
  max-width: 96vw;
  max-height: 94vh;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(16, 20, 18, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 16px; color: var(--gold); }

#bm-canvas {
  display: block;
  width: min(92vw, calc((94vh - 110px) * 2));
  height: auto;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  border-radius: 8px;
  background: #0c0f0c;
}

.bm-foot { font-size: 12px; text-align: center; }

/* ---------- arriving on a map / entering an area ---------- */

#map-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 2px 6px #000, 0 0 2px #000;
}
#map-banner .mb-name { font-size: 34px; font-weight: 800; letter-spacing: 0.05em; color: #fff3c8; }
#map-banner .mb-levels { font-size: 15px; color: #e6dcc0; margin-top: 2px; }
#map-banner.show { animation: banner 4.5s ease-out forwards; }

#zone-banner {
  position: absolute;
  top: 88px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(10, 12, 10, 0.6);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: #fff3c8;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
#zone-banner.show { animation: banner 3s ease-out forwards; }

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 6px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- talking to townspeople ---------- */

#dialog {
  position: absolute;
  left: 50%;
  bottom: 118px;
  transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px));
  padding: 14px 16px 12px;
  border-radius: 12px;
  background: rgba(16, 20, 18, 0.95);
  border: 1px solid rgba(143, 227, 255, 0.35);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 6;
}
.dlg-head { font-weight: 700; color: #8fe3ff; font-size: 15px; }
.dlg-head .muted { font-weight: 500; font-size: 12px; }
#dialog-text { margin: 8px 0 12px; line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-actions button {
  font: inherit;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #c99a2e;
  color: #1a140a;
  cursor: pointer;
}
.dlg-actions button.secondary { background: rgba(255, 255, 255, 0.08); color: var(--text); }

@media (max-width: 700px) {
  #zone-banner { top: 64px; font-size: 12px; }
  #map-banner .mb-name { font-size: 24px; }
  #dialog { bottom: 100px; }
}

/* ---------- gold and the XP skill button ---------- */

#gold-chip { display: inline-flex; align-items: center; gap: 4px; }
#gold-chip svg { width: 16px; height: 16px; }
#gold-chip b { color: #ffd98a; font-weight: 700; }

#xp-slot { overflow: visible; }
#xp-slot .xp-ring { position: absolute; inset: 0; width: 52px; height: 52px; margin: 0; transform: rotate(-90deg); }
#xp-slot .xp-track { fill: none; stroke: rgba(255, 255, 255, 0.12); stroke-width: 3.5; }
#xp-slot .xp-arc { fill: none; stroke: #c9a6ff; stroke-width: 3.5; stroke-linecap: round; transition: stroke-dashoffset 0.4s; }
#xp-slot .xp-icon { position: absolute; left: 50%; top: 46%; width: 26px; height: 26px; transform: translate(-50%, -50%); }
#xp-slot .xp-icon svg { width: 26px; height: 26px; margin: 0; }
#xp-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: #e6dcff;
  text-shadow: 0 1px 2px #000;
}
#xp-slot.ready { border-color: var(--gold); animation: xpready 0.9s ease-in-out infinite; }
#xp-slot.ready .xp-arc { stroke: var(--gold); }
#xp-slot.ready #xp-count { color: var(--gold); }
#xp-slot.on { border-color: #ffd36b; background: rgba(255, 211, 107, 0.25); }
#xp-slot.on .xp-arc { stroke: #ffd36b; }
#xp-slot.flash { animation: xpready 0.9s ease-in-out infinite, levelflash 1.2s; }
@keyframes xpready {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 211, 107, 0.0); }
  50% { box-shadow: 0 0 14px 3px rgba(255, 211, 107, 0.7); }
}

/* ---------- shops and warehouses ---------- */

.window.side { right: auto; left: 16px; top: 46px; width: min(360px, calc(100vw - 32px)); }
.shop-gold { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.shop-gold b { color: #ffd98a; }
.shop-tabs { margin-bottom: 8px; }
.shop-list { display: flex; flex-direction: column; gap: 4px; max-height: 42vh; overflow-y: auto; }
.shop-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.shop-row:hover { background: rgba(255, 255, 255, 0.06); }
.shop-group { font-family: 'Cinzel', Georgia, serif; font-size: 12px; font-weight: 700; letter-spacing: 0.04em; color: #e8c98a; padding: 6px 4px 1px; border-bottom: 1px solid rgba(232, 201, 138, 0.25); }
.shop-group:first-child { padding-top: 0; }
.shop-row.selected { outline: 2px solid var(--gold); outline-offset: -1px; }
.shop-row.too-low .shop-name { color: var(--muted); }
.shop-row .item-slot.mini { width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; cursor: inherit; }
.shop-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.shop-name small { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.shop-price { font-weight: 700; color: #ffd98a; font-size: 13px; }
.shop-price.short { color: #ff8a7a; }
.small { font-size: 12px; margin: 4px 0 8px; }
.wh-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.wh-grid .item-slot svg { width: 78%; height: 78%; }

@media (max-width: 700px) {
  .window.side { top: 40px; left: 16px; max-height: calc(100vh - 150px); }
}
.shop-tabs { margin: 0 0 8px; grid-template-columns: repeat(3, 1fr); }
.shop-tabs .tab { font: inherit; font-size: 13px; font-weight: 600; padding: 6px; border: none; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.shop-tabs .tab.active { background: var(--gold); color: #1b1408; }

/* ---------- v0.8: rarities, six gear slots, action bar ---------- */

.cw-equip { grid-template-columns: repeat(6, 1fr); gap: 6px; }

/* A coloured frame round rare items: green Refined, blue Unique, purple Elite, gold Super. */
.item-rarity {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 2px solid transparent;
  pointer-events: none;
}
.item-rarity.r-refined { border-color: #7ee08a; box-shadow: inset 0 0 6px rgba(126, 224, 138, 0.35); }
.item-rarity.r-unique { border-color: #6fa8ff; box-shadow: inset 0 0 7px rgba(111, 168, 255, 0.45); }
.item-rarity.r-elite { border-color: #c27bff; box-shadow: inset 0 0 9px rgba(194, 123, 255, 0.55), 0 0 6px rgba(194, 123, 255, 0.45); }
.item-rarity.r-super {
  border-color: #ffcc33;
  box-shadow: inset 0 0 10px rgba(255, 204, 51, 0.6), 0 0 8px rgba(255, 204, 51, 0.6);
  animation: superglow 1.6s ease-in-out infinite;
}
@keyframes superglow {
  0%, 100% { box-shadow: inset 0 0 8px rgba(255, 204, 51, 0.45), 0 0 5px rgba(255, 204, 51, 0.4); }
  50% { box-shadow: inset 0 0 14px rgba(255, 204, 51, 0.8), 0 0 12px rgba(255, 204, 51, 0.8); }
}

/* The action bar sits at the very bottom; everything else moves up to make room. */
.actionbar {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  pointer-events: auto;
}

.ab-slot {
  position: relative;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
}
.ab-slot.empty { background: rgba(0, 0, 0, 0.22); border-style: dashed; border-color: rgba(255, 255, 255, 0.14); }
.ab-slot .ab-icon { position: absolute; inset: 4px; display: flex; align-items: center; justify-content: center; }
.ab-slot .ab-icon svg { width: 100%; height: 100%; }
.ab-slot .ab-key {
  position: absolute;
  left: 3px;
  top: 2px;
  font-size: 9px;
  line-height: 1;
  color: var(--muted);
}
.ab-slot.pressed { animation: abpress 0.25s ease-out; }
@keyframes abpress {
  0% { background: rgba(255, 211, 107, 0.45); transform: scale(0.92); }
  100% { transform: scale(1); }
}

.bottom { bottom: 62px; }
#log { bottom: 146px; }
#dialog { bottom: 150px; }


/* The help line moves up under the top bar and fades away after a while. */
.help {
  top: 44px;
  bottom: auto;
  animation: helpfade 45s forwards;
  pointer-events: none;
}
@keyframes helpfade {
  0%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 600px) {
  .actionbar { gap: 3px; padding: 3px; bottom: 4px; width: calc(100vw - 16px); }
  .ab-slot { flex: 1 1 0; width: auto; height: auto; aspect-ratio: 1; }
  .ab-slot .ab-key { font-size: 7px; left: 2px; }
  .bottom { bottom: calc((100vw - 16px) / 12 + 12px); gap: 5px; padding: 7px 8px; max-width: calc(100vw - 12px); }
  .bottom .slot { width: 40px; height: 40px; }
  .bottom .slot svg { width: 26px; height: 26px; margin-top: 3px; }
  #xp-slot .xp-ring { width: 40px; height: 40px; }
  #xp-slot .xp-icon, #xp-slot .xp-icon svg { width: 20px; height: 20px; }
  .char { width: 34vw; }
  #log { bottom: calc((100vw - 16px) / 12 + 84px); }
  #dialog { bottom: calc((100vw - 16px) / 12 + 84px); }
}

/* ---------- v0.9: character page and inventory as separate windows ---------- */

.window.front { z-index: 6; }

#invwin { width: min(380px, calc(100vw - 32px)); }
/* Windows stop above the health bar and action bar (and scroll if the screen is short). */
.window { max-height: calc(100vh - 200px); }
#charwin .cw-details, #invwin .cw-details { min-height: 0; }
.inv-bag { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; }
.inv-bag .item-slot svg { width: 78%; height: 78%; }

/* Both open: the character page sits to the left of the inventory. */
#hud.both-windows #charwin { right: calc(16px + min(380px, calc(100vw - 32px)) + 12px); }
@media (max-width: 800px) {
  /* Not enough room side by side: they overlap, and the one you clicked last is on top. */
  #hud.both-windows #charwin { right: 16px; }
}

/* What you're wearing, laid out roughly where it goes on a person. */
.cw-doll {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  grid-template-areas:
    '. helmet necklace'
    'weapon armour ring'
    '. boots .';
  gap: 8px;
  justify-content: center;
  padding: 10px;
  border-radius: 10px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.25) 70%);
}
.cw-doll .slot-weapon { grid-area: weapon; }
.cw-doll .slot-helmet { grid-area: helmet; }
.cw-doll .slot-necklace { grid-area: necklace; }
.cw-doll .slot-armour { grid-area: armour; }
.cw-doll .slot-ring { grid-area: ring; }
.cw-doll .slot-boots { grid-area: boots; }
.cw-doll .item-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.cw-doll .item-slot svg { width: 70%; height: 70%; }
.item-slot .empty-icon { display: block; width: 46%; height: 46%; color: rgba(255, 255, 255, 0.2); }
.item-slot .empty-icon svg { width: 100%; height: 100%; }
.item-slot .slot-name { font-size: 9px; color: var(--muted); margin-top: 3px; }

.cw-stats { display: block; margin-top: 0; }
.cw-stats .stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: help;
}
.cw-stats .stat span { flex: none; width: 74px; }
.cw-stats .stat small { order: 2; flex: 1; text-align: right; color: var(--muted); font-size: 11px; }
.cw-stats .stat b { order: 3; min-width: 64px; text-align: right; }
.cw-stats .stat-health b { color: #ff9a9a; }
.cw-stats .stat-extra { margin-top: 6px; font-size: 11px; color: var(--muted); }

@media (max-width: 600px) {
  .bottom .slot { width: 36px; height: 36px; }
  .bottom .slot svg { width: 24px; height: 24px; margin-top: 2px; }
  #xp-slot .xp-ring { width: 36px; height: 36px; }
  #xp-slot .xp-icon, #xp-slot .xp-icon svg { width: 18px; height: 18px; }
  .char { width: 30vw; }
  .bottom { gap: 4px; }
  .cw-doll { grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); }
}

/* ---------- v0.10: shields, stacks, drag and drop, skills, number-key action bar ---------- */

.cw-doll {
  grid-template-areas:
    '. helmet necklace'
    'weapon armour shield'
    'ring boots .';
}
.cw-doll .slot-shield { grid-area: shield; }
.cw-doll .slot-shield.hidden { display: flex !important; visibility: hidden; }

/* How many are in a stack (potions), in place of the level number. */
.item-count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 2px #000;
  pointer-events: none;
}

/* Dragging things around. */
[data-drag] { touch-action: none; }
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  z-index: 50;
  pointer-events: none;
  border-radius: 8px;
  border: 1px solid rgba(255, 211, 107, 0.8);
  background: rgba(20, 24, 22, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}
.drag-ghost svg { width: 74%; height: 74%; }
.drag-ghost .item-level, .drag-ghost .item-count { position: absolute; right: 3px; bottom: 1px; }
.drag-ghost .ab-key, .drag-ghost .ab-cd, .drag-ghost .ab-cdtext, .drag-ghost .slot-name, .drag-ghost .empty-icon { display: none; }
.drag-ghost .ab-icon { position: absolute; inset: 4px; display: flex; align-items: center; justify-content: center; }
.drag-source { opacity: 0.4; }
.drop-over { outline: 2px solid var(--gold) !important; outline-offset: 1px; background: rgba(255, 211, 107, 0.15) !important; }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* The action bar: 12 numbered slots and the right mouse button. */
.ab-gap { width: 10px; }
.ab-slot .ab-icon .item-count { right: 0; bottom: -2px; font-size: 10px; }
.ab-slot .ab-icon b { font-size: 13px; color: var(--gold); }
.ab-slot.out .ab-icon { opacity: 0.35; filter: grayscale(1); }
.ab-slot .ab-cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: rgba(0, 0, 0, 0.6); pointer-events: none; }
.ab-slot .ab-cdtext {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}
.ab-slot.ab-rmb { border-color: rgba(255, 211, 107, 0.35); }
.ab-slot.ab-rmb .ab-key { left: auto; right: 2px; top: 2px; width: 12px; height: 12px; color: var(--muted); }
.ab-slot.ab-rmb .ab-key svg { width: 12px; height: 12px; }

/* Skills on the character page. */
.cw-skills { font-size: 12px; }
.wskills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 8px; }
.wskill { padding: 5px 7px; border-radius: 7px; background: rgba(0, 0, 0, 0.25); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 6px; cursor: help; }
.wskill.using { outline: 1px solid rgba(255, 211, 107, 0.45); }
.wskill span { color: var(--muted); }
.wskill b { font-size: 14px; }
.wskill i { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.wskill i em { display: block; height: 100%; background: #9fe0ff; }
.askill { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: 8px; background: rgba(0, 0, 0, 0.25); margin-bottom: 6px; }
.askill-icon {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(255, 211, 107, 0.5);
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
}
.askill-icon svg { width: 80%; height: 80%; }
.askill-text b { display: block; font-size: 13px; }
.askill-text small { color: var(--muted); font-size: 11px; line-height: 1.35; display: block; }

@media (max-width: 600px) {
  .ab-gap { width: 4px; }
  .ab-slot .ab-cdtext { font-size: 11px; }
}

/* ---------- v0.11: quests, promotions, dungeons ---------- */

/* Skills you haven't learned yet, and the row of promotions. */
.askill.locked { opacity: 0.55; }
.askill.locked .askill-icon { cursor: not-allowed; filter: grayscale(0.9); border-color: rgba(255, 255, 255, 0.18); }
.askill-text em { display: block; font-style: normal; font-size: 11px; color: #ffd36b; margin: 1px 0 2px; }
.promos { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.promo { padding: 4px 8px; border-radius: 999px; background: rgba(0, 0, 0, 0.3); color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.1); cursor: help; }
.promo small { opacity: 0.7; margin-left: 2px; }
.promo.done { color: #ffe08a; border-color: rgba(255, 211, 107, 0.55); background: rgba(255, 211, 107, 0.08); }
.promo-hint { margin: 2px 0 8px; }

/* A bus conductor's stops: one button per portal out of the land. */
#dialog-bus { display: flex; flex-direction: column; gap: 6px; margin: -4px 0 12px; }
#dialog-bus .bus-head { font-size: 12px; color: var(--muted); }
#dialog-bus button { text-align: left; }
#dialog-bus small { font-weight: 400; opacity: 0.8; margin-left: 6px; }

/* The quest part of a conversation. */
#dialog-quest {
  margin: -4px 0 12px;
  padding: 10px 12px;
  border-radius: 9px;
  background: rgba(255, 210, 58, 0.07);
  border: 1px solid rgba(255, 210, 58, 0.3);
  font-size: 13px;
}
.dq-title { font-weight: 700; color: #ffd23a; margin-bottom: 4px; }
.dq-goals { margin: 0 0 6px; padding-left: 18px; }
.dq-goals li.done, .qt li.done { color: #9fdc8a; }
.dq-reward { color: var(--muted); }
#dialog-quest .link {
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}
.dlg-actions .quest-btn { background: #ffd23a; color: #2a1e00; border-color: #ffd23a; }
.qmark { color: #ffd23a; font-weight: 900; }

/* Quest tracker, under the minimap. */
#quests {
  position: absolute;
  top: 182px;
  right: 16px;
  width: 218px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}
.qt {
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(10, 12, 11, 0.6);
  border: 1px solid rgba(255, 210, 58, 0.25);
  font-size: 12px;
}
.qt.ready { border-color: rgba(255, 210, 58, 0.7); box-shadow: 0 0 12px rgba(255, 210, 58, 0.25); }
.qt-name { font-weight: 700; color: #ffd23a; margin-bottom: 2px; }
.qt ul { margin: 0; padding-left: 16px; }
@media (max-width: 600px) {
  #quests { top: 150px; width: 170px; right: 8px; }
  .qt { font-size: 11px; padding: 5px 7px; }
}
@media (min-width: 900px) {
  .char { width: 300px; }
}

/* ---------- skill levels, Descend ---------- */
.special .special-level { margin-left: 6px; font-weight: 800; color: var(--gold, #ffd36b); font-size: 11px; }
.askill-level { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 11px; font-weight: 800; color: #ffd36b; vertical-align: middle; }
.askill-level i { display: inline-block; width: 46px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.askill-level em { display: block; height: 100%; background: linear-gradient(90deg, #c99a2e, #ffd36b); }
.askill.passive .askill-icon { cursor: default; }
.askill .tag { font-style: normal; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: #9fe0ff; margin-left: 4px; }
.descend {
  align-self: center; height: 34px; padding: 0 12px; border-radius: 8px; cursor: pointer; pointer-events: auto;
  font: inherit; font-weight: 800; font-size: 13px; color: #10222a;
  background: linear-gradient(#bfefff, #7fd0f0); border: 1px solid #e8fbff; box-shadow: 0 0 10px rgba(127, 208, 240, 0.6);
}
.descend:hover { filter: brightness(1.08); }

/* ---------- durability, repairs, the confirm box ---------- */
#game.drop-over { outline: none !important; background: none !important; }
.item-slot.broken, .cw-equip button.broken { box-shadow: inset 0 0 0 2px #d8382a; background-color: rgba(216, 56, 42, 0.18); }
.item-slot.broken::after, .cw-equip button.broken::after {
  content: 'BROKEN'; position: absolute; left: 0; right: 0; bottom: 1px; font-size: 8px; font-weight: 900; letter-spacing: 0.04em;
  color: #fff; text-align: center; text-shadow: 0 1px 2px #000; pointer-events: none;
}
.item-slot.worn-low, .cw-equip button.worn-low { box-shadow: inset 0 0 0 2px #e8952e; }
.item-slot, .cw-equip button { position: relative; }
.item-dura { margin-top: 4px; font-size: 12px; color: #c9c2b0; }
.item-dura.low { color: #f0a848; }
.item-dura.broken { color: #ff7a6a; font-weight: 700; }
.repair-all { width: 100%; margin: 4px 0 8px; padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 800; color: #1a1408; background: linear-gradient(#ffe08a, #e0b048); border: 1px solid #fff0b8; }
.repair-all:disabled, .repair-one:disabled { opacity: 0.5; cursor: default; }
.repair-row { cursor: default; display: flex; align-items: center; gap: 8px; }
.repair-row .shop-name { flex: 1; }
.repair-row .dura.low { color: #f0a848; }
.repair-row .dura.broken { color: #ff7a6a; }
.repair-one { padding: 5px 9px; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700; font-size: 12px; color: #1a1408; background: #e8c870; border: 1px solid #fff0b8; }
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.5); pointer-events: auto; }
.modal-box { max-width: 360px; margin: 16px; padding: 16px 18px; border-radius: 12px; background: rgba(20, 24, 22, 0.98); border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.modal-box p { margin: 0 0 14px; line-height: 1.45; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button { padding: 7px 14px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 700; border: 1px solid var(--border); background: #e0b048; color: #1a1408; }
.modal-actions button.secondary { background: rgba(255, 255, 255, 0.08); color: var(--text); }

/* ---------- v0.14: rare materials, sockets, Artisan Gurung's forge ---------- */
.item-slot svg.item-art { width: 90%; height: 90%; }
.wh-grid .item-slot svg.item-art { width: 92%; height: 92%; }
.item-sockets { position: absolute; left: 3px; top: 3px; display: flex; gap: 2px; pointer-events: none; }
.item-sockets i, .socket-rings i, .art-sockets i {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  border: 1.5px solid #e8dcb8; background: rgba(0, 0, 0, 0.55); box-shadow: 0 0 2px #000;
}
.socket-rings { display: inline-flex; gap: 4px; margin: 0 4px; vertical-align: middle; }
.item-socket-line { margin-top: 4px; font-size: 12px; color: #d8cfb8; }
.gold-text { color: #ffd98a; }
.art-bench { display: flex; align-items: flex-start; justify-content: center; gap: 8px; padding: 12px 8px 8px; border-radius: 10px; background: radial-gradient(ellipse at 50% 40%, rgba(255, 170, 80, 0.12), rgba(0, 0, 0, 0.3)); border: 1px solid rgba(255, 255, 255, 0.08); }
.art-piece { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; }
.art-slot { width: 60px; height: 60px; display: flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid rgba(255, 220, 160, 0.35); background: rgba(0, 0, 0, 0.45); }
.art-slot.empty { border-style: dashed; }
.art-result { cursor: default; opacity: 0.9; }
.art-result.none { opacity: 0.35; }
.art-sockets { display: flex; gap: 8px; height: 12px; }
.art-sockets i { width: 10px; height: 10px; opacity: 0.25; }
.art-sockets i.on { opacity: 1; border-color: #ffe7a8; box-shadow: 0 0 4px rgba(255, 220, 140, 0.8); }
.art-label { font-size: 10px; line-height: 1.2; text-align: center; color: var(--muted); }
.art-plus { align-self: center; margin-top: -26px; font-size: 22px; font-weight: 800; color: #ffd36b; }
.art-status { margin: 10px 0 0; padding: 8px 10px; min-height: 36px; border-radius: 8px; background: rgba(0, 0, 0, 0.25); font-size: 12px; line-height: 1.4; }
.art-status .chance { font-weight: 800; color: #b9e6a8; }
.art-status .chance.risky { color: #f0c048; }
.art-status .chance.hard { color: #ff8a7a; }
.art-status .ok { color: #9dff9a; font-weight: 800; }
.art-status .fail { color: #ff8a7a; font-weight: 800; }
.art-actions { margin-top: 8px; }
.art-help { margin: 10px 0; padding: 8px 10px; border-radius: 8px; background: rgba(255, 211, 107, 0.07); border: 1px solid rgba(255, 211, 107, 0.18); font-size: 11px; line-height: 1.4; color: #d8cfb8; }
.art-help b { color: #ffd36b; }
.art-help p { margin: 4px 0 0; }
.art-slot.forge-ok { animation: forgeok 1.2s ease-out; }
.art-slot.forge-fail { animation: forgefail 0.8s ease-out; }
@keyframes forgeok { 0% { box-shadow: 0 0 0 0 rgba(160, 255, 150, 0.9); } 40% { box-shadow: 0 0 24px 8px rgba(160, 255, 150, 0.7); } 100% { box-shadow: 0 0 0 0 rgba(160, 255, 150, 0); } }
@keyframes forgefail { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-4px); box-shadow: 0 0 16px 4px rgba(255, 90, 70, 0.7); } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
#artwin { max-height: calc(100vh - 120px); overflow-y: auto; }

/* ---------- v0.15: Wizards and Pub Brawlers ---------- */
.mpbar { position: relative; height: 12px; margin-top: 4px; border-radius: 4px; background: #14203a; overflow: hidden; border: 1px solid rgba(0, 0, 0, 0.5); }
#mp-fill { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(#6aa8ff, #2f5fd0); transition: width 0.15s; }
#mp-text { position: relative; text-align: center; font-size: 10px; font-weight: 700; line-height: 11px; text-shadow: 0 1px 2px #000; }
#xp-slot2 { overflow: visible; }
#xp-slot2 .xp-icon { position: absolute; left: 50%; top: 46%; width: 26px; height: 26px; transform: translate(-50%, -50%); }
#xp-slot2 .xp-icon svg { width: 26px; height: 26px; margin: 0; }
#xp-slot2.ready { border-color: var(--gold); animation: xpready 0.9s ease-in-out infinite; }
#xp-slot2.on { border-color: #ffd36b; background: rgba(255, 211, 107, 0.25); }
#xp-slot2.locked { opacity: 0.45; }
#death .panel button { pointer-events: auto; margin-top: 6px; }
.ab-slot.no-mana .ab-icon { filter: grayscale(0.8) brightness(0.7); }
.ab-slot.no-mana::after { content: ''; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 2px rgba(80, 130, 255, 0.7); pointer-events: none; }
.path-choice { display: flex; gap: 8px; margin-top: 8px; }
.path-choice button { flex: 1; }
.path-choice small { display: block; font-weight: 400; font-size: 11px; opacity: 0.85; margin-top: 2px; }
.stat-magic b { color: #9fc4ff; }

/* ---------- a trainer's skills ---------- */

.train-list { display: flex; flex-direction: column; gap: 4px; max-height: 64vh; overflow-y: auto; }
.train-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}
.train-row .skill-icon { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; }
.train-row .skill-icon svg { width: 30px; height: 30px; }
.train-row.ready { border-color: rgba(255, 211, 107, 0.55); background: rgba(255, 211, 107, 0.08); }
.train-row.later { opacity: 0.72; }
.train-row.later .skill-icon { filter: grayscale(0.8); }
.train-text { font-size: 13px; line-height: 1.25; }
.train-text small { display: block; font-size: 11px; color: var(--muted); }
.train-text b + small.muted { display: inline; margin-left: 4px; text-transform: capitalize; }
.train-note { color: #ffb38a !important; margin-top: 2px; }
.train-row button { padding: 6px 12px; }
.train-tick { color: #8ee08a; font-weight: 700; font-size: 18px; padding: 0 6px; }

/* ---------- v0.16: the character window, with tabs down the left ---------- */

@font-face { font-family: 'Cinzel'; src: url('fonts/cinzel-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cinzel'; src: url('fonts/cinzel-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

:root {
  --cw-gold: #e8cf98;
  --cw-bronze: #a07a42;
  --cw-text: #e6dccb;
  --cw-dim: #a8998a;
  --cw-serif: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
}
#charwin.cw2 {
  width: min(660px, calc(100vw - 24px));
  max-height: calc(100vh - 150px);
  min-height: 486px;
  top: 54px;
  padding: 44px 18px 18px 104px;
  border-radius: 6px;
  overflow: visible;
  color: var(--cw-text);
  font-family: var(--cw-serif);
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.012) 0 2px, rgba(0, 0, 0, 0.02) 2px 5px),
    linear-gradient(#24272a, #15171a);
  border: 2px solid #5a4528;
  box-shadow: 0 0 0 1px #0a0806, 0 0 0 4px #2a2016, 0 0 0 5px #8a6a3a, 0 14px 50px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.6);
}
#hud.both-windows #charwin.cw2 { right: calc(16px + min(380px, calc(100vw - 32px)) + 18px); }
@media (max-width: 1100px) { #hud.both-windows #charwin.cw2 { right: 16px; } }
.cw-corner { position: absolute; width: 46px; height: 46px; background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2064%2064%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22g%22%20x1%3D%220%22%20y1%3D%220%22%20x2%3D%221%22%20y2%3D%221%22%3E%3Cstop%20offset%3D%220%22%20stop-color%3D%22%23f0d9a2%22/%3E%3Cstop%20offset%3D%22.55%22%20stop-color%3D%22%23a07a42%22/%3E%3Cstop%20offset%3D%221%22%20stop-color%3D%22%234e391e%22/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath%20d%3D%22M4%2060%20V14%20Q4%204%2014%204%20H60%22%20fill%3D%22none%22%20stroke%3D%22url%28%23g%29%22%20stroke-width%3D%223%22/%3E%3Cpath%20d%3D%22M10%2060%20V18%20Q10%2010%2018%2010%20H60%22%20fill%3D%22none%22%20stroke%3D%22%236a4f2a%22%20stroke-width%3D%221.2%22/%3E%3Cpath%20d%3D%22M4%2022%20Q14%2022%2014%2012%20Q14%204%2022%204%22%20fill%3D%22none%22%20stroke%3D%22url%28%23g%29%22%20stroke-width%3D%222%22/%3E%3Cpath%20d%3D%22M2%202%20L16%202%20L2%2016%20Z%22%20fill%3D%22url%28%23g%29%22/%3E%3Ccircle%20cx%3D%2220%22%20cy%3D%2220%22%20r%3D%223.2%22%20fill%3D%22url%28%23g%29%22%20stroke%3D%22%233a2814%22%20stroke-width%3D%221%22/%3E%3Cpath%20d%3D%22M28%206%20Q32%2012%2038%206%20M6%2028%20Q12%2032%206%2038%22%20fill%3D%22none%22%20stroke%3D%22%23c9a265%22%20stroke-width%3D%221.4%22/%3E%3C/svg%3E") no-repeat center / contain; pointer-events: none; z-index: 2; }
.cw-corner.tl { top: -7px; left: -7px; }
.cw-corner.tr { top: -7px; right: -7px; transform: scaleX(-1); }
.cw-corner.bl { bottom: -7px; left: -7px; transform: scaleY(-1); }
.cw-corner.br { bottom: -7px; right: -7px; transform: scale(-1, -1); }
.cw-banner {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 46%;
  padding: 7px 34px 6px;
  text-align: center;
  font-family: 'Cinzel', var(--cw-serif);
  font-size: 22px;
  letter-spacing: 0.06em;
  color: var(--cw-gold);
  text-shadow: 0 1px 0 #000, 0 0 10px rgba(232, 207, 152, 0.25);
  background: linear-gradient(#3a3631, #1c1a17);
  border: 1px solid #0c0a08;
  box-shadow: 0 0 0 2px #8a6a3a, 0 0 0 3px #2a2016, 0 4px 12px rgba(0, 0, 0, 0.6);
  clip-path: polygon(14px 0, calc(100% - 14px) 0, 100% 50%, calc(100% - 14px) 100%, 14px 100%, 0 50%);
  white-space: nowrap;
  z-index: 3;
}
.cw-x {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 30px;
  height: 30px;
  font: 700 20px/1 var(--cw-serif);
  color: var(--cw-gold);
  background: linear-gradient(#3a3631, #1a1816);
  border: 1px solid #8a6a3a;
  box-shadow: inset 0 0 0 1px #000;
  border-radius: 4px;
  cursor: pointer;
  z-index: 3;
}
.cw-x:hover { color: #fff3d0; border-color: var(--cw-gold); }

/* The tabs: medallions down the left. */
.cw-tabs { position: absolute; left: 12px; top: 48px; display: flex; flex-direction: column; gap: 10px; width: 80px; }
.cw-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
  background: none;
  border: none;
  color: var(--cw-dim);
  font: 600 13px var(--cw-serif);
  cursor: pointer;
}
.cw-tab .cw-medal { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)) saturate(0.85) brightness(0.88); transition: filter 0.15s; }
.cw-tab:hover .cw-medal { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)) brightness(1.05); }
.cw-tab.active { color: #f6ead2; }
.cw-tab.active .cw-medal { filter: drop-shadow(0 0 6px rgba(232, 207, 152, 0.45)) brightness(1.1); }
.cw-tab.active::before { content: ''; position: absolute; left: -9px; top: 10px; width: 3px; height: 34px; background: linear-gradient(transparent, var(--cw-gold), transparent); }

.cw-body { max-height: calc(100vh - 230px); overflow-y: auto; padding-right: 2px; }
.cw-panel {
  border: 1px solid rgba(160, 122, 66, 0.55);
  border-radius: 4px;
  background: rgba(8, 10, 12, 0.55);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 18px rgba(0, 0, 0, 0.5);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.cw-small { font-family: 'Cinzel', var(--cw-serif); font-size: 12px; letter-spacing: 0.04em; color: var(--cw-gold); opacity: 0.85; text-transform: uppercase; }

/* Status */
.cw-id { display: grid; grid-template-columns: 120px 1fr; gap: 16px; align-items: center; }
.cw-portrait-frame { width: 120px; height: 120px; border: 2px solid #8a6a3a; box-shadow: 0 0 0 1px #000, inset 0 0 20px rgba(0, 0, 0, 0.8); background: radial-gradient(circle at 50% 40%, #4a5560, #1c2228 75%); }
.cw-portrait-frame canvas { width: 100%; height: 100%; display: block; }
.cw-name { font-family: 'Cinzel', var(--cw-serif); font-size: 28px; color: #f2e8d4; line-height: 1.1; }
.cw-rank { color: var(--cw-gold); font-size: 16px; margin: 4px 0 2px; }
.cw-classline { font-size: 17px; font-weight: 600; color: #efe4cf; }
.cw-idmeta { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(160, 122, 66, 0.35); font-size: 13px; color: var(--cw-dim); }
.cw-killbar { display: flex; align-items: center; gap: 12px; width: 100%; font: inherit; color: var(--cw-text); text-align: left; cursor: pointer; padding: 8px 14px; }
.cw-killbar:hover { border-color: var(--cw-gold); }
.cw-killmedal { display: flex; }
.cw-killlabel { flex: 1; font-size: 17px; }
.cw-killbar b { font-family: 'Cinzel', var(--cw-serif); font-size: 26px; color: var(--cw-gold); }
.cw-chev { font-size: 22px; color: var(--cw-dim); }
.cw-attrpanel { display: grid; grid-template-columns: 1fr 1.25fr; gap: 0; padding: 10px 0; }
.cw-col { padding: 0 16px; }
.cw-col-right { border-left: 1px solid rgba(160, 122, 66, 0.35); }
.cw-colhead { font-family: 'Cinzel', var(--cw-serif); font-size: 13px; letter-spacing: 0.05em; color: var(--cw-gold); padding-bottom: 6px; margin-bottom: 4px; border-bottom: 1px solid rgba(160, 122, 66, 0.35); }
.cw-colhead.right { text-align: right; }
.cw-row { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; font-size: 16px; cursor: help; }
.cw-row span { flex: none; color: #ddd2bf; }
.cw-row small { flex: 1; text-align: right; font-size: 11px; color: var(--cw-dim); }
.cw-row b { margin-left: auto; font-weight: 600; color: #f6efe0; font-variant-numeric: tabular-nums; }
.cw-extra { margin: 0 2px; font-size: 13px; color: var(--cw-dim); }

/* Equip */
.cw-equipsum { display: flex; justify-content: space-around; gap: 8px; padding: 8px 10px; }
.cw-equipsum span { display: flex; flex-direction: column; align-items: center; }
.cw-equipsum small { font-family: 'Cinzel', var(--cw-serif); font-size: 11px; color: var(--cw-gold); opacity: 0.8; letter-spacing: 0.04em; }
.cw-equipsum b { font-size: 20px; font-weight: 600; color: #f6efe0; }
.cw-doll2 { display: grid; grid-template-columns: 74px 1fr 74px; gap: 6px; align-items: center; margin-bottom: 12px; }
.cw-slots { display: flex; flex-direction: column; gap: 12px; position: relative; }
.cw-slots .item-slot { width: 72px; height: 72px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px solid #5a4528; box-shadow: 0 0 0 1px #000, inset 0 0 14px rgba(0, 0, 0, 0.8); background: linear-gradient(#22262b, #121418); border-radius: 3px; }
.cw-slots .item-slot svg { width: 78%; height: 78%; }
.cw-slots .item-slot.filled { border-color: #8a6a3a; }
.cw-slots .item-slot.unused { opacity: 0.3; }
.cw-slots .item-slot.selected { outline: 2px solid var(--cw-gold); outline-offset: 1px; }
.cw-slots::after { content: ''; position: absolute; top: 36px; bottom: 36px; width: 1px; background: rgba(160, 122, 66, 0.45); }
.cw-slots.left::after { right: -4px; }
.cw-slots.right::after { left: -4px; }
.cw-stage { position: relative; display: flex; flex-direction: column; align-items: center; }
.cw-stagelabel { font-family: 'Cinzel', var(--cw-serif); font-size: 13px; letter-spacing: 0.06em; color: var(--cw-gold); opacity: 0.8; }
.cw-stage canvas { width: 210px; height: 240px; cursor: grab; touch-action: none; }
.cw-stage canvas:active { cursor: grabbing; }
.cw-pedestal { margin-top: -18px; width: 220px; padding: 14px 0 8px; text-align: center; font-size: 13px; color: var(--cw-text); border-radius: 50%; border: 2px solid rgba(200, 160, 90, 0.75); box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.25), inset 0 0 0 7px rgba(200, 160, 90, 0.35); background: radial-gradient(ellipse, rgba(232, 207, 152, 0.12), transparent 70%); pointer-events: none; }
#charwin .cw-details { min-height: 64px; }

/* Proficiency */
.cw-profname { font-family: 'Cinzel', var(--cw-serif); font-size: 19px; color: #f2e8d4; }
.cw-profsub { font-size: 14px; color: #ddd2bf; }
.cw-proflist { display: flex; flex-direction: column; gap: 10px; }
.cw-prof { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid rgba(160, 122, 66, 0.45); background: rgba(8, 10, 12, 0.55); border-radius: 4px; cursor: help; }
.cw-prof.using { border-color: var(--cw-gold); box-shadow: inset 0 0 0 1px rgba(232, 207, 152, 0.25); }
.cw-profimg { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; }
.cw-profimg svg { width: 40px; height: 40px; }
.cw-profimg .item-count { display: none; }
.cw-proftext b { display: block; font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.cw-profnum { font-size: 15px; color: #ddd2bf; align-self: start; padding-top: 2px; }
.cw-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.cw-dots i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(232, 207, 152, 0.45); background: rgba(0, 0, 0, 0.4); }
.cw-dots i.on { background: radial-gradient(circle at 35% 35%, #fff2c8, #e0bf74 55%, #a07a42); border-color: #e8cf98; }
.cw-dots i.part { background: linear-gradient(90deg, rgba(232, 207, 152, 0.6) var(--p, 0%), rgba(0, 0, 0, 0.4) var(--p, 0%)); }
.cw-dots.small i { width: 8px; height: 8px; }

/* Skills */
.cw-subtabs { display: flex; gap: 8px; margin-bottom: 12px; }
.cw-subtab {
  flex: 1;
  padding: 7px 8px;
  font: 600 14px 'Cinzel', var(--cw-serif);
  letter-spacing: 0.04em;
  color: var(--cw-dim);
  background: linear-gradient(#2a2c2f, #16181b);
  border: 1px solid #5a4528;
  box-shadow: inset 0 0 0 1px #000;
  border-radius: 3px;
  cursor: pointer;
}
.cw-subtab.active { color: #f6ead2; border-color: var(--cw-gold); background: linear-gradient(#4a3f2e, #241e16); }
.cw-skilllist { display: flex; flex-direction: column; gap: 8px; }
.cw-skill { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: start; padding: 10px 14px; border: 1px solid rgba(160, 122, 66, 0.45); background: rgba(8, 10, 12, 0.55); border-radius: 4px; }
.cw-skill.ready { border-color: var(--cw-gold); }
.cw-skill.locked { opacity: 0.6; }
.cw-skill.locked .cw-skillimg { filter: grayscale(0.85); }
.cw-skillimg { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 1px solid #5a4528; background: linear-gradient(#22262b, #121418); border-radius: 3px; }
.cw-skillimg[data-drag] { cursor: grab; border-color: #8a6a3a; }
.cw-skillimg svg { width: 34px; height: 34px; }
.cw-skilltext b { font-size: 17px; font-weight: 600; }
.cw-skilltext small { display: block; font-size: 12px; color: var(--cw-dim); line-height: 1.35; }
.cw-skilltext b + small.muted { display: inline; margin-left: 4px; text-transform: capitalize; }
.cw-skilltext em { display: block; font-style: normal; font-size: 12px; color: #ffcf8a; margin: 2px 0; }
.cw-skilltext .cw-dots { margin: 4px 0 3px; }
.cw-skillnum { font-size: 15px; color: #ddd2bf; white-space: nowrap; }
.cw-bar { display: block; height: 4px; margin-top: 5px; border-radius: 2px; background: rgba(0, 0, 0, 0.5); overflow: hidden; }
.cw-bar i { display: block; height: 100%; background: linear-gradient(90deg, #a07a42, #e8cf98); }

/* Hunts */
.cw-huntrecord { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; }
.cw-huntbig { font-family: 'Cinzel', var(--cw-serif); font-size: 44px; line-height: 1.1; color: #f2e8d4; }
.cw-huntsub { font-size: 15px; color: #ddd2bf; }
.cw-huntmedal { display: flex; }
.cw-huntstats { display: grid; grid-template-columns: 1fr 1.6fr; gap: 12px; padding: 4px 4px 10px; border-bottom: 1px solid rgba(160, 122, 66, 0.35); margin-bottom: 8px; }
.cw-huntval { font-family: 'Cinzel', var(--cw-serif); font-size: 26px; color: var(--cw-gold); }
.cw-huntval.name { font-family: var(--cw-serif); font-size: 20px; color: #f2e8d4; padding-top: 6px; }
.cw-hunthead { display: flex; justify-content: space-between; padding: 0 4px 6px; font-family: 'Cinzel', var(--cw-serif); font-size: 12px; letter-spacing: 0.04em; color: var(--cw-gold); opacity: 0.8; }
.cw-huntlist { display: flex; flex-direction: column; gap: 10px; }
.cw-hunt { display: grid; grid-template-columns: 34px 1fr auto; grid-template-rows: auto 6px; gap: 4px 6px; align-items: baseline; padding: 0 4px; }
.cw-huntno { color: var(--cw-gold); opacity: 0.75; font-size: 14px; }
.cw-huntname { font-size: 17px; color: #f2e8d4; }
.cw-huntnum { font-size: 14px; color: #ddd2bf; font-variant-numeric: tabular-nums; }
.cw-hunt.first .cw-huntnum { color: var(--cw-gold); }
.cw-huntbar { grid-column: 2 / -1; height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 1px; overflow: hidden; }
.cw-huntbar i { display: block; height: 100%; background: #6f8aa0; }
.cw-hunt.first .cw-huntbar i { background: linear-gradient(90deg, #a07a42, #e8cf98); }
.cw-pager { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; color: var(--cw-dim); }
.cw-pagebtn { width: 64px; height: 30px; margin-left: 8px; font: 700 18px var(--cw-serif); color: var(--cw-gold); background: linear-gradient(#2a2c2f, #16181b); border: 1px solid #5a4528; box-shadow: inset 0 0 0 1px #000; border-radius: 3px; cursor: pointer; }
.cw-pagebtn:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 640px) {
  #charwin.cw2 { padding: 74px 10px 12px 10px; min-height: 0; }
  .cw-tabs { flex-direction: row; left: 10px; right: 10px; top: 28px; width: auto; justify-content: space-between; }
  .cw-tab span { display: none; }
  .cw-tab .cw-medal { width: 38px; height: 38px; }
  .cw-tab.active::before { display: none; }
  .cw-id { grid-template-columns: 84px 1fr; }
  .cw-portrait-frame { width: 84px; height: 84px; }
  .cw-name { font-size: 22px; }
  .cw-attrpanel { grid-template-columns: 1fr; }
  .cw-col-right { border-left: none; border-top: 1px solid rgba(160, 122, 66, 0.35); margin-top: 8px; padding-top: 8px; }
  .cw-doll2 { grid-template-columns: 60px 1fr 60px; }
  .cw-slots .item-slot { width: 58px; height: 58px; }
  .cw-stage canvas { width: 150px; height: 172px; }
  .cw-pedestal { width: 160px; }
}


/* ---------- v0.17: the character window's look on every window ---------- */

/* The frame: dark, faintly textured, with a bronze border and corners. */
.window.orn, .orn-frame {
  color: var(--cw-text);
  font-family: var(--cw-serif);
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.012) 0 2px, rgba(0, 0, 0, 0.02) 2px 5px),
    linear-gradient(#24272a, #15171a);
  border: 2px solid #5a4528;
  box-shadow: 0 0 0 1px #0a0806, 0 0 0 4px #2a2016, 0 0 0 5px #8a6a3a, 0 14px 50px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(0, 0, 0, 0.6);
}
.orn-frame { position: relative; }
#dialog.orn-frame { position: absolute; }
.window.orn { top: 60px; padding: 34px 14px 14px; overflow: visible; max-height: none; }
.window.orn.side { top: 58px; left: 22px; }
.window.orn .cw-banner, .orn-frame .cw-banner { font-size: 18px; padding: 6px 28px 5px; max-width: calc(100% - 70px); overflow: hidden; text-overflow: ellipsis; }
.window.orn .cw-x { top: 6px; right: 8px; }
.orn-body { max-height: calc(100vh - 260px); overflow-y: auto; padding-right: 2px; }
.orn-sub { text-align: center; font-size: 13px; color: var(--cw-dim); margin: 0 0 10px; min-height: 2px; }
.orn-sub:empty { display: none; }

/* Inside: bronze-edged panels, small-caps labels, serif text. */
.orn .cw-label, .orn-frame .cw-label { font-family: 'Cinzel', var(--cw-serif); font-size: 12px; letter-spacing: 0.05em; color: var(--cw-gold); opacity: 0.9; }
.orn .cw-details, .orn .art-help, .orn .train-row, .orn .shop-row, .orn .art-status {
  border: 1px solid rgba(160, 122, 66, 0.45);
  border-radius: 4px;
  background: rgba(8, 10, 12, 0.55);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.5);
  color: var(--cw-text);
  font-family: var(--cw-serif);
}
.orn .shop-row:hover, .orn .train-row.ready { border-color: rgba(232, 207, 152, 0.7); background: rgba(40, 32, 18, 0.55); }
.orn .shop-row.selected { outline: 1px solid var(--cw-gold); }
.orn .shop-price, .orn .shop-gold b, .orn .gold-text { color: #f0d898; }
.orn .shop-name small, .orn .train-text small, .orn .muted, .orn .win-sub { color: var(--cw-dim); }
.orn .item-slot { border-color: rgba(160, 122, 66, 0.55); background: radial-gradient(circle at 50% 35%, #2c3036, #14171a); box-shadow: inset 0 0 0 1px #000, inset 0 0 10px rgba(0, 0, 0, 0.6); }
.orn .item-name { font-family: 'Cinzel', var(--cw-serif); }

/* Tabs and buttons in bronze. */
.orn .tabs, .orn-frame .tabs { background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(160, 122, 66, 0.4); border-radius: 4px; }
.orn .tab, .orn-frame .tab {
  font-family: 'Cinzel', var(--cw-serif);
  letter-spacing: 0.04em;
  color: var(--cw-dim);
  background: linear-gradient(#26231f, #17150f);
  border: 1px solid #3a2e1c;
  border-radius: 3px;
}
.orn .tab.active, .orn-frame .tab.active { color: #fff3d6; background: linear-gradient(#6e5530, #45341c); border-color: var(--cw-gold); }
.orn .orn-body button:not(.tab):not(.item-slot):not(.shop-row):not(.art-slot),
.orn-frame button:not(.tab):not(.quest-btn):not(.cw-x):not(.class-card) {
  font-family: 'Cinzel', var(--cw-serif);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #f6e6bf;
  background: linear-gradient(#6a522e, #3e2f1a);
  border: 1px solid #a07a42;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 236, 190, 0.18), 0 1px 0 #000;
  text-shadow: 0 1px 0 #000;
  cursor: pointer;
}
.orn .orn-body button:not(.tab):not(.item-slot):not(.shop-row):not(.art-slot):hover,
.orn-frame button:not(.tab):not(.quest-btn):not(.cw-x):not(.class-card):hover { border-color: var(--cw-gold); color: #fff6dc; }
.orn .orn-body button.secondary, .orn-frame button.secondary { background: linear-gradient(#34302a, #1e1b17); color: var(--cw-text); border-color: #6a5432; }
.orn button:disabled, .orn-frame button:disabled { opacity: 0.55; cursor: default; }

/* The conversation box. */
#dialog.orn-frame { padding: 16px 18px 14px; }
#dialog .dlg-head { font-family: 'Cinzel', var(--cw-serif); font-size: 17px; color: var(--cw-gold); padding-bottom: 6px; border-bottom: 1px solid rgba(160, 122, 66, 0.35); }
#dialog .dlg-head .muted { font-family: var(--cw-serif); font-size: 13px; color: var(--cw-dim); }
#dialog-text { font-size: 15px; }
#dialog .dlg-actions button { padding: 7px 14px; }

/* Confirmations, the map, the login and other panels. */
.modal-box.orn-frame { padding: 20px 20px 16px; }
.bm-panel.orn-frame { padding: 34px 14px 12px; }
.bm-panel .cw-x { top: 6px; right: 8px; }
.panel.orn-frame { padding: 28px 24px 22px; }
.panel.orn-frame h1, .panel.orn-frame h2 { font-family: 'Cinzel', var(--cw-serif); color: var(--cw-gold); text-shadow: 0 1px 0 #000, 0 0 12px rgba(232, 207, 152, 0.25); }
.panel.orn-frame input { background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(160, 122, 66, 0.5); border-radius: 4px; color: var(--cw-text); font-family: var(--cw-serif); }
.panel.orn-frame input:focus { border-color: var(--cw-gold); }
.panel.orn-frame label, .panel.orn-frame .label { color: var(--cw-dim); }
.panel.orn-frame .class-card { border-color: rgba(160, 122, 66, 0.45); background: rgba(8, 10, 12, 0.5); border-radius: 4px; }
#death .panel.orn-frame { background: radial-gradient(ellipse at 50% 0%, rgba(160, 40, 30, 0.25), transparent 70%), linear-gradient(#26191a, #151012); }
@media (max-width: 600px) {
  .window.orn.side { left: 12px; }
  .window.orn .cw-banner, .orn-frame .cw-banner { font-size: 15px; }
}

/* ---------- v0.19: pluses and Pemba Sherpa's bench ---------- */
.item-plus {
  position: absolute; right: 2px; top: 1px; font-size: 10px; font-weight: 800; line-height: 1;
  color: #ffd36b; text-shadow: 0 1px 2px #000, 0 0 2px #000; pointer-events: none;
}
.plus-text { color: #ffd36b; font-weight: 800; }
.item-plus-line { margin-top: 4px; font-size: 12px; font-weight: 700; color: #ffd36b; }
.pls-bench { gap: 6px; }
.pls-pair { width: auto; }
.pls-mats { display: flex; gap: 6px; }
.pls-mats .art-slot { width: 52px; height: 52px; }
#plswin { max-height: calc(100vh - 120px); overflow-y: auto; }
.wh-grid .item-slot.fits { box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.75) inset, 0 0 6px rgba(255, 211, 107, 0.5); }

/* ---------- v0.23: gems, Dorje Lama and Artisan Shrestha ---------- */
.item-sockets i.gem, .socket-rings i.gem { box-shadow: 0 0 3px #000, 0 0 4px rgba(255, 255, 255, 0.35); }
.item-sockets i.gem.g-flawless, .socket-rings i.gem.g-flawless { box-shadow: 0 0 2px #000, 0 0 6px #fff; }
.item-slot svg.item-art + .item-count { z-index: 1; }
#gcwin, #gswin { max-height: calc(100vh - 120px); overflow-y: auto; }
.gc-list { max-height: 40vh; }
.gc-row { cursor: default; grid-template-columns: 38px 1fr auto; }
.gc-btns { display: flex; gap: 4px; }
.gc-btns button { padding: 4px 8px; font-size: 12px; }
.gc-need { font-size: 12px; color: var(--muted); font-weight: 700; }
.gs-grid { min-height: 40px; }
.gs-none { grid-column: 1 / -1; margin: 4px 0; font-size: 12px; }
.orn .gs-grid .item-slot.gs-worn { border-color: #e0b048; box-shadow: inset 0 0 0 1px #000, 0 0 6px rgba(224, 176, 72, 0.6); }
.gs-bench { align-items: center; gap: 14px; }
.gs-sockets { display: flex; gap: 10px; border-radius: 30px; }
.gs-sockets.forge-ok { animation: forgeok 1.2s ease-out; }
.gs-socket {
  width: 46px; height: 46px; border-radius: 50%; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #8a7a58; background: radial-gradient(circle at 50% 40%, #1a1c20, #050608);
  box-shadow: inset 0 2px 8px #000;
}
.gs-socket.ghost { opacity: 0.25; cursor: default; display: inline-block; }
.gs-socket.full { border-color: #e8dcb8; }
.gs-socket.selected { border-color: #ffd36b; box-shadow: inset 0 2px 8px #000, 0 0 8px rgba(255, 211, 107, 0.8); }
.gs-socket svg.gs-gem { width: 38px; height: 38px; }
.gs-piecelabel { flex: 1; text-align: left; font-size: 12px; }

/* ---------- v0.27.2: keeping the scenery on this device ---------- */
#scenery { z-index: 90; }
.scenery-box { max-width: 420px; }
.scenery-box h3 { margin: 0 0 8px; font-family: 'Cinzel', var(--cw-serif, serif); color: var(--cw-gold, #e8cf98); font-size: 17px; }
.scenery-box p { margin: 0 0 10px; }
#scenery-status { font-weight: 700; }
.scenery-bar { height: 10px; margin: 0 0 10px; border-radius: 5px; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(160, 122, 66, 0.5); overflow: hidden; }
.scenery-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #b8862a, #f0cf70); transition: width 0.3s; }
#scenery-open { pointer-events: auto; font: inherit; font-size: 12px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; cursor: pointer; margin-right: 6px; }
#scenery-open:hover { color: var(--text); }
.scenery-hint { margin: 10px 0 0; font-size: 13px; }
#join .orn-frame button.linkish, button.linkish { width: auto; background: none; border: 0; box-shadow: none; padding: 0; font: inherit; font-family: inherit; text-transform: none; letter-spacing: 0; color: var(--cw-gold, #e8cf98); text-decoration: underline; cursor: pointer; }

/* ---------- v0.28: teams, trading, the player menu ---------- */
#player-menu { position: fixed; z-index: 40; min-width: 170px; padding: 10px 10px 8px; display: flex; flex-direction: column; gap: 6px; pointer-events: auto; }
#player-menu .pm-name { font-family: 'Cinzel', var(--cw-serif); color: var(--cw-gold); font-size: 14px; padding-bottom: 4px; border-bottom: 1px solid rgba(160, 122, 66, 0.35); }
#player-menu .pm-name .muted { font-family: var(--cw-serif); font-size: 12px; }
#player-menu button { padding: 6px 10px; text-align: left; }
#requests { position: absolute; top: 120px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); z-index: 30; pointer-events: auto; }
#requests .req { display: flex; align-items: center; gap: 10px; padding: 10px 12px; font-size: 14px; }
#requests .req > span:first-child { flex: 1; }
#requests .req small { margin-left: 6px; }
#requests .req-btns { display: flex; gap: 6px; }
#requests .req-btns button { padding: 6px 10px; }
#team { position: absolute; top: 60px; left: 16px; width: 200px; padding: 8px 10px; border-radius: 8px; background: rgba(14, 15, 14, 0.92); border: 1px solid rgba(160, 122, 66, 0.45); font-size: 12px; pointer-events: auto; font-family: var(--cw-serif); color: var(--cw-text); }
.tm-head { font-family: 'Cinzel', var(--cw-serif); color: var(--cw-gold); font-size: 13px; margin-bottom: 4px; }
.tm { padding: 4px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.tm.dead { opacity: 0.5; }
.tm.away .tm-hp { opacity: 0.5; }
.tm-top { display: flex; align-items: center; gap: 4px; }
.tm-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tm-crown { color: #ffd36b; }
.tm-btn { width: 18px; height: 18px; padding: 0; line-height: 1; font-size: 11px; color: var(--cw-dim); background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(160, 122, 66, 0.4); border-radius: 3px; cursor: pointer; }
.tm-btn:hover { color: #fff; border-color: var(--cw-gold); }
.tm-hp { height: 5px; margin-top: 3px; background: #3a1517; border-radius: 3px; overflow: hidden; }
.tm-hp i { display: block; height: 100%; background: linear-gradient(#e85a60, #d8343c); }
.tm-loot { display: flex; flex-direction: column; gap: 2px; margin: 6px 0; padding-top: 6px; border-top: 1px solid rgba(160, 122, 66, 0.3); }
.tm-loot label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.tm-loot input:disabled + * , .tm-loot input:disabled { cursor: default; }
.tm-leave { width: 100%; padding: 4px; font: inherit; font-size: 12px; color: var(--cw-dim); background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(160, 122, 66, 0.4); border-radius: 4px; cursor: pointer; }
.tm-leave:hover { color: #fff; }
#tradewin { width: min(420px, calc(100vw - 32px)); max-height: calc(100vh - 120px); overflow-y: auto; }
.tr-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tr-side { padding: 6px; border: 1px solid rgba(160, 122, 66, 0.4); border-radius: 4px; background: rgba(8, 10, 12, 0.45); }
.tr-side.drop-over { outline: 2px solid var(--gold); }
.tr-side .cw-label { margin-top: 0; }
.tr-grid { grid-template-columns: repeat(5, 1fr); }
.tr-gold { margin-top: 6px; font-size: 13px; }
.tr-ok { color: #9dff9a; font-family: var(--cw-serif); text-transform: none; letter-spacing: 0; }
.tr-goldform { display: flex; gap: 6px; margin-top: 10px; }
.tr-goldform input { flex: 1; min-width: 0; padding: 6px 8px; font: inherit; color: var(--cw-text); background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(160, 122, 66, 0.5); border-radius: 4px; user-select: text; -webkit-user-select: text; }
.tr-goldform button { padding: 6px 12px; }
#tr-bag .item-slot.offered { opacity: 0.35; }
@media (max-width: 700px) { #team { top: 54px; width: 160px; } }

/* ---------- v0.29: chat and emotes ---------- */

#chat { position: absolute; left: 16px; bottom: 78px; width: min(340px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 4px; pointer-events: none; z-index: 12; }
#chat-lines { max-height: 132px; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding: 4px 6px; border-radius: 8px; font-size: 13px; line-height: 1.35; text-shadow: 0 1px 2px #000, 0 0 3px #000; scrollbar-width: thin; }
#chat-lines:empty { display: none; }
#chat:not(.active) #chat-lines { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px); mask-image: linear-gradient(to bottom, transparent 0, #000 16px); }
.chat-line { overflow-wrap: anywhere; transition: opacity 1.2s; }
.chat-line.old { opacity: 0; }
.chat-name { font-weight: 700; cursor: pointer; pointer-events: auto; }
.chat-name:hover { text-decoration: underline; }
#chat-form { display: none; gap: 4px; pointer-events: auto; }
#chat.active #chat-form { display: flex; }
#chat.active #chat-lines { max-height: 240px; background: rgba(8, 10, 9, 0.72); border: 1px solid rgba(160, 122, 66, 0.35); pointer-events: auto; }
#chat.active .chat-line.old { opacity: 0.85; }
#chat-form select, #chat-form input, #chat-form button { font: inherit; font-size: 13px; border-radius: 6px; border: 1px solid rgba(160, 122, 66, 0.5); background: rgba(14, 15, 14, 0.92); color: #f4ecd8; padding: 6px 8px; }
#chat-form input { flex: 1; min-width: 0; }
#chat-form input:focus { outline: 2px solid rgba(232, 201, 138, 0.6); outline-offset: 0; }
#chat-emote { cursor: pointer; font-size: 16px !important; padding: 2px 9px !important; }
#emote-menu { position: absolute; bottom: 44px; right: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 8px; pointer-events: auto; min-width: 200px; }
#emote-menu.hidden { display: none; }
#emote-menu button { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
#chat-open { position: absolute; left: 16px; bottom: 30px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(160, 122, 66, 0.5); background: rgba(14, 15, 14, 0.85); font-size: 18px; cursor: pointer; pointer-events: auto; z-index: 11; }
#log { bottom: 230px; }

/* Narrow screens: the chat sits above the bar along the bottom, and the
   speech-bubble button opens it. */
@media (max-width: 1100px) {
  #chat { bottom: 150px; }
  #chat:not(.active) #chat-lines { max-height: 64px; }
  #log { bottom: 230px; }
  #chat-open { bottom: 104px; }
}
@media (max-width: 700px) {
  #chat { bottom: 170px; }
  #log { bottom: 254px; }
  #chat-open { bottom: 124px; }
}

/* v0.29: windows can be dragged about by their titles. */
.window .cw-banner { cursor: move; touch-action: none; user-select: none; }
body.moving-window, body.moving-window * { user-select: none !important; cursor: move !important; }
.window.moved { margin: 0; transform: none; }

/* ---------- v0.30: PK mode, friends and the market's stalls ---------- */
#team { top: 98px; }
#pk-panel { position: absolute; top: 52px; left: 16px; z-index: 5; pointer-events: auto; }
#pk-mode { padding: 6px 12px; font-family: var(--cw-serif); font-size: 13px; color: var(--cw-text); cursor: pointer; border-radius: 6px; background: rgba(14, 15, 14, 0.9); }
#pk-mode .pk-label { color: var(--cw-dim); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
#pk-mode b { color: var(--cw-gold); }
#pk-mode.mode-pk b { color: #ff7a5a; }
#pk-mode.mode-capture b { color: #7ac4ff; }
#pk-mode .pk-points { margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.45); font-size: 11px; }
#pk-mode .pk-points.red { color: #ff5a4a; }
#pk-mode .pk-points.black { color: #e8e2d8; background: #000; }
#pk-menu { position: absolute; top: calc(100% + 6px); left: 0; width: 280px; padding: 10px; display: flex; flex-direction: column; gap: 5px; }
#pk-menu .pk-head { font-family: 'Cinzel', var(--cw-serif); color: var(--cw-gold); font-size: 13px; padding-bottom: 4px; border-bottom: 1px solid rgba(160, 122, 66, 0.35); }
#pk-menu button { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 10px; text-align: left; }
#pk-menu button small { font-weight: 400; opacity: 0.8; font-size: 11px; line-height: 1.3; }
#pk-menu button.on { outline: 1px solid var(--cw-gold); }
#pk-menu .pk-friends { margin-top: 4px; }
.fr-add, .st-advert, .st-askrow { display: flex; gap: 6px; margin: 8px 0; }
.fr-add input, .st-advert input, .st-askrow input { flex: 1; min-width: 0; }
.st-askrow input.st-qty { flex: 0 0 4.2em; }
#fr-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
.fr-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.25); }
.fr-name { flex: 1; font-weight: 600; }
.fr-row button { padding: 3px 8px; font-size: 12px; }
.fr-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; }
.fr-dot.on { background: #6ad06a; }
.st-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.st-slot { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(160, 122, 66, 0.3); }
.st-slot .item-slot { width: 52px; height: 52px; }
.st-price { min-height: 16px; font-size: 12px; }
.st-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; }
.st-pager button { padding: 2px 10px; }
.st-ask { padding: 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.35); border: 1px solid rgba(160, 122, 66, 0.45); }
#sv-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.sv-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; background: rgba(0, 0, 0, 0.28); }
.sv-row.selected { outline: 1px solid var(--cw-gold); }
.sv-row .item-slot { width: 42px; height: 42px; flex: none; }
.sv-name { flex: 1; min-width: 0; text-align: left; background: none; border: none; padding: 0; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sv-price { font-size: 13px; white-space: nowrap; }
.sv-row button[data-buy] { padding: 5px 12px; }

/* ---------- v0.32: lucky finds ---------- */
#announce { position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); width: min(820px, calc(100vw - 32px)); text-align: center; font-family: 'Cinzel', var(--cw-serif); font-size: clamp(20px, 3.2vw, 34px); font-weight: 700; color: #ffd86a; text-shadow: 0 0 6px #000, 0 2px 4px #000, 0 0 18px rgba(255, 120, 200, 0.8); pointer-events: none; z-index: 60; opacity: 0; }
#announce.show { animation: announceflash 0.5s steps(2, jump-none) 12, announcefade 7s forwards; }
@keyframes announceflash { from { color: #ffd86a; } to { color: #ff7ad8; } }
@keyframes announcefade { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); } 6% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 10% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; } }
#lucky { position: absolute; top: 46%; left: 50%; transform: translate(-50%, -50%); text-align: center; font-family: 'Cinzel', var(--cw-serif); font-size: clamp(18px, 2.6vw, 28px); font-weight: 700; pointer-events: none; z-index: 59; opacity: 0; text-shadow: 0 0 6px #000, 0 2px 4px #000; white-space: nowrap; }
#lucky.turd { color: #d8a8ff; }
#lucky.bollock { color: #ff9ad8; }
#lucky.show { animation: luckypop 3.5s forwards; }
@keyframes luckypop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 18% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%); } }
