/* RustCraft — forged iron & ember. No external assets, everything self-hosted. */

:root {
  --ember: #ff7a2d;
  --ember-hot: #ffb35c;
  --copper: #c96f2f;
  --iron: #101318;
  --iron-2: #181c24;
  --steel: #232936;
  --bone: #ece5d4;
  --ash: #9aa0ad;
  --moss: #8fbf5a;
  --blood: #e23b3b;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --body: "Avenir Next", Avenir, "Trebuchet MS", Verdana, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--iron);
  font-family: var(--body);
  color: var(--bone);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* no pinch-zoom / pull-to-refresh while playing */
}

/* mobile browsers: track the *visible* viewport, not the URL-bar-inflated one */
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
  #game { height: 100dvh; }
  .overlay, #title, #touch { height: 100dvh; }
}

.hidden { display: none !important; }

#game {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  cursor: crosshair;
}

/* ============== floating name tags ============== */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 5; }
.tag-label {
  position: absolute;
  transform: translate(-50%, -100%);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: rgba(8, 10, 14, 0.62);
  border: 1px solid rgba(255, 122, 45, 0.25);
  border-radius: 3px;
  color: var(--bone);
  white-space: nowrap;
  text-shadow: 0 1px 0 #000;
}
.tag-label.bot { color: var(--ember-hot); border-color: rgba(255, 122, 45, 0.55); }

/* ============== HUD ============== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.42) 100%);
}

#hurt {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(226, 59, 59, 0.08) 40%, rgba(226, 59, 59, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.45s ease-out;
}
#hurt.flash { opacity: 1; transition: none; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
#crosshair i { position: absolute; background: rgba(255, 255, 255, 0.85); mix-blend-mode: difference; }
#crosshair .h { width: 18px; height: 2px; left: -9px; top: -1px; }
#crosshair .v { width: 2px; height: 18px; left: -1px; top: -9px; }
#crosshair .dot { width: 2px; height: 2px; left: -1px; top: -1px; background: var(--ember); }

#topbar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top, 0px));
  right: calc(16px + env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 12px;
}
#clock {
  display: flex; align-items: center; gap: 8px;
  background: rgba(8, 10, 14, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 12px; border-radius: 4px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em;
}
#clock-dial {
  width: 18px; height: 18px; border-radius: 50%;
  background: conic-gradient(from 0deg, #ffd97a 0 50%, #2c3550 50% 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 1s linear;
}
#fly-tag {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em;
  color: var(--iron); background: var(--ember-hot);
  padding: 6px 10px; border-radius: 4px; font-weight: 700;
  box-shadow: 0 0 18px rgba(255, 179, 92, 0.5);
}

/* chat */
#chat {
  position: absolute; left: 16px; bottom: 120px;
  width: min(540px, 60vw);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
