/* Let's Build! — matches claudlings.com: warm near-black, coral accent, system fonts only. */

:root {
  --ink: #0b0a09;
  --surface: #1a1512;
  --line: #2e2620;
  --text: #f6f1eb;
  --dim: #a6998c;
  --coral: #d97757;
  --amber: #e8a24a;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Cascadia Mono", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font-weight: 600;
}

button:hover {
  border-color: var(--coral);
}

button.primary {
  background: var(--coral);
  border-color: var(--coral);
  color: #1b0f0a;
}

button.primary:hover {
  background: var(--amber);
  border-color: var(--amber);
}

input {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}

input:focus {
  outline: 2px solid var(--coral);
  outline-offset: 1px;
}

kbd {
  font-family: var(--mono);
  font-size: 0.78em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0.05em 0.4em;
  background: var(--ink);
}

.small {
  color: var(--dim);
  font-size: 0.82rem;
}

/* ---------------------------------------------------------------- lobby */

#lobby {
  position: fixed;
  inset: 0;
  z-index: 10;
  overflow-y: auto;
  /* The warm glow is painted as this box's own background. A separate position:fixed glow
     layer (as on claudlings.com) froze compositing on a Qualcomm Adreno laptop: the page stopped
     drawing, so clicks and typing never landed. Keep it a plain background. */
  background:
    radial-gradient(60% 45% at 50% 18%, rgba(217, 119, 87, 0.2), transparent 70%),
    radial-gradient(45% 35% at 70% 8%, rgba(232, 162, 74, 0.12), transparent 70%),
    var(--ink);
  padding: 0 16px 2rem;
}

.site-nav {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  justify-content: center;
  padding: 1.1rem 0 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-nav a {
  color: var(--dim);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--amber);
}

.site-nav a[aria-current="page"] {
  color: var(--coral);
}

.lobby-card {
  position: relative;
  max-width: 30rem;
  margin: clamp(2.5rem, 10vh, 6rem) auto 0;
  text-align: center;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--coral);
  margin: 0;
}

h1 {
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  line-height: 1.05;
  margin: 0.4rem 0 0.8rem;
  letter-spacing: -0.02em;
}

h1 span {
  color: var(--coral);
}

.lede {
  color: var(--dim);
  margin: 0 0 1.6rem;
}

#lobby-form {
  display: grid;
  gap: 0.7rem;
  text-align: left;
}

#lobby-form label {
  font-size: 0.85rem;
  color: var(--dim);
}

.or {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

#lobby-msg {
  min-height: 1.6em;
  color: var(--amber);
}

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

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  mix-blend-mode: difference;
}

#info {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  background: rgba(11, 10, 9, 0.55);
  font-size: 0.85rem;
}

#world-code {
  font-family: var(--mono);
  color: var(--amber);
}

#game-mode:not(:empty)::before,
#mode:not(:empty)::before,
#time:not(:empty)::before {
  content: " · ";
}

#time {
  color: #ffd27a;
  font-variant-numeric: tabular-nums; /* the countdown's digits don't jiggle */
}

#time.night {
  color: #a9b8ff;
}

#chat {
  position: absolute;
  left: 12px;
  bottom: 96px;
  width: min(26rem, calc(100% - 24px));
  font-size: 0.9rem;
}

#chat-log div {
  padding: 0.15rem 0.6rem;
  margin-top: 2px;
  border-radius: 6px;
  background: rgba(11, 10, 9, 0.55);
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  transition: opacity 1s;
}

#chat-log div.old {
  opacity: 0;
}

#chat-log b {
  color: var(--amber);
}

#chat-input {
  margin-top: 6px;
  pointer-events: auto;
  background: rgba(11, 10, 9, 0.8);
}

#hotbar {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: rgba(11, 10, 9, 0.55);
}

.slot {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid transparent;
  border-radius: 7px;
  display: grid;
  place-items: center;
}

.slot.on {
  border-color: #fff;
}

.icon {
  width: 30px;
  height: 30px;
}

.icon.cube {
  border-radius: 3px;
  background: linear-gradient(var(--top) 0 35%, var(--side) 35% 100%);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}

.slot .count {
  position: absolute;
  right: 4px;
  bottom: 0;
  font: 700 0.78rem var(--mono);
  text-shadow: 0 1px 2px #000;
}

