* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; background: #0e1116; font-family: system-ui, sans-serif; }
#game { display: block; width: 100vw; height: 100vh; cursor: crosshair; }
#hud {
  position: fixed; left: 12px; top: 12px; color: #d7e0ea;
  font-size: 13px; line-height: 1.4; pointer-events: none;
  text-shadow: 0 1px 2px #000;
}
#status { font-weight: 600; }
#help { opacity: 0.7; margin-top: 2px; }
#skills {
  margin-top: 10px; background: rgba(14,17,22,0.6); padding: 6px 10px;
  border-radius: 6px; min-width: 140px; display: inline-block;
}
.skill-title { font-weight: 600; margin-bottom: 4px; }
.skill-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.skill-row.hp-row { font-weight: 700; color: #ff6b6b; border-bottom: 1px solid rgba(255,255,255,0.15); padding-bottom: 3px; margin-bottom: 3px; }

/* Inventory panel (28 slots, 4x7 grid) */
#equip-btn {
  position: fixed; right: 12px; bottom: 312px; pointer-events: auto;
  background: rgba(14,17,22,0.75); color: #d7e0ea; border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; text-shadow: 0 1px 2px #000;
}
#equip-btn:hover { border-color: rgba(255,210,74,0.5); color: #ffe9a8; }
#inv {
  position: fixed; right: 12px; bottom: 12px; color: #d7e0ea;
  font-size: 12px; pointer-events: auto; text-shadow: 0 1px 2px #000;
  background: rgba(14,17,22,0.6); padding: 6px 10px; border-radius: 6px;
}
.inv-grid { display: grid; grid-template-columns: repeat(4, 34px); grid-template-rows: repeat(7, 34px); gap: 3px; margin-top: 4px; }
.inv-cell { width: 34px; height: 34px; border-radius: 4px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; }
.inv-cell.filled { background: rgba(255,210,74,0.12); border-color: rgba(255,210,74,0.4); }
.inv-name { font-size: 8px; line-height: 1; text-align: center; padding: 0 2px; color: #ffe9a8; }
.inv-qty { font-size: 11px; font-weight: 700; color: #fff; }

/* Right-click context menu (RuneScape-style pick/inspect) */
.ctx-menu {
  position: fixed; z-index: 50; min-width: 140px;
  background: #1b212b; border: 1px solid #3a4452; border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.55); padding: 4px; color: #e6edf3;
  font-size: 13px; user-select: none;
}
.ctx-item {
  padding: 6px 10px; border-radius: 4px; cursor: pointer; white-space: nowrap;
}
.ctx-item:hover { background: #2d3744; }

/* Login overlay */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,0.82); z-index: 10;
}
#login-form {
  background: #161b22; padding: 28px 32px; border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5); width: 280px; text-align: center;
  border: 1px solid #2a313c;
}
#login-form .login-logo {
  display: block; width: 240px; max-width: 100%; height: auto; margin: 0 auto 18px;
}
#login-form h1 { color: #ffd24a; font-size: 20px; margin-bottom: 18px; font-weight: 700; }
#login-form .row { margin-bottom: 12px; }
#login-form input {
  width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid #2a313c;
  background: #0e1116; color: #e6edf3; font-size: 14px; outline: none;
}
#login-form input:focus { border-color: #ffd24a; }
#login-form .buttons { display: flex; gap: 10px; }
#login-form button {
  flex: 1; padding: 10px; border-radius: 6px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; background: #ffd24a; color: #1a1a1a;
}
#login-form button:hover { background: #ffdd6e; }
#login-form .msg { min-height: 16px; margin-top: 10px; font-size: 12px; color: #ff8a8a; }

/* Hidden utility (picker + preview only show in register mode) */
.hidden { display: none !important; }

