* { margin: 0; padding: 0; box-sizing: border-box; }

html, body, #app, #game {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #17181c;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #e8e6df;
}

#game { position: absolute; inset: 0; }
.game-canvas { display: block; cursor: default; touch-action: none; user-select: none; }

/* ------------------------------------------------------------- top bar */
.top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: linear-gradient(to bottom, rgba(12,12,16,0.92), rgba(12,12,16,0.55) 75%, transparent);
  z-index: 10;
  pointer-events: none;
}
.top-bar > * { pointer-events: auto; }
.brand {
  font-weight: 800;
  letter-spacing: 3px;
  font-size: 14px;
  color: #d8b45a;
}
.chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e8e6df;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.chip:hover { background: rgba(255,255,255,0.16); }
.room-chip { font-family: ui-monospace, monospace; letter-spacing: 1px; }
.spacer { flex: 1; }
.status { font-size: 12px; color: #999; }
.status.offline { color: #e5735d; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.players { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.player { display: inline-flex; align-items: center; gap: 5px; opacity: 0.92; }
.player i {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px rgba(0,0,0,0.6);
}
.player.spectator { opacity: 0.6; }
.spec-tag {
  font-style: normal;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #b9b6ac;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 5px;
  padding: 1px 4px;
  margin-left: 2px;
}

/* ----------------------------------------------------------------- log */
.log {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: 12.5px;
  line-height: 1.55;
  color: #cfccc2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 10;
  max-width: 42ch;
}

/* ---------------------------------------------------------------- menu */
.menu {
  position: absolute;
  z-index: 30;
  min-width: 190px;
  background: rgba(24,25,30,0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}
.menu-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9b988e;
  padding: 6px 10px 4px;
}
.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #e8e6df;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.menu-item:hover { background: rgba(255,255,255,0.1); }
.menu-sub { color: #d6d3c8; }
.menu-back {
  color: #b9b6ab;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px 6px 0 0;
  margin-bottom: 3px;
}

/* ---------------------------------------------------------- action bar */
.action-bar {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 10px;
  z-index: 12;
  display: flex;
  gap: 5px;
  padding: 5px;
  background: rgba(24,25,30,0.82);
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  max-width: min(94vw, 720px);
  flex-wrap: wrap;
  justify-content: center;
}
.action-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #e8e6df;
  font-size: 12.5px;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.action-btn:hover { background: rgba(255,255,255,0.16); }
.action-btn kbd {
  font: 10px/1 ui-monospace, monospace;
  color: #b9b6ab;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 4px;
  padding: 1.5px 4px;
}

/* --------------------------------------------------------------- toast */
.toast {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translate(-50%, -8px);
  background: rgba(24,25,30,0.95);
  border: 1px solid rgba(255,255,255,0.16);
  padding: 8px 16px;
  border-radius: 9px;
  font-size: 13px;
  opacity: 0;
  transition: all .25s;
  z-index: 40;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------- find bar */
.find-bar {
  position: absolute;
  top: 58px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(24,25,30,0.95);
  border: 1px solid rgba(255,255,255,0.16);
  padding: 8px 12px;
  border-radius: 9px;
  z-index: 41;
}
.find-bar input {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #e8e6df;
  font: inherit;
  font-size: 13.5px;
  padding: 5px 9px;
  border-radius: 6px;
  width: 200px;
}
.find-bar input:focus { border-color: #d8b45a; outline: none; }
.find-count { font-size: 12.5px; color: #b9b6ac; min-width: 70px; }

/* ------------------------------------------------------------- chat bar */
.chat-bar {
  position: absolute;
  left: 14px;
  bottom: 12px;
  z-index: 41;
}
.chat-bar input {
  background: rgba(24,25,30,0.95);
  border: 1px solid rgba(255,255,255,0.16);
  color: #e8e6df;
  font: inherit;
  font-size: 13px;
  padding: 7px 11px;
  border-radius: 9px;
  width: min(300px, 70vw);
}
.chat-bar input:focus { border-color: #d8b45a; outline: none; }
/* While typing, the log shifts up to sit above the input. */
.log.chat-open { bottom: 52px; }

/* ---------------------------------------------------------------- help */
.help {
  position: absolute;
  top: 60px;
  right: 14px;
  z-index: 25;
  width: 380px;
  background: rgba(24,25,30,0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.help h2 { font-size: 15px; margin-bottom: 10px; color: #d8b45a; }
.help table { width: 100%; border-collapse: collapse; font-size: 13px; }
.help td { padding: 3.5px 4px; vertical-align: top; }
.help td:first-child { color: #a8a49a; white-space: nowrap; padding-right: 12px; }
.help p { font-size: 12.5px; color: #a8a49a; margin: 10px 0; }
.help button { margin-top: 4px; }

/* ---------------------------------------------------------------- join */
.join {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #23252c 0%, #131418 75%);
}
.join-card {
  width: 380px;
  text-align: center;
  padding: 40px 34px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.join-card h1 {
  font-size: 26px;
  letter-spacing: 5px;
  color: #d8b45a;
  margin-bottom: 6px;
}
.join-card h1 span { color: #7a766c; font-size: 15px; letter-spacing: 2px; }
.join-card p { color: #a8a49a; font-size: 13.5px; margin-bottom: 24px; }
.join-card input {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #e8e6df;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
}
.join-card input:focus { border-color: #d8b45a; }
.join-card button {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 9px;
  border: none;
  background: #d8b45a;
  color: #221d10;
  cursor: pointer;
  transition: filter .15s;
}
.join-card button:hover { filter: brightness(1.08); }

/* --------------------------------------------------------------- lobby */
.lobby {
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, #23252c 0%, #131418 75%);
}
.lobby-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 48px 20px 60px;
}
.lobby-inner h1 {
  font-size: 30px;
  letter-spacing: 6px;
  color: #d8b45a;
  text-align: center;
}
.lobby-inner h1 span { color: #7a766c; font-size: 16px; letter-spacing: 2px; }
.lobby-sub {
  color: #a8a49a;
  font-size: 13.5px;
  text-align: center;
  margin: 6px 0 34px;
}
.lobby-inner h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #9b988e;
  margin: 26px 0 12px;
}
.lobby-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.lobby-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 14px 16px 13px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 3px solid var(--accent, #d8b45a);
  border-radius: 12px;
  color: #e8e6df;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.lobby-card:hover { background: rgba(255,255,255,0.08); transform: translateY(-1px); }
.lobby-icon {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 20px;
  color: var(--accent, #d8b45a);
  opacity: 0.9;
}
.lobby-card-head { display: flex; flex-direction: column; gap: 2px; padding-right: 30px; }
.lobby-card-name { font-size: 15.5px; font-weight: 650; }
.lobby-card-players { font-size: 11.5px; color: #9b988e; }
.lobby-card-tag { font-size: 12.5px; color: #a8a49a; line-height: 1.45; }
.lobby-join { display: flex; gap: 10px; }
.lobby-join input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  font-family: ui-monospace, monospace;
  letter-spacing: 1px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(0,0,0,0.35);
  color: #e8e6df;
  outline: none;
  min-width: 0;
}
.lobby-join input:focus { border-color: #d8b45a; }
.lobby-go {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 9px;
  border: none;
  background: #d8b45a;
  color: #221d10;
  cursor: pointer;
}
.lobby-go:hover { filter: brightness(1.08); }
.lobby-rooms { display: flex; flex-direction: column; gap: 7px; margin-top: 14px; }
.lobby-loading { color: #7a766c; font-size: 13px; padding: 6px 2px; }
.lobby-room {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  color: #e8e6df;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.lobby-room:hover { background: rgba(255,255,255,0.07); }
.lobby-room-code { font-family: ui-monospace, monospace; letter-spacing: 1px; }
.lobby-room-type { font-size: 12.5px; }
.lobby-live { color: #3dc76a; margin-left: auto; font-size: 12px; }
.lobby-saved { color: #7a766c; margin-left: auto; font-size: 12px; }

/* ------------------------------------------------------------ select box */
.select-box {
  position: fixed;
  z-index: 20;
  border: 1.5px solid rgba(77, 163, 255, 0.9);
  background: rgba(77, 163, 255, 0.12);
  border-radius: 2px;
  pointer-events: none;
}

/* -------------------------------------------------------------- settings */
.settings {
  position: absolute;
  top: 60px;
  right: 14px;
  z-index: 26;
  width: 340px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: rgba(24,25,30,0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.settings h2 { font-size: 15px; color: #d8b45a; margin-bottom: 12px; }
.settings h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #9b988e;
  margin: 14px 0 8px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.settings-row select,
.settings-row input[type="range"] {
  background: rgba(0,0,0,0.35);
  color: #e8e6df;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 12.5px;
  max-width: 200px;
}
.settings-row input[type="range"] { padding: 0; accent-color: #d8b45a; }
.settings-hint { font-size: 11.5px; color: #8a867c; margin: 4px 0 6px; }
.bind-btn { min-width: 74px; text-align: center; font-family: ui-monospace, monospace; font-size: 12px; }
.bind-btn.capturing { border-color: #d8b45a; color: #d8b45a; animation: pulse 1s infinite; }
.settings-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
}

/* -------------------------------------------------------------- card zoom */
.card-zoom {
  position: absolute;
  top: 50%;
  right: 26px;
  transform: translateY(-50%);
  z-index: 35;
  pointer-events: none;
  text-align: center;
  filter: drop-shadow(0 14px 40px rgba(0,0,0,0.75));
  animation: zoom-in .12s ease-out;
}
@keyframes zoom-in { from { opacity: 0; transform: translateY(-50%) scale(0.94); } }
.card-zoom-face {
  width: min(420px, 38vw, 62vh);
  height: auto;
  border-radius: 14px;
  display: block;
}
.card-zoom-name {
  margin-top: 8px;
  font-size: 13px;
  color: #e8e6df;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

/* -------------------------------------------------------------- inspector */
.inspector {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 28;
  width: min(1000px, calc(100vw - 40px));
  background: rgba(24,25,30,0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.inspector-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.inspector-title { font-size: 13.5px; font-weight: 600; color: #d8b45a; }
.inspector-hint { flex: 1; font-size: 12px; color: #9b988e; }
.inspector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-w, 92px), 1fr));
  gap: 8px;
  overflow-y: auto;
  max-height: 46vh;
  padding: 2px 2px 4px;
}
.inspector-card {
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 0;
  cursor: grab;
  user-select: none;
  transition: transform .1s, border-color .1s;
}
.inspector-card canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
.inspector-card:hover { transform: translateY(-4px); border-color: #4da3ff; }

/* --------------------------------------------------------- settings tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 8px;
}
.settings-tab {
  background: none;
  border: 1px solid transparent;
  color: #9b988e;
  font-size: 12.5px;
  padding: 5px 12px;
  border-radius: 7px;
  cursor: pointer;
}
.settings-tab:hover { color: #e8e6df; background: rgba(255,255,255,0.06); }
.settings-tab.active {
  color: #d8b45a;
  background: rgba(216,180,90,0.1);
  border-color: rgba(216,180,90,0.35);
}

/* ------------------------------------------------------------------- bags */
.bag-panel {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 29;
  width: min(560px, calc(100vw - 40px));
  background: rgba(24,25,30,0.97);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.bag-list { max-height: 40vh; overflow-y: auto; }
.bag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.bag-row:last-child { border-bottom: none; }
.bag-name { flex: 1; font-size: 13.5px; }
.bag-when { font-size: 11.5px; color: #9b988e; }
.bag-empty { padding: 14px 4px; font-size: 13px; color: #9b988e; }
.inspector-shuffle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #cfccc2;
  white-space: nowrap;
  cursor: pointer;
}
.inspector-shuffle input { accent-color: #d8b45a; }

.bag-thumb { width: 34px; flex: 0 0 auto; display: flex; }
.bag-thumb canvas { width: 100%; height: auto; border-radius: 3px; }

/* ------------------------------------------------------------- life panel */
.life-panel {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(24,25,30,0.92);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}
.life-row { display: flex; align-items: center; gap: 5px; }
.life-row.mine .life-total { color: #ffd479; }
.life-row i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.life-name { max-width: 9ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cfccc2; }
.life-total { font-weight: 700; font-size: 15px; min-width: 2.2ch; text-align: center; }
.life-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e8e6df;
  border-radius: 6px;
  width: 20px; height: 20px;
  cursor: pointer;
  line-height: 1;
}
.life-btn:hover { background: rgba(255,255,255,0.18); }
.life-toggle { font-size: 11px; padding: 3px 8px; }
.cmd-grid { display: flex; flex-direction: column; gap: 3px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,0.12); }
.cmd-head, .cmd-hint { font-size: 10px; color: #9b988e; }
.cmd-row { display: flex; align-items: center; gap: 4px; }
.cmd-row i { width: 7px; height: 7px; border-radius: 50%; }
.cmd-cell {
  width: 22px; text-align: center; font-size: 12px;
  background: rgba(255,255,255,0.06); border-radius: 4px; cursor: pointer;
  user-select: none;
}
.cmd-cell:hover { background: rgba(255,255,255,0.14); }
.cmd-self { opacity: 0.3; cursor: default; }

/* ------------------------------------------------------------ scry panel */
.scry-card { position: relative; }
.scry-tag {
  position: absolute;
  bottom: 4px; left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 6px;
  background: rgba(47,158,68,0.9);
  color: #fff;
  pointer-events: none;
}
.scry-card.scry-away { opacity: 0.6; }
.scry-card.scry-away .scry-tag { background: rgba(192,57,43,0.9); }
.inspector-search {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 7px;
  color: #e8e6df;
  font-size: 12px;
  padding: 4px 9px;
  width: 190px;
}
.inspector-search:focus { border-color: #d8b45a; outline: none; }
