/* Skeleton Horde — menu chrome. The game itself renders to canvas. */

:root {
  --bone: #e8dfc0;
  --bone-dim: #a2947a;
  --bone-faint: #6f6857;
  --blood: #e04a3a;
  --ember: #f2c14e;
  --ink: #0a0908;
  --panel: rgba(12, 11, 9, 0.92);
  --font: "Courier New", ui-monospace, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#view { z-index: 1; image-rendering: pixelated; cursor: crosshair; }
#hud  { z-index: 2; pointer-events: none; }

/* ------------------------------------------------------------- overlay */

#overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(ellipse at center, rgba(10, 9, 8, 0.72) 0%, rgba(6, 5, 5, 0.96) 70%);
  backdrop-filter: blur(3px);
}
#overlay.hidden { display: none; }

/*
 * Over the menu backdrop rather than over the live game: much lighter, and no
 * blur, so the ossuary wall behind is actually readable as a wall of skulls.
 * The panels carry their own near-opaque background, so text stays legible.
 */
#overlay.menu {
  background:
    radial-gradient(ellipse at center, rgba(10, 9, 8, 0.10) 0%, rgba(6, 5, 5, 0.62) 80%);
  backdrop-filter: none;
}

.screen { display: none; width: 100%; }
.screen.active { display: grid; place-items: center; }

.panel {
  width: min(520px, 100%);
  padding: 32px 34px 28px;
  background: var(--panel);
  border: 1px solid rgba(180, 168, 130, 0.28);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 24px 70px rgba(0, 0, 0, 0.75);
  text-align: center;
}
.panel.wide { width: min(880px, 100%); }

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

.title {
  font-size: clamp(30px, 6vw, 52px);
  font-weight: bold;
  letter-spacing: 0.1em;
  line-height: 1.05;
  color: var(--bone);
  text-shadow: 0 3px 0 #000, 0 0 26px rgba(255, 120, 40, 0.22);
}
.title span { display: block; color: var(--blood); }
.title.small { font-size: clamp(24px, 4vw, 34px); letter-spacing: 0.16em; }
.title.dead { color: var(--blood); }

.tagline {
  margin-top: 12px;
  color: var(--bone-dim);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.best {
  margin-top: 10px;
  color: var(--ember);
  font-size: 13px;
  letter-spacing: 0.1em;
  min-height: 16px;
}
.best.highlight {
  color: #8fe36a;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }

/* ------------------------------------------------------------- buttons */

button {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 15px 18px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: linear-gradient(180deg, #efe6c6, #b9ad8a);
  border: 1px solid #6a6047;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

button.ghost {
  margin-top: 10px;
  color: var(--bone-dim);
  background: transparent;
  border-color: rgba(180, 168, 130, 0.3);
  font-size: 13px;
  padding: 11px 16px;
}
button.ghost:hover { color: var(--bone); border-color: rgba(180, 168, 130, 0.6); }

/* ------------------------------------------------------------- columns */

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 26px;
  margin-top: 28px;
  text-align: left;
}
@media (max-width: 700px) {
  .columns { grid-template-columns: 1fr; gap: 20px; }
}

.col h2 {
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--bone-faint);
  border-bottom: 1px solid rgba(180, 168, 130, 0.2);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.col h2:not(:first-child) { margin-top: 22px; }

.keys {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  font-size: 12px;
}
.keys dt { color: var(--ember); white-space: nowrap; }
.keys dd { color: var(--bone-dim); }

.bestiary { list-style: none; font-size: 12px; line-height: 1.65; }
.bestiary li { color: var(--bone-faint); }
.bestiary b { display: inline-block; min-width: 108px; letter-spacing: 0.06em; }

/* ------------------------------------------------------------- options */

.options { display: grid; gap: 9px; }
.options label {
  display: grid;
  grid-template-columns: 88px 1fr 46px;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--bone-dim);
}
.options label.check {
  grid-template-columns: auto 1fr;
  cursor: pointer;
}
.options em { font-style: normal; color: var(--bone-faint); text-align: right; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: rgba(180, 168, 130, 0.22);
  border-radius: 2px;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ember);
  border: 1px solid #6a6047;
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border: 1px solid #6a6047;
  border-radius: 50%;
  background: var(--ember);
}
input[type="checkbox"] { accent-color: var(--ember); width: 14px; height: 14px; cursor: pointer; }

/* --------------------------------------------------------------- misc */

.status { margin-top: 18px; color: var(--bone-dim); font-size: 13px; letter-spacing: 0.06em; }

.loadbar {
  margin-top: 14px;
  height: 3px;
  background: rgba(180, 168, 130, 0.16);
  border-radius: 2px;
  overflow: hidden;
}
.loadbar i {
  display: block;
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  animation: slide 1.15s ease-in-out infinite;
}
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(320%); } }

