:root {
  --bg: #05070a;
  --lime: #cfff04;
  --orange: #ff7a1a;
  --dim: #5c6870;
  --ink: #e8eef2;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
}

#stage3d, #stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#stage3d { z-index: 1; }
#stage { z-index: 2; pointer-events: none; cursor: crosshair; }

/* top + bottom chrome float over the canvas */
.arena-head, .arena-foot {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  z-index: 5;
  pointer-events: none;
}
.arena-head { top: 0; }
.arena-foot { bottom: 0; }

.arena-head a {
  pointer-events: auto;
  color: var(--dim);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: color 0.2s;
}
.arena-head a:hover { color: var(--ink); }

.arena-head .title {
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--dim);
}
.arena-head .duel { color: var(--lime); }

.arena-foot span {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--dim);
}

/* ── wallet connect button (header) ── */
.connect {
  pointer-events: auto;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: rgba(8, 12, 16, 0.7);
  border: 1px solid var(--lime);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, color 0.15s;
  white-space: nowrap;
}
.connect:hover { background: rgba(207, 255, 4, 0.14); box-shadow: 0 0 22px rgba(207, 255, 4, 0.25); }
.connect.on { color: var(--lime); border-color: rgba(207, 255, 4, 0.55); }

/* ── duel HUD (right panel) ── */
.duel-hud {
  position: fixed;
  top: 62px;
  right: 18px;
  width: 300px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  z-index: 6;
  background: rgba(7, 10, 14, 0.82);
  border: 1px solid rgba(92, 104, 112, 0.35);
  border-radius: 12px;
  padding: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.duel-hud.collapsed { display: none; }

.dh-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.dh-title {
  font-size: 11px;
  letter-spacing: 0.28em;
  color: var(--lime);
}
.dh-close {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.dh-close:hover { color: var(--ink); }

.mono { font-family: inherit; }

.dh-status {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--dim);
  min-height: 1.5em;
  margin-bottom: 10px;
}

.dh-approve {
  width: 100%;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #05070a;
  background: var(--lime);
  border: 0;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  margin-bottom: 12px;
  box-shadow: 0 0 24px rgba(207, 255, 4, 0.25);
}
.dh-approve:hover { filter: brightness(1.08); }
.dh-approve:disabled { opacity: 0.5; cursor: default; }

.dh-section { margin-bottom: 12px; }
.dh-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dh-pool { color: var(--lime); }

.dh-list { display: flex; flex-direction: column; gap: 6px; }

.dh-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 7px 9px;
  border: 1px solid rgba(92, 104, 112, 0.28);
  border-radius: 8px;
  color: var(--ink);
}
.dh-row.mine { border-color: rgba(207, 255, 4, 0.5); background: rgba(207, 255, 4, 0.05); }
.dh-id { font-weight: 700; color: var(--ink); }
.dh-tier { font-size: 10px; letter-spacing: 0.04em; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--dim); color: var(--dim); }
.dh-tier.legendary { color: #ffd166; border-color: #ffd166; }
.dh-tier.elite { color: #c792ea; border-color: #c792ea; }
.dh-tier.rare { color: #5fe0d0; border-color: #5fe0d0; }
.dh-tier.standard { color: var(--dim); border-color: rgba(92, 104, 112, 0.4); }
.dh-who { color: var(--dim); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.dh-tag { font-size: 9.5px; letter-spacing: 0.05em; color: var(--lime); text-transform: uppercase; }

.dh-hres {
  font-size: 9px;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.dh-hres.win { color: #05070a; background: var(--lime); }
.dh-hres.loss { color: #ff6b6b; border: 1px solid #ff6b6b; }

.dh-btn {
  margin-left: auto;
  font-family: inherit;
  font-size: 11px;
  padding: 4px 10px;
  border: 1px solid var(--lime);
  background: transparent;
  color: var(--lime);
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}
.dh-btn:hover { background: rgba(207, 255, 4, 0.12); }
.dh-btn.ghost { border-color: var(--dim); color: var(--dim); }
.dh-btn.ghost:hover { background: rgba(255, 255, 255, 0.05); }

.dh-empty {
  font-size: 11px;
  color: var(--dim);
  padding: 8px 10px;
  border: 1px dashed rgba(92, 104, 112, 0.35);
  border-radius: 8px;
}

.dh-note {
  font-size: 10px;
  color: var(--dim);
  word-break: break-all;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(92, 104, 112, 0.25);
}

/* ── leaderboard (left panel) ── */
.lb-hud {
  position: fixed;
  top: 62px;
  left: 18px;
  width: 250px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  z-index: 6;
  background: rgba(7, 10, 14, 0.82);
  border: 1px solid rgba(92, 104, 112, 0.35);
  border-radius: 12px;
  padding: 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
}
.lb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.lb-title {
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--lime);
}
.lb-live {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--orange);
  display: flex;
  align-items: center;
  gap: 5px;
}
.lb-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 8px var(--orange);
  animation: lb-blink 1.2s infinite;
}
@keyframes lb-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.lb-sub {
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 10px;
}
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 8px;
  border: 1px solid rgba(92, 104, 112, 0.18);
  border-radius: 7px;
  color: var(--ink);
}
.lb-rank {
  width: 18px;
  text-align: center;
  font-weight: 700;
  color: var(--dim);
}
.lb-row.top1 { border-color: rgba(255, 209, 102, 0.6); background: rgba(255, 209, 102, 0.06); box-shadow: 0 0 16px rgba(255, 209, 102, 0.12); }
.lb-row.top2 { border-color: rgba(214, 225, 235, 0.45); background: rgba(214, 225, 235, 0.05); }
.lb-row.top3 { border-color: rgba(224, 158, 106, 0.45); background: rgba(224, 158, 106, 0.05); }
.lb-row.top1 .lb-rank { color: #ffd166; }
.lb-row.top2 .lb-rank { color: #d6e1eb; }
.lb-row.top3 .lb-rank { color: #e09e6a; }
.lb-addr {
  color: var(--dim);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
}
.lb-nft { color: var(--ink); font-weight: 700; }
.lb-pts { color: var(--lime); font-weight: 700; text-align: right; }

/* wallet picker overlay */
.picker-wrap {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(4, 6, 4, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.picker-box {
  background: #0c0f0b;
  border: 1px solid #1e2420;
  border-radius: 10px;
  padding: 18px;
  width: 100%;
  max-width: 320px;
}
.picker-box .pk-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #8b9490;
  margin-bottom: 12px;
}
.picker-box button.pk {
  display: block;
  width: 100%;
  text-align: left;
  margin: 6px 0;
  padding: 11px 13px;
  background: #11150f;
  border: 1px solid #1e2420;
  color: #e8ece8;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.picker-box button.pk:hover { border-color: var(--lime); }
.picker-box button.pk-cancel {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  background: none;
  border: 0;
  color: #8b9490;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

/* wallet menu dropdown */
.wallet-menu {
  position: fixed;
  z-index: 9999;
  width: 260px;
  max-width: calc(100vw - 24px);
  background: #0c0f0b;
  border: 1px solid #1e2420;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65);
}
.wallet-menu .wm-addr {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  margin-bottom: 8px;
  background: #11150f;
  border: 1px solid #1e2420;
  border-radius: 8px;
  color: #e8ece8;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.5;
  word-break: break-all;
}
.wallet-menu .wm-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  margin: 4px 0;
  background: none;
  border: 1px solid #1e2420;
  border-radius: 8px;
  color: #cfff04;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
}
.wallet-menu .wm-row.danger { color: #ff6b6b; }

@media (max-width: 640px) {
  .arena-head, .arena-foot { padding: 12px 14px; }
  .arena-head .title { display: none; }
  .lb-hud { display: none; }
  .duel-hud {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    max-height: 46vh;
    border-radius: 14px 14px 0 0;
  }
}
