:root {
  --ink: #efe3cc;
  --dim: #a8987c;
  --gold: #e8c060;
  --panel: rgba(20, 13, 10, 0.92);
  --edge: #6a4a2c;
  --edge-hi: #b88a4c;
  --hp: #c8302a;
  --xp: #5a9a3a;
  --r0: #c8c2b4;
  --r1: #5f9cff;
  --r2: #f2d24b;
  --r3: #b45cff;
  --r4: #ff9a2e;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #050306;
  color: var(--ink);
  font-family: "Alegreya Sans", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
canvas#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  color: var(--ink);
  background: linear-gradient(#4a3020, #2c1c12);
  border: 2px solid var(--edge);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.15);
}
button:hover:not(:disabled) {
  border-color: var(--edge-hi);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: linear-gradient(#b0641e, #6e3410);
  border-color: #e09040;
  font-weight: 800;
}
input {
  font: inherit;
  color: var(--ink);
  background: #120a08;
  border: 2px solid var(--edge);
  border-radius: 6px;
  padding: 8px 10px;
}
.fine {
  color: var(--dim);
  font-size: 13px;
  line-height: 1.4;
}
.kicker {
  font-family: "Alegreya Sans SC", serif;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-size: 13px;
  margin: 14px 0 6px;
}

/* ---------- title ---------- */

/* The two prototypes: tabs at the top of each title card. */
.modes {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.modes a {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  border: 2px solid var(--edge);
  border-radius: 6px;
  color: var(--dim);
  text-decoration: none;
  font-family: "Alegreya Sans SC", serif;
  letter-spacing: 0.06em;
  background: #1a100c;
}
.modes a.on {
  color: var(--ink);
  border-color: var(--gold);
  background: linear-gradient(#6a4420, #3a2010);
}
.modes a:hover:not(.on) {
  border-color: var(--edge-hi);
}


.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 20%, rgba(120, 50, 10, 0.35), rgba(5, 3, 6, 0.92) 70%);
  z-index: 5;
}
.card {
  width: min(760px, 100%);
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 10px;
  padding: 20px 24px;
  box-shadow: 0 0 60px rgba(255, 120, 30, 0.12), inset 0 0 0 1px rgba(255, 200, 120, 0.08);
}
h1 {
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: clamp(42px, 9vw, 72px);
  margin: 0;
  letter-spacing: 0.04em;
  background: linear-gradient(#ffe8a0, #ff9a2e 55%, #a83a10);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #2a1208);
}
.lede {
  line-height: 1.5;
  color: #d8c8a8;
  margin: 8px 0 0;
}
#classes,
#roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.cls,
.saved {
  display: flex;
  gap: 8px;
  align-items: center;
  text-align: left;
  padding: 6px;
  border-radius: 8px;
}
.cls canvas,
.saved canvas {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 1px solid #000;
  image-rendering: pixelated;
  flex: none;
}
.cls b,
.saved b {
  display: block;
  font-weight: 800;
}
.cls small,
.saved small {
  color: var(--dim);
  font-size: 12px;
}
.cls.on,
.saved.on {
  border-color: var(--gold);
  background: linear-gradient(#6a4420, #3a2010);
  box-shadow: 0 0 12px rgba(255, 180, 60, 0.35);
}
.saved {
  position: relative;
}
.saved .del {
  position: absolute;
  right: 4px;
  top: 2px;
  font-size: 11px;
  color: var(--dim);
  padding: 2px 4px;
  border: none;
  background: none;
}
.row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.row.join input {
  width: 110px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}
label.name {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
#hud > * {
  pointer-events: auto;
}
#me {
  position: absolute;
  left: 10px;
  top: 10px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
}
.portrait-wrap {
  position: relative;
}
.portrait-wrap canvas {
  width: 56px;
  height: 56px;
  border: 2px solid #c08a40;
  border-radius: 6px;
  display: block;
  image-rendering: pixelated;
}
#me-lvl {
  position: absolute;
  left: -4px;
  bottom: -4px;
  background: #1a0e08;
  border: 2px solid #c08a40;
  border-radius: 8px;
  font-weight: 800;
  font-size: 13px;
  padding: 0 5px;
}
.me-bars {
  width: 170px;
}
#me-name {
  margin: 0 0 3px;
  font-weight: 800;
  font-size: 15px;
}
.bar {
  position: relative;
  height: 12px;
  background: #1a0c0a;
  border: 1px solid #000;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 3px;
}
.bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(#e85048, #8a1a14);
  transition: width 0.25s;
}
.bar.xp {
  height: 6px;
}
.bar.xp span {
  background: linear-gradient(#a0e060, #3a7a20);
}
.bar em {
  position: absolute;
  inset: 0;
  font-style: normal;
  font-size: 10px;
  font-weight: 800;
  text-align: center;
  line-height: 12px;
  text-shadow: 0 1px 0 #000;
}
.me-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
}
#me-gold {
  color: var(--gold);
  font-weight: 700;
}
#party {
  position: absolute;
  left: 10px;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pal {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 3px 6px 3px 3px;
  width: 172px;
  font-size: 12px;
}
.pal canvas {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  image-rendering: pixelated;
}
.pal .bar {
  height: 6px;
  margin: 2px 0 0;
}
.pal.down {
  filter: grayscale(1);
}
.pal .tag {
  margin-left: auto;
  color: var(--dim);
  font-size: 11px;
}
.pal .tag.ready {
  color: #8ae070;
}
#banner {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none !important;
  text-shadow: 0 2px 0 #000, 0 0 12px #000;
}
#banner-main {
  margin: 0;
  font-family: "Cinzel", serif;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.05em;
}
#banner-main.foes {
  color: #ff6a4a;
}
#banner-main.you {
  color: #ffd870;
}
#banner-sub {
  margin: 2px 0 0;
  font-size: 14px;
  color: #d8c8a8;
}
#mapbox {
  position: absolute;
  right: 10px;
  top: 10px;
  padding: 6px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 8px;
  text-align: center;
}
#minimap {
  display: block;
  width: 184px;
  height: 144px;
  background: #060408;
  border: 1px solid #000;
  border-radius: 4px;
}
#floor-name {
  margin: 4px 0 0;
  font-family: "Alegreya Sans SC", serif;
  font-size: 13px;
  color: var(--gold);
}
#party-code {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--dim);
  cursor: pointer;
}
#bar {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: flex-end;
  padding: 6px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 10px;
}
#skills {
  display: flex;
  gap: 6px;
}
.sk {
  position: relative;
  width: 54px;
  height: 54px;
  padding: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(#3a2618, #1c120c);
}
.sk canvas {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
}
.sk .key {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 11px;
  color: var(--dim);
  font-weight: 700;
}
.sk .cd {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.6);
  font-weight: 800;
  font-size: 20px;
  border-radius: 4px;
}
.sk .lock {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.7);
  font-size: 11px;
  color: var(--dim);
}
.sk .count {
  position: absolute;
  right: 3px;
  bottom: 1px;
  font-size: 12px;
  font-weight: 800;
}
.sk.on {
  border-color: #ffd060;
  box-shadow: 0 0 10px rgba(255, 200, 80, 0.6);
}
.sk.quick::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ad0ff;
}
button.end {
  height: 54px;
  font-family: "Cinzel", serif;
  font-weight: 800;
  background: linear-gradient(#8a3a18, #4a1a08);
  border-color: #c0602a;
}
button.end.ready {
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  50% {
    box-shadow: 0 0 16px rgba(255, 140, 60, 0.8);
  }
}
button.side {
  height: 54px;
}
#log {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: min(360px, 40vw);
  max-height: 150px;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  text-shadow: 0 1px 0 #000, 0 0 6px #000;
  pointer-events: none !important;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
#log p {
  margin: 0;
}
#log .warn {
  color: #ffb050;
}
#log .bad {
  color: #ff6a5a;
}
#log .good {
  color: #9ae07a;
}
#log .area {
  color: var(--gold);
  font-family: "Alegreya Sans SC", serif;
}
#log .sys,
#log .chat-sys {
  color: var(--dim);
}
#log .r1 {
  color: var(--r1);
}
#log .r2 {
  color: var(--r2);
}
#log .r3 {
  color: var(--r3);
}
#log .r4 {
  color: var(--r4);
}
#log .chat b {
  color: var(--gold);
}
#chat {
  position: absolute;
  left: 10px;
  bottom: 166px;
  width: min(360px, 40vw);
}
#zoom {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
#zoom button {
  width: 38px;
  height: 34px;
  padding: 0;
  font-weight: 800;
}
#toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: rgba(20, 8, 6, 0.9);
  border: 1px solid #a04030;
  padding: 6px 14px;
  border-radius: 6px;
  pointer-events: none !important;
}
#hover-card {
  position: absolute;
  pointer-events: none !important;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  min-width: 140px;
}
#hover-card b {
  display: block;
}
#hover-card .sub {
  display: block;
  color: var(--dim);
  font-size: 12px;
}
#hover-card .boss {
  color: #ff8a5a;
}

