* { 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; }

/* ========== HOODCRAFT title screen ========== */
:root {
  --lime: #d0e50d;      /* HoodCraft logo background — the brand theme colour */
  --clay: #d0e50d;      /* theme accent (var name kept as --clay for compatibility) */
  --clay-deep: #aac400; /* mid lime */
  --clay-dark: #5f7000; /* dark green — shadows, borders, text on lime */
  --cream: #f4efe6;
  --cream-soft: #efe7d8;
  --ink: #241f1a;
  --grass: #7cc04f;
  --grass-dk: #5fa138;
}

/* Live game renders on #game behind the title — keep a readable scrim only. */
#titleScreen {
  flex-direction: column; overflow: hidden;
  background:
    linear-gradient(rgba(18,14,10,0.30) 0%, rgba(18,14,10,0.48) 55%, rgba(18,14,10,0.66) 100%),
    radial-gradient(ellipse at center, rgba(18,14,10,0) 30%, rgba(18,14,10,0.35) 100%);
}

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-14px) rotate(1deg); } }

.title-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 22px;
}

/* ---- brand / logo ---- */
.cw-brand { display: flex; align-items: center; gap: 10px; }
.cw-brandlogo {
  width: clamp(96px, 15vw, 156px); height: auto; flex: none;
  border-radius: 18px; border: 4px solid var(--clay-dark);
  box-shadow: 0 6px 14px rgba(0,0,0,0.45);
  animation: bob 6s ease-in-out infinite;
}

.logo {
  font-family: 'Press Start 2P', monospace;
  display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.logo-sup {
  font-size: clamp(11px, 1.7vw, 18px); letter-spacing: clamp(6px, 1.4vw, 14px);
  color: var(--cream); margin: 0 0 10px 8px;
  text-shadow: 2px 2px 0 var(--clay-dark);
}
.logo-main {
  font-size: clamp(30px, 6.2vw, 66px); color: var(--clay);
  text-shadow: 3px 3px 0 var(--clay-dark), 6px 6px 0 rgba(60,30,15,0.35);
  letter-spacing: 2px;
}

.splash {
  color: var(--clay-dark); font-weight: bold; font-size: 22px; transform: rotate(-5deg);
  background: var(--clay); padding: 4px 12px; border-radius: 4px;
  box-shadow: 2px 2px 0 var(--clay-dark);
  animation: splashPulse 0.95s infinite alternate ease-in-out;
}
@keyframes splashPulse { from { scale: 0.96; } 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: var(--ink);
  padding: 11px 18px; cursor: pointer; width: 100%;
  background: var(--cream);
  border-top: 3px solid #fffdf7; border-left: 3px solid #fffdf7;
  border-bottom: 3px solid #c3b79f; border-right: 3px solid #c3b79f;
  text-shadow: none; transition: background .12s, transform .05s;
}
.mc-btn:hover { background: #fff9ee; }
.mc-btn:active { transform: translateY(1px);
  border-top-color: #c3b79f; border-left-color: #c3b79f; border-bottom-color: #fffdf7; border-right-color: #fffdf7; }

.mc-btn.primary {
  color: var(--clay-dark); font-weight: bold; background: var(--clay);
  border-top-color: #e9f76a; border-left-color: #e9f76a;
  border-bottom-color: var(--clay-dark); border-right-color: var(--clay-dark);
  text-shadow: none;
}
.mc-btn.primary:hover { background: #dcef3a; }
.mc-btn.primary:active {
  border-top-color: var(--clay-dark); border-left-color: var(--clay-dark);
  border-bottom-color: #e9f76a; border-right-color: #e9f76a;
}

.mc-btn.ghost {
  background: transparent; color: var(--cream);
  border-top-color: rgba(255,255,255,0.35); border-left-color: rgba(255,255,255,0.35);
  border-bottom-color: rgba(0,0,0,0.4); border-right-color: rgba(0,0,0,0.4);
  text-decoration: none; display: block; text-align: center;
}
.mc-btn.ghost:hover { background: rgba(255,255,255,0.08); }

.mc-btn:disabled {
  cursor: not-allowed; opacity: 0.45; filter: grayscale(0.3);
}
.mc-btn:disabled:hover { background: var(--cream); }
.mc-btn.primary:disabled:hover { background: var(--clay); }

.mc-input {
  font-family: 'VT323', monospace; font-size: 22px; color: var(--ink);
  background: #fffdf7; border: 2px solid #c3b79f; padding: 9px 12px; outline: none;
  width: 100%;
}
.mc-input::placeholder { color: #9a8f7a; }
.mc-input:focus { border-color: var(--clay); }

.controls-hint {
  max-width: 640px; text-align: center; color: #e6ddcb; font-size: 18px; line-height: 1.5;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.6);
}
.controls-hint b { color: var(--clay); }
.footer { color: #cdbfa6; font-size: 16px; text-shadow: 1px 1px 0 rgba(0,0,0,0.6); }
.footer-domain { color: var(--clay); font-weight: normal; letter-spacing: 0.5px; }
.footer a { color: var(--clay); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- token gate (inline bar above the play buttons) ---------- */
.gate-bar {
  width: min(420px, 86vw); background: rgba(27, 23, 18, 0.78); border: 2px solid var(--clay-dark);
  border-radius: 10px; padding: 14px 18px; text-align: center; backdrop-filter: blur(2px);
}
.gate-msg { color: #e6ddcb; font-size: 15px; line-height: 1.4; margin-bottom: 8px; }
.gate-status { min-height: 20px; font-size: 13px; font-weight: bold; margin-bottom: 8px; color: #b3a68f; }
.gate-status.ok { color: #7fce8a; }
.gate-status.err { color: #e77f6a; }
.gate-bar .mc-btn { margin-top: 6px; }

/* ---------- 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; }