/* Appearance picker (registration) */
#appearance { margin: 4px 0 10px; display: flex; flex-direction: column; gap: 6px; }
.appear-row { display: flex; align-items: center; gap: 8px; }
.appear-label { width: 46px; font-size: 12px; color: #cdd6e2; text-align: right; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatch {
  width: 22px; height: 22px; border-radius: 4px; border: 2px solid transparent;
  cursor: pointer; padding: 0; color: #888; font-size: 9px; line-height: 1;
  background: #2a2f3a; display: flex; align-items: center; justify-content: center;
}
.swatch.def { width: auto; padding: 0 6px; }
.swatch.sel { border-color: #ffd24a; }
.swatch:hover { outline: 1px solid #ffd24a; }

/* Live avatar preview (registration) */
.appearance-preview { margin: 4px auto 10px; width: 56px; text-align: center; }
.appearance-preview .preview-label { font-size: 10px; color: #cdd6e2; margin-bottom: 2px; }
.appearance-preview canvas { background: #1b1f29; border: 1px solid #333a47; border-radius: 4px; }

/* Chat feed (player speech + game events) */
#chat-log {
  position: fixed; left: 12px; bottom: 12px; width: 320px; max-height: 180px;
  overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  color: #eaf0f7; font-size: 13px; line-height: 1.4; pointer-events: auto;
  /* Solid dark panel so text stays readable over the game canvas. */
  background: rgba(8, 10, 14, 0.88);
  border: 1px solid #1c222b; border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
  text-shadow: 0 1px 2px #000;
  -webkit-mask-image: none;
  mask-image: none;
}
#chat-log::-webkit-scrollbar { width: 6px; }
#chat-log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.chat-row { word-wrap: break-word; }
.chat-name { font-weight: 700; color: #ffd24a; }
.chat-say .chat-text { color: #f2f6fb; }
.chat-system { font-style: italic; }
.chat-system .chat-text { color: #cdd9e5; } /* brighter than the old muted blue */

#chat-input {
  position: fixed; left: 12px; bottom: 200px; width: 320px;
  padding: 8px 10px; border-radius: 6px; border: 1px solid #2a313c;
  background: rgba(14,17,22,0.85); color: #e6edf3; font-size: 13px; outline: none;
  pointer-events: auto; display: none;
}
#chat-input.open { display: block; }
#chat-input:focus { border-color: #ffd24a; }

/* Bank modal (100 slots, 10x10) with bag shown side-by-side */
#bank-window {
  background: #161b22; padding: 16px 18px; border-radius: 10px;
  border: 1px solid #2a313c; box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  color: #e6edf3; max-width: 92vw;
}
.bank-header {
  font-size: 15px; font-weight: 700; color: #ffd24a; margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.bank-hint { font-size: 11px; font-weight: 400; color: #9fb3c8; }
.bank-close { margin-left: auto; cursor: pointer; color: #9fb3c8; font-size: 18px; line-height: 1; padding: 0 4px; }
.bank-close:hover { color: #ff8a8a; }
#bank-body { display: flex; gap: 18px; }
.bank-col { display: flex; flex-direction: column; }
.bank-col-title { font-size: 12px; color: #9fb3c8; margin-bottom: 6px; text-align: center; }
.bank-grid {
  grid-template-columns: repeat(10, 34px);
  grid-template-rows: repeat(10, 34px);
}

/* Pouch / coins HUD */
#pouch {
  position: fixed; top: 10px; right: 12px; z-index: 8;
  color: #ffd24a; font-weight: 700; font-size: 14px;
  background: rgba(14,17,22,0.7); padding: 6px 10px; border-radius: 6px;
  border: 1px solid #2a313c;
  pointer-events: auto; cursor: context-menu;
}
#pouch #coins { color: #fff; }

/* Shop reuses the bank-window / bank-* styling; just reuse .bank-* classes.
   The shop uses id #shop-window (styled like #bank-window) and .shop-coins. */
#shop-window { max-width: 92vw; }
.shop-coins { margin-left: auto; color: #ffd24a; font-weight: 700; font-size: 13px; }

/* Death screen overlay */
#death-window {
  background: #1a1116; padding: 30px 38px; border-radius: 12px; text-align: center;
  box-shadow: 0 12px 50px rgba(0,0,0,0.6); border: 1px solid #3a1f25; width: 300px;
}
#death-title { font-size: 26px; font-weight: 800; color: #ff7a7a; letter-spacing: 0.5px; }
#death-sub { margin-top: 6px; color: #c9b3b8; font-size: 13px; }
#death-lost { margin: 16px 0; font-size: 12px; color: #e6d2d2; min-height: 1px; }
#death-lost .lost-row { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
#death-lost .lost-skill { font-weight: 600; }
#death-lost .lost-xp { color: #ffb0b0; }
#death-respawn {
  margin-top: 8px; background: #2a1418; color: #ffd24a; border: 1px solid #50303a;
  border-radius: 6px; padding: 9px 26px; font-size: 14px; font-weight: 700; cursor: pointer;
}
#death-respawn:hover { background: #3a1c22; color: #ffe9a8; }