.hint {
  margin-top: 16px;
  font-size: 11px;
  color: var(--bone-faint);
  letter-spacing: 0.05em;
}
.hint.hidden { display: none; }

kbd {
  padding: 1px 5px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--bone);
  background: rgba(180, 168, 130, 0.14);
  border: 1px solid rgba(180, 168, 130, 0.3);
  border-radius: 3px;
}

/* ---------------------------------------------------------------- chat */

#chat-bar {
  position: fixed;
  left: 24px;
  bottom: 190px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  width: min(560px, calc(100vw - 48px));
  background: rgba(6, 6, 5, 0.88);
  border: 1px solid rgba(159, 216, 255, 0.4);
  border-radius: 4px;
}
#chat-bar.hidden { display: none; }

.chat-prompt {
  font-family: var(--font);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.18em;
  color: #9fd8ff;
}

#chat-input {
  flex: 1;
  padding: 4px 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--bone);
  background: transparent;
  border: none;
  outline: none;
}
#chat-input::placeholder { color: var(--bone-faint); font-size: 12px; }

/* ------------------------------------------------------- touch controls */

#touch-controls {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;         /* only the widgets take input */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
#touch-controls.hidden { display: none; }
/* The whole surface must accept the stick and look drags. */
#touch-controls { pointer-events: auto; }

.tc-stick {
  position: absolute;
  left: 40px;
  bottom: 150px;
  width: 124px;
  height: 124px;
  border: 2px solid rgba(180, 168, 130, 0.28);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.tc-stick.active { opacity: 1; }
.tc-stick i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(232, 223, 192, 0.32);
  border: 1px solid rgba(232, 223, 192, 0.5);
}

.tc-buttons {
  position: absolute;
  right: 18px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 12px;
  justify-items: end;
  align-items: end;
}

.tc-btn {
  width: 74px;
  height: 74px;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.08em;
  color: var(--bone);
  background: rgba(20, 18, 15, 0.55);
  border: 1px solid rgba(180, 168, 130, 0.4);
  border-radius: 50%;
  transition: none;
}
.tc-btn.down {
  background: rgba(242, 193, 78, 0.35);
  border-color: var(--ember);
  transform: none;
}
.tc-btn.tc-fire {
  grid-row: span 2;
  width: 104px;
  height: 104px;
  font-size: 14px;
  background: rgba(120, 30, 22, 0.5);
  border-color: rgba(224, 86, 63, 0.6);
}
.tc-btn.tc-fire.down { background: rgba(224, 86, 63, 0.55); }

@media (max-height: 480px) {
  .tc-btn { width: 60px; height: 60px; font-size: 11px; }
  .tc-btn.tc-fire { width: 84px; height: 84px; }
  .tc-stick { bottom: 110px; }
}

/* ----------------------------------------------------------- main menu */

.mainmenu { margin-top: 26px; }
.mainmenu button { margin-top: 10px; }
.mainmenu button:first-child { margin-top: 0; }

button.menu {
  color: var(--bone);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(180, 168, 130, 0.32);
  font-size: 14px;
}
button.menu:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(180, 168, 130, 0.6);
  filter: none;
}
button.menu:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
button.back { margin-top: 22px; }

.wide-options { margin-top: 22px; text-align: left; }
.wide-options label { grid-template-columns: 110px 1fr 52px; font-size: 12px; }

/* ---------------------------------------------------------- difficulty */

.difficulty { margin-top: 20px; }
.difficulty .roomlabel { margin-top: 0; }

.tiers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin: 8px 0 6px;
}

