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

:root {
  --panel: #c6c6c6;
  --panel-dark: #8b8b8b;
  --panel-light: #ffffff;
  --slot: #8b8b8b;
}

html, body { width: 100%; height: 100%; overflow: hidden; background: #000; }
body { font-family: 'VT323', monospace; font-size: 20px; color: #fff; }

#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }

.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

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

#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -52%);
  font-size: 26px; color: rgba(255,255,255,0.85); text-shadow: 0 0 3px #000;
  mix-blend-mode: difference;
}

#hudBottom {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}

#statusRow { display: flex; justify-content: space-between; width: 424px; }
#hearts, #food, #bubbles { display: flex; gap: 1px; }
#food { flex-direction: row-reverse; }
#bubbles { width: 424px; justify-content: flex-start; min-height: 20px; }
.heart, .bubble, .drum { font-size: 20px; text-shadow: 1px 1px 0 #000; line-height: 1; }
.heart { color: #e8271f; }
.heart.half { opacity: 0.9; }
.heart.empty { color: #3a3a3a; }
.drum { filter: saturate(1.1); }
.drum.half { opacity: 0.75; }
.drum.empty { filter: grayscale(1) brightness(0.4); opacity: 0.85; }
.bubble { color: #6fb8ff; }

#hotbar { display: flex; gap: 0; background: rgba(0,0,0,0.35); padding: 2px; border: 2px solid rgba(0,0,0,0.6); }
.hotbar-slot { width: 44px; height: 44px; }
.hotbar-slot.selected { outline: 3px solid #fff; outline-offset: -1px; z-index: 2; }

#itemTip {
  position: absolute; bottom: 78px; left: 50%; transform: translateX(-50%);
  font-size: 22px; text-shadow: 2px 2px 0 #000; opacity: 0; transition: opacity .4s;
  pointer-events: none;
}

#debug {
  position: absolute; top: 8px; left: 8px; font-size: 18px; line-height: 1.25;
  background: rgba(0,0,0,0.45); padding: 6px 10px; white-space: pre;
}

#waterOverlay { position: absolute; inset: 0; background: rgba(20, 60, 160, 0.28); }
#hurtOverlay { position: absolute; inset: 0; background: rgba(200, 0, 0, 0.35); opacity: 0; transition: opacity .12s; }

/* ---------- slots ---------- */
.slot {
  width: 44px; height: 44px; position: relative;
  background: var(--slot);
  border-top: 2px solid #545454; border-left: 2px solid #545454;
  border-bottom: 2px solid #fefefe; border-right: 2px solid #fefefe;
  image-rendering: pixelated;
  pointer-events: auto;
}
.slot img { width: 100%; height: 100%; image-rendering: pixelated; pointer-events: none; }
.slot .count {
  position: absolute; right: 2px; bottom: 0; font-size: 19px; color: #fff;
  text-shadow: 2px 2px 0 #3f3f3f; pointer-events: none;
}
.slot .durbar {
  position: absolute; left: 4px; right: 4px; bottom: 4px; height: 3px; background: #2b2b2b;
}
.slot .durbar div { height: 100%; }
.slot.result { width: 52px; height: 52px; }

/* ---------- modal ---------- */
#modal { background: rgba(0,0,0,0.5); }
#modalPanel {
  background: var(--panel);
  border-top: 3px solid var(--panel-light); border-left: 3px solid var(--panel-light);
  border-bottom: 3px solid #555; border-right: 3px solid #555;
  padding: 14px 18px; color: #3f3f3f; min-width: 460px;
}
#modalPanel h2 { font-size: 24px; margin-bottom: 8px; font-weight: normal; }
#modalPanel .hint { font-size: 16px; color: #5a5a5a; margin-top: 8px; }

.inv-grid { display: grid; grid-template-columns: repeat(9, 44px); gap: 2px; margin-top: 10px; }
.inv-grid.hotrow { margin-top: 12px; }
.creative-grid { max-height: 320px; overflow-y: auto; pointer-events: auto; }

.craft-area { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.craft-grid { display: grid; gap: 2px; }
.craft-grid.w2 { grid-template-columns: repeat(2, 44px); }
.craft-grid.w3 { grid-template-columns: repeat(3, 44px); }
.arrow { font-size: 30px; color: #5a5a5a; }

.furnace-area { display: flex; align-items: center; gap: 16px; margin-bottom: 6px; }
.furnace-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.flame { width: 22px; height: 22px; background: #3f3f3f; position: relative; display: flex; align-items: flex-end; }
.flame-fill { width: 100%; background: linear-gradient(#ffc14d, #e25822); height: 0%; }
.smelt-progress { width: 70px; height: 14px; background: #3f3f3f; }
.smelt-fill { height: 100%; width: 0%; background: #fff; }

#cursorStack {
  position: fixed; z-index: 60; width: 40px; height: 40px; pointer-events: none;
  transform: translate(-50%, -50%);
}
#cursorStack img { width: 100%; height: 100%; image-rendering: pixelated; }
#cursorStack .count { position: absolute; right: -2px; bottom: -4px; font-size: 19px; text-shadow: 2px 2px 0 #3f3f3f; }

/* ---------- title ---------- */
#titleScreen { background: #333 center/128px repeat; flex-direction: column; }
.title-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 20px; }

.logo {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(28px, 6vw, 62px);
  color: #e8e8e8;
  text-shadow: 4px 4px 0 #2c2c2c, 8px 8px 0 rgba(0,0,0,0.4);
  letter-spacing: 2px;
}
.logo span { color: #5ad838; }
.banner {
  width: min(880px, 92vw); height: auto; display: block;
  image-rendering: auto; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45));
  border-radius: 6px;
}

.splash {
  color: #ffff55; font-size: 24px; transform: rotate(-6deg);
  text-shadow: 2px 2px 0 #3f3f00;
  animation: splashPulse 0.9s infinite alternate ease-in-out;
}
@keyframes splashPulse { from { scale: 0.95; } to { scale: 1.05; } }

.menu { display: flex; flex-direction: column; gap: 10px; width: min(420px, 86vw); }
.menu .row { display: flex; gap: 10px; }
.menu .row .mc-btn { flex: 1; }

.mc-btn {
  font-family: 'VT323', monospace; font-size: 24px; color: #fff;
  padding: 10px 18px; cursor: pointer;
  background: #6f6f6f;
  border-top: 3px solid #a8a8a8; border-left: 3px solid #a8a8a8;
  border-bottom: 3px solid #3c3c3c; border-right: 3px solid #3c3c3c;
  text-shadow: 2px 2px 0 #3f3f3f;
  width: 100%;
}
.mc-btn:hover { background: #7e8cbf; }
.mc-btn:active { border-top-color: #3c3c3c; border-left-color: #3c3c3c; border-bottom-color: #a8a8a8; border-right-color: #a8a8a8; }

.mc-input {
  font-family: 'VT323', monospace; font-size: 22px; color: #e0e0e0;
  background: #000; border: 2px solid #a8a8a8; padding: 9px 12px; outline: none;
  width: 100%;
}

#tokenPanel {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(0, 0, 0, 0.5); border: 2px solid #5ad838;
  padding: 12px 22px; max-width: min(520px, 90vw); text-align: center;
}
#tokenReward { color: #eaeaea; font-size: 19px; line-height: 1.35; }
#tokenReward, #distributeRow { text-shadow: 1px 1px 0 #000; }
#distributeRow { font-size: 22px; color: #ffff77; }
#distributeTimer { color: #5ad838; font-weight: bold; letter-spacing: 1px; }
#tokenCA {
  font-family: 'VT323', monospace; font-size: 18px; color: #eaeaea;
  background: #000; border: 2px solid #6a6a6a; padding: 6px 12px; cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#tokenCA:hover { border-color: #5ad838; color: #5ad838; }
#tokenX { color: #7ec8ff; font-size: 18px; text-decoration: none; }
#tokenX:hover { text-decoration: underline; }

.controls-hint {
  max-width: 640px; text-align: center; color: #cfcfcf; font-size: 18px; line-height: 1.5;
  text-shadow: 1px 1px 0 #000;
}
.controls-hint b { color: #ffff55; }
.footer { color: #9a9a9a; font-size: 16px; text-shadow: 1px 1px 0 #000; }

/* ---------- pause / death ---------- */
.panel {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  min-width: 320px; padding: 26px 30px;
  background: rgba(20,20,20,0.85);
  border: 2px solid #555;
}
.panel h2 { font-size: 30px; font-weight: normal; text-shadow: 2px 2px 0 #000; }
.panel .hint { font-size: 16px; color: #9a9a9a; min-height: 18px; }
#deathScreen { background: rgba(120, 0, 0, 0.45); }
.panel.death h2 { color: #ff6b5e; }