/* ---------- inventory ---------- */

#bag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  background: linear-gradient(rgba(34, 20, 14, 0.97), rgba(16, 10, 8, 0.97));
  border: 2px solid var(--edge-hi);
  border-radius: 10px;
  padding: 10px 14px 14px;
  z-index: 4;
}
.bag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bag-head h2 {
  font-family: "Cinzel", serif;
  margin: 0;
  font-size: 20px;
  color: var(--gold);
}
.bag-head button {
  padding: 2px 10px;
}
.bag-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  margin-top: 8px;
}
@media (max-width: 560px) {
  .bag-body {
    grid-template-columns: 1fr;
  }
}
.slots {
  display: grid;
  grid-template-columns: repeat(4, 50px);
  gap: 6px;
}
.slot,
.cell {
  position: relative;
  width: 50px;
  height: 50px;
  border: 2px solid #3a2818;
  border-radius: 6px;
  background: radial-gradient(#2a1a12, #120a08);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.slot canvas,
.cell canvas {
  width: 40px;
  height: 40px;
  image-rendering: pixelated;
}
.slot small {
  color: #5a4630;
  font-size: 10px;
}
.slot.r0,
.cell.r0 {
  border-color: #6a6458;
}
.slot.r1,
.cell.r1 {
  border-color: var(--r1);
}
.slot.r2,
.cell.r2 {
  border-color: var(--r2);
}
.slot.r3,
.cell.r3 {
  border-color: var(--r3);
  box-shadow: inset 0 0 10px rgba(180, 92, 255, 0.4);
}
.slot.r4,
.cell.r4 {
  border-color: var(--r4);
  box-shadow: inset 0 0 12px rgba(255, 154, 46, 0.45);
}
.cell.sel {
  outline: 2px solid #fff;
}
.cell .new {
  position: absolute;
  right: 2px;
  top: 0;
  color: #8ae070;
  font-size: 12px;
  font-weight: 800;
}
#bag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 50px);
  gap: 6px;
}
#stats {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
}
#stats b {
  color: var(--gold);
}
#stats .row2 {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dotted #3a2818;
}