.slot small {
  position: absolute;
  top: 0;
  left: 4px;
  font: 600 0.7rem var(--mono);
  color: var(--dim);
}

#block-name {
  position: absolute;
  left: 50%;
  bottom: 104px;
  transform: translateX(-50%);
  font-weight: 600;
  text-shadow: 0 1px 3px #000;
  opacity: 0;
}

#block-name.fade {
  animation: fade 1.8s ease-out;
}

@keyframes fade {
  0%,
  60% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

#status {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.9rem;
  border-radius: 8px;
  background: var(--coral);
  color: #1b0f0a;
  font-weight: 600;
}

#underwater {
  position: absolute;
  inset: 0;
  background: rgba(30, 80, 170, 0.45);
}

/* ---------------------------------------------------------------- combat */

/* A blocky sword for the tenth hotbar slot: blade, guard, grip, and a clay pommel. */
.slot span.sword {
  width: 34px;
  height: 34px;
  border-radius: 0;
  box-shadow: none;
  transform: rotate(45deg);
  background:
    linear-gradient(#e8edf3, #e8edf3) 14px 0 / 6px 21px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 8px 21px / 18px 4px no-repeat,
    linear-gradient(#5b3a1d, #5b3a1d) 15px 25px / 4px 6px no-repeat,
    linear-gradient(#d97757, #d97757) 14px 30px / 6px 4px no-repeat;
}

/* The same slot with the bow in it (key 0 again): a stepped wooden arc, a darker grip, and the
   string. Drawn upright, then tipped like the sword. */
.slot span.bow {
  width: 34px;
  height: 34px;
  border-radius: 0;
  box-shadow: none;
  transform: rotate(45deg);
  background:
    linear-gradient(#f2efe6, #f2efe6) 8px 3px / 2px 28px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 8px 1px / 5px 4px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 12px 4px / 5px 5px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 16px 8px / 4px 6px no-repeat,
    linear-gradient(#5b3a1d, #5b3a1d) 18px 13px / 4px 8px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 16px 20px / 4px 6px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 12px 25px / 5px 5px no-repeat,
    linear-gradient(#8a5a2b, #8a5a2b) 8px 29px / 5px 4px no-repeat;
}

/* How far the bow is drawn, just under the crosshair. It brightens once a shot would fly. */
#charge {
  position: absolute;
  left: 50%;
  top: calc(50% + 18px);
  width: 48px;
  height: 5px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: rgba(11, 10, 9, 0.6);
  overflow: hidden;
}

#charge i {
  display: block;
  height: 100%;
  width: 0;
  background: #9a948c;
}

#charge.ready i {
  background: var(--amber);
}

#charge.full i {
  background: #fff;
}

/* Ten pixel hearts above the hotbar. Each is full, half, or empty. */
#hearts {
  position: absolute;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%);
  display: flex;
  gap: 3px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.8));
}

#hearts i {
  width: 17px;
  height: 15px;
  background: rgba(20, 12, 12, 0.6);
  clip-path: polygon(
    14.29% 0,
    42.86% 0,
    42.86% 16.67%,
    57.14% 16.67%,
    57.14% 0,
    85.71% 0,
    85.71% 16.67%,
    100% 16.67%,
    100% 50%,
    85.71% 50%,
    85.71% 66.67%,
    71.43% 66.67%,
    71.43% 83.33%,
    57.14% 83.33%,
    57.14% 100%,
    42.86% 100%,
    42.86% 83.33%,
    28.57% 83.33%,
    28.57% 66.67%,
    14.29% 66.67%,
    14.29% 50%,
    0 50%,
    0 16.67%,
    14.29% 16.67%
  );
}

#hearts i.full {
  background: #e8413b;
}

#hearts i.half {
  background: linear-gradient(90deg, #e8413b 50%, rgba(20, 12, 12, 0.6) 50%);
}

#hearts.low i {
  animation: throb 0.8s ease-in-out infinite;
}

@keyframes throb {
  50% {
    transform: translateY(-2px);
  }
}

/* The red flash when something bites. JS sets the opacity and lets it fade. */
#hurt {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(closest-side, transparent 55%, rgba(200, 20, 20, 0.55));
}

/* The soft pink-and-green glow when a heart heals you; the hearts give a little hop too. */
#heal {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(
    closest-side,
    transparent 60%,
    rgba(255, 120, 160, 0.35) 85%,
    rgba(120, 230, 160, 0.4)
  );
}

