* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #000; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: #eee; user-select: none; }
canvas#gl, canvas#ov { position: fixed; inset: 0; display: block; }
canvas#ov { pointer-events: none; }
.hidden { display: none !important; }
.muted { color: #9a9aaa; font-size: 12px; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#topleft { position: absolute; left: 14px; top: 12px; }
#healthbar { position: relative; width: 220px; height: 18px; background: #2a0a10cc; border: 2px solid #000; box-shadow: 0 0 0 1px #ffffff30; }
#healthfill { position: absolute; inset: 0; width: 100%; background: linear-gradient(#ff5a6a, #c8102e); transition: width .15s; }
#healthtxt { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 14px; font-weight: bold; text-shadow: 1px 1px #000; }
#biome { margin-top: 6px; font-size: 12px; color: #ddd; text-shadow: 1px 1px 0 #000; }
#compass { position: absolute; right: 12px; bottom: 12px; width: 180px; height: 180px; }
#minimap { position: absolute; right: 12px; top: 12px; width: 180px; height: 180px; border: 2px solid #000; box-shadow: 0 0 0 1px #ffffff40; image-rendering: pixelated; }
#insetLabel { position: absolute; font-size: 11px; color: #6ff; text-shadow: 1px 1px #000; }
#insetLabel span { color: #999; }
#hotbar { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 3px; padding: 4px; background: #00000080; border: 2px solid #000; }
#heldname { position: absolute; left: 50%; bottom: 68px; transform: translateX(-50%); font-size: 13px; text-shadow: 1px 1px 0 #000; transition: opacity .4s; }
.slot { width: 48px; height: 48px; position: relative; background: #3a3a46cc; border: 2px solid #1a1a22; box-shadow: inset 2px 2px #ffffff18, inset -2px -2px #00000040; }
.slot img { position: absolute; left: 6px; top: 6px; width: 32px; height: 32px; image-rendering: pixelated; pointer-events: none; }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 13px; font-weight: bold; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; pointer-events: none; }
.slot.sel { border-color: #fff; box-shadow: 0 0 0 2px #ffd84a; }
.slot .num { position: absolute; left: 3px; top: 1px; font-size: 10px; color: #aaa; pointer-events: none; }
#toasts { position: absolute; right: 16px; bottom: 210px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.toast { background: #000000a0; padding: 4px 8px; font-size: 13px; display: flex; align-items: center; gap: 6px; animation: toast 2.6s forwards; }
.toast img { width: 20px; height: 20px; image-rendering: pixelated; }
@keyframes toast { 0% { opacity: 0; transform: translateX(20px); } 8% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#hint { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: 640px; text-align: center; font-size: 15px; padding: 8px 14px; background: #000000a8; border: 1px solid #ffffff30; transition: opacity .6s; opacity: 0; }
#hint.show { opacity: 1; }
#debug { position: absolute; left: 14px; top: 64px; font-size: 11px; white-space: pre; color: #cfc; text-shadow: 1px 1px #000; }
#slicegauge { position: absolute; left: 14px; bottom: 14px; width: 80px; height: 80px; }
#slicegauge span { position: absolute; left: 0; right: 0; bottom: -2px; text-align: center; font-size: 11px; color: #ccc; text-shadow: 1px 1px #000; }

/* big map */
#bigmap { position: fixed; inset: 0; background: #000000b0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#bigmapc { width: min(80vh, 80vw); height: min(80vh, 80vw); image-rendering: pixelated; border: 3px solid #c89a40; }
#bigmap .cap { margin-top: 8px; color: #e8c060; font-size: 13px; }

/* panels */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); max-height: 96vh; max-width: 98vw; overflow: auto; background: #1c1c26f2; border: 3px solid #000; box-shadow: 0 0 0 2px #ffffff30, 0 20px 60px #000; padding: 14px 16px; }
.panel h3 { margin: 4px 0 8px; font-size: 14px; color: #ffd84a; }
.cols { display: flex; gap: 22px; }
.grid { display: grid; grid-template-columns: repeat(9, 48px); gap: 3px; }
.sep { height: 10px; }
.trashrow { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.slot.trash { display: flex; align-items: center; justify-content: center; color: #f66; font-size: 20px; cursor: pointer; }
#inv .slot { cursor: pointer; }
#inv .slot:hover { background: #50505ecc; }
.craftcol { width: 360px; }
#recipes { max-height: 470px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 4px; }
.recipe { display: flex; align-items: center; gap: 6px; padding: 4px 6px; background: #2a2a36; border: 1px solid #000; cursor: pointer; font-size: 12px; }
.recipe.no { opacity: 0.4; cursor: default; }
.recipe:not(.no):hover { background: #3a3a50; border-color: #ffd84a; }
.recipe img { width: 24px; height: 24px; image-rendering: pixelated; }
.recipe .out { display: flex; align-items: center; gap: 4px; min-width: 150px; color: #fff; }
.recipe .ing { display: flex; align-items: center; gap: 2px; color: #bbb; }
.recipe .ing img { width: 18px; height: 18px; }
.recipe .ing .have { color: #7f7; } .recipe .ing .miss { color: #f77; }
#cursorItem { position: fixed; width: 40px; height: 40px; pointer-events: none; z-index: 50; }
#cursorItem img { width: 32px; height: 32px; image-rendering: pixelated; }
#cursorItem span { position: absolute; right: 2px; bottom: 0; font-weight: bold; text-shadow: 1px 1px #000; }
#tooltip { position: fixed; z-index: 60; background: #0a0a12f0; border: 1px solid #6a5acd; padding: 6px 8px; font-size: 12px; max-width: 280px; pointer-events: none; }
#tooltip b { color: #ffd84a; }

/* screens */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
#menu { overflow-y: auto; justify-content: safe center; padding: 24px 12px 36px; background: radial-gradient(ellipse at 50% 40%, rgba(10,16,34,0.72) 0%, rgba(3,4,10,0.86) 80%); }
.screen.dim { background: #000000a0; }
.logo { text-align: center; }
.title { font-size: 76px; font-weight: 900; letter-spacing: 6px; color: #ffd84a; text-shadow: 6px 6px 0 #6a3fd1, 12px 12px 0 #00000080; }
.sub { margin-top: 8px; font-size: 16px; color: #8fd8ff; letter-spacing: 2px; }
.title2 { font-size: 30px; text-align: center; color: #ffd84a; margin-bottom: 4px; }
.title2.red { color: #ff5a6a; }
.menubox { display: flex; flex-direction: column; gap: 10px; min-width: 360px; background: #0c0c16c0; padding: 18px; border: 2px solid #ffffff20; }
.menubox .row { display: flex; gap: 8px; }
button { font: inherit; font-size: 16px; padding: 10px 14px; background: #3a3a50; color: #fff; border: 2px solid #000; box-shadow: inset 2px 2px #ffffff30, inset -2px -2px #00000060; cursor: pointer; }
button:hover { background: #4a4a6a; border-color: #ffd84a; }
input { font: inherit; padding: 8px; background: #111; color: #fff; border: 2px solid #444; flex: 1; }
.opt { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.opt input[type=range] { flex: 1; }
.opt input[type=checkbox] { flex: none; margin: 0; width: 16px; height: 16px; accent-color: #ffd84a; }
.howbox { max-width: 640px; background: #0c0c16e0; padding: 14px 18px; border: 2px solid #ffffff20; font-size: 13px; line-height: 1.5; }
.howbox table { border-collapse: collapse; margin: 8px 0; }
.howbox td { padding: 2px 10px 2px 0; }
.howbox td:first-child { color: #ffd84a; white-space: nowrap; }
.credit { position: absolute; bottom: 10px; font-size: 11px; color: #667; }
#errorbox { position: fixed; left: 10px; right: 10px; top: 10px; background: #400; color: #fcc; padding: 10px; white-space: pre-wrap; font-size: 12px; z-index: 999; }

select { font: inherit; padding: 6px; background: #111; color: #fff; border: 2px solid #444; flex: 1; }
.opt.big { align-items: flex-start; line-height: 1.35; }
.opt.big input { margin-top: 3px; }
#hotbar .slot { pointer-events: auto; cursor: pointer; }

/* educational split view */
body.split #hotbar, body.split #heldname, body.split #hint { left: 25%; }
body.split #hotbar { transform: translateX(-50%) scale(var(--hb, 1)); transform-origin: 50% 100%; }
body.split #heldname { bottom: calc(68px * var(--hb, 1)); }
body.split #hint { bottom: calc(96px * var(--hb, 1)); }
body.split #hint { max-width: 46vw; }
body.split #minimap { right: calc(50% + 12px); top: 40px; }
body.split #compass { right: auto; left: 12px; bottom: auto; top: 214px; width: 150px; height: 150px; } /* clear of the half-width hotbar */
body.split #toasts { right: calc(50% + 16px); }
body.split #topleft { top: 36px; }
#edumath { position: absolute; left: calc(50% + 12px); top: 40px; max-width: min(430px, 46vw); background: #05081ab8; border: 1px solid #9fe8ff40; padding: 8px 10px; font-size: 12px; line-height: 1.55; color: #dde; }
#edumath .mt { color: #9fe8ff; font-weight: bold; letter-spacing: 1px; margin-bottom: 2px; }
#edumath b { color: #fff; }
#edumath .dim { color: #889; }
#edumath .hov { margin-top: 4px; padding-top: 4px; border-top: 1px solid #ffffff20; }
#edumath .bar { display: inline-block; width: 80px; height: 7px; background: #ffffff20; vertical-align: middle; margin-left: 6px; }
#edumath .bar span { display: block; height: 100%; background: #ffd84a; }
#lesson { position: absolute; left: calc(50% + 12px); right: 12px; bottom: 12px; max-width: 560px; max-height: 46vh; overflow-y: auto; background: #0a0d1ef0; border: 2px solid #ffd84a; box-shadow: 0 8px 30px #000a; padding: 12px 14px; pointer-events: auto; font-size: 12.5px; line-height: 1.5; }
#lesson .ltitle { font-size: 16px; font-weight: bold; color: #ffd84a; margin-bottom: 4px; }
#lesson .lnum { font-size: 11px; color: #9fe8ff; font-weight: normal; margin-right: 6px; letter-spacing: 1px; }
#lesson .ltext b { color: #fff; }
#lesson .ltask { margin-top: 8px; color: #ffcf7a; }
#lesson .ltask.done { color: #8f8; }
#lesson .lprog { color: #aaa; margin-left: 6px; }
#lesson .lbtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
#lesson button { font-size: 13px; padding: 6px 12px; }
#lesson button.next.ready { background: #3a6a3a; border-color: #8f8; }

#helpcard { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: #0a0d1ef2; border: 2px solid #9fe8ff; padding: 14px 18px; font-size: 13px; z-index: 40; box-shadow: 0 10px 40px #000c; }
body.split #helpcard { left: 25%; }
#helpcard .ht { color: #9fe8ff; font-weight: bold; letter-spacing: 1px; margin-bottom: 6px; }
#helpcard td { padding: 2px 12px 2px 0; }
#helpcard td:first-child { color: #ffd84a; white-space: nowrap; }
#edumath { pointer-events: auto; cursor: pointer; }
#edumath.min > :not(.mt) { display: none; }
#edumath .mt::after { content: ' ▾'; color: #889; }
#edumath.min .mt::after { content: ' ▸ (click to expand)'; }
.toast .n { color: #ffd84a; font-weight: bold; }
.recipe.new { animation: pulse 1.2s 2; }
@keyframes pulse { 50% { border-color: #ffd84a; background: #4a4a2a; } }
.craftsep { font-size: 11px; color: #889; margin: 6px 0 2px; letter-spacing: 1px; }
