/* AetherForge KO 1298 web client — HUD in the spirit of the 1298 layout.
   Dark umber frames with brass edges, red/blue bars, chat bottom-left, skills bottom-centre,
   mini map top-right. All artwork is CSS; nothing is copied from Knight Online. */

:root {
  --ink: #f3ead7;
  --dim: #cbb892;
  --brass: #a98443;
  --brass-dark: #6b5126;
  --frame: rgba(26, 19, 13, 0.9);
  --frame-light: rgba(52, 38, 24, 0.95);
  --hp: #b8312a;
  --mp: #2f63b6;
  --exp: #c89a2d;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font: 13px/1.35 "Segoe UI", Tahoma, sans-serif;
  color: var(--ink);
  background: #100e0c;
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.frame {
  background: var(--frame);
  border: 1px solid var(--brass);
  box-shadow:
    inset 0 0 0 1px rgba(255, 224, 150, 0.14),
    0 2px 10px rgba(0, 0, 0, 0.55);
  border-radius: 3px;
}

h1,
h2,
h3 {
  margin: 0 0 6px;
  font-size: 15px;
  letter-spacing: 0.3px;
  color: #f0d48a;
  text-shadow: 0 1px 0 #000;
}

h2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--brass-dark);
}

h3 {
  margin-top: 8px;
  font-size: 13px;
}

p {
  margin: 3px 0;
}

.sub,
.note {
  color: var(--dim);
  font-size: 12px;
}

button,
input,
select {
  font: inherit;
  color: var(--ink);
  background: linear-gradient(#4a3620, #2c1f12);
  border: 1px solid var(--brass);
  border-radius: 2px;
  padding: 3px 8px;
  margin: 2px 3px 2px 0;
}

button:hover:not(:disabled) {
  background: linear-gradient(#5f4628, #3a2918);
}

button:disabled {
  opacity: 0.45;
}

input,
select {
  background: #1a130d;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 1px solid #f0d48a;
}

kbd {
  display: inline-block;
  margin-left: 5px;
  padding: 0 4px;
  font: 10px/14px Consolas, monospace;
  color: #f0d48a;
  border: 1px solid var(--brass-dark);
  border-radius: 2px;
  background: #1a130d;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}

.row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--dim);
  font-size: 12px;
}

.row input {
  width: 90px;
}

/* ---------- character gate ---------- */

#gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  pointer-events: none;
}

.dev {
  display: none;
}

#gate[hidden] {
  display: none;
}

.gate-card {
  pointer-events: auto;
  width: min(420px, calc(100vw - 32px));
  padding: 22px 22px 18px;
  border: 1px solid rgba(232, 208, 160, 0.35);
  border-radius: 16px;
  background: rgba(12, 14, 18, 0.82);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.gate-card .kicker {
  margin: 0;
  letter-spacing: 0.18em;
  font-size: 12px;
  color: #e8d0a0;
}

.gate-card h1 {
  margin: 4px 0 8px;
  font-size: 28px;
}

#status {
  margin: 0 0 12px;
  color: #d7d2c8;
}

#gate #error {
  margin: 0 0 12px;
  color: #ffb4a8;
}

#nation-pick:not([hidden]) {
  display: flex;
  gap: 8px;
}

#nation-pick[hidden],
#create-form[hidden] {
  display: none;
}

#nation-pick button,
#create-form button,
#characters button {
  border: 1px solid rgba(232, 208, 160, 0.4);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

#create-form:not([hidden]) {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

#create-form input {
  width: 100%;
  margin-top: 4px;
}

#characters {
  display: grid;
  gap: 8px;
}

#characters button {
  text-align: left;
}

#gate-back[hidden] {
  display: none;
}

#gate-back:not([hidden]) {
  display: inline-block;
  margin-top: 14px;
  color: #e8d0a0;
}

.link-note {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(12, 14, 18, 0.82);
  color: #e8d0a0;
}

/* ---------- HUD ---------- */

#hud[hidden] {
  display: none;
}

#plate {
  position: fixed;
  top: 10px;
  left: 10px;
  width: 262px;
  padding: 8px 10px;
}

.plate-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  width: 34px;
  height: 34px;
  border: 1px solid var(--brass);
  border-radius: 50%;
  background: #3a3228;
  box-shadow: inset 0 0 0 3px #1a130d;
  flex: none;
}