#hearts.healed i {
  animation: healed 0.5s ease-out;
}

@keyframes healed {
  40% {
    transform: translateY(-4px) scale(1.15);
  }
}

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(11, 10, 9, 0.6);
}

#pause {
  cursor: pointer;
}

#welcome {
  background: rgba(11, 10, 9, 0.78);
}

.card {
  max-width: 34rem;
  padding: 1.6rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.card h2 {
  margin: 0 0 0.6rem;
  line-height: 1.2;
}

#welcome-name {
  color: var(--coral);
}

.welcome-card {
  max-width: 46rem;
}

.welcome-card .lede {
  margin-bottom: 1.2rem;
}

.how {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.4rem;
  text-align: left;
}

.how > div {
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ink);
}

.how h3 {
  margin: 0 0 0.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
}

.how p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--dim);
}

#welcome-go {
  font-size: 1.05rem;
  padding: 0.7rem 2rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin: 1rem 0 0.4rem;
}

#chat-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  color: rgba(246, 241, 235, 0.75);
  text-shadow: 0 1px 2px #000;
}

/* ---------------------------------------------------------------- colour picker */

#lobby-form .label {
  font-size: 0.85rem;
  color: var(--dim);
}

#profile-note {
  min-height: 1.3em;
  margin: -0.3rem 0 0;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
}

.swatch {
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 9px;
  background: var(--c);
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.18);
}

.swatch[aria-checked="true"] {
  border-color: var(--text);
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

#history {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

#history i {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--c);
  display: inline-block;
}

/* ---------------------------------------------------------------- world modes */

.start-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

@media (max-width: 420px) {
  .start-row {
    grid-template-columns: 1fr;
  }
}

.toggle {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.toggle button {
  border: 0;
  border-radius: 0;
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  color: var(--dim);
  background: var(--ink);
}

.toggle button[aria-checked="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 -2px 0 var(--coral);
}

body:not([data-mode="survival"]) .survival-only,
body[data-mode="survival"] .creative-only {
  display: none;
}

/* ---------------------------------------------------------------- menus (backpack, crafting) */

.menu {
  background: rgba(11, 10, 9, 0.72);
}

.menu-card {
  max-width: 40rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(9, 52px);
  gap: 4px;
  justify-content: center;
  margin-top: 0.8rem;
}

.grid.hot {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.grid .slot {
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 7px;
  background: var(--ink);
}

.grid .slot:hover {
  border-color: var(--amber);
}

.grid .slot.picked {
  border-color: var(--coral);
  background: var(--line);
}

/* Crafting: one row per recipe — result, ingredients with what you have, Craft. */

.recipes {
  display: grid;
  gap: 6px;
  margin: 0.8rem 0;
  max-height: 58vh;
  overflow-y: auto;
  text-align: left;
}

.recipe {
  display: grid;
  grid-template-columns: 11rem 1fr auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
}

.recipe.can {
  border-color: rgba(217, 119, 87, 0.55);
}

.recipe .out,
.recipe .needs span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.recipe .icon {
  flex: none;
  width: 22px;
  height: 22px;
}

.recipe .needs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  font-size: 0.85rem;
}

.recipe .needs small {
  color: var(--dim);
}

.recipe .needs .short {
  color: var(--dim);
}

.recipe .needs .short small {
  color: var(--amber);
}

.recipe button {
  padding: 0.35rem 0.9rem;
}

.recipe button:disabled {
  opacity: 0.4;
  cursor: default;
  border-color: var(--line);
}

/* The dig ring at the crosshair fills while a survival block is being dug. */

#dig-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 36px;
  height: 36px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(var(--coral) calc(var(--p, 0) * 1turn), rgba(246, 241, 235, 0.25) 0);
  -webkit-mask: radial-gradient(circle, transparent 12px, #000 13px);
  mask: radial-gradient(circle, transparent 12px, #000 13px);
}

@media (max-width: 560px) {
  .recipe {
    grid-template-columns: 1fr auto;
  }

  .recipe .needs {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 2px;
  }

  .grid .slot {
    width: auto;
    height: auto;
    aspect-ratio: 1;
  }

  .grid .icon {
    width: 70%;
    height: 70%;
  }
}