#chat-log { display: flex; flex-direction: column; gap: 3px; max-height: 40vh; overflow: hidden; justify-content: flex-end; }
.chat-line {
  font-size: 14px; line-height: 1.45;
  background: rgba(8, 10, 14, 0.55);
  padding: 4px 10px; border-radius: 3px;
  border-left: 2px solid rgba(255, 255, 255, 0.12);
  width: fit-content; max-width: 100%;
  animation: chat-in 0.18s ease-out;
  transition: opacity 0.8s;
  text-shadow: 0 1px 0 #000;
  word-wrap: break-word;
}
.chat-line.faded { opacity: 0; }
.chat-line .who { font-family: var(--mono); font-weight: 700; margin-right: 6px; color: #8fc1ff; }
.chat-line.bot .who { color: var(--ember-hot); }
.chat-line.bot { border-left-color: var(--ember); }
.chat-line.system { font-style: italic; color: var(--ash); border-left-color: transparent; }
@keyframes chat-in { from { transform: translateX(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

#chat-hint {
  font-size: 12px;
  color: var(--ash);
  background: rgba(8, 10, 14, 0.78);
  border: 1px solid rgba(255, 122, 45, 0.30);
  border-left: 3px solid var(--ember);
  border-radius: 4px;
  padding: 7px 10px;
  animation: chat-in 0.18s ease-out;
}
#chat-hint b { color: var(--ember-hot); font-family: var(--mono); }
#chat-hint i { color: var(--bone); }

#chat-input {
  pointer-events: auto;
  font-family: var(--mono); font-size: 14px;
  color: var(--bone);
  background: rgba(8, 10, 14, 0.85);
  border: 1px solid var(--copper);
  border-radius: 4px;
  padding: 10px 12px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(201, 111, 47, 0.15), 0 8px 30px rgba(0, 0, 0, 0.5);
}
#chat-input::placeholder { color: #6b7280; }

/* hearts + hotbar */
#bottom {
  position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#status-row { display: flex; gap: 24px; align-items: center; }
#hearts { display: flex; gap: 3px; height: 18px; }
#hunger { display: flex; gap: 3px; height: 16px; flex-direction: row-reverse; }
.drumstick {
  width: 14px; height: 15px; position: relative;
  clip-path: polygon(35% 0%, 75% 5%, 100% 30%, 95% 60%, 65% 70%, 45% 100%, 20% 95%, 15% 70%, 40% 55%, 25% 30%);
  background: #3a2a14;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.6));
}
.drumstick .fill { position: absolute; inset: 0; background: linear-gradient(180deg, #d8913c, #9c5a1d); }
.drumstick .fill.half { width: 55%; }
#breakbar {
  position: absolute; left: 50%; top: 50%;
  width: 46px; height: 5px;
  transform: translate(-50%, 26px);
  background: rgba(8, 10, 14, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.12s;
}
#breakbar.on { opacity: 1; }
#breakbar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ember-hot), var(--ember)); border-radius: 2px; }
.heart {
  width: 18px; height: 17px; position: relative;
  clip-path: polygon(50% 100%, 8% 56%, 0% 36%, 0% 18%, 14% 4%, 32% 0%, 50% 12%, 68% 0%, 86% 4%, 100% 18%, 100% 36%, 92% 56%);
  background: #3a1014;
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.6));
}
.heart .fill {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #ff5b5b, #c01919);
}
.heart .fill.half { width: 50%; }

#hotbar { display: flex; gap: 4px; padding: 5px; background: rgba(8, 10, 14, 0.6); border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.07); pointer-events: auto; }
.slot {
  width: 52px; height: 52px;
  background: linear-gradient(160deg, #2a303c, #1a1f28);
  border: 2px solid #3a4150;
  border-radius: 4px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s ease-out, border-color 0.08s;
}
.slot.sel {
  border-color: var(--ember);
  transform: translateY(-4px);
  box-shadow: 0 0 16px rgba(255, 122, 45, 0.45), inset 0 0 8px rgba(255, 122, 45, 0.18);
}
.slot .chip {
  width: 30px; height: 30px;
  border-radius: 2px;
  border-top: 3px solid rgba(255, 255, 255, 0.45);
  border-left: 3px solid rgba(255, 255, 255, 0.18);
  border-right: 3px solid rgba(0, 0, 0, 0.35);
  border-bottom: 3px solid rgba(0, 0, 0, 0.5);
  image-rendering: pixelated;
}
.slot .cnt {
  position: absolute; right: 4px; bottom: 2px;
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: #fff; text-shadow: 0 1px 0 #000, 1px 0 0 #000;
}
.slot .key {
  position: absolute; left: 4px; top: 2px;
  font-family: var(--mono); font-size: 9px; color: var(--ash);
}

/* scoreboard */
#scores {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  min-width: 420px;
  background: rgba(10, 12, 17, 0.88);
  border: 1px solid rgba(255, 122, 45, 0.35);
  border-radius: 8px;
  padding: 18px 22px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
}
#scores h3 { font-family: var(--mono); letter-spacing: 0.25em; font-size: 14px; color: var(--ember-hot); margin-bottom: 12px; }
#scores table { width: 100%; border-collapse: collapse; font-size: 14px; }
#scores th { font-family: var(--mono); font-size: 10px; letter-spacing: 0.15em; color: var(--ash); text-align: right; padding: 4px 8px; border-bottom: 1px solid #2c3340; }
#scores th:first-child, #scores td:first-child { text-align: left; }
#scores td { padding: 6px 8px; text-align: right; border-bottom: 1px solid rgba(255, 255, 255, 0.04); }
#scores tr.rank0 td:first-child { color: #ffd34d; }
#scores tr.rank1 td:first-child { color: #cfd6e4; }
#scores tr.rank2 td:first-child { color: #d89a66; }
#scores tr.me td { background: rgba(255, 122, 45, 0.08); }
#scores td.bot-name::after { content: " ⚙"; color: var(--ember); }
#scores .hint { margin-top: 10px; font-size: 11px; color: var(--ash); font-family: var(--mono); }

#toast {
  position: absolute; left: 50%; bottom: 96px;
  transform: translateX(-50%);
  font-family: var(--mono); font-size: 13px;
  background: rgba(10, 12, 17, 0.85);
  border: 1px solid var(--copper);
  padding: 8px 16px; border-radius: 4px;
  animation: chat-in 0.15s ease-out;
}

/* ============== overlays ============== */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px;
  text-align: center;
}
#death { background: radial-gradient(ellipse at center, rgba(60, 4, 4, 0.55), rgba(20, 2, 2, 0.92)); z-index: 36; }
#death h1 {
  font-family: var(--mono); font-size: clamp(48px, 9vw, 110px); font-weight: 900;
  letter-spacing: 0.08em; color: #ff4646;
  text-shadow: 0 4px 0 #5e0c0c, 0 8px 0 #2e0505, 0 12px 40px rgba(255, 70, 70, 0.4);
  animation: death-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes death-in { from { transform: scale(2.2); opacity: 0; } to { transform: none; opacity: 1; } }