.badge.karus {
  background: radial-gradient(#d24a3a, #6e1d15);
}

.badge.elmorad {
  background: radial-gradient(#4f82d6, #1a3a7a);
}

#char-name {
  margin: 0;
  font-size: 18px;
  color: #f0d48a;
  text-shadow: 0 1px 0 #000;
}

.bars {
  display: grid;
  gap: 4px;
  margin-top: 6px;
}

.bar {
  position: relative;
  height: 14px;
}

.bar i {
  display: block;
  height: 100%;
  border: 1px solid #000;
  background: #1a0f0d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bar i b {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(#e0574d, var(--hp) 55%, #7a1e18);
  transition: width 0.15s linear;
}

.bar.mana i {
  background: #0d1220;
}

.bar.mana i b {
  background: linear-gradient(#6c9ae8, var(--mp) 55%, #1c3a70);
}

.bar.exp {
  height: 9px;
}

.bar.exp i b {
  background: linear-gradient(#f2cf6a, var(--exp) 55%, #7a5a16);
}

.bar span {
  position: absolute;
  inset: 0;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.bar.exp span {
  line-height: 9px;
  font-size: 8px;
}

.bar.small {
  height: 11px;
}

.bar.small span {
  line-height: 11px;
  font-size: 9px;
}

.plate-foot {
  margin-top: 6px;
  font-size: 12px;
  color: var(--dim);
}

#target-frame {
  position: fixed;
  top: 10px;
  left: 282px;
  width: 230px;
  padding: 6px 10px;
}

.target-head {
  margin: 0 0 4px;
  font-size: 14px;
  color: #f0d48a;
}

#target-frame.hostile .target-head {
  color: #ffb4a8;
}

#menu {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 92px;
  display: grid;
  gap: 2px;
  padding: 4px;
}

#menu button {
  margin: 0;
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px;
}

#menu button.on {
  background: linear-gradient(#7a5a2a, #4a3620);
}

#minimap-box {
  position: fixed;
  top: 10px;
  right: 110px;
  width: 196px;
  padding: 4px;
}

#minimap {
  display: block;
  width: 196px;
  height: 196px;
  border: 1px solid var(--brass-dark);
  background: #24180f;
}

.map-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--dim);
}

.map-zoom button {
  margin: 0;
  padding: 0 6px;
  line-height: 16px;
}

#chat {
  position: fixed;
  left: 10px;
  bottom: 10px;
  width: 400px;
  padding: 4px 6px 6px;
}

#chat-tabs {
  display: flex;
  gap: 2px;
}

#chat-tabs button {
  margin: 0;
  padding: 1px 8px;
  font-size: 11px;
  border-bottom: none;
  border-radius: 2px 2px 0 0;
  background: #2a1f14;
}

#chat-tabs button.on {
  background: linear-gradient(#5f4628, #3a2918);
  color: #f0d48a;
}

#chat-log {
  height: 128px;
  overflow-y: auto;
  padding: 4px 6px;
  font-size: 12px;
  background: rgba(10, 7, 5, 0.7);
  border: 1px solid var(--brass-dark);
}

#chat-log p {
  margin: 1px 0;
  word-break: break-word;
}

#chat-log .general { color: #f3ead7; }
#chat-log .party { color: #8fd4ff; }
#chat-log .clan { color: #a4e49a; }
#chat-log .shout { color: #ffcf6a; }
#chat-log .whisper { color: #e3a6ff; }
#chat-log .war { color: #ff9f8a; }
#chat-log .system { color: #b7a98a; }
#chat-log .error { color: #ff8e7e; }

#chat-form {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}

#chat-form select {
  width: 74px;
  margin: 0;
}

#chat-form input {
  flex: 1;
  margin: 0;
}

#chat-form button {
  margin: 0;
}

#skills {
  position: fixed;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 6px 8px 4px;
}

.slots {
  display: flex;
  gap: 3px;
}

