:root {
  --bg: #0d1016; --panel: rgba(18, 22, 30, 0.92); --line: #3a4252; --text: #e8ecf2; --dim: #9aa4b4;
  --accent: #7ccf5a; --accent2: #5aa83a; --slot: #2a303c; --slotb: #4a5466; --danger: #d85a4a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 15px/1.35 "Segoe UI", system-ui, sans-serif; user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px; mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; }
#crosshair::before { left: 9px; top: 0; width: 2px; height: 20px; }
#crosshair::after { top: 9px; left: 0; height: 2px; width: 20px; }
#atk { position: absolute; left: 50%; top: calc(50% + 16px); width: 22px; height: 3px; margin-left: -11px; background: rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.2s; }
#atk b { display: block; height: 100%; width: 0; background: #e8e8e8; }
#vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 0, 0, 0.55)); transition: opacity 0.1s; }
#underwater { position: absolute; inset: 0; background: rgba(20, 60, 160, 0.28); opacity: 0; }
#portal { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
#bossbar { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: min(520px, 80vw); text-align: center; font-weight: 700; color: #c8b8ff; text-shadow: 2px 2px 0 #000; }
#bossbar .bb { height: 10px; margin-top: 4px; background: #1a1030; border: 2px solid #000; }
#bossbar .bb b { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #7af0ff, #8a5aff); }
#sleep { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity 1.2s; }
#fire { position: absolute; inset: 0; opacity: 0; background: linear-gradient(to top, rgba(255, 120, 20, 0.6), transparent 55%); }
#debug { position: absolute; left: 8px; top: 8px; font: 13px/1.4 Consolas, monospace; background: rgba(0, 0, 0, 0.45); padding: 6px 9px; white-space: pre; text-shadow: 1px 1px 0 #000; }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 18px; text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity 0.4s; text-align: center; }
#itemname { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); text-shadow: 2px 2px 0 #000; font-weight: 600; opacity: 0; transition: opacity 0.4s; }
#clock { position: absolute; right: 10px; top: 8px; font: 13px Consolas, monospace; text-shadow: 1px 1px 0 #000; opacity: 0.85; }
#bottom { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
#bars { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 2px 8px; }
.bar { display: flex; gap: 1px; height: 18px; }
.bar.right { flex-direction: row-reverse; grid-column: 2; }
#hearts { grid-column: 1; grid-row: 2; }
#armorbar { grid-column: 1; grid-row: 1; }
#food { grid-row: 2; }
#air { grid-row: 1; }
.bar i { width: 18px; height: 18px; image-rendering: pixelated; background-size: 18px 18px; }
#hotrow { position: relative; }
#offhand { position: absolute; right: 100%; bottom: 0; margin-right: 10px; background: rgba(40, 46, 58, 0.7); border: 2px solid rgba(0, 0, 0, 0.6); visibility: hidden; }
#hotbar { display: flex; gap: 2px; background: rgba(0, 0, 0, 0.45); padding: 3px; border: 2px solid rgba(0, 0, 0, 0.6); }

.slot { position: relative; width: 44px; height: 44px; background: var(--slot); border: 2px solid var(--slotb); display: flex; align-items: center; justify-content: center; }
.slot img { width: 36px; height: 36px; image-rendering: pixelated; pointer-events: none; }
.slot .n { position: absolute; right: 2px; bottom: 0; font: bold 14px Consolas, monospace; text-shadow: 2px 2px 0 #000; pointer-events: none; }
.slot .dur { position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; background: #000; pointer-events: none; }
.slot .dur b { display: block; height: 100%; }
#hotbar .slot.sel { border-color: #fff; box-shadow: 0 0 0 2px #000, inset 0 0 0 1px #000; }
#hotbar .slot { background: rgba(40, 46, 58, 0.7); }

/* screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 8, 12, 0.55); z-index: 10; }
.screen.dim { background: rgba(0, 0, 0, 0.45); }
.screen.red { background: rgba(110, 10, 10, 0.55); }
.title-row { display: flex; gap: 28px; align-items: center; justify-content: center; flex-wrap: wrap; max-height: 100vh; overflow-y: auto; padding: 24px 16px; box-sizing: border-box; }
.panel { background: var(--panel); border: 2px solid var(--line); padding: 22px 26px; min-width: 320px; max-width: 92vw; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); }
.title-panel { align-items: stretch; min-width: 420px; }
h1 { margin: 0; font-size: 46px; letter-spacing: 6px; text-align: center; color: #9be070; text-shadow: 4px 4px 0 #24401a, 0 0 30px rgba(120, 220, 80, 0.25); font-family: Consolas, monospace; }
h2 { margin: 0 0 6px; text-align: center; }
h3 { margin: 0; }
.sub { margin: 0 0 8px; text-align: center; color: var(--dim); }
button { font: inherit; font-weight: 600; color: var(--text); background: #3a4a36; border: 2px solid #5a7a4a; padding: 10px 14px; cursor: pointer; }
button:hover { background: #4a6040; border-color: var(--accent); }
button.secondary { background: #343a46; border-color: #4a5466; }
button.secondary:hover { background: #40485a; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); }
label.check, label.radio { flex-direction: row; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
label.small { font-size: 13px; }
input[type=range] { width: 100%; }
select { font: inherit; padding: 6px; background: #11151c; color: var(--text); border: 2px solid var(--line); }
input:not([type]) , input[type=text] { font: inherit; padding: 8px; background: #11151c; color: var(--text); border: 2px solid var(--line); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.warn { color: #f0b04a; margin: 0; text-align: center; }
.help { display: flex; flex-direction: column; gap: 3px; margin-top: 10px; font-size: 13px; color: var(--dim); border-top: 1px solid var(--line); padding-top: 10px; }
.help b { color: var(--text); }
.progress { width: 320px; height: 14px; border: 2px solid var(--line); background: #11151c; }
#loadBar { height: 100%; width: 0; background: var(--accent2); }

/* inventory */
.inv-wrap { display: flex; gap: 12px; align-items: flex-start; max-height: 92vh; }
.inv-panel { min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(9, 44px); gap: 2px; }
.grid.hot { margin-top: 8px; }
.grid .slot { cursor: pointer; }
.grid .slot:hover, #palette .slot:hover { background: #3a4252; }
.inv-foot { display: flex; justify-content: space-between; align-items: center; color: var(--dim); font-size: 13px; }
.slot.trash { color: var(--danger); font-size: 20px; cursor: pointer; }
.trash-wrap { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; }
.inv-panel { position: relative; }
.close-btn { position: absolute; top: 6px; right: 6px; padding: 2px 10px; font-size: 18px; line-height: 1.4; background: #5a2a2a; border-color: #8a3a3a; z-index: 2; }
.close-btn:hover { background: #7a3030; border-color: #d85a4a; }
.tabs { display: flex; gap: 4px; }
.inv-body { display: flex; gap: 10px; align-items: flex-start; }
.armor-wrap { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.armor-col { display: flex; flex-direction: column; gap: 2px; }
.armor-col .slot.empty::after { content: attr(data-label); font-size: 9px; color: #6a7486; text-align: center; }
#armorPts { font-size: 12px; color: var(--dim); white-space: nowrap; }
#container { border-bottom: 1px solid var(--line); padding-bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
#container h3 { font-size: 15px; }
.furnace-ui { display: flex; align-items: center; gap: 18px; padding: 4px 0 0 54px; }
.f-left { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.flame { width: 14px; height: 16px; background: #2a1a10; display: flex; align-items: flex-end; }
.flame b { width: 100%; background: linear-gradient(#ffd24a, #ff6a1a); }
.arrow { width: 54px; height: 12px; background: #3a4252; position: relative; }
.arrow b { display: block; height: 100%; width: 0; background: #e8e8e8; }
.slot.big { width: 54px; height: 54px; }
.craft-area { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; justify-content: flex-end; }
.craft-area .lbl { color: var(--dim); font-size: 13px; margin-right: auto; }
.cgrid { display: grid; gap: 2px; }
.carrow { font-size: 26px; color: var(--dim); }
.trades { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.trade { display: flex; align-items: center; gap: 8px; padding: 3px 6px; background: #1c222c; }
.trade.no { opacity: 0.5; }
.trade button { margin-left: auto; padding: 6px 12px; }
.sub.small { font-size: 12px; margin: 0; text-align: left; }
.tabs button { padding: 5px 10px; font-size: 13px; }
.tabs button.on { background: #5a7a4a; }
#palette { display: grid; grid-template-columns: repeat(9, 44px); gap: 2px; max-height: 380px; overflow-y: auto; padding-right: 4px; }
#palSearch { display: block; width: 100%; box-sizing: border-box; margin: 0 0 6px; padding: 6px 8px; font: 14px system-ui, sans-serif; background: #fff; color: #222; border: 2px solid; border-color: #373737 #fff #fff #373737; }
#palSearch[hidden] { display: none; }
#palette .slot { cursor: pointer; }
.craft-panel { width: 360px; max-height: 80vh; }
#recipes { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; max-height: 62vh; padding-right: 4px; }
.recipe { display: flex; align-items: center; gap: 8px; padding: 4px; border: 2px solid transparent; background: #1c222c; cursor: pointer; }
.recipe:hover { border-color: var(--accent2); }
.recipe.no { opacity: 0.45; cursor: default; }
.recipe .slot { width: 40px; height: 40px; flex: none; }
.recipe .slot img { width: 30px; height: 30px; }
.recipe .info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recipe .nm { font-weight: 600; font-size: 14px; }
.recipe .ing { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; color: var(--dim); }
.recipe .ing span { display: inline-flex; align-items: center; gap: 2px; }
.recipe .ing img { width: 16px; height: 16px; image-rendering: pixelated; }
.recipe .ing .miss { color: var(--danger); }
.recipe .st { font-size: 11px; color: #e0c070; }
.ghost { position: fixed; pointer-events: none; background: transparent !important; border: none !important; z-index: 20; }
#tooltip { position: fixed; pointer-events: none; background: rgba(20, 10, 30, 0.95); border: 2px solid #3a1a5a; padding: 4px 8px; z-index: 30; font-size: 14px; }
#tooltip small { color: var(--dim); display: block; }

@media (max-width: 900px) {
  .inv-wrap { flex-direction: column; overflow-y: auto; }
  .craft-panel { width: auto; }
}

/* ---------- inventory v2 ---------- */
.inv-panel { padding: 18px 20px 14px; gap: 8px; }
.inv-title { font-size: 18px; margin: 0 0 2px; letter-spacing: 0.5px; }
.sec-title { color: var(--dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; margin-top: 2px; }
.inv-top { display: flex; gap: 18px; align-items: stretch; justify-content: space-between; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.equip { display: flex; gap: 10px; }
.doll { display: flex; flex-direction: column; justify-content: space-between; width: 128px; padding: 8px; background: #161b23; border: 2px solid; border-color: #10141a #3a4352 #3a4352 #10141a; }
.stats { display: flex; flex-direction: column; gap: 6px; font: bold 14px Consolas, monospace; }
.stats div { display: flex; align-items: center; gap: 8px; }
.stats i { width: 18px; height: 18px; image-rendering: pixelated; background-size: 18px 18px; }
.off-wrap { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; }
.craft-area { display: flex; flex-direction: column; justify-content: center; gap: 6px; margin: 0; }
.craft-row { display: flex; align-items: center; gap: 12px; }
.carrow { width: 30px; height: 22px; background: linear-gradient(90deg, #6a7486 0 60%, transparent 60%), none; clip-path: polygon(0 35%, 60% 35%, 60% 0, 100% 50%, 60% 100%, 60% 65%, 0 65%); font-size: 0; }
.carrow.ready { background: var(--accent); }
.craft-hint { color: var(--dim); font-size: 12px; max-width: 230px; }
#craftOut .slot.big { width: 56px; height: 56px; }
#craftOut .slot.big img { width: 42px; height: 42px; }
#craftOut .slot.big.ready { border-color: var(--accent); box-shadow: 0 0 10px rgba(124, 207, 90, 0.45); cursor: pointer; }
.inv-panel .slot { border-color: #141920 #5a6476 #5a6476 #141920; background: #2a303c; }
.inv-panel .slot:hover { background: #3c4556; }
.grid.hot { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.armor-col { gap: 3px; }
.armor-col .slot.empty::after { content: none; }
.armor-col .slot.empty { background-repeat: no-repeat; background-position: center; background-size: 30px 30px; }
.inv-foot { margin-top: 4px; font-size: 12px; }
.inv-foot .keys b { color: #c8d0dc; font-weight: 600; }
.slot.trash { background: #3a2226 !important; border-color: #1c1012 #7a3a40 #7a3a40 #1c1012 !important; }
.slot.trash::before { content: ''; width: 18px; height: 20px; background: #d85a4a; clip-path: polygon(0 12%, 100% 12%, 100% 22%, 88% 22%, 80% 100%, 20% 100%, 12% 22%, 0 22%, 0 12%, 35% 12%, 35% 0, 65% 0, 65% 12%); }
.inv-panel.mode-bench .equip, .inv-panel.mode-cont .inv-top { display: none; }
.inv-panel.mode-bench .inv-top { justify-content: center; }

/* ---------- experience, enchanting ---------- */
#xpbar { position: relative; width: 420px; height: 7px; background: #1a2a10; border: 1px solid #000; margin-bottom: 3px; }
#xpbar b { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#b8f040, #6ab820); }
#xpbar span { position: absolute; left: 50%; top: -15px; transform: translateX(-50%); font: bold 14px Consolas, monospace; color: #9cf040; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.slot.ench img { filter: drop-shadow(0 0 3px #b070ff) drop-shadow(0 0 2px #b070ff); }
.ench-ui { display: flex; gap: 16px; align-items: flex-start; }
.ench-ui .ins { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.ench-ui .opts { display: flex; flex-direction: column; gap: 4px; min-width: 260px; }
.ench-opt { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; background: #2a2236; border: 2px solid #4a3a5e; cursor: pointer; font-size: 13px; color: #cfc0e8; }
.ench-opt:hover { border-color: #b070ff; }
.ench-opt.no { opacity: 0.4; cursor: default; }
.ench-opt b { color: #9cf040; }
.anvil-ui { display: flex; gap: 12px; align-items: center; }
.anvil-cost { color: #9cf040; font-weight: 600; margin-left: 8px; }
.anvil-cost.bad { color: #d85a4a; }
#tooltip .ench-line { color: #b8a0ff; }

.sign-panel textarea { width: 260px; height: 96px; font: 18px Consolas, monospace; background: #b08a54; color: #1a1208; border: 3px solid #6a4e2e; padding: 6px; resize: none; text-align: center; line-height: 22px; }

#heldInfo { position: absolute; top: 44px; right: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
#heldInfo canvas { image-rendering: pixelated; border: 3px solid #6a5a3a; background: #d6c8a0; }
#heldInfo .dial { width: 72px; height: 72px; border-radius: 50%; border: 3px solid #555; background: radial-gradient(#f0eee4, #c8c4b4); position: relative; }
#heldInfo .needle { position: absolute; left: 33px; top: 6px; width: 6px; height: 60px; background: linear-gradient(#d22 0 50%, #333 50%); transform-origin: 3px 30px; }
#heldInfo .sky { background: conic-gradient(#ffd24a 0 25%, #6aaee8 25% 50%, #1a2040 50% 75%, #e88a4a 75%); }

/* ---------- Minecraft-like inventory skin ---------- */
.inv-panel, .craft-panel { background: #c6c6c6; color: #3f3f3f; border: 3px solid; border-color: #fff #555 #555 #fff; border-radius: 6px; box-shadow: 0 0 0 2px #000, 0 10px 30px rgba(0, 0, 0, 0.5); }
.inv-panel .inv-title, .craft-panel h3 { color: #3f3f3f; font-weight: 600; text-align: left; }
.inv-panel .sec-title, .inv-panel .craft-hint, .inv-panel .inv-foot, .craft-panel .sub, .craft-panel .check { color: #3f3f3f; text-transform: none; letter-spacing: 0; }
.inv-panel .inv-foot .keys b { color: #222; }
.inv-panel .slot, .craft-panel .slot, #container .slot { background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737; border-radius: 0; }
.inv-panel .slot:hover { background: #a6a6a6; }
.inv-panel .inv-top { border-bottom: none; }
.inv-panel .grid.hot { border-top: none; margin-top: 8px; padding-top: 0; }
.inv-panel .doll { background: #000; border: 2px solid; border-color: #373737 #fff #fff #373737; color: #e8e8e8; }
.inv-panel .off-wrap { color: #c8c8c8; }
.inv-panel .carrow { background: #8b8b8b; }
.inv-panel .carrow.ready { background: #5aa83a; }
#craftOut .slot.big.ready { border-color: #373737 #fff #fff #373737; box-shadow: 0 0 0 2px #5aa83a; }
.inv-panel .close-btn { background: #c6c6c6; color: #3f3f3f; border: 2px solid; border-color: #fff #555 #555 #fff; }
.craft-panel .recipe { background: #b4b4b4; border: 2px solid; border-color: #fff #777 #777 #fff; color: #2a2a2a; }
.craft-panel .recipe:hover { border-color: #5aa83a; }
.craft-panel .recipe .ing { color: #444; }
.craft-panel .recipe .ing .miss { color: #a02020; }
.craft-panel .recipe .st { color: #6a4a10; }
.slot.trash { background: #8b8b8b !important; border-color: #373737 #fff #fff #373737 !important; }
#container h3, #container .sub { color: #3f3f3f; }
.ench-opt { background: #8b8b8b; color: #222; border-color: #373737 #fff #fff #373737; }
.ench-opt b { color: #2a6a10; }

/* OneBlock market */
.mk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mk-head h3 { margin: 0 0 6px; }
.mk-coins { font-weight: bold; color: #ffd75a; }
.mk-tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.mk-tabs button { padding: 6px 12px; }
.mk-tabs button.on { outline: 2px solid #ffd75a; }
.mk-info { line-height: 1.25; }
.mk-info .sub { opacity: 0.75; font-size: 12px; }
.mk-sell { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.mk-price { width: 90px; padding: 6px; }

/* ---------- menus: the blocky look — the game's own pixel font (fonts/blockfont.ttf, made by tools/makefont.mjs),
   stone buttons, the world blurred behind. 20px text = 2 screen pixels per font pixel. ---------- */
@font-face { font-family: 'Blockfont'; src: url(fonts/blockfont.ttf) format('truetype'); font-display: swap; }
:root { --ui: 'Blockfont', system-ui, sans-serif; }
.screen:not(#title):not(#inventory):not(.dim) { background: rgba(8, 8, 12, 0.5); backdrop-filter: blur(5px); }
.screen.red { background: rgba(120, 0, 0, 0.42) !important; }
.screen > .panel { position: relative; width: 416px; min-width: 0; max-width: calc(100vw - 16px); max-height: 100vh; overflow-y: auto; padding: 20px 8px; gap: 8px; background: none; border: none; border-radius: 0; box-shadow: none; font: 20px/1.2 var(--ui); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; animation: panelIn 0.15s ease-out; }
@keyframes panelIn { from { opacity: 0; } to { opacity: 1; } }
.screen > .panel h2, .mc-screen h2 { margin: 0 0 16px; font: 20px/1 var(--ui); letter-spacing: 0; text-transform: none; text-align: center; color: #fff; background: none; -webkit-background-clip: border-box; background-clip: border-box; text-shadow: 2px 2px 0 #3f3f3f; }
.screen.red > .panel h2 { font-size: 40px; text-shadow: 4px 4px 0 #3f3f3f; margin-bottom: 24px; }
.screen > .panel h3 { margin: 6px 0 4px; font: 20px/1 var(--ui); }
.screen > .panel .sub { color: #a8a8a8; font: 20px/1.2 var(--ui); margin: 0; }
.screen > .panel .sub.small, .screen > .panel label.small { font-size: 20px; }
.screen > .panel p { margin: 0; }
/* buttons */
.mcb, .screen > .panel button, .mm-root button, .mc-screen button {
  height: 40px; padding: 0 12px; font: 20px/1 var(--ui); letter-spacing: 0; color: #fff; text-shadow: 2px 2px 0 #3f3f3f;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath fill='%23000' fill-opacity='.07' d='M2 2h2v2H2zM10 4h4v2h-4zM6 10h2v2H6zM12 12h2v2h-2zM0 14h2v2H0z'/%3E%3Cpath fill='%23fff' fill-opacity='.06' d='M6 0h2v2H6zM14 8h2v2h-2zM2 8h2v2H2zM8 14h4v2H8z'/%3E%3C/svg%3E") 0 0 / 16px 16px, #6f6f6f; border: 2px solid #000; border-radius: 0;
  box-shadow: inset 2px 2px 0 #a6a6a6, inset -2px -4px 0 #4a4a4a; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transform: none; filter: none; transition: none; }
.mcb:hover, .screen > .panel button:hover, .mm-root button:hover, .mc-screen button:hover,
.mcb:focus-visible, .screen > .panel button:focus-visible, .mm-root button:focus-visible { border-color: #fff; color: #ffffa0; background-color: #7a7a7a; outline: none; transform: none; filter: none; }
.mcb:active, .screen > .panel button:active, .mm-root button:active { transform: none; box-shadow: inset 2px 2px 0 #4a4a4a, inset -2px -2px 0 #8a8a8a; }
.mcb:disabled, .screen > .panel button:disabled, .mm-root button:disabled, .mc-screen button:disabled { background: #2c2c2c; color: #a0a0a0; text-shadow: none; box-shadow: none; border-color: #000; cursor: default; }
.screen > .panel button.big { font-size: 20px; padding: 0 12px; }
.screen > .panel button small { opacity: 0.7; }
.screen > .panel button.secondary, .screen > .panel button.danger { color: #fff; }
.screen > .panel button.secondary:hover, .screen > .panel button.danger:hover { color: #ffffa0; border-color: #fff; }
.menu-row { display: flex; gap: 8px; }
.menu-row > button { flex: 1 1 0; min-width: 0; white-space: nowrap; }
.screen > .panel.pause-panel { width: 500px; }
.screen > .panel.settings-panel { width: 640px; max-height: 100vh; overflow-y: auto; }
/* fields */
.screen > .panel label { color: #e0e0e0; font: 20px/1.2 var(--ui); gap: 6px; }
.screen > .panel label b { color: #ffff55; font-weight: normal; }
.screen > .panel select, .screen > .panel input:not([type]), .screen > .panel input[type=text], #cmdBox {
  height: 40px; padding: 0 8px; font: 20px var(--ui); color: #e0e0e0; background: #000; border: 2px solid #a0a0a0; border-radius: 0; outline: none; }
.screen > .panel select { -webkit-appearance: none; appearance: none; padding-right: 32px; background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 4' shape-rendering='crispEdges'%3E%3Cpath fill='%23e0e0e0' d='M0 0h7v1H0zM1 1h5v1H1zM2 2h3v1H2zM3 3h1v1H3z'/%3E%3C/svg%3E") right 10px center / 14px 8px no-repeat; }
.screen > .panel select:focus, .screen > .panel input:focus { border-color: #fff; outline: none; }
.screen > .panel input::placeholder { color: #707070; }
.screen > .panel input[type=range] { -webkit-appearance: none; appearance: none; height: 40px; margin: 0; background: #2c2c2c; border: 2px solid #000; box-shadow: inset 0 0 0 2px #1c1c1c; cursor: pointer; }
.screen > .panel input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 36px; background: #6f6f6f; border: 2px solid #000; box-shadow: inset 2px 2px 0 #a6a6a6, inset -2px -2px 0 #4a4a4a; }
.screen > .panel input[type=range]:hover::-webkit-slider-thumb { border-color: #fff; }
.screen > .panel input[type=range]::-moz-range-thumb { width: 12px; height: 32px; border-radius: 0; background: #6f6f6f; border: 2px solid #000; }
.screen > .panel input[type=checkbox], .screen > .panel input[type=radio] { -webkit-appearance: none; appearance: none; flex: none; width: 20px; height: 20px; margin: 0; background: #000; border: 2px solid #a0a0a0; cursor: pointer; }
.screen > .panel input[type=checkbox]:checked { background: #000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23fff' d='M6 1h1v2H6zM5 3h1v1H5zM4 4h1v1H4zM1 4h1v1H1zM2 5h1v1H2zM3 5h1v2H3z'/%3E%3C/svg%3E") center / 16px 16px no-repeat; }
.screen > .panel input[type=radio]:checked { box-shadow: inset 0 0 0 3px #000, inset 0 0 0 10px #e0e0e0; }
.screen > .panel input[type=checkbox]:hover, .screen > .panel input[type=radio]:hover { border-color: #fff; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; padding: 12px; margin: 4px 0; background: rgba(0, 0, 0, 0.5); border: 2px solid #000; border-radius: 0; }
.screen > .panel label.check, .screen > .panel label.radio { color: #e0e0e0; gap: 10px; }
.screen > .panel .row { gap: 8px; }
.screen > .panel .warn { color: #ff5555; text-align: center; margin: 0; }
.screen > .panel .progress { width: 100%; height: 8px; background: #000; border: 2px solid #a0a0a0; border-radius: 0; overflow: hidden; }
.screen > .panel #loadBar { height: 100%; background: #6cd64a; border-radius: 0; }

/* the title screen: the world turning behind, the logo, a splash, the buttons in a column */
#title { flex-direction: column; justify-content: center; background: radial-gradient(ellipse at 50% 45%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, 0.5) 100%); backdrop-filter: blur(2px); }
.mc-title { display: flex; flex-direction: column; align-items: center; width: 100%; max-height: 100vh; overflow-y: auto; overflow-x: hidden; padding: 3vh 16px 48px; }
.mc-logo { position: relative; margin: 1vh 0 7vh; text-align: center; }
.mc-logo h1 { position: relative; margin: 0; font: clamp(40px, 9vw, 100px)/1 var(--ui); letter-spacing: 0.02em; color: transparent; text-shadow: none;
  background: linear-gradient(180deg, #a8ec74 0 17%, #74c84c 17% 24%, #4f9a31 24% 31%, #9a6844 31% 45%, #845634 45% 62%, #6c4428 62% 100%); -webkit-background-clip: text; background-clip: text; }
.mc-logo h1::before { content: attr(data-text); position: absolute; inset: 0; z-index: -1; color: #000;
  text-shadow: 0.03em 0 #000, -0.03em 0 #000, 0 0.03em #000, 0 -0.03em #000, 0.03em 0.03em #000, -0.03em 0.03em #000, 0.03em -0.03em #000, -0.03em -0.03em #000,
    0 0.07em 0 #3a2616, 0 0.1em 0 #2a1a0e, 0 0.13em 0 #000, 0 0.16em 0.06em rgba(0, 0, 0, 0.45); }
.mc-ed { margin-top: 0.4em; font: 20px var(--ui); letter-spacing: 6px; text-transform: uppercase; color: #fff; text-shadow: 2px 2px 0 #3f3f3f; }
.mc-splash { position: absolute; right: 0; bottom: 34%; white-space: nowrap; font: 20px var(--ui); color: #ffff00; text-shadow: 2px 2px 0 #3f3f00; transform: translateX(45%) rotate(-20deg); animation: splash 0.25s ease-in-out infinite alternate; pointer-events: none; }
@keyframes splash { from { transform: translateX(45%) rotate(-20deg) scale(1); } to { transform: translateX(45%) rotate(-20deg) scale(0.92); } }
.mc-menu { display: flex; flex-direction: column; gap: 8px; width: 400px; max-width: calc(100vw - 112px); }
.mc-row4 { display: flex; gap: 8px; margin: 16px -48px 0; }
.mc-row4 .mcb { flex: 1 1 0; min-width: 0; }
.mcb.mc-sq { flex: 0 0 40px; width: 40px; padding: 0; }
.mc-sq svg { display: block; width: 20px; height: 20px; margin: auto; }
.mc-ver, .mc-copy { position: fixed; bottom: 4px; font: 20px var(--ui); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; pointer-events: none; }
.mc-ver { left: 6px; }
.mc-copy { right: 6px; }
.tp-help { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; max-width: 820px; margin-top: 16px; padding: 10px 14px; background: rgba(0, 0, 0, 0.55); border: 2px solid #000; font: 20px var(--ui); color: #e0e0e0; text-shadow: 2px 2px 0 #3f3f3f; }
.tp-help span { white-space: nowrap; }
.tp-help kbd { font: 20px var(--ui); color: #ffff55; margin-right: 8px; }

/* list screens (select world, multiplayer, minigames): a dark band with the list, buttons under it */
.mc-screen { display: flex; flex-direction: column; align-items: center; width: 100%; height: 100%; padding: 16px 0 12px; font: 20px/1.2 var(--ui); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; }
.mc-screen h2 { margin: 0 0 14px; }
.mc-band { flex: 1; width: 100%; overflow-y: auto; padding: 8px 0; background: rgba(0, 0, 0, 0.5); border-top: 2px solid rgba(255, 255, 255, 0.28); border-bottom: 2px solid rgba(255, 255, 255, 0.28); box-shadow: 0 -2px 0 #000, 0 2px 0 #000; }
.mc-list { display: flex; flex-direction: column; gap: 4px; width: 620px; max-width: calc(100vw - 24px); margin: 0 auto; }
.mc-item { display: flex; align-items: center; gap: 10px; padding: 4px; border: 2px solid transparent; cursor: pointer; }
.mc-item:hover { background: rgba(255, 255, 255, 0.06); }
.mc-item.sel { background: #000; border-color: #a0a0a0; }
.mc-item img { flex: none; width: 64px; height: 64px; object-fit: cover; image-rendering: pixelated; }
.mc-txt { flex: 1; min-width: 0; line-height: 21px; }
.mc-txt b { display: block; font-weight: normal; color: #fff; }
.mc-txt span { display: block; color: #8a8a8a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-right { align-self: flex-start; display: flex; align-items: center; gap: 8px; color: #a0a0a0; white-space: nowrap; }
.mc-ping { display: inline-block; width: 20px; height: 16px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23555' d='M0 6h2v2H0zM2 4h2v4H2zM4 3h2v5H4zM6 1h2v7H6zM8 0h2v8H8z'/%3E%3C/svg%3E") center / 20px 16px no-repeat; }
.mc-ping.ok { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8' shape-rendering='crispEdges'%3E%3Cpath fill='%2355ff55' d='M0 6h2v2H0zM2 4h2v4H2zM4 3h2v5H4zM6 1h2v7H6zM8 0h2v8H8z'/%3E%3C/svg%3E"); }
.mc-ping.bad { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23aa2222' d='M0 6h2v2H0zM2 4h2v4H2zM4 3h2v5H4zM6 1h2v7H6zM8 0h2v8H8z'/%3E%3C/svg%3E"); }
.mc-empty { padding: 40px 0; text-align: center; color: #a0a0a0; }
.mc-foot { display: flex; flex-direction: column; gap: 8px; width: 616px; max-width: calc(100vw - 24px); margin-top: 12px; }
.mc-pair { display: flex; gap: 8px; }
.mc-pair .mcb { flex: 1 1 0; min-width: 0; }
.mc-foot .mc-back { align-self: center; width: 304px; max-width: 100%; }
.mc-minis { width: 1100px; max-width: calc(100vw - 24px); margin: 0 auto; padding: 4px 0; }
#titleMinisGrid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { #titleMinisGrid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { #titleMinisGrid { grid-template-columns: 1fr; } .mc-ed { font-size: 10px; letter-spacing: 3px; } .mc-splash { font-size: 10px; transform: translateX(30%) rotate(-20deg); animation: none; } .mc-row4 { margin: 16px 0 0; } .mc-menu { max-width: calc(100vw - 32px); } .mc-ver, .mc-copy { font-size: 10px; } .mc-logo { margin-bottom: 5vh; } }
@media (max-height: 520px) { .mc-logo { margin: 0 0 4vh; } .mc-logo h1 { font-size: clamp(30px, 7vw, 60px); } .mc-ed { display: none; } .mc-title { padding-top: 10px; } .mc-row4 { margin-top: 8px; } }

/* the HUD's words in the same font */
#toast, #itemname, #bossbar, #xplvl { font-family: var(--ui); font-weight: normal; }
#toast { font-size: 20px; text-shadow: 2px 2px 0 #3f3f3f; }
#itemname { font-size: 20px; text-shadow: 2px 2px 0 #3f3f3f; }

/* ---------- market / shop / villager trades: item cards ---------- */
.mk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.mk-tabs { display: flex; gap: 3px; padding: 3px; background: #8b8b8b; border: 2px solid; border-color: #373737 #fff #fff #373737; }
#container .mk-tabs button { background: transparent; border: none; color: #f0f0f0; padding: 6px 13px; font-weight: 800; font-size: 13px; border-radius: 4px; outline: none; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
#container .mk-tabs button:hover { background: rgba(255, 255, 255, 0.15); }
#container .mk-tabs button.on { background: linear-gradient(180deg, #6cc84a, #4a9a30); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.3); }
.mk-coins { margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 8px; border-radius: 16px; background: #2a2416; border: 2px solid #8a6a1c; color: #ffd75a; font-weight: 900; font-size: 15px; }
.mk-coins::before, .mk-chip::before { content: ''; width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff3a0, #f0b820 55%, #a87010); box-shadow: 0 0 0 1px #6a4808; }
.mk-lead { margin: 0 0 6px; font-size: 12px; color: #4a4a4a; }
.mk-empty { margin: 6px 0; padding: 16px; text-align: center; color: #555; background: #b4b4b4; border: 2px dashed #8a8a8a; border-radius: 8px; font-size: 13px; }
.mk-sec { margin: 8px 0 2px; font-size: 12px; font-weight: 700; color: #3f3f3f; }
#container .trades { gap: 5px; max-height: 300px; padding-right: 3px; }
#container .trade { gap: 10px; padding: 5px 8px 5px 5px; background: #dcdcdc; border: 2px solid; border-color: #fff #8a8a8a #8a8a8a #fff; border-radius: 7px; color: #2a2a2a; transition: background 0.1s; }
#container .trade:hover { background: #ebebeb; }
#container .trade.no { opacity: 0.55; }
#container .trade button { margin-left: 0; background: linear-gradient(180deg, #6cc84a, #4a9a30); color: #fff; border: 2px solid #2e6a1c; border-radius: 6px; padding: 6px 16px; font-weight: 800; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
#container .trade button:hover { filter: brightness(1.1); }
#container .trade:not(.mk-row) button { margin-left: auto; }
#container .trade.no button { background: #9a9a9a; border-color: #6a6a6a; }
.mk-info { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.mk-info b { color: #262626; font-size: 14px; }
.mk-info .sub { color: #5a5a5a; opacity: 1; font-size: 11.5px; text-align: left; margin: 0; }
.mk-chip { display: flex; align-items: center; gap: 5px; padding: 3px 10px 3px 6px; border-radius: 12px; background: #2a2416; color: #ffd75a; font-weight: 900; font-size: 13px; white-space: nowrap; }
.mk-sell { gap: 8px; padding: 8px; background: #b4b4b4; border: 2px solid; border-color: #8a8a8a #fff #fff #8a8a8a; border-radius: 8px; }
#container .mk-price { width: 92px; padding: 7px 8px; border-radius: 6px; border: 2px solid #6a6a6a; background: #f4f4f4; color: #222; font-weight: 700; }
#container .mk-sell button { border-radius: 6px; padding: 7px 12px; font-weight: 800; border: 2px solid; }
#container .mk-sell .mk-go { background: linear-gradient(180deg, #6cc84a, #4a9a30); color: #fff; border-color: #2e6a1c; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
#container .mk-sell .mk-alt { background: linear-gradient(180deg, #f0c040, #c89418); color: #2a1e04; border-color: #8a6a10; }
.settings-panel { gap: 9px; }
.settings-panel label:not(.check) { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }
.settings-panel label:not(.check) > input, .settings-panel label:not(.check) > select { grid-column: 1 / -1; }
.settings-panel label b { justify-self: end; padding: 1px 8px; border-radius: 10px; background: #1c2a18; font-size: 12px; }
#inventory.panel-only .craft-panel { display: none; }

/* records board, pet shop */
.rec-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 330px; overflow-y: auto; padding-right: 3px; }
.rec-card { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; background: #dcdcdc; border: 2px solid; border-color: #fff #8a8a8a #8a8a8a #fff; border-radius: 7px; color: #2a2a2a; }
.rec-card > b { font-size: 13px; margin-bottom: 3px; color: #262626; }
.rec-card .sub { color: #6a6a6a; font-size: 12px; text-align: left; margin: 0; }
.rec-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; padding: 1px 4px; border-radius: 4px; }
.rec-row.first { background: #2a2416; color: #ffd75a; font-weight: 800; }
.mk-crystal::before { border-radius: 2px !important; transform: rotate(45deg); background: linear-gradient(135deg, #b8fff8, #40d8d0 55%, #1a8a90) !important; box-shadow: 0 0 0 1px #0c5a60 !important; }
.mk-coins.mk-crystal, .mk-chip.mk-crystal { color: #8af4ec; border-color: #1a8a90; background: #0e2a2e; }
.mk-head .mk-lead { margin: 0; flex: 1; }
#inventory.panel-only .inv-panel { min-width: 470px; }
#container .mk-ad { align-self: flex-start; margin: 0 0 6px; padding: 7px 14px; border-radius: 6px; border: 2px solid #8a6a10; background: linear-gradient(180deg, #f0c040, #c89418); color: #2a1e04; font-weight: 800; }
#container .mk-ad:hover { filter: brightness(1.08); }

/* ---------- touch controls (Minecraft-on-a-phone layout) ---------- */
#tc { position: absolute; inset: 0; pointer-events: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#tc > * { pointer-events: auto; touch-action: none; }
.tc-look { position: absolute; inset: 0; }
.tc-joy { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: 22px; width: 132px; height: 132px; border-radius: 50%; background: rgba(20, 24, 32, 0.34); border: 2px solid rgba(255, 255, 255, 0.32); }
.tc-joy i { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.5); border: 2px solid rgba(0, 0, 0, 0.35); }
.tc-joy.run { border-color: #9fe08a; } .tc-joy.run i { background: rgba(159, 224, 138, 0.75); }
.tc-btn { position: absolute; display: flex; align-items: center; justify-content: center; border-radius: 14px; background: rgba(20, 24, 32, 0.4); border: 2px solid rgba(255, 255, 255, 0.34); color: #fff; font: 700 26px system-ui, sans-serif; text-shadow: 0 1px 2px #000; }
.tc-btn.on { background: rgba(159, 224, 138, 0.55); border-color: #fff; }
.tc-jump { right: max(22px, env(safe-area-inset-right)); bottom: 86px; width: 78px; height: 78px; border-radius: 50%; }
.tc-sneak { right: max(112px, calc(env(safe-area-inset-right) + 90px)); bottom: 30px; width: 62px; height: 62px; border-radius: 50%; }
.tc-pause { right: max(10px, env(safe-area-inset-right)); top: 8px; width: 44px; height: 40px; font-size: 15px; }
.tc-inv { left: calc(50% + 232px); bottom: 10px; width: 46px; height: 46px; }
#tcRotate { display: none; position: fixed; inset: 0; z-index: 2000; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #10141b; color: #e8ecf2; font: 600 18px system-ui, sans-serif; text-align: center; padding: 24px; }
#tcRotate b { font-size: 64px; color: #9fe08a; }
body:not(.touch) #tcRotate { display: none !important; }
body.touch #hud { pointer-events: none; }
body.touch #hotbar { pointer-events: auto; touch-action: none; }
body.touch #clock { right: 64px; }
body.touch #debug { display: none; }
body.touch #crosshair { opacity: 0.45; }
body.touch .tp-help { display: none; }
body.touch, body.touch * { -webkit-tap-highlight-color: transparent; }
/* small screens: everything a size down so it fits a phone held sideways */
@media (max-height: 520px) {
  #hotbar .slot, #offhand.slot { width: 36px; height: 36px; }
  #hotbar .slot img, #offhand.slot img { width: 28px; height: 28px; }
  #xpbar { width: 344px; }
  #bottom { bottom: 4px; gap: 2px; }
  .tc-inv { left: calc(50% + 192px); bottom: 6px; width: 40px; height: 40px; }
  .tc-joy { width: 116px; height: 116px; bottom: 14px; }
  .tc-jump { width: 68px; height: 68px; bottom: 70px; }
  .tc-sneak { width: 54px; height: 54px; bottom: 16px; }
  #toast { font-size: 14px; top: 16%; max-width: 70vw; }
  .screen > .panel { padding: 16px 18px 14px; gap: 7px; max-height: 96vh; overflow-y: auto; }
  .screen > .panel h2 { font-size: 20px; letter-spacing: 4px; margin-bottom: 4px; }
  .screen > .panel button { padding: 8px 12px; } .screen > .panel button.big { padding: 10px 14px; font-size: 15px; }
}
body.touch .inv-wrap { transform-origin: center center; }
/* inventory on a phone */
@media (max-height: 520px) {
  .inv-wrap { flex-direction: row !important; max-height: none !important; overflow: visible !important; flex-shrink: 0; }
  .craft-panel { width: 300px !important; max-height: 470px !important; }
  #inventory { overflow: hidden; }
}
body.touch .inv-foot .keys { visibility: hidden; }
body.touch .inv-foot .keys::before { content: "Tap: move  ·  hold: half the stack"; visibility: visible; }

/* ---------- chat ---------- */
#chat { position: fixed; left: 8px; bottom: 96px; width: min(520px, 62vw); z-index: 60; display: flex; flex-direction: column; gap: 4px; pointer-events: none; font: 14px/1.35 system-ui, "Segoe UI", sans-serif; }
#chatLog { max-height: 190px; overflow: hidden; display: flex; flex-direction: column; }
.chat-line { align-self: flex-start; max-width: 100%; margin-top: 2px; padding: 2px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.42); color: #fff; text-shadow: 1px 1px 0 #000; overflow-wrap: anywhere; transition: opacity 0.8s; }
.chat-line.sys { color: #ffe9a0; font-style: italic; }
.chat-line.old { opacity: 0; }
.chat-line b { font-weight: 800; }
#cmdBox { display: none; width: 100%; padding: 8px 10px; font: inherit; color: #fff; background: rgba(0, 0, 0, 0.72); border: 2px solid rgba(255, 255, 255, 0.35); border-radius: 8px; outline: none; }
#cmdBox::placeholder { color: rgba(255, 255, 255, 0.5); }
#chat.open { pointer-events: auto; }
#chat.open #cmdBox { display: block; }
#chat.open #chatLog { overflow-y: auto; background: rgba(0, 0, 0, 0.3); border-radius: 8px; padding: 4px; }
#chat.open .chat-line.old { opacity: 1; }
.tc-chat { right: max(62px, calc(env(safe-area-inset-right) + 52px)); top: 8px; width: 44px; height: 40px; font-size: 18px; }
body.touch #clock { right: 116px; }
@media (max-height: 520px) { #chat { bottom: 62px; width: min(420px, 50vw); left: 150px; font-size: 13px; } #chatLog { max-height: 110px; } #chat.open { bottom: auto; top: 8px; left: 8px; width: calc(100vw - 16px); } }

/* ---------- lobby browser ---------- */
#lobbies, #codejoin, #invite { z-index: 1200; }
#namebox { z-index: 1250; }
.lob-panel { width: 440px; }
.screen > .panel .lob-random { width: 100%; font-size: 19px; padding: 14px; }
.lob-or { text-align: center; color: #93a0b4; font-size: 13px; margin: 10px 0 6px; }
.lob-list:empty { display: none; }
.lob-foot { margin-top: 10px; }
.lob-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 30vh; overflow-y: auto; padding: 2px; }
.lob-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: #12161d; border: 1px solid #2b3240; border-radius: 10px; }
.lob-row b { min-width: 54px; font-size: 17px; color: #9fe08a; }
.lob-row span { flex: 1; color: #c8d0dc; font-size: 14px; }
.lob-row.full { opacity: 0.55; }
.lob-seg { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.lob-seg span { color: #93a0b4; font-size: 13px; margin-right: 4px; }
.screen > .panel .lob-seg button { flex: 1; padding: 8px 6px; }
.screen > .panel .lob-seg button.on { background: #2b93f0; color: #fff; border-color: #2b93f0; }
.lob-row.other { opacity: 0.6; }
.lob-priv { margin-top: 14px; padding-top: 12px; border-top: 1px solid #2b3240; }
.lob-priv h3, .cj-h { margin: 0 0 4px; font-size: 16px; }
.lob-priv .sub { margin: 0 0 8px; }
.screen > .panel .lob-priv .lob-random { font-size: 16px; padding: 10px; margin-bottom: 8px; }
.priv-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; max-height: 24vh; overflow-y: auto; padding: 2px; }
.priv-list:empty { display: none; }
.priv-list .lob-row b { font-family: Consolas, monospace; letter-spacing: 1px; }
.screen > .panel .priv-list .lob-row button { padding: 7px 10px; }
#privCode, #cjCode { text-transform: uppercase; font-family: Consolas, monospace; letter-spacing: 2px; }
.inv-code { text-align: center; font: bold 40px Consolas, monospace; letter-spacing: 8px; color: #9fe08a; margin: 8px 0 4px; user-select: all; }
#invLink { flex: 1; font-size: 13px; }
.screen > .panel .lob-row button { padding: 7px 16px; }
#lobNo { flex: 1.4; }
.mm-root .mm-btns { flex-wrap: wrap; }

/* ---- skin editor ---- */
.sk-root { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(6, 8, 12, 0.78); backdrop-filter: blur(6px); font: 14px system-ui, sans-serif; color: #e8ecf2; outline: none; }
.sk-win { width: min(1260px, 97vw); height: min(820px, 95vh); display: flex; flex-direction: column; background: linear-gradient(#1a2030, #12161f); border: 1px solid #2e3648; border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65); overflow: hidden; }
.sk-head { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-bottom: 1px solid #262e3e; }
.sk-head h2 { margin: 0; font-size: 20px; letter-spacing: 3px; text-transform: uppercase; color: #bfe8a8; }
.sk-name { color: #93a0b4; font-weight: 600; }
.sk-tabs { margin-left: auto; display: flex; background: #0e1219; border-radius: 10px; padding: 3px; }
.sk-tabs button { background: none; border: 0; color: #93a0b4; padding: 7px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; }
.sk-tabs button.on { background: #2b93f0; color: #fff; }
.sk-body { flex: 1; display: grid; grid-template-columns: 236px 1fr 252px; min-height: 0; }
.sk-presets { border-right: 1px solid #262e3e; padding: 14px; overflow-y: auto; }
.sk-root h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 1.6px; color: #7f8ba0; }
.sk-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.sk-card { background: #161c28; border: 1px solid #283044; border-radius: 10px; padding: 6px 2px 5px; color: #cfd6e2; cursor: pointer; font: 600 11px system-ui, sans-serif; transition: transform 0.12s, border-color 0.12s; }
.sk-card:hover { border-color: #4a90e2; transform: translateY(-2px); }
.sk-card.on { border-color: #7ad04a; background: #1b2a1e; }
.sk-card canvas { display: block; margin: 0 auto 4px; max-width: 100%; height: auto; image-rendering: pixelated; }
.sk-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: radial-gradient(ellipse at 50% 38%, #2c3a58 0%, #161c2a 55%, #0f131c 100%); }
.sk-3d, .sk-flat { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.sk-flat { cursor: crosshair; image-rendering: pixelated; }
.sk-3d[hidden], .sk-flat[hidden], .sk-views[hidden] { display: none; }
.sk-views { position: absolute; left: 50%; bottom: 42px; transform: translateX(-50%); display: flex; gap: 4px; background: rgba(10, 13, 20, 0.72); padding: 4px; border-radius: 12px; border: 1px solid #262e3e; }
.sk-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: #8994a8; font-size: 12px; pointer-events: none; }
.sk-tools { border-left: 1px solid #262e3e; padding: 14px; overflow-y: auto; }
.sk-toolrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.sk-tool { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px; background: #161c28; border: 1px solid #283044; border-radius: 10px; color: #cfd6e2; cursor: pointer; font: 600 11px system-ui, sans-serif; }
.sk-tool i { font-style: normal; font-size: 19px; line-height: 1; }
.sk-tool.on { background: #2b93f0; border-color: #2b93f0; color: #fff; }
.sk-colrow { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sk-color { width: 58px; height: 42px; border: 1px solid #2e3648; border-radius: 10px; background: none; cursor: pointer; padding: 2px; }
.sk-hex { font: 600 14px Consolas, monospace; color: #cfd6e2; }
.sk-pal { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin-bottom: 14px; }
.sk-pal button { aspect-ratio: 1; border: 1px solid rgba(0, 0, 0, 0.6); border-radius: 5px; cursor: pointer; padding: 0; }
.sk-pal button.on { outline: 2px solid #fff; outline-offset: 1px; }
.sk-root .sk-check { display: flex; flex-direction: row; gap: 8px; align-items: center; color: #cfd6e2; margin: 0 0 10px; cursor: pointer; }
.sk-undo { display: flex; gap: 6px; }
.sk-undo button, .sk-views button, .sk-foot button { background: #1e2533; border: 1px solid #2e3648; color: #e8ecf2; border-radius: 8px; padding: 8px 12px; cursor: pointer; font: 700 13px system-ui, sans-serif; }
.sk-views button.on { background: #2b93f0; border-color: #2b93f0; }
.sk-undo button { flex: 1; }
.sk-note { color: #7f8ba0; font-size: 12px; line-height: 1.4; margin: 12px 0 0; }
.sk-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid #262e3e; }
.sk-foot .sk-done { background: linear-gradient(#6fd04a, #47a636); border-color: #3e8a30; color: #fff; padding: 10px 28px; }
.sk-root button:hover { filter: brightness(1.15); }
.sk-root, .sk-root * { scrollbar-width: thin; scrollbar-color: #3a4458 transparent; }
.sk-presets { overflow-x: hidden; }
.sk-check input { accent-color: #2b93f0; width: 16px; height: 16px; }
@media (max-width: 900px) { .sk-body { grid-template-columns: 1fr; grid-template-rows: 130px 1fr auto; } .sk-presets { border: 0; border-bottom: 1px solid #262e3e; } .sk-grid { grid-template-columns: repeat(6, 1fr); } .sk-tools { border: 0; border-top: 1px solid #262e3e; max-height: 34vh; } }

/* your name, and the Tab list of who is here */
.tp-name span { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btnName2 .my-name { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.lob-me { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; color: #93a0b4; font-size: 14px; }
.lob-me b { color: #fff; }
.screen > .panel .lob-me button { margin-left: auto; padding: 6px 10px; font-size: 13px; }
.screen > .panel #nmIn { flex: 1 1 auto; min-width: 0; font-size: 18px; }
.screen > .panel #nmDice { flex: 0 0 56px; padding: 8px 0; font-size: 20px; }
.screen > .panel .nm-err { font-size: 13px; }
.screen > .panel .nm-err.bad { color: #ff8a7a; }
#plist { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); min-width: 260px; max-width: 90vw; max-height: 70vh; overflow-y: auto; z-index: 40; background: rgba(10, 14, 22, 0.78); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 8px; padding: 8px 12px; font: 15px system-ui, sans-serif; color: #e8edf4; pointer-events: none; }
.pl-h { color: #93a0b4; font-size: 13px; margin-bottom: 6px; text-align: center; }
.pl-row { padding: 3px 0; border-top: 1px solid rgba(255, 255, 255, 0.06); }
.pl-row i { color: #93a0b4; font-style: normal; font-size: 13px; }
.pl-row span { color: #ffd75a; }

/* lobby lists and the small dialogs, in the blocky look */
.screen > .panel.lob-panel { width: 520px; }
.lob-row { background: rgba(0, 0, 0, 0.55); border: 2px solid #000; border-radius: 0; padding: 4px 4px 4px 10px; gap: 10px; }
.lob-row b { font: 20px var(--ui); color: #fff; min-width: 54px; }
.lob-row span { font: 20px var(--ui); color: #a0a0a0; }
.screen > .panel .lob-row button { height: 32px; padding: 0 12px; }
.lob-or, .lob-seg span, .lob-me { font: 20px var(--ui); color: #a0a0a0; }
.lob-priv { border-top: 2px solid rgba(255, 255, 255, 0.2); }
.lob-priv h3, .cj-h { font: 20px var(--ui); }
.screen > .panel .lob-seg button.on { background-color: #4a5a8a; border-color: #fff; color: #ffffa0; }
.screen > .panel .lob-me button { height: 32px; font-size: 20px; }
.inv-code { font: 60px var(--ui); letter-spacing: 6px; color: #55ff55; text-shadow: 4px 4px 0 #154015; }
#plist { font: 20px var(--ui); border-radius: 0; border: 2px solid #000; background: rgba(0, 0, 0, 0.6); }
.pl-h, .pl-row i { font-size: 20px; }
.screen > .panel input[type=number] { height: 40px; padding: 0 8px; font: 20px var(--ui); color: #e0e0e0; background: #000; border: 2px solid #a0a0a0; border-radius: 0; outline: none; -moz-appearance: textfield; }
.screen > .panel input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }
.screen > .panel input[type=number]:focus { border-color: #fff; }
.screen > .panel .lob-random, .screen > .panel .lob-priv .lob-random { width: 100%; height: 40px; padding: 0 12px; font-size: 20px; margin-bottom: 0; }
#privCode, #cjCode { font-family: var(--ui); letter-spacing: 2px; }
/* Options: sliders in two columns, the name and the value written on the slider itself */
.screen > .panel.settings-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; }
.settings-panel > h2, .settings-panel > p, .settings-panel > .checks, .settings-panel > button, .settings-panel > label:has(select) { grid-column: 1 / -1; }
.screen > .panel.settings-panel > label:has(input[type=range]) { position: relative; z-index: 0; display: block; height: 40px; line-height: 40px; text-align: center; white-space: nowrap; overflow: hidden; color: #fff; pointer-events: none; }
.settings-panel > label:has(input[type=range]) b { padding: 0; border-radius: 0; background: none; font-size: 20px; color: #fff; }
.screen > .panel.settings-panel > label:has(input[type=range]) input { position: absolute; inset: 0; width: 100%; z-index: -1; pointer-events: auto; }
.settings-panel > label:has(select) { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; }
.settings-panel > label:has(select) select { grid-column: auto; }
.screen > .panel.settings-panel > #rdHint { text-align: center; font-size: 20px; color: #a0a0a0; margin: 0; }

/* chat in the blocky look */
#chat { font: 20px/1.1 var(--ui); }
.chat-line { border-radius: 0; padding: 1px 4px; margin-top: 0; text-shadow: 2px 2px 0 #3f3f3f; background: rgba(0, 0, 0, 0.5); }
.chat-line b { font-weight: normal; }
.chat-line.sys { font-style: normal; color: #ffff55; }
#cmdBox { border-radius: 0; border: 2px solid #a0a0a0; background: rgba(0, 0, 0, 0.75); font: 20px var(--ui); }
#chat.open #chatLog { border-radius: 0; }
#btnName2 .my-name { max-width: 170px; }
#newworld > .panel { width: 560px; }
#newworld .row { flex-wrap: wrap; }

/* ---------- inventory, chests, shops: the light gray boxes with the pixel font and stone buttons ---------- */
.inv-panel, .craft-panel { font: 20px/1.2 var(--ui); border-radius: 4px; }
.inv-panel .inv-title, .craft-panel h3, #container h3, .inv-panel .sec-title { font: 20px/1.1 var(--ui); color: #404040; text-shadow: none; letter-spacing: 0; text-transform: none; font-weight: normal; }
.inv-panel .craft-hint, .inv-panel .inv-foot, .craft-panel .sub, .inv-panel .off-wrap, #container .sub, .mk-lead, .mk-sec { font: 10px/1.4 var(--ui); }
.craft-panel .check { font: 20px var(--ui); color: #404040; }
.craft-panel .check input { accent-color: #555; }
.stats { font: 20px var(--ui); }
.slot .n { font: 20px/1 var(--ui); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; right: 1px; bottom: 0; }
#tooltip { font: 20px/1.25 var(--ui); color: #fff; text-shadow: 2px 2px 0 #3f3f3f; background: rgba(16, 0, 16, 0.94); border: 2px solid #2d0a6a; box-shadow: 0 0 0 2px rgba(16, 0, 16, 0.94); padding: 4px 8px; border-radius: 0; }
#tooltip small { color: #a8a8a8; font-size: 20px; }
.craft-panel .recipe { border-radius: 0; }
.recipe .nm { font: 20px var(--ui); font-weight: normal; }
.recipe .ing, .recipe .st { font: 10px var(--ui); }
#inventory .panel button, .sk-root button:not([data-c]):not(.sk-card) {
  height: 32px; padding: 0 10px !important; font: 20px/1 var(--ui) !important; letter-spacing: 0 !important; color: #fff !important; text-shadow: 2px 2px 0 #3f3f3f !important;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Cpath fill='%23000' fill-opacity='.07' d='M2 2h2v2H2zM10 4h4v2h-4zM6 10h2v2H6zM12 12h2v2h-2zM0 14h2v2H0z'/%3E%3Cpath fill='%23fff' fill-opacity='.06' d='M6 0h2v2H6zM14 8h2v2h-2zM2 8h2v2H2zM8 14h4v2H8z'/%3E%3C/svg%3E") 0 0 / 16px 16px, #6f6f6f; border: 2px solid #000; border-radius: 0 !important; border: 2px solid #000 !important; border-radius: 0 !important;
  box-shadow: inset 2px 2px 0 #a6a6a6, inset -2px -4px 0 #4a4a4a !important; filter: none !important; transform: none !important; cursor: pointer; white-space: nowrap; }
#inventory .panel button:hover, .sk-root button:not([data-c]):not(.sk-card):hover { border-color: #fff !important; color: #ffffa0 !important; background-color: #7a7a7a !important; }
#inventory .panel button:disabled { background: #2c2c2c !important; color: #a0a0a0 !important; box-shadow: none !important; text-shadow: none !important; }
#inventory .panel button.on, .sk-root button.on:not([data-c]) { border-color: #fff !important; color: #ffff55 !important; background-color: #4e5a86 !important; }
#container .trade.no button { background: #2c2c2c !important; color: #a0a0a0 !important; box-shadow: none !important; }
#inventory .inv-panel .close-btn { position: absolute; top: 8px; right: 8px; width: 32px; padding: 0 !important; }
#container .mk-tabs { background: none; border: none; padding: 0; gap: 4px; }
#container .trade, #container .mk-empty, .mk-coins { border-radius: 0; font-family: var(--ui); }
#container .trade { font-size: 20px; }
.mk-coins { font-size: 20px; font-weight: normal; }
#palSearch, #container .mk-price { font: 20px var(--ui) !important; border-radius: 0 !important; height: 32px; }

/* ---------- the skin editor: a dark screen with stone buttons, like the other menus ---------- */
.sk-root { font: 20px/1.2 var(--ui); color: #fff; background: rgba(8, 8, 12, 0.6); text-shadow: 2px 2px 0 #3f3f3f; }
.sk-win { background: rgba(0, 0, 0, 0.62); border: 2px solid #000; border-radius: 0; box-shadow: inset 0 0 0 2px #4a4a4a, 0 20px 60px rgba(0, 0, 0, 0.6); }
.sk-head, .sk-foot { border-color: rgba(255, 255, 255, 0.22); }
.sk-head h2 { font: 20px var(--ui); letter-spacing: 0; text-transform: none; color: #fff; text-shadow: 2px 2px 0 #3f3f3f; }
.sk-name { color: #a0a0a0; font-weight: normal; }
.sk-tabs { background: none; padding: 0; gap: 4px; border-radius: 0; }
.sk-presets, .sk-tools { border-color: rgba(255, 255, 255, 0.18) !important; }
.sk-root h3 { font: 20px var(--ui); letter-spacing: 0; text-transform: none; color: #e0e0e0; }
.sk-card { background: #000; border: 2px solid #555; border-radius: 0; font: 10px var(--ui); color: #e0e0e0; transition: none; }
.sk-card:hover { border-color: #fff; transform: none; }
.sk-card.on { border-color: #fff; background: #1c1c1c; color: #ffff55; }
.sk-stage { background: radial-gradient(ellipse at 50% 38%, #4c4c4c 0%, #262626 60%, #141414 100%); }
.sk-views { background: rgba(0, 0, 0, 0.6); border: 2px solid #000; border-radius: 0; }
.sk-hint, .sk-note { font: 10px/1.5 var(--ui); color: #a0a0a0; }
.sk-root .sk-tool { height: auto !important; padding: 6px 2px !important; flex-direction: column; gap: 4px; font-size: 10px !important; }
.sk-tool i { font-size: 20px; }
.sk-color { border: 2px solid #a0a0a0; border-radius: 0; background: #000; }
.sk-hex { font: 20px var(--ui); color: #e0e0e0; }
.sk-root .sk-pal button { height: auto !important; aspect-ratio: 1; padding: 0 !important; border: 2px solid #000 !important; box-shadow: none !important; background-image: none !important; }
.sk-root .sk-pal button:hover { border-color: #fff !important; }
.sk-pal button.on { outline: 2px solid #fff; outline-offset: 0; }
.sk-root .sk-check { color: #e0e0e0; font: 20px var(--ui); }
.sk-check input { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin: 0; background: #000; border: 2px solid #a0a0a0; }
.sk-check input:checked { box-shadow: inset 0 0 0 3px #000, inset 0 0 0 10px #e0e0e0; }
.sk-root .sk-foot button { height: 40px; min-width: 160px; }
.sk-root .sk-foot .sk-done { color: #fff !important; }
.sk-root .sk-tool { min-width: 0; overflow: hidden; white-space: normal; line-height: 1.1 !important; }
.sk-card { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 1px 1px 0 #000; }
.sk-toolrow { gap: 4px; }
.sk-root .sk-toolrow button.sk-tool.sk-tool { height: auto !important; padding: 6px 2px !important; font: 10px/1.1 var(--ui) !important; text-shadow: 1px 1px 0 #3f3f3f !important; }
.sk-root .sk-toolrow button.sk-tool i { font: 20px/1 system-ui, sans-serif; }
/* the recipe book is never taller than the inventory next to it: it takes its height from it (contain: size), the list scrolls */
@media (min-width: 901px) {
  .inv-wrap { align-items: stretch; }
  .inv-wrap > .craft-panel { contain: size; max-height: none !important; align-self: stretch; }
  .inv-wrap > .craft-panel #recipes { flex: 1 1 0; min-height: 0; max-height: none; }
}