.tier {
  padding: 10px 8px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: var(--bone-faint);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(180, 168, 130, 0.18);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.tier:hover { color: var(--bone-dim); border-color: rgba(180, 168, 130, 0.4); }
.tier.selected {
  color: var(--ink);
  background: linear-gradient(180deg, #efe4c0, #c9bb90);
  border-color: rgba(242, 193, 78, 0.7);
  text-shadow: none;
}
/* Deeper tiers read hotter, so the ladder is obvious before you read a word. */
.tier[data-tier="ossuary"].selected { background: linear-gradient(180deg, #e8a765, #c07c3a); }
.tier[data-tier="charnel"].selected { background: linear-gradient(180deg, #e0705a, #b03a2c); color: #fff2e8; }

#difficulty-blurb, #mode-blurb { min-height: 30px; margin-top: 4px; }
#mode-blurb { margin-bottom: 14px; }
/* Only two run modes, so they get a row each rather than a 2x2 block. */
#mode-tiers { grid-template-columns: repeat(2, 1fr); }
#mode-tiers .tier.selected { background: linear-gradient(180deg, #c9b0e8, #8f6fbe); color: #17111f; }

.title.won { color: var(--ember); text-shadow: 0 0 30px rgba(242, 193, 78, 0.35); }
.best.rank { color: var(--ember); min-height: 16px; }

/* -------------------------------------------------------- leaderboards */

.boards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 16px;
  text-align: left;
}
@media (max-width: 720px) {
  .boards { grid-template-columns: 1fr; }
}

.board h2 {
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.18em;
  color: var(--ember);
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(180, 168, 130, 0.22);
}

.board ol { list-style: none; margin-top: 8px; }
.board li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 6px;
  align-items: baseline;
  padding: 5px 4px;
  font-size: 12px;
  color: var(--bone-dim);
  border-bottom: 1px solid rgba(180, 168, 130, 0.07);
}
.board li .rank { color: var(--bone-faint); font-size: 11px; }
.board li .who { color: var(--bone); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .val { color: var(--ember); font-weight: bold; }
.board li .sub { grid-column: 2 / 4; font-size: 10px; color: var(--bone-faint); }
/* Your own runs, so you can find yourself in a long list. */
.board li.mine { background: rgba(242, 193, 78, 0.09); border-radius: 3px; }
.board li.mine .who { color: var(--ember); }
.board .empty { padding: 10px 4px; font-size: 11px; font-style: italic; color: var(--bone-faint); }

/* --------------------------------------------------------- multiplayer */

.status.good { color: #8fe36a; }
.status.bad { color: var(--blood); }

.joinrow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}
.joinrow button { margin-top: 0; }

#mp-code {
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(180, 168, 130, 0.32);
  border-radius: 4px;
}
#mp-code:focus { outline: none; border-color: var(--ember); }
#mp-code::placeholder { color: var(--bone-faint); letter-spacing: 0.2em; }

.mp-error { margin-top: 10px; min-height: 16px; font-size: 12px; color: var(--blood); }

/* Survivor name — the lobby copy and the settings copy edit the same value. */
.namebox {
  width: 100%;
  margin: 4px 0 16px;
  padding: 11px 14px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-align: center;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(180, 168, 130, 0.32);
  border-radius: 4px;
}
.namebox:focus { outline: none; border-color: var(--ember); }
.namebox::placeholder { color: var(--bone-faint); letter-spacing: 0.1em; }
.namebox:disabled { opacity: 0.5; cursor: not-allowed; }

.options label.namefield { grid-template-columns: 110px 1fr; }
.options label.namefield input {
  padding: 7px 10px;
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(180, 168, 130, 0.32);
  border-radius: 3px;
}
.options label.namefield input:focus { outline: none; border-color: var(--ember); }

.namestatus {
  min-height: 15px;
  margin: -8px 0 12px;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--bone-faint);
}
.namestatus.good { color: #8fe36a; }
.namestatus.bad { color: var(--blood); }

.roomlabel {
  margin-top: 20px;
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--bone-faint);
}
.roomcode {
  font-size: clamp(38px, 9vw, 58px);
  font-weight: bold;
  letter-spacing: 0.28em;
  color: var(--ember);
  text-shadow: 0 0 24px rgba(242, 193, 78, 0.28);
  margin: 4px 0 2px;
}

.playerlist {
  list-style: none;
  margin-top: 18px;
  text-align: left;
  display: grid;
  gap: 6px;
}
.playerlist li {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--bone-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(180, 168, 130, 0.16);
  border-radius: 4px;
}
.playerlist li.you { color: var(--bone); border-color: rgba(242, 193, 78, 0.45); }
.playerlist li.empty { color: var(--bone-faint); font-style: italic; opacity: 0.55; }

.warnbox {
  margin-top: 18px;
  padding: 11px 13px;
  font-size: 11px;
  line-height: 1.55;
  text-align: left;
  color: #e0c07a;
  background: rgba(224, 135, 63, 0.09);
  border: 1px solid rgba(224, 135, 63, 0.3);
  border-radius: 4px;
}

.hidden { display: none; }

.scoreline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 22px;
}
.scoreline div {
  padding: 12px 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(180, 168, 130, 0.16);
  border-radius: 4px;
}
.scoreline b { display: block; font-size: 24px; color: var(--bone); }
.scoreline span { font-size: 10px; letter-spacing: 0.16em; color: var(--bone-faint); }
