/* In-game HUD */
/* Interface size: set from the Esc menu (or fitted to the screen) as --ui; every HUD group and card scales with it. */
:root { --ui: 1; }
.top-left, .top-right, .side-btns, .emotes, .bottom, .coords, .crosshair, .mine, .flash, .lockhint, .netbanner, .share, .verify,
.inv-card, .death-card, .menu-card, .start-card, .touch-btns { zoom: var(--ui); }
.game-page { overflow: hidden; height: 100%; position: fixed; inset: 0; overscroll-behavior: none; touch-action: none; }
#game { position: fixed; inset: 0; }
#view { width: 100%; height: 100%; display: block; background: #86b9ec; }
.loading { position: absolute; inset: 0; z-index: 25; pointer-events: none; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, #141a22, #0b0d11 70%); transition: opacity var(--slow) var(--ease); }
.loading.done { opacity: 0; pointer-events: none; }
.ld-card { display: grid; justify-items: center; gap: 14px; }
.ld-card img { image-rendering: pixelated; animation: hop 1s var(--step) infinite; }
@keyframes hop { 50% { transform: translateY(-6px); } }
.ld-t { font: 600 18px/1 var(--pix); color: var(--muted); }
.ld-bar { width: 220px; height: 10px; border: 1px solid var(--line); background: var(--panel); }
.ld-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width var(--mid) var(--step); }

.start { position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, rgba(11,13,17,.2), rgba(11,13,17,.7)); }
.start-card { width: min(520px, 100%); background: rgba(18,23,30,.94); border: 1px solid var(--line); padding: 26px 22px; text-align: center; backdrop-filter: blur(6px); }
.start-card .brand { justify-content: center; margin-bottom: 14px; }
.start-card .brand img.wm { height: 14px; width: auto; }
.start-card h2 { font-size: 30px; }
.start-btns { display: grid; gap: 10px; margin: 18px 0 12px; }
@media (min-width: 520px) { .start-btns { grid-template-columns: 1fr 1fr; } }
.start .trust { color: var(--muted); } .start .trust b { color: var(--text); }
.start .keys { margin-top: 8px; line-height: 1.7; }
body:not(.touch) #keys-touch, body.touch #keys-desktop { display: none; }
.start.busy .start-btns { opacity: .7; }
#ts { margin: 10px auto 0; display: flex; justify-content: center; }