#death p { color: #d9a0a0; font-size: 16px; font-style: italic; }
#death button, #join button {
  font-family: var(--mono); font-weight: 800; letter-spacing: 0.18em;
  font-size: 15px;
  color: var(--iron);
  background: linear-gradient(180deg, var(--ember-hot), var(--ember) 55%, #d4581b);
  border: none; border-radius: 5px;
  padding: 14px 34px;
  cursor: pointer;
  box-shadow: 0 5px 0 #8c3a10, 0 12px 30px rgba(255, 122, 45, 0.35);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
#death button:hover, #join button:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 7px 0 #8c3a10, 0 16px 36px rgba(255, 122, 45, 0.45); }
#death button:active, #join button:active { transform: translateY(3px); box-shadow: 0 2px 0 #8c3a10; }

#pause { background: rgba(8, 10, 14, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#pause h2 { font-family: var(--mono); letter-spacing: 0.3em; font-size: 28px; color: var(--bone); }
#pause p { color: var(--ash); }
#pause .keys-hint { font-family: var(--mono); font-size: 12px; color: #59616f; letter-spacing: 0.1em; }

#net-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  text-align: center;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.15em;
  padding: 8px;
  background: linear-gradient(90deg, transparent, rgba(226, 59, 59, 0.25), transparent);
  color: #ffb4b4;
}

/* ============== title screen ============== */
#title { position: fixed; inset: 0; z-index: 50; overflow: hidden; }

#title .sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(255, 122, 45, 0.28) 0%, transparent 55%),
    linear-gradient(180deg, #07090f 0%, #0c1019 38%, #1b1410 78%, #2a160c 100%);
}
#title .stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 9%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 41% 24%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 57% 12%, #fff5 50%, transparent 51%),
    radial-gradient(2px 2px at 69% 21%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 81% 8%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 91% 27%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 7% 38%, #fff5 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 49% 33%, #fff6 50%, transparent 51%);
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.5; } to { opacity: 1; } }

#title .ground {
  position: absolute; left: -5%; right: -5%; bottom: -28px; height: 120px;
  background:
    linear-gradient(180deg, #1d2410 0 18px, #2a1c10 18px 100%);
  border-top: 4px solid #3d5222;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.55);
  transform: rotate(-1.2deg);
}

