﻿  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { width: 100%; height: 100%; overflow: hidden; background: #87ceeb; font-family: 'Courier New', monospace; color: #fff; user-select: none; }
  canvas { display: block; }

  #crosshair {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: 20px; height: 20px; pointer-events: none; z-index: 10;
  }
  #crosshair::before, #crosshair::after {
    content: ""; position: absolute; background: #fff; mix-blend-mode: difference;
  }
  #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: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 4px; padding: 4px; background: rgba(0,0,0,0.45);
    border: 2px solid #222; border-radius: 4px; z-index: 10;
  }
  .slot {
    width: 52px; height: 52px; background: rgba(60,60,60,0.7);
    border: 2px solid #555; display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: bold; text-align: center; line-height: 1.1;
    text-shadow: 1px 1px 0 #000; position: relative;
  }
  .slot.active { border-color: #fff; background: rgba(120,120,120,0.7); }
  .slot.toolSlot { border-color: #6a5a3a; }
  .slot.toolSlot.active { border-color: #ffd700; }
  #hotbarPage {
    position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
    font-size: 11px; color: #ccc; background: rgba(0,0,0,0.45);
    padding: 3px 10px; border-radius: 3px; z-index: 10;
  }
  .slot .num { position: absolute; top: 1px; left: 3px; font-size: 10px; opacity: 0.7; }
  .slot .count {
    position: absolute; bottom: 1px; right: 3px; font-size: 14px; font-weight: bold;
    color: #fff; text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000;
  }
  .slot .swatch { width: 32px; height: 32px; border: 1px solid #000; box-shadow: inset -4px -4px 0 rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; }
  .slot.empty .swatch { visibility: hidden; }
  .slot .swatch svg { width: 28px; height: 28px; }

  /* Crafting UI */
  #craftUI {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 200; display: none; align-items: center; justify-content: center;
    cursor: default;
  }
  #craftUI .panel {
    background: #2a2a36; border: 2px solid #4a4a5a; border-radius: 8px;
    padding: 24px; min-width: 480px; max-width: 92vw; color: #fff;
  }
  #craftUI h2 { font-size: 20px; text-align: center; letter-spacing: 1px; }
  #craftUI h3 { margin: 16px 0 8px; font-size: 13px; color: #bbb; font-weight: normal; }
  #craftUI .craftRow {
    display: flex; align-items: center; justify-content: center;
    gap: 18px; margin: 18px 0;
  }
  #craftGrid { display: grid; gap: 4px; }
  #craftGrid.grid2 { grid-template-columns: repeat(2, 58px); grid-template-rows: repeat(2, 58px); }
  #craftGrid.grid3 { grid-template-columns: repeat(3, 58px); grid-template-rows: repeat(3, 58px); }
  .cellSlot {
    width: 58px; height: 58px; background: #1a1a22; border: 2px solid #444;
    display: flex; align-items: center; justify-content: center;
    position: relative; cursor: pointer;
  }
  .cellSlot:hover { border-color: #888; }
  .cellSlot .swatch { width: 38px; height: 38px; }
  .cellSlot .swatch svg { width: 36px; height: 36px; }
  .resultSlot { background: #2d3a2d; border-color: #4d6b4a; }
  .resultSlot .resCount {
    position: absolute; bottom: 1px; right: 4px; font-size: 14px; font-weight: bold;
    color: #ffd700; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  }
  .arrow { font-size: 32px; opacity: 0.6; }
  #invGrid {
    display: flex; flex-wrap: wrap; gap: 6px;
    background: #1a1a22; padding: 10px; border-radius: 4px; min-height: 56px;
    max-height: 220px; overflow-y: auto;
  }
  .invItem {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px 4px 4px; background: #33333e; border: 2px solid #444;
    cursor: pointer; font-size: 12px;
  }
  .invItem:hover { border-color: #888; }
  .invItem.held { border-color: #ffd700; background: #3a3a26; }
  .invItem .swatch { width: 26px; height: 26px; border: 1px solid #000; box-shadow: inset -2px -2px 0 rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; }
  .invItem .swatch svg { width: 22px; height: 22px; }
  .invName { color: #ddd; }
  .invCount { color: #ffd700; font-weight: bold; margin-left: 4px; }
  #craftUI .hint { font-size: 11px; color: #888; margin-top: 14px; text-align: center; }
  #craftUI .emptyInv { color: #666; font-style: italic; padding: 8px; }

  #heldItem {
    position: fixed; pointer-events: none; z-index: 300;
    display: none; transform: translate(-50%, -50%);
    width: 38px; height: 38px;
  }
  #heldItem .swatch { width: 38px; height: 38px; border: 1px solid #000; box-shadow: inset -3px -3px 0 rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; }
  #heldItem .swatch svg { width: 34px; height: 34px; }

  #hud {
    position: fixed; top: 12px; left: 12px; z-index: 10;
    background: rgba(0,0,0,0.45); padding: 8px 12px; border-radius: 4px;
    font-size: 13px; line-height: 1.6;
  }
  #hud b { color: #ffd700; }
  #hud b#gameModeInfo.creative { color: #8aeaea; }

  /* Health + hunger bars sit just above the hotbar */
  #status {
    position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 4px; z-index: 11;
    pointer-events: none;
  }
  .statRow { display: flex; gap: 2px; justify-content: center; }
  .heart, .drumstick {
    width: 18px; height: 18px; display: inline-block;
    background-position: center; background-repeat: no-repeat;
  }
  .heart {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 21s-7-4.5-9.5-9C.5 8 3 4 6.5 4c2 0 3.5 1 5.5 3 2-2 3.5-3 5.5-3 3.5 0 6 4 4 8-2.5 4.5-9.5 9-9.5 9z' fill='%23d83a3a' stroke='%237a141a' stroke-width='2'/></svg>");
  }
  .heart.half { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><defs><linearGradient id='g'><stop offset='50%25' stop-color='%23d83a3a'/><stop offset='50%25' stop-color='%23333'/></linearGradient></defs><path d='M12 21s-7-4.5-9.5-9C.5 8 3 4 6.5 4c2 0 3.5 1 5.5 3 2-2 3.5-3 5.5-3 3.5 0 6 4 4 8-2.5 4.5-9.5 9-9.5 9z' fill='url(%23g)' stroke='%237a141a' stroke-width='2'/></svg>"); }
  .heart.empty { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 21s-7-4.5-9.5-9C.5 8 3 4 6.5 4c2 0 3.5 1 5.5 3 2-2 3.5-3 5.5-3 3.5 0 6 4 4 8-2.5 4.5-9.5 9-9.5 9z' fill='%23333' stroke='%23000' stroke-width='2'/></svg>"); }
  .drumstick {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 20 L9 15 M9 15 C 7 13 9 9 13 9 C 17 9 21 13 19 17 C 17 21 13 19 11 17 Z' fill='%23a06a3a' stroke='%23502a14' stroke-width='2' stroke-linejoin='round'/></svg>");
  }
  .drumstick.half { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 20 L9 15 M9 15 C 7 13 9 9 13 9 C 17 9 21 13 19 17 C 17 21 13 19 11 17 Z' fill='%23805030' stroke='%23502a14' stroke-width='2' stroke-linejoin='round'/></svg>"); }
  .drumstick.empty { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M4 20 L9 15 M9 15 C 7 13 9 9 13 9 C 17 9 21 13 19 17 C 17 21 13 19 11 17 Z' fill='%23333' stroke='%23000' stroke-width='2' stroke-linejoin='round'/></svg>"); }

  /* Creative inventory grid */
  #creativeGrid {
    display: grid; grid-template-columns: repeat(10, 50px); gap: 4px;
    background: #1a1a22; padding: 10px; border-radius: 4px;
    max-height: 360px; overflow-y: auto;
  }
  #creativeGrid .cellSlot { cursor: pointer; }
  #creativeGrid .cellSlot:hover { border-color: #ffd700; background: #2a2a18; }

  #damageFlash {
    position: fixed; inset: 0; pointer-events: none; z-index: 5;
    background: radial-gradient(closest-side, transparent 50%, rgba(160,0,0,0.55));
    opacity: 0; transition: opacity 0.3s;
  }
  #damageFlash.show { opacity: 1; }

  /* Armor slots — left-center, stacked vertically */
  #armor {
    position: fixed; top: 50%; left: 14px; transform: translateY(-50%);
    display: flex; flex-direction: column; gap: 4px; z-index: 11;
    pointer-events: none;
  }
  .armorSlot {
    width: 40px; height: 40px; background: rgba(0,0,0,0.45);
    border: 2px solid #555; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
  }
  .armorSlot.empty { opacity: 0.4; }
  .armorSlot svg { width: 30px; height: 30px; }

  /* Admin panel — hidden by default; toggled by JS once the secret unlock is complete */
  #adminPanel {
    position: fixed; top: 60px; right: 14px; z-index: 50;
    background: rgba(20,0,30,0.92); border: 2px solid #a040ff;
    padding: 12px 14px; border-radius: 6px; color: #fff;
    display: none; min-width: 180px;
    box-shadow: 0 6px 24px rgba(160,64,255,0.4);
  }
  #adminPanel.open { display: block; }
  #adminPanel h3 { font-size: 16px; color: #d09aff; letter-spacing: 2px; margin-bottom: 6px; }
  #adminPanel p { font-size: 11px; color: #c0a0d0; margin-bottom: 8px; }
  #adminPanel button {
    display: block; width: 100%; margin: 3px 0;
    padding: 6px 10px; background: #46264a; border: 1px solid #a040ff;
    color: #fff; font-family: inherit; font-size: 13px; cursor: pointer;
    border-radius: 3px;
  }
  #adminPanel button:hover { background: #5c2f60; }
  #adminPanel #adminClose { background: #2a1030; margin-top: 8px; }

  #adminToast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.78); border: 1px solid #888; color: #fff;
    padding: 10px 18px; border-radius: 4px; font-size: 14px;
    z-index: 200; opacity: 0; transition: opacity 0.3s;
    pointer-events: none;
  }
  #adminToast.show { opacity: 1; }

  /* Villager trade UI */
  #tradeUI {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    z-index: 210; display: none; align-items: center; justify-content: center;
  }
  #tradeUI.open { display: flex; }
  #tradeUI .panel {
    background: #2a2a36; border: 2px solid #4a4a5a; padding: 24px;
    border-radius: 8px; min-width: 440px; max-width: 92vw; color: #fff;
  }
  #tradeUI h2 { font-size: 20px; text-align: center; letter-spacing: 1px; }
  #tradeList { margin: 16px 0; display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow-y: auto; }
  .tradeRow {
    display: flex; align-items: center; gap: 8px;
    background: #1a1a22; border: 2px solid #444;
    padding: 6px 10px; cursor: pointer; border-radius: 4px;
  }
  .tradeRow:hover { border-color: #ffd700; background: #2a2a18; }
  .tradeRow.disabled { opacity: 0.45; cursor: not-allowed; border-color: #555; }
  .tradeArrow { font-size: 20px; color: #888; padding: 0 8px; }
  .tradeIcon { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
  .tradeQty { color: #ffd700; font-weight: bold; margin-right: 4px; }
  .tradeName { color: #ddd; font-size: 12px; }

  /* Credits sequence */
  #credits {
    position: fixed; inset: 0; background: #04000a; z-index: 500;
    display: none; align-items: center; justify-content: center;
    color: #fff; overflow: hidden;
  }
  #credits.show { display: flex; }
  .creditsInner { text-align: center; padding: 30px; max-width: 80%; }
  #credits h1 {
    font-size: 64px; letter-spacing: 6px; margin-bottom: 16px;
    background: linear-gradient(120deg, #6fe6e6, #c69c6d, #6cc24a);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  #credits h2 { font-size: 22px; opacity: 0.85; margin-bottom: 40px; letter-spacing: 1px; }
  #credits h3 { font-size: 16px; letter-spacing: 4px; color: #ffd700; margin-top: 32px; }
  #credits p { font-size: 20px; opacity: 0.92; margin: 4px 0; }
  .creditsRoll {
    max-height: 50vh; overflow: hidden; position: relative; mask-image: linear-gradient(transparent, #000 20%, #000 80%, transparent);
  }
  .creditsRoll.animate {
    animation: creditScroll 30s linear forwards;
  }
  @keyframes creditScroll {
    from { transform: translateY(50vh); }
    to   { transform: translateY(-100%); }
  }
  #creditsClose {
    margin-top: 28px; padding: 10px 24px; background: #444; border: 1px solid #888;
    color: #fff; cursor: pointer; font-family: inherit; font-size: 14px; border-radius: 3px;
  }
  #creditsClose:hover { background: #666; }

  /* Settings */
  #settingsBtn {
    position: fixed; top: 12px; right: 14px; z-index: 30;
    width: 32px; height: 32px; font-size: 18px; border: 1px solid #888;
    background: rgba(0,0,0,0.4); color: #fff; cursor: pointer; border-radius: 4px;
  }
  #settingsBtn:hover { background: rgba(0,0,0,0.7); }
  #settings {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 300;
    display: none; align-items: center; justify-content: center;
  }
  #settings.open { display: flex; }
  .settingsInner {
    background: #2a2a36; border: 2px solid #4a4a5a; padding: 22px 28px;
    border-radius: 8px; color: #fff; min-width: 280px;
  }
  .settingsInner h2 { font-size: 20px; margin-bottom: 16px; }
  .settingsInner label { display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 6px 0; font-size: 14px; }
  .settingsInner select, .settingsInner input[type="range"] {
    background: #1a1a22; color: #fff; border: 1px solid #444; padding: 4px; border-radius: 3px;
  }
  .settingsInner button { margin-top: 14px; padding: 6px 14px; background: #46264a;
    border: 1px solid #888; color: #fff; cursor: pointer; border-radius: 3px;
  }

  #blocker {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center; flex-direction: column;
    z-index: 100; cursor: pointer;
  }
  #blocker h1 {
    font-size: 56px; letter-spacing: 4px; margin-bottom: 12px;
    background: linear-gradient(120deg, #8b6f47, #4d9b3a, #6cc24a);
    -webkit-background-clip: text; background-clip: text; color: transparent;
  }
  #blocker p { font-size: 16px; max-width: 460px; text-align: center; opacity: 0.9; margin-bottom: 4px; }
  #blocker .play { margin-top: 18px; padding: 12px 28px; background: #4d9b3a; border: 2px solid #2d6b1f;
    font-size: 18px; font-weight: bold; letter-spacing: 1px; color: #fff; cursor: pointer; border-radius: 3px; }
  #blocker .play:hover { background: #5dab4a; }

  #breakOverlay { position: absolute; pointer-events: none; }

  #craftUI {
    position: fixed; inset: 0; display: none; z-index: 200;
    background: rgba(0,0,0,0.75); align-items: center; justify-content: center;
  }
  #craftUI .panel {
    background: #2a2a36; border: 2px solid #555; padding: 24px 32px;
    border-radius: 8px; min-width: 480px; max-width: 720px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  }
  #craftUI h2 { font-size: 22px; margin-bottom: 16px; letter-spacing: 2px; text-align: center; color: #ffd700; }
  #craftUI h3 { font-size: 14px; margin-top: 20px; margin-bottom: 8px; color: #aaa; letter-spacing: 1px; }
  #craftUI .craftRow {
    display: flex; align-items: center; justify-content: center; gap: 18px;
    padding: 12px; background: rgba(0,0,0,0.3); border-radius: 6px;
  }
  #craftGrid { display: grid; gap: 3px; }
  #invGrid {
    display: grid; grid-template-columns: repeat(9, 50px); gap: 3px;
    min-height: 50px; padding: 6px; background: rgba(0,0,0,0.3); border-radius: 6px;
  }
  .cellSlot {
    width: 50px; height: 50px; background: rgba(70,70,80,0.7);
    border: 2px solid #444; display: flex; align-items: center; justify-content: center;
    position: relative; cursor: pointer; user-select: none;
  }
  .cellSlot:hover { border-color: #888; }
  .cellSlot .swatch { width: 32px; height: 32px; border: 1px solid #000; box-shadow: inset -4px -4px 0 rgba(0,0,0,0.25); pointer-events: none; }
  .cellSlot .count {
    position: absolute; bottom: 0px; right: 3px; font-size: 14px; font-weight: bold;
    color: #fff; text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000;
    pointer-events: none;
  }
  .resultSlot {
    width: 64px; height: 64px; background: rgba(80,60,40,0.7); border-color: #8a6a3a;
  }
  .resultSlot .swatch { width: 40px; height: 40px; }
  .arrow { font-size: 32px; color: #888; padding: 0 6px; }
  #craftUI .hint { margin-top: 14px; font-size: 11px; color: #888; text-align: center; line-height: 1.5; }
  #heldItem {
    position: fixed; pointer-events: none; z-index: 300;
    width: 50px; height: 50px; display: none; transform: translate(-25px, -25px);
  }
  #heldItem .swatch { width: 32px; height: 32px; border: 1px solid #000; box-shadow: inset -4px -4px 0 rgba(0,0,0,0.25); }
  #heldItem .count {
    position: absolute; bottom: -2px; right: 0px; font-size: 14px; font-weight: bold;
    color: #fff; text-shadow: 1px 1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, -1px -1px 0 #000;
  }