.slots button {
  position: relative;
  width: 48px;
  height: 48px;
  margin: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  border: 1px solid var(--brass);
  background: linear-gradient(#2d2419, #1a130d);
  color: var(--ink);
  font-size: 10px;
  line-height: 1.1;
  padding: 2px;
}

.slots button .key {
  position: absolute;
  top: 1px;
  left: 3px;
  font-size: 9px;
  color: #f0d48a;
}

.slots button .mark {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.slots button .cool {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 13px;
}

.slots button.ready {
  box-shadow: 0 0 6px rgba(240, 212, 138, 0.45);
}

.mark.warrior { background: #b23b2f; }
.mark.rogue { background: #3d6b4f; }
.mark.mage { background: #3a5f99; }
.mark.priest { background: #c7b15a; }
.mark.empty { background: #2a241c; }

.actions {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 4px;
}

.actions button {
  margin: 0;
  padding: 2px 8px;
  font-size: 12px;
}

#skills .sub {
  margin: 3px 0 0;
  text-align: center;
  min-height: 14px;
}

#toasts {
  position: fixed;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 3px;
  pointer-events: none;
  z-index: 5;
}

#toasts p {
  margin: 0;
  padding: 3px 12px;
  background: rgba(20, 14, 10, 0.82);
  border: 1px solid var(--brass-dark);
  color: #f6e7bf;
  font-size: 13px;
  text-align: center;
  animation: toast 4s forwards;
}

#toasts p.bad {
  color: #ffb4a8;
}

#toasts p.good {
  color: #b8f0a8;
}

@keyframes toast {
  0% { opacity: 0; transform: translateY(-6px); }
  8% { opacity: 1; transform: none; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- panels ---------- */

.panel {
  position: fixed;
  padding: 8px 10px 10px;
  z-index: 6;
  max-height: calc(100vh - 220px);
  overflow: auto;
}

.panel h2 .close {
  margin: 0;
  padding: 0 7px;
  line-height: 16px;
  font-size: 13px;
}

#inventory-panel {
  top: 150px;
  right: 110px;
  width: 470px;
}

.inventory-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
}

.equip-grid {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-auto-rows: 46px;
  gap: 3px;
  padding: 4px;
  background: rgba(10, 7, 5, 0.6);
  border: 1px solid var(--brass-dark);
  align-content: start;
}

.bag-grid {
  display: grid;
  grid-template-columns: repeat(7, 40px);
  grid-auto-rows: 40px;
  gap: 3px;
  padding: 4px;
  background: rgba(10, 7, 5, 0.6);
  border: 1px solid var(--brass-dark);
}

.slot {
  position: relative;
  margin: 0;
  padding: 1px;
  display: grid;
  place-items: center;
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
  overflow: hidden;
  border: 1px solid var(--brass-dark);
  background: #1d1810;
  color: var(--ink);
}

.slot.empty {
  color: #6b5c45;
}

.slot.filled {
  background: linear-gradient(#3b2d1b, #241a10);
  border-color: var(--brass);
}

.slot.selected {
  outline: 2px solid #f0d48a;
}

.slot .count {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 9px;
  color: #f0d48a;
}

.slot .gap {
  visibility: hidden;
}

#npc-panel {
  top: 150px;
  left: 10px;
  width: 400px;
}

.list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 4px 0;
}

.list button {
  margin: 0;
  font-size: 11px;
  padding: 2px 6px;
}

.list button.monster {
  border-color: #8a3a2f;
}

.list button.merchant {
  border-color: #c89a2d;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.shop-grid button {
  margin: 0;
  font-size: 11px;
  text-align: left;
  padding: 3px 6px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.shop-grid button span {
  color: #f0d48a;
}

#party-panel {
  left: 10px;
  bottom: 230px;
  width: 400px;
}

#party-panel .member {
  margin: 4px 0;
  padding: 4px 6px;
  border: 1px solid var(--brass-dark);
  background: rgba(10, 7, 5, 0.5);
}

#party-panel .member p {
  margin: 1px 0;
}

#party-panel .mini {
  display: block;
  height: 6px;
  margin: 2px 0;
  background: #3a2418;
}

#party-panel .mini b {
  display: block;
  height: 6px;
  background: #c4473a;
}

#party-panel .mini.mana b {
  background: #3a6ea5;
}

#clan-panel {
  left: 420px;
  bottom: 230px;
  width: 460px;
}

#trade-panel {
  top: 150px;
  left: 420px;
  width: 460px;
}

#system-panel {
  top: 220px;
  right: 110px;
  width: 440px;
  font-size: 12px;
}

#help-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 440px;
}

#help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

#help-table td {
  padding: 3px 4px;
  border-bottom: 1px solid var(--brass-dark);
  vertical-align: top;
}

#help-table td:first-child {
  width: 46%;
  color: #f0d48a;
}

@media (max-width: 1100px) {
  #chat {
    width: 300px;
  }

  #inventory-panel,
  #system-panel {
    right: 10px;
  }
}
