  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { width: 100%; height: 100%; overflow: hidden; background: #000;
    font-family: "Segoe UI", system-ui, sans-serif; }
  canvas.game { display: block; }

  /* ---------- HUD ---------- */
  #crosshair { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%);
    color: #fff; font-size: 22px; pointer-events: none; text-shadow: 0 0 3px #000;
    z-index: 10; user-select: none; }
  #hotbar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
    display: flex; gap: 4px; z-index: 10; pointer-events: none; }
  .slot { width: 52px; height: 52px; background: rgba(0,0,0,.45); border: 2px solid #666;
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    position: relative; }
  .slot canvas { image-rendering: pixelated; }
  .slot.active { border-color: #fff; box-shadow: 0 0 8px rgba(255,255,255,.6); }
  .slot .key { position: absolute; top: 2px; left: 4px; color: #ccc; font-size: 10px; }
  .slot .name { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%);
    color: #eee; font-size: 12px; text-shadow: 0 1px 2px #000; white-space: nowrap; display: none; }
  .slot.active .name { display: block; }
  #debug { position: fixed; left: 10px; top: 10px; color: #fff; font-size: 12px;
    text-shadow: 0 1px 2px #000; z-index: 10; pointer-events: none; line-height: 1.5; }

  /* ---------- Здоровье, сообщения ---------- */
  #hearts { position: fixed; left: 12px; top: 66px; z-index: 10; font-size: 21px;
    letter-spacing: 2px; pointer-events: none; text-shadow: 0 1px 3px #000; }
  #hurt { position: fixed; inset: 0; z-index: 15; pointer-events: none; opacity: 0;
    transition: opacity .5s; box-shadow: inset 0 0 120px 40px rgba(200,0,0,.75); }
  #msg { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); z-index: 12;
    color: #fff; font-size: 26px; text-shadow: 0 2px 4px #000; pointer-events: none;
    opacity: 0; transition: opacity .4s; }

  /* ---------- Стартовое меню ---------- */
  #overlay { position: fixed; inset: 0; z-index: 20; display: flex;
    align-items: center; justify-content: center;
    background: linear-gradient(160deg, rgba(15,30,55,.94), rgba(10,45,30,.94)); }
  #panel { background: rgba(0,0,0,.55); border: 1px solid #445; border-radius: 12px;
    padding: 26px 34px; color: #eee; width: 640px; max-width: 94vw; max-height: 92vh;
    overflow-y: auto; text-align: center; }
  #panel h1 { font-size: 30px; margin-bottom: 4px; letter-spacing: 1px; }
  #panel h1 span { color: #7dc95f; }
  #panel p.sub { color: #aaa; margin-bottom: 16px; font-size: 13px; }
  #panel label { font-size: 13px; color: #bbb; }
  #seed { width: 120px; padding: 6px 8px; margin: 4px 8px; border-radius: 6px;
    border: 1px solid #667; background: #12161c; color: #fff; font-size: 14px; }
  #play { margin: 12px 0 14px; padding: 10px 34px; font-size: 17px; cursor: pointer;
    background: #4c8a3a; color: #fff; border: none; border-radius: 8px; }
  #play:hover { background: #5aa046; }
  #help { text-align: left; font-size: 13px; line-height: 1.8; color: #cfd6dd; }
  #help b { color: #ffd76a; font-family: Consolas, monospace; }
  #craftGuide { text-align: left; font-size: 13px; color: #cfd6dd; margin-top: 8px; }
  #craftGuide h3 { color: #7dc95f; margin-bottom: 6px; font-size: 15px; }
  #craftGuide .grid { font-family: Consolas, monospace; background: rgba(0,0,0,.35);
    border-radius: 6px; padding: 6px 10px; margin: 6px 0; white-space: pre; font-size: 12px;
    line-height: 1.4; display: inline-block; }
  #craftGuide .out { color: #ffd76a; }
  .hidden { display: none !important; }

  /* ---------- GUI инвентаря / крафта / сундука / печки ---------- */
  #gui { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center;
    justify-content: center; background: rgba(0,0,0,.45); }
  #guiPanel { background: #2b2b33; border: 2px solid #55555f; border-radius: 10px;
    padding: 16px 20px; color: #ddd; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
  #guiTitle { font-size: 16px; margin-bottom: 10px; color: #fff; }
  .gridRow { display: flex; gap: 4px; margin-bottom: 4px; }
  .gslot { width: 50px; height: 50px; background: #3b3b45; border: 2px solid #55555f;
    border-radius: 4px; position: relative; display: flex; align-items: center;
    justify-content: center; cursor: pointer; }
  .gslot:hover { border-color: #9a9ab0; background: #45454f; }
  .gslot canvas { image-rendering: pixelated; pointer-events: none; }
  .gslot .cnt { position: absolute; right: 3px; bottom: 1px; color: #fff; font-size: 12px;
    font-weight: bold; text-shadow: 1px 1px 0 #000; pointer-events: none; }
  .gslot.hot { background: #4a4a58; }
  .gslot.craftOut { background: #46543c; border-color: #6f8050; }
  #craftZone, #smeltZone { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
  .arrow { font-size: 24px; color: #999; }
  #fBar { width: 40px; height: 8px; background: #222; border-radius: 3px; overflow: hidden; margin-top: 4px; }
  #fBarIn { height: 100%; background: #f80; width: 0%; }
  #pBar { width: 40px; height: 8px; background: #222; border-radius: 3px; overflow: hidden; }
  #pBarIn { height: 100%; background: #6cf; width: 0%; }
  #invSeparator { height: 8px; }
  #guiHelp { font-size: 11px; color: #999; margin-top: 10px; max-width: 500px; line-height: 1.5; }
  #guiClose { margin-top: 10px; padding: 6px 18px; background: #5a4a3a; color: #fff;
    border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
  #cursorStack { position: fixed; z-index: 40; width: 40px; height: 40px; pointer-events: none;
    display: none; }
  #cursorStack canvas { image-rendering: pixelated; }
  #cursorStack .cnt { position: absolute; right: 0; bottom: -2px; color: #fff; font-size: 12px;
    font-weight: bold; text-shadow: 1px 1px 0 #000; }

  /* ---------- Сенсорное управление ---------- */
  #touchUI { position: fixed; inset: 0; z-index: 11; pointer-events: none; display: none; }
  body.is-touch #touchUI { display: block; }
  #joyZone { position: absolute; left: 18px; bottom: 84px; width: 150px; height: 150px; border-radius: 50%;
    background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25);
    pointer-events: auto; touch-action: none; }
  #joyKnob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
    border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.6);
    pointer-events: none; }
  .tbtn { position: absolute; width: 54px; height: 54px; border-radius: 12px;
    background: rgba(0,0,0,.45); border: 2px solid rgba(255,255,255,.35); color: #fff; font-size: 21px;
    display: flex; align-items: center; justify-content: center; pointer-events: auto;
    touch-action: none; user-select: none; -webkit-user-select: none; }
  .tbtn:active { background: rgba(255,255,255,.3); }
  #tBreak { right: 20px; bottom: 150px; width: 74px; height: 74px; font-size: 30px; }
  #tPlace { right: 106px; bottom: 206px; }
  #tJump  { right: 106px; bottom: 140px; }
  #tDown  { right: 20px; bottom: 76px; }
  #tInv   { right: 20px; top: 14px; }
  #tFly   { right: 20px; top: 76px; }
  #tMenu  { right: 20px; top: 138px; }
  #tPrev  { left: 184px; bottom: 92px; width: 44px; height: 44px; font-size: 18px; }
  #tNext  { left: 236px; bottom: 92px; width: 44px; height: 44px; font-size: 18px; }
  @media (pointer: coarse) {
    .slot { width: 34px; height: 34px; }
    .slot canvas { width: 28px; height: 28px; }
    .slot .key { display: none; }
    #hotbar { bottom: 8px; gap: 2px; }
    #hearts { font-size: 16px; top: 50px; }
    #debug { font-size: 10px; line-height: 1.3; }
  }
