:root {
  --wood: #7a5230;
  --wood-dark: #4a3018;
  --wood-light: #a3743f;
  --slot-bg: #8a6234;
  --ink: #fff4e0;
  --accent: #ffd35c;
}
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif; color: var(--ink); }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.px { image-rendering: pixelated; image-rendering: crisp-edges; }

#loading { position: fixed; inset: 0; background: linear-gradient(#274a63, #0d1b28); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; z-index: 60; transition: opacity .4s; }
#loading.done { opacity: 0; pointer-events: none; }
.loading-title { font-size: 56px; font-weight: 900; letter-spacing: 6px; color: #ffe9b8; text-shadow: 0 4px 0 #7a4a1e, 0 8px 18px rgba(0,0,0,.5); }
.loading-sub { font-size: 15px; color: #9fc3d8; letter-spacing: 2px; }
.loading-track { width: 320px; height: 18px; border: 3px solid #4a3018; border-radius: 10px; background: #1d3140; overflow: hidden; }
#loading-bar { width: 0%; height: 100%; background: linear-gradient(#ffe08a, #e9a13b); transition: width .15s; }

.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; }
.dim { background: rgba(10, 14, 22, .55); backdrop-filter: blur(2px); }
.panel { background: linear-gradient(#8a6234, #6d4a26); border: 4px solid var(--wood-dark); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.18), inset 0 -4px 0 rgba(0,0,0,.25); padding: 22px 26px; }
.panel-title { text-align: center; font-weight: 900; font-size: 26px; letter-spacing: 2px; color: #ffe9b8; text-shadow: 0 3px 0 rgba(0,0,0,.35); margin-bottom: 14px; }

.btn { display: block; width: 100%; margin: 8px 0; padding: 12px 18px; font-family: inherit; font-size: 17px; font-weight: 800; letter-spacing: 1px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); background: linear-gradient(#67a84e, #4c7f39); border: 3px solid #2f4f23; border-radius: 10px; cursor: pointer; box-shadow: inset 0 2px 0 rgba(255,255,255,.25), inset 0 -3px 0 rgba(0,0,0,.25); transition: transform .05s, filter .1s; }
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(2px); box-shadow: inset 0 2px 6px rgba(0,0,0,.35); }
.btn.stone { background: linear-gradient(#8f8f97, #6e6e76); border-color: #4a4a50; }
.btn.red { background: linear-gradient(#d05a4a, #a23a2e); border-color: #6e231a; }
.btn.small { width: auto; display: inline-block; padding: 8px 14px; font-size: 14px; margin: 4px; }

#title-menu { flex-direction: column; gap: 0; }
.title-logo { text-align: center; margin-bottom: 20px; }
.title-logo .t1 { font-size: 74px; font-weight: 900; letter-spacing: 10px; color: #ffe9b8; text-shadow: 0 5px 0 #7a4a1e, 0 10px 24px rgba(0,0,0,.55); }
.title-logo .t2 { font-size: 16px; letter-spacing: 4px; color: #dff3ff; text-shadow: 0 2px 4px rgba(0,0,0,.5); margin-top: 6px; }
.title-menu-box { width: 340px; display: flex; flex-direction: column; }
.title-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.title-row input[type=text] { flex: 1; padding: 10px 12px; border-radius: 8px; border: 3px solid var(--wood-dark); background: #f4e8cf; color: #4a3018; font-weight: 700; font-size: 15px; outline: none; user-select: text; }
.title-row label { font-size: 13px; color: #ffe9b8; font-weight: 700; text-shadow: 0 1px 0 rgba(0,0,0,.4); white-space: nowrap; }
select { padding: 8px; border-radius: 8px; border: 3px solid var(--wood-dark); background: #f4e8cf; color: #4a3018; font-weight: 700; font-family: inherit; }
.title-foot { margin-top: 14px; font-size: 11px; color: rgba(255,244,224,.75); text-align: center; letter-spacing: 1px; }

.controls-table { width: 460px; font-size: 14px; line-height: 1.9; color: #fff4e0; }
.controls-table td:first-child { color: var(--accent); font-weight: 800; padding-right: 16px; white-space: nowrap; }
.controls-table td:last-child { color: #f3e6cd; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; transform: translate(-50%, -50%); mix-blend-mode: difference; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: #fff; }
#crosshair::before { left: 50%; top: 0; width: 2px; height: 100%; transform: translateX(-50%); }
#crosshair::after { top: 50%; left: 0; height: 2px; width: 100%; transform: translateY(-50%); }

#hotbar { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; padding: 5px; background: rgba(20, 14, 8, .55); border: 3px solid rgba(74, 48, 24, .9); border-radius: 10px; }
.hb-slot { width: 52px; height: 52px; border-radius: 6px; background: rgba(0,0,0,.28); box-shadow: inset 0 0 0 2px rgba(255,255,255,.09); position: relative; }
.hb-slot.sel { box-shadow: inset 0 0 0 3px #ffe08a, 0 0 8px rgba(255,224,138,.45); background: rgba(255,255,255,.08); }

.slot-icon { position: absolute; inset: 5px; background-size: contain; background-repeat: no-repeat; background-position: center; image-rendering: pixelated; }
.slot-count { position: absolute; right: 3px; bottom: 1px; font-size: 14px; font-weight: 900; color: #fff; text-shadow: 1px 1px 0 #000, 0 0 3px #000; }
.dur-bar { position: absolute; left: 6px; right: 6px; bottom: 4px; height: 3px; background: rgba(0,0,0,.55); border-radius: 2px; }
.dur-fill { height: 100%; border-radius: 2px; background: linear-gradient(#7dff6a, #2ea82e); }

#stats { position: absolute; bottom: 76px; left: 50%; transform: translateX(-50%); width: 500px; display: flex; justify-content: space-between; }
.stat-row { display: flex; gap: 1px; }
.stat-row .ic { width: 18px; height: 18px; background-size: contain; image-rendering: pixelated; }
#bubbles-row { position: absolute; bottom: 98px; left: 50%; transform: translateX(-50%); width: 500px; display: flex; justify-content: flex-end; gap: 1px; }
#bubbles-row .ic { width: 18px; height: 18px; background-size: contain; image-rendering: pixelated; }

#itemname { position: absolute; bottom: 132px; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 16px; color: #fff; text-shadow: 0 2px 3px rgba(0,0,0,.8); opacity: 0; transition: opacity .5s; }
#itemname.show { opacity: 1; transition: none; }

#debug { position: absolute; top: 10px; left: 10px; font: 13px/1.5 ui-monospace, Menlo, monospace; color: #eaf6ff; text-shadow: 1px 1px 0 rgba(0,0,0,.9); background: rgba(0,0,0,.3); padding: 6px 10px; border-radius: 8px; white-space: pre; }
#toast { position: absolute; top: 18%; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 18px; color: #fff; text-shadow: 0 2px 4px #000; opacity: 0; transition: opacity .4s; }
#toast.show { opacity: 1; transition: none; }

#vignette { position: absolute; inset: 0; pointer-events: none; }
#water-overlay { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(18,64,140,.28), rgba(10,40,100,.55)); opacity: 0; transition: opacity .15s; }
#hurt-overlay { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(190,20,20,0) 55%, rgba(190,20,20,.5)); opacity: 0; }

#screen-layer { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; background: rgba(8, 10, 16, .45); }
.window { background: linear-gradient(#8a6234, #6d4a26); border: 4px solid var(--wood-dark); border-radius: 12px; box-shadow: 0 14px 50px rgba(0,0,0,.65), inset 0 2px 0 rgba(255,255,255,.15); padding: 16px 18px; }
.window h3 { text-align: center; font-size: 15px; letter-spacing: 2px; color: #ffe9b8; text-shadow: 0 2px 0 rgba(0,0,0,.35); margin-bottom: 10px; font-weight: 900; }

.grid { display: grid; gap: 4px; }
.slot { width: 48px; height: 48px; border-radius: 6px; background: rgba(0,0,0,.3); box-shadow: inset 0 0 0 2px rgba(255,255,255,.1), inset 0 2px 4px rgba(0,0,0,.35); position: relative; cursor: pointer; }
.slot:hover::after { content: ""; position: absolute; inset: 0; border-radius: 6px; background: rgba(255,255,255,.14); }
.slot.armor { background: rgba(40,80,120,.35); }
.slot.result { width: 56px; height: 56px; box-shadow: inset 0 0 0 3px rgba(255,224,138,.35); }

.inv-layout { display: flex; gap: 22px; align-items: center; }
.inv-main { display: grid; grid-template-columns: repeat(9, 48px); gap: 4px; margin-top: 12px; }
.inv-hot { display: grid; grid-template-columns: repeat(9, 48px); gap: 4px; margin-top: 10px; }
.craft-area { display: flex; align-items: center; gap: 14px; }
.arrow { width: 40px; height: 24px; background: linear-gradient(#ffe9b8, #d8b26a); clip-path: polygon(0 30%, 60% 30%, 60% 0, 100% 50%, 60% 100%, 60% 70%, 0 70%); opacity: .85; }
.armor-col { display: flex; flex-direction: column; gap: 6px; }

.furnace-layout { display: flex; align-items: center; gap: 20px; }
.furnace-mid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.flame { width: 28px; height: 28px; background-size: contain; image-rendering: pixelated; }
.burn-arrow { width: 60px; height: 14px; background: rgba(0,0,0,.35); border-radius: 7px; overflow: hidden; }
.burn-arrow > div { height: 100%; background: linear-gradient(90deg, #ffd35c, #ff9a3c); width: 0%; }

#cursor-item { position: fixed; z-index: 40; width: 44px; height: 44px; pointer-events: none; background-size: contain; background-repeat: no-repeat; image-rendering: pixelated; display: none; }
#cursor-item .slot-count { right: 0; bottom: 0; font-size: 13px; }
#tooltip { position: fixed; z-index: 45; padding: 6px 10px; background: rgba(16, 10, 30, .92); border: 2px solid #5a4a7a; border-radius: 6px; font-size: 13px; font-weight: 700; color: #fff; pointer-events: none; display: none; white-space: pre; }
#tooltip .sub { color: #9fd0ff; font-weight: 400; }

#death-menu { background: rgba(120, 10, 10, .45); }
#death-menu .panel { background: linear-gradient(#7e2f24, #571e15); border-color: #3a100a; }

.heart-flash { animation: heartpop .3s; }
@keyframes heartpop { 50% { transform: scale(1.3); } }