/* ---------- the loot tooltip ---------- */

#tip {
  position: fixed;
  z-index: 10;
  width: 290px;
  background: linear-gradient(160deg, rgba(36, 22, 44, 0.98), rgba(14, 10, 18, 0.98));
  border: 2px solid var(--rc, #888);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.7), 0 0 18px color-mix(in srgb, var(--rc, #888) 35%, transparent), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}
#tip.pinned {
  pointer-events: auto;
}
#tip::before,
#tip::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid var(--rc, #888);
  transform: rotate(45deg);
  background: #1a1020;
}
#tip::before {
  left: -7px;
  top: -7px;
}
#tip::after {
  right: -7px;
  bottom: -7px;
}
#tip .head {
  display: flex;
  gap: 10px;
}
#tip .ic {
  width: 52px;
  height: 52px;
  flex: none;
  border: 2px solid var(--rc, #888);
  border-radius: 6px;
  background: radial-gradient(color-mix(in srgb, var(--rc, #888) 30%, #1a1020), #0a0610);
  display: grid;
  place-items: center;
}
#tip .ic canvas {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
}
#tip .nm {
  font-weight: 800;
  font-size: 17px;
  color: var(--rc, #fff);
  margin: 0;
}
#tip .ty {
  color: #c8b8a0;
  margin: 0;
}
#tip .rr {
  color: var(--rc, #fff);
  margin: 0;
}
#tip .val {
  margin: 2px 0 0;
  color: #e8d8b8;
}
#tip .coin {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2a0, #d89a20 60%, #8a5a10);
  margin-right: 4px;
  vertical-align: -1px;
}
#tip hr {
  border: none;
  height: 1px;
  margin: 8px 0;
  background: linear-gradient(90deg, transparent, var(--rc, #888), transparent);
}
#tip .big {
  font-weight: 800;
  font-size: 15px;
  margin: 0;
}
#tip .up {
  color: #7ae060;
}
#tip .down {
  color: #ff5a4a;
}
#tip .ln {
  margin: 1px 0;
  padding-left: 18px;
  position: relative;
  color: #e0d4ff;
}
#tip .ln::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 7px;
  height: 7px;
  transform: rotate(45deg);
  background: var(--ac, #9a8aff);
}
#tip .sub {
  color: #b8a890;
  padding-left: 18px;
  margin: 1px 0;
}
#tip .uniq {
  color: #ffb860;
  margin: 4px 0 0;
}
#tip .uniq b {
  color: #ffd070;
}
#tip .req {
  color: #9a8a70;
  font-size: 12px;
  margin: 4px 0 0;
}
#tip .req.bad {
  color: #ff6a5a;
}
#tip .foot {
  display: flex;
  justify-content: space-between;
  color: #d8c8a8;
  font-size: 12px;
}
#tip .acts {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
#tip .acts button {
  flex: 1;
  padding: 6px;
  font-size: 13px;
}
#link-lost {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 2px solid #a04030;
  padding: 12px 20px;
  border-radius: 8px;
  z-index: 20;
}

@media (max-width: 700px) {
  #party,
  #log {
    display: none;
  }
  #mapbox {
    transform: scale(0.6);
    transform-origin: top right;
  }
  #banner {
    top: 128px;
    width: 100%;
  }
  #banner-main {
    font-size: 16px;
  }
  #banner-sub {
    font-size: 12px;
  }
  #me {
    transform: scale(0.85);
    transform-origin: top left;
  }
  .me-bars {
    width: 120px;
  }
  .sk {
    width: 46px;
    height: 46px;
  }
  button.end,
  button.side {
    height: 46px;
    padding: 4px 8px;
  }
  #zoom {
    bottom: 76px;
  }
}