#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud a, #hud .hotbar, #hud .emotes, #hud .share, #hud .mebar, #hud .land, #hud .goal { pointer-events: auto; }
#hud .hotbar, #hud .bottom-in { touch-action: none; }
.tl-col { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.goal { background: rgba(11,13,17,.72); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 7px 8px 7px 10px; font-size: 13px; line-height: 1.4; max-width: min(420px, calc(42vw / var(--ui))); display: flex; gap: 8px; align-items: baseline; }
.goal[hidden] { display: none; }
.goal .goal-k { font: 700 10px/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--gold); flex: none; }
.goal b { color: var(--gold); font-weight: 600; }
.goal .x { background: none; border: 0; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 0 2px; margin-left: auto; flex: none; }
.crosshair { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); }
.crosshair::before, .crosshair::after { content: ""; position: absolute; background: rgba(255,255,255,.9); mix-blend-mode: difference; }
.crosshair::before { left: 8px; top: 0; width: 2px; height: 18px; } .crosshair::after { top: 8px; left: 0; width: 18px; height: 2px; }
.top-left { position: absolute; left: 10px; top: calc(10px + env(safe-area-inset-top)); display: flex; gap: 8px; align-items: flex-start; max-width: calc(100% - 20px); }
.brand.mini img { width: 34px; height: 34px; background: rgba(11,13,17,.6); padding: 3px; border: 1px solid var(--line); }
.land { background: rgba(11,13,17,.72); border: 1px solid var(--line); padding: 7px 10px; font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; max-width: min(560px, calc(42vw / var(--ui))); }
.land .gold { font-family: var(--pix); }
.btn-claim { background: var(--gold); color: #1a1406; border: 0; font: 700 12px/1 var(--mono); text-transform: uppercase; padding: 7px 10px; cursor: pointer; animation: glow 1.6s var(--step) infinite; }
@keyframes glow { 50% { box-shadow: 0 0 14px rgba(245,197,66,.8); } }
.btn-ghost { background: none; border: 1px solid var(--gold); color: var(--gold); font: 700 11px/1 var(--mono); text-transform: uppercase; padding: 6px 8px; cursor: pointer; }
.top-right { position: absolute; right: 10px; top: calc(10px + env(safe-area-inset-top)); display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(46vw / var(--ui)); }
.top-right .chip { background: rgba(11,13,17,.72); }
.mebar { display: flex; gap: 6px; }
.mebar .chip { cursor: pointer; }
@media (max-width: 700px) { .hide-xs { display: none; } .top-right { max-width: calc(50vw / var(--ui)); } .land { max-width: calc(44vw / var(--ui)); font-size: 12px; } .goal { max-width: calc(44vw / var(--ui)); font-size: 12px; } }
.side-btns { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: grid; gap: 6px; }
.hb { width: 40px; height: 40px; background: rgba(11,13,17,.72); border: 1px solid var(--line); cursor: pointer; font-size: 18px; }
.hb:hover { border-color: var(--gold); } .hb.off { opacity: .45; }
.emotes { position: absolute; right: 58px; top: 50%; transform: translateY(-50%); display: grid; gap: 4px; background: rgba(11,13,17,.9); border: 1px solid var(--line); padding: 6px; animation: rise var(--mid) var(--ease); }
.emotes button { background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; font: 600 13px/1 var(--mono); cursor: pointer; text-transform: capitalize; }
.emotes button:hover { border-color: var(--gold); }
.bottom { position: absolute; left: 0; right: 0; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
.hotbar { display: flex; gap: 3px; padding: 4px; background: rgba(11,13,17,.72); border: 1px solid var(--line); max-width: min(calc(96vw / var(--ui)), 560px); overflow-x: auto; scrollbar-width: none; scroll-snap-type: x mandatory; }
.hotbar::-webkit-scrollbar { display: none; }
.slot { position: relative; flex: 0 0 auto; width: 48px; height: 48px; display: grid; place-items: center; background: rgba(22,28,36,.85); border: 2px solid transparent; cursor: pointer; scroll-snap-align: center; transition: transform var(--fast) var(--ease); }
.slot canvas { width: 34px; height: 34px; image-rendering: pixelated; }
.slot.on { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 0 12px rgba(245,197,66,.4); }
.slot .n { position: absolute; left: 3px; top: 2px; font: 600 10px/1 var(--pix); color: var(--muted); }
/* the bottom stack: the held item's name, then health and hunger, then the hotbar (nothing can cover the name) */
.bottom-in { display: flex; flex-direction: column; align-items: stretch; gap: 5px; max-width: 100%; }
.blockname { align-self: center; height: 20px; font: 600 16px/20px var(--pix); text-shadow: 0 2px 0 #000; opacity: 0; white-space: nowrap; }
.blockname.show { animation: fadeout 1.6s var(--ease); }
@keyframes fadeout { 0%, 60% { opacity: 1; } 100% { opacity: 0; } }
.flash { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font: 600 16px/1.2 var(--pix); text-shadow: 0 2px 0 #000; opacity: 0; text-align: center; max-width: calc(80vw / var(--ui)); }
.flash.show { animation: fadeout 2s var(--ease); }
body.buried .flash { color: #16202b; text-shadow: 0 1px 0 #fff; }
.coords { position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); color: rgba(221,225,230,.75); text-shadow: 0 1px 0 #000; }
body.touch .coords { display: none; }
.lockhint { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(11,13,17,.8); border: 1px solid var(--line); padding: 10px 16px; font: 600 15px/1 var(--pix); }
.netbanner { position: absolute; left: 50%; top: 60px; transform: translateX(-50%); background: var(--warn); color: #1a0f06; padding: 6px 12px; font: 600 13px/1 var(--pix); }
.share { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); width: min(360px, calc(92vw / var(--ui))); background: rgba(18,23,30,.97); border: 1px solid var(--gold); padding: 18px; text-align: center; animation: pop var(--slow) var(--ease); box-shadow: 0 0 40px rgba(245,197,66,.25); }
.share h4 { font-size: 22px; color: var(--gold); margin-bottom: 6px; }
.share .x { position: absolute; right: 6px; top: 4px; background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
@keyframes pop { 0% { transform: translateX(-50%) scale(.85); opacity: 0; } 60% { transform: translateX(-50%) scale(1.04); } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

/* Touch controls */
.touch-btns { display: none; }
body.touch .touch-btns { display: grid; position: absolute; right: calc(12px + env(safe-area-inset-right)); bottom: calc(116px + env(safe-area-inset-bottom)); grid-template-columns: auto auto; gap: 8px; align-items: end; }
.tb { min-width: 56px; height: 52px; background: rgba(11,13,17,.6); border: 1px solid rgba(221,225,230,.25); font: 700 13px/1 var(--mono); text-transform: uppercase; color: var(--text); touch-action: none; }
.tb.big { width: 72px; height: 72px; font-size: 22px; }
.tb.sm { height: 44px; }
body.touch:not(.flying) #b-down { visibility: hidden; }
.tb.on { background: rgba(245,197,66,.85); color: #1a1406; }
.cc-stick { position: absolute; width: 120px; height: 120px; border: 2px solid rgba(221,225,230,.25); background: rgba(11,13,17,.25); border-radius: 50%; opacity: 0; pointer-events: none; transition: opacity var(--fast); z-index: 5; }
.cc-stick.on { opacity: 1; }
.cc-knob { position: absolute; left: 36px; top: 36px; width: 48px; height: 48px; background: rgba(221,225,230,.55); border-radius: 50%; }
body.touch .side-btns { top: auto; bottom: calc(220px + env(safe-area-inset-bottom)); transform: none; }

.mapov { position: absolute; inset: 0; z-index: 60; background: rgba(5,6,8,.6); display: grid; place-items: center; padding: 12px; }
.mapov-card { width: min(900px, 100%); height: min(720px, 92vh); background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; }
.mapov-h { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.mapov-h .x { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; }
.mapov .map { flex: 1; border: 0; }

.verify { position: absolute; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(340px, calc(92vw / var(--ui))); background: rgba(18,23,30,.96); border: 1px solid var(--line); padding: 14px; text-align: center; pointer-events: auto; animation: rise var(--mid) var(--ease); }
.verify p { margin: 6px 0 10px; }
#verify-box { display: flex; justify-content: center; margin-bottom: 8px; }

/* Survival HUD: health on the left, hunger on the right, both as wide as the hotbar */
.vitals { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 3px; }
.hp, .food { display: flex; gap: 2px; height: 17px; }
.food { flex-direction: row-reverse; }
.hp i { width: 17px; height: 17px; display: block; clip-path: polygon(50% 100%, 0 40%, 0 15%, 25% 0, 50% 18%, 75% 0, 100% 15%, 100% 40%); background: #e04848; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); }
.hp i.h { background: linear-gradient(90deg, #e04848 50%, rgba(40,20,24,.85) 50%); }
.hp i.e { background: rgba(40,20,24,.85); }
.hp.low i.f, .hp.low i.h { animation: beat .6s var(--step) infinite; }
.food i { width: 17px; height: 17px; display: block; background: var(--food-img) center / contain no-repeat; image-rendering: pixelated; filter: drop-shadow(0 1px 0 rgba(0,0,0,.6)); }
.food i.h { background: linear-gradient(90deg, rgba(14,12,10,.78) 50%, transparent 50%), var(--food-img) center / contain no-repeat; }
.food i.e { filter: grayscale(1) brightness(.3); opacity: .75; }
.food.low i.f, .food.low i.h { animation: shiver .5s var(--step) infinite; }
@keyframes shiver { 25% { transform: translate(-1px, 1px); } 75% { transform: translate(1px, -1px); } }
@keyframes beat { 50% { transform: translateY(-2px); } }
.slot .cnt { position: absolute; right: 3px; bottom: 2px; font: 600 12px/1 var(--pix); color: #fff; text-shadow: 1px 1px 0 #000; }
.slot .wear { position: absolute; left: 4px; bottom: 3px; height: 3px; max-width: calc(100% - 8px); }
.slot.picked { border-color: #7ed650; background: rgba(126,214,80,.18); }
.mine { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%); border-radius: 50%; background: conic-gradient(rgba(255,255,255,.85) calc(var(--p, 0) * 360deg), rgba(255,255,255,.12) 0); -webkit-mask: radial-gradient(circle, transparent 12px, #000 13px); mask: radial-gradient(circle, transparent 12px, #000 13px); }
body.on-mob .crosshair::before, body.on-mob .crosshair::after { background: #ff6a5a; mix-blend-mode: normal; }
.hurt { position: absolute; inset: 0; pointer-events: none; }
.hurt.on { animation: hurt .45s var(--ease); }
@keyframes hurt { 0% { box-shadow: inset 0 0 140px rgba(220,30,30,.65); } 100% { box-shadow: inset 0 0 140px rgba(220,30,30,0); } }
/* buried in the edge mountains' deep snow: frost closes in */
body.buried .hurt { background: radial-gradient(ellipse at center, rgba(233,241,248,.25), rgba(233,241,248,.95) 70%); }
#tod.night { color: #9fb4ff; }
.inv, .death { position: absolute; inset: 0; z-index: 55; display: grid; place-items: center; padding: 10px; background: rgba(5,6,8,.55); pointer-events: auto; }
.inv[hidden], .death[hidden] { display: none; }
.inv-card { width: min(980px, 100%); max-height: calc(94vh / var(--ui)); overflow: auto; background: rgba(18,23,30,.97); border: 1px solid var(--line); }
.inv-h { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(18,23,30,.98); z-index: 1; }
.inv-h .inv-worth { flex: 1; }
.inv-x { background: none; border: 0; color: var(--muted); font-size: 24px; cursor: pointer; }
.inv-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; padding: 14px; }
@media (max-width: 760px) { .inv-body { grid-template-columns: 1fr; } .inv-slots { order: -1; } }
.inv h4 { font: 600 13px/1 var(--mono); text-transform: uppercase; color: var(--muted); margin: 0 0 8px; letter-spacing: .04em; }
.inv .grid { display: grid; grid-template-columns: repeat(9, 44px); gap: 3px; margin-bottom: 12px; }
.inv .grid .slot { width: 44px; height: 44px; }
@media (max-width: 440px) { .inv .grid { grid-template-columns: repeat(9, 34px); } .inv .grid .slot { width: 34px; height: 34px; } .inv .grid .slot canvas { width: 24px; height: 24px; } }
.inv-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inv-name { min-height: 22px; margin: 0 0 10px; font: 600 15px/22px var(--pix); color: var(--text); }
.inv-name .muted { font: 500 13px/22px var(--sans, inherit); }
.craft-q { width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 8px 10px; font: 500 13px/1 var(--mono); margin-bottom: 8px; }
.craft-list { display: grid; gap: 4px; max-height: calc(52vh / var(--ui)); overflow: auto; }
.craft { display: flex; gap: 10px; align-items: center; text-align: left; background: var(--panel2); border: 1px solid var(--line); padding: 6px 8px; cursor: pointer; color: var(--muted); opacity: .62; }
.craft.ok { opacity: 1; color: var(--text); border-color: rgba(126,214,80,.45); }
.craft.far { opacity: .85; }
.craft:hover { border-color: var(--gold); }
.craft .ci { width: 28px; height: 28px; image-rendering: pixelated; flex: none; }
.craft .cn { display: grid; gap: 2px; }
.craft .cn small { font-size: 11px; color: var(--muted); }
.craft .cn small .miss { color: #e07a6a; }
.craft .st { font-style: normal; font: 600 10px/1 var(--mono); text-transform: uppercase; margin-left: 8px; color: var(--gold); }
.craft .st.away { color: #e07a6a; }
.death { background: rgba(80,8,8,.55); z-index: 70; }
.death-card { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 20px; }
.death-card h2 { font-size: 46px; color: #ffdede; text-shadow: 0 3px 0 #000; }
/* The Esc menu (a menu button opens it on phones) */
.menu { position: absolute; inset: 0; z-index: 65; display: grid; place-items: center; padding: 12px; background: rgba(5,6,8,.6); pointer-events: auto; }
.menu[hidden] { display: none; }
.menu-card { width: min(580px, 100%); max-height: calc(94vh / var(--ui)); overflow: auto; background: rgba(18,23,30,.97); border: 1px solid var(--line); padding: 18px; display: grid; gap: 16px; }
.menu-h { display: grid; gap: 4px; }
.menu-h b { font-size: 28px; }
.menu-sec h4 { font: 600 13px/1 var(--mono); text-transform: uppercase; color: var(--muted); letter-spacing: .04em; margin: 0 0 10px; }
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 14px; }
label.mrow { grid-template-columns: 1fr auto 56px; }
.mrow input[type=range] { width: min(240px, calc(44vw / var(--ui))); accent-color: var(--gold); }
.mrow output { text-align: right; }
.mkeys { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; margin-bottom: 10px; font-size: 14px; }
.mkeys button { min-width: 120px; background: var(--panel2); border: 1px solid var(--line); color: var(--text); padding: 7px 10px; font: 600 13px/1 var(--mono); cursor: pointer; }
.mkeys button:hover { border-color: var(--gold); }
.mkeys button.wait { border-color: var(--gold); color: var(--gold); }
.menu-foot { display: flex; justify-content: flex-end; }
body.touch #m-keys-sec { display: none; }
@media (max-width: 760px) { .coords { display: none; } }
/* Phones: all nine hotbar slots fit across the screen */
.hotbar .slot { width: clamp(36px, calc((96vw / var(--ui) - 36px) / 9), 48px); height: clamp(36px, calc((96vw / var(--ui) - 36px) / 9), 48px); }
.hotbar .slot canvas { width: 70%; height: 70%; }
/* Phones held sideways: a compact top bar, and the side buttons tucked under it, clear of the jump button */
@media (max-height: 500px) {
  .hide-xs { display: none; }
  .top-right { max-width: calc(50vw / var(--ui)); }
  .land, .goal { max-width: calc(40vw / var(--ui)); font-size: 12px; }
  body.touch .side-btns { top: calc(52px + env(safe-area-inset-top)); bottom: auto; transform: none; }
}