/* floating voxel cubes (pure CSS 3D) */
.cubes { position: absolute; inset: 0; perspective: 900px; }
.c3 { position: absolute; width: 64px; height: 64px; transform-style: preserve-3d; animation: bob 7s ease-in-out infinite; }
.c3 i { position: absolute; width: 64px; height: 64px; border: 2px solid rgba(0, 0, 0, 0.35); }
.c3 .t { transform: rotateX(90deg) translateZ(32px); }
.c3 .l { transform: rotateY(-90deg) translateZ(32px); }
.c3 .r { transform: translateZ(32px); }
.c3.a { left: 8%; top: 22%; transform: rotateX(-24deg) rotateY(38deg); animation-delay: 0s; }
.c3.a .t { background: #79b94c; } .c3.a .l { background: #5b3f28; } .c3.a .r { background: #6f4c30; }
.c3.b { right: 12%; top: 16%; scale: 0.7; transform: rotateX(-18deg) rotateY(-30deg); animation-delay: 1.2s; }
.c3.b .t { background: #8d8d92; } .c3.b .l { background: #5e5e64; } .c3.b .r { background: #74747a; }
.c3.c { left: 18%; bottom: 22%; scale: 0.55; transform: rotateX(-30deg) rotateY(55deg); animation-delay: 2.1s; }
.c3.c .t { background: #ffd97a; box-shadow: 0 0 42px rgba(255, 200, 90, 0.8); } .c3.c .l { background: #c99b3f; } .c3.c .r { background: #e0b557; }
.c3.d { right: 20%; bottom: 28%; scale: 0.8; transform: rotateX(-22deg) rotateY(20deg); animation-delay: 0.6s; }
.c3.d .t { background: #4f7e3a; } .c3.d .l { background: #2f4d22; } .c3.d .r { background: #3d642c; }
.c3.e { left: 42%; top: 9%; scale: 0.45; transform: rotateX(-26deg) rotateY(-45deg); animation-delay: 3s; }
.c3.e .t { background: #bfe3f0; opacity: 0.8; } .c3.e .l { background: #8fb6c4; opacity: 0.8; } .c3.e .r { background: #a7cdda; opacity: 0.8; }
.c3.f { right: 38%; bottom: 14%; scale: 0.6; transform: rotateX(-20deg) rotateY(65deg); animation-delay: 1.8s; }
.c3.f .t { background: #b0552f; } .c3.f .l { background: #7a3217; } .c3.f .r { background: #964322; }
@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -22px; }
}

#title .panel {
  position: relative; z-index: 2;
  max-width: 660px;
  margin: max(7vh, 30px) auto 0;
  padding: 44px 48px 36px;
  background: rgba(10, 12, 17, 0.72);
  border: 1px solid rgba(255, 122, 45, 0.28);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-align: center;
  animation: panel-in 0.7s cubic-bezier(0.2, 1.2, 0.3, 1);
}
@keyframes panel-in { from { transform: translateY(26px); opacity: 0; } to { transform: none; opacity: 1; } }

.forge-line {
  height: 3px; width: 120px; margin: 0 auto 22px;
  background: linear-gradient(90deg, transparent, var(--ember), transparent);
  box-shadow: 0 0 18px rgba(255, 122, 45, 0.8);
}

.logo {
  font-family: var(--mono);
  font-size: clamp(46px, 8vw, 84px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 0.95;
  color: var(--bone);
  text-shadow: 0 3px 0 #2b2017, 0 6px 0 #1a130d, 0 9px 0 #0d0a06, 0 14px 34px rgba(0, 0, 0, 0.8);
}
.logo span {
  background: linear-gradient(180deg, var(--ember-hot) 12%, var(--ember) 55%, #b94c12 92%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #3a1c06) drop-shadow(0 8px 22px rgba(255, 122, 45, 0.35));
}

.tag { margin: 18px 0 26px; color: var(--ash); font-size: 15px; line-height: 1.6; }
.tag em { color: var(--ember-hot); font-style: normal; }

#join { display: flex; gap: 10px; justify-content: center; }
#join input {
  flex: 1; max-width: 280px;
  font-family: var(--mono); font-size: 16px;
  color: var(--bone);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid #3a4150;
  border-radius: 5px;
  padding: 13px 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#join input:focus { border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255, 122, 45, 0.18); }
#join input::placeholder { color: #545b68; }

#title-err { margin-top: 12px; color: #ff8080; font-family: var(--mono); font-size: 13px; }

.controls {
  margin-top: 30px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 10px;
}
.controls div {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  padding: 8px 4px;
  display: flex; flex-direction: column; gap: 2px;
}
.controls b { font-family: var(--mono); font-size: 12px; color: var(--ember-hot); }
.controls span { font-size: 11px; color: var(--ash); }

.foot { margin-top: 24px; font-size: 11px; color: #59616f; font-family: var(--mono); letter-spacing: 0.06em; }

/* ============== inventory & crafting (E) ============== */
#inv {
  position: fixed; left: 50%; top: 50%; z-index: 25;
  transform: translate(-50%, -50%);
  width: min(880px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: rgba(10, 12, 17, 0.92);
  border: 1px solid rgba(255, 122, 45, 0.35);
  border-radius: 10px;
  padding: 18px 22px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: panel-in 0.22s cubic-bezier(0.2, 1.2, 0.3, 1);
}
.inv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.inv-head h3 { font-family: var(--mono); letter-spacing: 0.22em; font-size: 15px; color: var(--ember-hot); }
#inv-close {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; font-weight: 700;
  color: var(--bone); background: var(--steel);
  border: 1px solid #3a4150; border-radius: 4px;
  padding: 8px 14px; cursor: pointer;
}
#inv-close:hover { border-color: var(--ember); }
.inv-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
#inv h4 { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: var(--ash); margin: 12px 0 8px; }
#inv h4 .sub { font-weight: 400; letter-spacing: 0.02em; text-transform: none; color: #59616f; margin-left: 6px; }
#inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; min-height: 60px; }
.inv-item {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 5px; padding: 6px 8px;
  cursor: pointer;
  transition: border-color 0.1s, transform 0.08s;
}
.inv-item:hover { border-color: var(--ember); transform: translateY(-1px); }
.inv-item .chip { width: 20px; height: 20px; flex: none; border-radius: 2px;
  border-top: 2px solid rgba(255,255,255,0.4); border-left: 2px solid rgba(255,255,255,0.15);
  border-right: 2px solid rgba(0,0,0,0.35); border-bottom: 2px solid rgba(0,0,0,0.5); }
.inv-item .nm { font-size: 11px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-item .ct { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ember-hot); }
#inv-grid .empty { grid-column: 1/-1; color: #59616f; font-size: 12px; font-style: italic; padding: 12px 4px; }
#inv-hotbar { display: flex; gap: 4px; }
#inv-hotbar .slot { width: 44px; height: 44px; cursor: pointer; }
#inv-recipes { display: flex; flex-direction: column; gap: 8px; }
.recipe {
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--copper);
  border-radius: 5px; padding: 9px 12px;
}
.recipe.off { opacity: 0.45; border-left-color: #3a4150; }
.recipe .rname { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; color: var(--bone); }
.recipe .io { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 11px; }
.recipe .io b { color: var(--ash); font-weight: 400; }
.rchip { display: inline-flex; align-items: center; gap: 5px; background: rgba(0,0,0,0.3); border-radius: 3px; padding: 3px 7px; }
.rchip i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
.rbtns { display: flex; gap: 6px; }
.rbtns button {
  font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  color: var(--iron); background: linear-gradient(180deg, var(--ember-hot), var(--ember));
  border: none; border-radius: 3px; padding: 6px 14px; cursor: pointer;
}
.rbtns button:disabled { background: #2c3340; color: #59616f; cursor: default; }
.rbtns button:not(:disabled):hover { filter: brightness(1.12); }

/* ============== touch controls ============== */
#touch { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
#touch > * { pointer-events: auto; }
#look-zone { position: absolute; top: 0; right: 0; width: 55%; height: 100%; pointer-events: auto; touch-action: none; }
#joy {
  position: absolute;
  left: calc(26px + env(safe-area-inset-left, 0px));
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(10, 12, 17, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.18);
  touch-action: none;
}
#joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 122, 45, 0.5);
  border: 2px solid var(--ember);
}
.tb {
  font-size: 22px; line-height: 1;
  width: 58px; height: 58px; border-radius: 50%;
  color: var(--bone);
  background: rgba(10, 12, 17, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.22);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.tb:active, .tb.held { background: rgba(255, 122, 45, 0.45); border-color: var(--ember); }
#tb-actions {
  position: absolute;
  right: calc(22px + env(safe-area-inset-right, 0px));
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
#tb-actions .big { width: 64px; height: 64px; }
#tb-side {
  position: absolute;
  right: calc(22px + env(safe-area-inset-right, 0px));
  top: calc(56px + env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 10px;
}

/* ============== chest panel ============== */
#chest-panel {
  position: fixed; left: 50%; top: 50%; z-index: 26;
  transform: translate(-50%, -50%);
  width: min(440px, 92vw);
  background: rgba(10, 12, 17, 0.94);
  border: 1px solid rgba(201, 111, 47, 0.5);
  border-radius: 10px;
  padding: 16px 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
  animation: panel-in 0.18s cubic-bezier(0.2, 1.2, 0.3, 1);
}
#chest-close {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; font-weight: 700;
  color: var(--bone); background: var(--steel);
  border: 1px solid #3a4150; border-radius: 4px;
  padding: 8px 14px; cursor: pointer;
}
.chest-hint { font-size: 11px; color: var(--ash); margin-bottom: 10px; font-family: var(--mono); }
#chest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; min-height: 50px; }
#chest-grid .empty { grid-column: 1/-1; color: #59616f; font-style: italic; font-size: 12px; padding: 8px 2px; }

@media (max-width: 720px) {
  .controls { grid-template-columns: repeat(3, 1fr); }
  #title { overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #title .panel { margin: 12px 10px calc(24px + env(safe-area-inset-bottom, 0px)); padding: 22px 16px; }
  #scores { min-width: 320px; max-width: 94vw; }
  .inv-cols { grid-template-columns: 1fr; }
  #chat { bottom: 190px; width: 70vw; left: calc(12px + env(safe-area-inset-left, 0px)); }
  #bottom { bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .slot { width: 38px; height: 38px; }
  .slot .chip { width: 20px; height: 20px; }
  .logo { font-size: clamp(34px, 10vw, 58px); }
  .tag { font-size: 13px; margin: 12px 0 18px; }
  #topbar { transform: scale(0.9); transform-origin: top right; }
  .heart { width: 15px; height: 14px; }
  .drumstick { width: 12px; height: 13px; }
}
