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

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: #101622;
  color: #f4f6f8;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  touch-action: manipulation;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  cursor: crosshair;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* Overlays: underwater & damage flash */
#underwater-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: rgba(20, 82, 170, 0.38);
  backdrop-filter: blur(1px);
  z-index: 2;
}

#night-vision-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(30, 230, 170, 0.03) 55%, rgba(20, 195, 135, 0.24) 100%);
  box-shadow: inset 0 0 28px rgba(45, 255, 180, 0.28);
  z-index: 3;
}

#damage-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle, rgba(220, 20, 20, 0) 45%, rgba(220, 20, 20, 0.58) 100%);
  z-index: 4;
}

/* Crisp pixel crosshair */
#crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
}

#crosshair::before,
#crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.85);
}

#crosshair::before {
  left: 9px;
  top: 2px;
  width: 2px;
  height: 16px;
}

#crosshair::after {
  top: 9px;
  left: 2px;
  width: 16px;
  height: 2px;
}

/* Top-left F3 debug */
#hud-top-left {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#debug-panel {
  padding: 8px 10px;
  background: rgba(12, 16, 24, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.45;
  color: #e6f1ff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.8);
  white-space: pre;
}

/* Toast */
#toast {
  position: fixed;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 55;
  padding: 7px 16px;
  background: rgba(15, 20, 30, 0.92);
  border: 2px solid #7de06c;
  font-size: 13px;
  font-weight: 700;
  color: #f0fff2;
  pointer-events: none;
  text-shadow: 1px 1px 0 #000;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* In-game Chat */
#chat-container {
  position: fixed;
  left: 12px;
  bottom: 138px;
  width: min(440px, calc(100vw - 24px));
  z-index: 22;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

#chat-messages {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 185px;
  overflow-y: auto;
}

.chat-msg {
  padding: 3px 8px;
  background: rgba(8, 10, 14, 0.62);
  color: #f4f6fa;
  font-size: 13px;
  line-height: 1.35;
  text-shadow: 1px 1px 0 #000;
  word-break: break-word;
}

.chat-msg.sys {
  color: #ffff88;
}

.chat-msg.err {
  color: #ff7a7a;
}

#chat-input-row {
  pointer-events: auto;
}

#chat-input {
  width: 100%;
  padding: 7px 10px;
  background: rgba(8, 10, 14, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.45);
  color: #ffffff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

/* Bottom HUD + Survival Bars */
#hud-bottom {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}

#selected-block-name {
  min-height: 18px;
  padding: 2px 10px;
  border-radius: 4px;
  background: rgba(10, 12, 18, 0.6);
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.85);
}

#survival-bars {
  width: 502px;
  max-width: calc(100vw - 24px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#bars-armor-row,
#bars-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#bars-armor-row {
  min-height: 18px;
}

#thirst-bar {
  margin-left: auto;
}

.stat-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(10, 12, 18, 0.45);
}

.stat-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  font-size: 13px;
  line-height: 14px;
  text-align: center;
  text-shadow: 1px 1px 0 #000;
}

.heart-full { color: #ef3333; }
.heart-half { color: #ff8080; }
.heart-empty { color: rgba(255, 255, 255, 0.22); }

.food-full { color: #d9822b; }
.food-half { color: #e8b068; }
.food-empty { color: rgba(255, 255, 255, 0.2); }

.bubble-full { color: #54c8ff; }
.bubble-empty { color: rgba(255, 255, 255, 0.18); }

.shield-full { color: #cfd8e3; }
.shield-half { color: #909eb0; }
.shield-empty { color: rgba(255, 255, 255, 0.16); }

.drop-full { color: #38bdf8; }
.drop-half { color: #7dd3fc; }
.drop-empty { color: rgba(255, 255, 255, 0.18); }

#xp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

#xp-level {
  min-width: 18px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: #84ff54;
  text-shadow: 1px 1px 0 #000;
}

#xp-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(15, 18, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

#xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5ed430, #a7ff5e);
  transition: width 0.15s ease;
}

#hotbar {
  display: flex;
  gap: 4px;
  padding: 5px;
  background: rgba(20, 22, 28, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
}

.hotbar-slot,
.inv-slot {
  position: relative;
  width: 50px;
  height: 50px;
  background: rgba(48, 52, 62, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.08s ease;
}

.hotbar-slot:hover,
.inv-slot:hover {
  border-color: rgba(255, 255, 255, 0.6);
}

.hotbar-slot.active {
  border-color: #ffffff;
  background: rgba(95, 110, 130, 0.84);
  box-shadow: inset 0 0 0 2px rgba(255, 225, 110, 0.85), 0 0 12px rgba(255, 255, 255, 0.25);
}

.hotbar-slot img,
.inv-slot img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  pointer-events: none;
}

.slot-num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.9);
}

.slot-count {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
}

.slot-durability {
  position: absolute;
  left: 5px;
  right: 5px;
  bottom: 3px;
  height: 3px;
  background: rgba(0, 0, 0, 0.75);
  overflow: hidden;
  pointer-events: none;
}

.slot-durability-fill {
  height: 100%;
  background: #5ee64d;
}

/* Cursor item */
#cursor-item {
  position: fixed;
  z-index: 60;
  width: 44px;
  height: 44px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

#cursor-item img {
  width: 38px;
  height: 38px;
  image-rendering: pixelated;
}

#cursor-item-count {
  position: absolute;
  bottom: 0;
  right: 2px;
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 1px 1px 0 #000;
}

/* Container & Death Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 20, 0.72);
  padding: 14px;
}

.death-bg {
  background: rgba(120, 12, 12, 0.72);
}

.death-card {
  width: min(420px, 100%);
  background: rgba(24, 18, 22, 0.92);
  border: 2px solid #000;
  box-shadow: inset 0 0 0 2px rgba(255, 110, 110, 0.35), 0 20px 48px rgba(0, 0, 0, 0.75);
  padding: 26px;
  text-align: center;
}

.death-card h1 {
  font-size: 34px;
  color: #ff5555;
  text-shadow: 3px 3px 0 #3a0808;
  margin-bottom: 8px;
}

.death-card p {
  font-size: 14px;
  color: #e2d4d8;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 18px;
}

.death-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* =========================================================================
   MINECRAFT JAVA EDITION TITLE, PAUSE & SUB-SCREENS
   ========================================================================= */

.mc-menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

/* Title screen: crisp 3D panorama with soft edge vignette */
.mc-menu-overlay.mode-title {
  background: radial-gradient(circle at 50% 42%, rgba(0, 0, 0, 0.08) 35%, rgba(0, 0, 0, 0.45) 100%);
}

/* Pause screen: classic semi-transparent dimming */
.mc-menu-overlay.mode-pause {
  background: rgba(0, 0, 0, 0.58);
}

/* Sub-screens: tiled pixel-art dark dirt background */
.mc-menu-overlay.mode-dirt {
  background-color: #261b12;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.54), rgba(0, 0, 0, 0.62)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%236b4b32'/%3E%3Crect x='1' y='1' width='2' height='2' fill='%23543924'/%3E%3Crect x='6' y='2' width='3' height='2' fill='%237b583c'/%3E%3Crect x='12' y='1' width='2' height='3' fill='%234b321f'/%3E%3Crect x='3' y='6' width='2' height='2' fill='%23825e40'/%3E%3Crect x='8' y='7' width='3' height='2' fill='%23503622'/%3E%3Crect x='13' y='6' width='2' height='2' fill='%236e4d33'/%3E%3Crect x='0' y='10' width='3' height='2' fill='%234c3320'/%3E%3Crect x='5' y='11' width='2' height='3' fill='%23593d27'/%3E%3Crect x='10' y='11' width='2' height='2' fill='%237e5a3d'/%3E%3Crect x='14' y='12' width='2' height='2' fill='%234a311e'/%3E%3Crect x='3' y='14' width='2' height='2' fill='%2379563a'/%3E%3Crect x='9' y='14' width='3' height='2' fill='%2349301d'/%3E%3C/svg%3E");
  background-size: 100% 100%, 64px 64px;
  image-rendering: pixelated;
}

.mc-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mc-title-screen {
  justify-content: space-between;
  padding: 26px 16px 8px;
}

/* Iconic MINECRAFT 3D stone logo + Splash */
.mc-logo-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
  margin-bottom: 18px;
}

.mc-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 26px 12px;
  background: linear-gradient(180deg, rgba(20, 22, 28, 0.32) 0%, rgba(20, 22, 28, 0.05) 100%);
  border-radius: 6px;
}

.mc-logo-text {
  font-family: "Arial Black", "Impact", "Segoe UI", sans-serif;
  font-size: clamp(42px, 7.2vw, 76px);
  font-weight: 900;
  letter-spacing: 5px;
  line-height: 1;
  color: #d8d8d8;
  text-shadow:
    0 2px 0 #9f9f9f,
    0 4px 0 #7b7b7b,
    0 6px 0 #5b5b5b,
    0 8px 0 #3c3c3c,
    0 10px 0 #202020,
    -2px -2px 0 #1f1f1f,
    2px -2px 0 #1f1f1f,
    -2px 2px 0 #1f1f1f,
    2px 2px 0 #1f1f1f,
    0 14px 24px rgba(0, 0, 0, 0.72);
}

.mc-logo-sub {
  margin-top: 8px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #e6ecf5;
  text-shadow: 2px 2px 0 #1c222d;
}

@keyframes splashPulse {
  0%, 100% { transform: rotate(-18deg) scale(1); }
  50% { transform: rotate(-18deg) scale(1.1); }
}

.mc-splash {
  position: absolute;
  right: -18px;
  bottom: 4px;
  background: none;
  border: none;
  padding: 2px 6px;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: clamp(14px, 2vw, 19px);
  font-weight: 900;
  color: #ffff00;
  text-shadow: 2px 2px 0 #3f3f00, 0 0 8px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  animation: splashPulse 0.9s ease-in-out infinite;
  white-space: nowrap;
}

.mc-splash:hover {
  filter: brightness(1.12);
}

/* Classic Stone Buttons */
.mc-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #f2f2f2;
  text-shadow: 2px 2px 0 #383838;
  background-color: #747474;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.14) 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 4px, rgba(0, 0, 0, 0.04) 4px 8px);
  border: 2px solid #000000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -3px 0 rgba(0, 0, 0, 0.45);
  cursor: pointer;
  border-radius: 0;
  transition: background-color 0.08s ease, color 0.08s ease;
}

.mc-btn:hover {
  background-color: #6b7ac9;
  color: #ffffa0;
  text-shadow: 2px 2px 0 #262e54;
  box-shadow:
    inset 2px 2px 0 rgba(196, 210, 255, 0.62),
    inset -2px -3px 0 rgba(35, 42, 92, 0.65);
}

.mc-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.42),
    inset -2px -2px 0 rgba(255, 255, 255, 0.25);
}

.mc-btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.mc-btn-sm {
  min-height: 36px;
  font-size: 13px;
  padding: 6px 10px;
}

.mc-btn-icon {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 14px;
}

.mc-menu-stack {
  width: min(410px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-btn-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mc-btn-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.mc-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  text-shadow: 2px 2px 0 #222222;
}

.mc-screen-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 2px 2px 0 #2b2b2b;
  margin-bottom: 18px;
  text-align: center;
}

/* Sub-screens: Worlds, Create, Options, Controls */
.mc-subscreen {
  justify-content: space-between;
  max-width: 680px;
  padding: 18px 8px;
  gap: 14px;
}

.mc-worlds-scroll {
  width: 100%;
  flex: 1;
  min-height: 180px;
  max-height: 55vh;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.56);
  border-top: 2px solid #000;
  border-bottom: 2px solid #000;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.world-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: rgba(25, 25, 25, 0.45);
  border: 2px solid transparent;
  cursor: pointer;
}

.world-row:hover {
  background: rgba(45, 45, 55, 0.55);
}

.world-row.selected {
  background: rgba(0, 0, 0, 0.78);
  border-color: #ffffff;
}

.world-row-icon {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.world-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.world-meta strong {
  font-size: 15px;
  color: #ffffff;
  text-shadow: 1px 1px 0 #000;
}

.world-meta span {
  font-size: 12px;
  color: #a6a6a6;
}

.mc-subscreen-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mc-subscreen-footer.narrow {
  width: min(320px, 90vw);
}

.mc-form-box {
  width: min(420px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mc-field-label {
  font-size: 13px;
  font-weight: 700;
  color: #b8b8b8;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: -4px;
}

.mc-input {
  width: 100%;
  padding: 10px 12px;
  background: #000000;
  border: 2px solid #a0a0a0;
  color: #ffffff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.mc-input:focus {
  border-color: #ffffff;
}

.mc-options-grid {
  width: min(640px, 96vw);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mc-slider-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  padding: 5px 12px;
  background-color: #747474;
  border: 2px solid #000000;
  box-shadow:
    inset 2px 2px 0 rgba(255, 255, 255, 0.42),
    inset -2px -3px 0 rgba(0, 0, 0, 0.45);
}

.mc-slider-btn label {
  font-size: 12px;
  font-weight: 700;
  color: #f2f2f2;
  text-shadow: 1px 1px 0 #383838;
  text-align: center;
}

.mc-slider-btn input[type="range"] {
  width: 100%;
  height: 12px;
  accent-color: #ffffa0;
  cursor: pointer;
}

.mc-controls-panel {
  width: min(600px, 94vw);
  background: rgba(0, 0, 0, 0.56);
  border: 2px solid #000;
  padding: 16px 20px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
  font-size: 13px;
  color: #e2e8f0;
  text-shadow: 1px 1px 0 #000;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  margin-right: 6px;
  font-family: Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: #ffffa0;
  background: #2f2f36;
  border: 1px solid #000;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.25);
}

/* =========================================================================
   CONTAINER MODAL (Inventory / Crafting / Furnace / Chest)
   ========================================================================= */

.modal-card {
  width: min(650px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: #c6c6c6;
  color: #262626;
  border: 3px solid #000000;
  box-shadow:
    inset 3px 3px 0 #ffffff,
    inset -3px -3px 0 #555555,
    0 20px 48px rgba(0, 0, 0, 0.72);
  padding: 16px 18px;
}

.container-card {
  width: min(860px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 800;
  color: #2b2b2b;
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header-actions .mc-btn {
  width: auto;
}

.container-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

#recipe-book-panel {
  width: 225px;
  flex-shrink: 0;
  background: #3a3a3a;
  color: #f4f4f4;
  border: 2px solid #000;
  padding: 8px;
  max-height: 440px;
  overflow-y: auto;
}

#recipe-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.recipe-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  background: #555555;
  border: 2px solid #1b1b1b;
  color: #ffffff;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.recipe-entry:hover {
  border-color: #ffffa0;
  background: #6776c2;
}

.recipe-entry img {
  width: 26px;
  height: 26px;
  image-rendering: pixelated;
}

.recipe-entry-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.recipe-entry-info small {
  font-size: 10px;
  color: #d4d8e0;
  font-weight: 500;
}

.container-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.subpanel-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #3a3a3a;
  margin-bottom: 4px;
}

#recipe-book-panel .subpanel-title {
  color: #e0e0e0;
}

.hotbar-sub {
  margin-top: 8px;
}

.station-section {
  background: rgba(0, 0, 0, 0.12);
  border: 2px solid #555555;
  padding: 10px;
}

.crafting-with-armor {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.armor-slots-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.armor-with-doll {
  display: flex;
  align-items: center;
  gap: 8px;
}

#player-paperdoll {
  width: 68px;
  height: 104px;
  background: #181c24;
  border-top: 2px solid #373737;
  border-left: 2px solid #373737;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.armor-grid {
  display: grid;
  grid-template-columns: repeat(2, 50px);
  gap: 4px;
}

.armor-slot-hint {
  font-size: 10px;
  font-weight: 700;
  color: rgba(30, 30, 30, 0.55);
  pointer-events: none;
  text-align: center;
}

.crafting-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex: 1;
}

.slot-grid {
  display: grid;
  gap: 4px;
}

.slot-grid.cols-2 {
  grid-template-columns: repeat(2, 50px);
}

.slot-grid.cols-3 {
  grid-template-columns: repeat(3, 50px);
}

.slot-grid.cols-9 {
  grid-template-columns: repeat(9, 50px);
}

.container-card .inv-slot {
  background: #8b8b8b;
  border-top: 2px solid #373737;
  border-left: 2px solid #373737;
  border-right: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
}

.container-card .inv-slot:hover {
  background: #a4a4a4;
}

.station-arrow {
  font-size: 22px;
  color: #3b3b3b;
}

.container-card .output-slot {
  background: #8b9a84;
}

/* Furnace UI */
.furnace-power-status {
  margin-bottom: 8px;
  padding: 5px 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  border: 2px solid #1a1a1a;
  background: #3a3a3a;
  color: #ffd166;
}

.furnace-power-status.powered {
  color: #5ef2b8;
  border-color: #218c6e;
}

.furnace-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.furnace-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.furnace-flame-box {
  width: 26px;
  height: 26px;
  background: #3a3a3a;
  border: 2px solid #1a1a1a;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

#furnace-flame-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, #ffd84d 0%, #ff6a1a 100%);
}

.furnace-arrow-box {
  width: 44px;
  height: 14px;
  background: #3a3a3a;
  border: 2px solid #1a1a1a;
  overflow: hidden;
}

#furnace-arrow-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #7de06c, #b4ff7a);
}

/* Creative Grid */
.creative-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.creative-header input {
  padding: 5px 8px;
  background: #222;
  color: #fff;
  border: 2px solid #000;
  font-size: 12px;
}

#creative-grid {
  display: grid;
  grid-template-columns: repeat(9, 50px);
  gap: 4px;
  max-height: 170px;
  overflow-y: auto;
}

.modal-hint {
  margin-top: 10px;
  font-size: 11px;
  font-weight: 600;
  color: #3a3a3a;
  text-align: center;
}

.mc-field-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: #d7d7d7;
}

#touch-hud {
  position: fixed;
  inset: 0;
  z-index: 24;
  pointer-events: none;
}

#touch-surface {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: calc(158px + env(safe-area-inset-bottom));
  pointer-events: auto;
  touch-action: none;
}

#joy-pad {
  position: absolute;
  width: 128px;
  height: 128px;
  margin-left: -64px;
  margin-top: -64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: inset 0 0 0 18px rgba(255, 255, 255, 0.05);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}

#joy-pad.is-active {
  opacity: 1;
}

#joy-knob {
  position: absolute;
  left: 42px;
  top: 42px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

#touch-actions {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: auto;
  z-index: 4;
  touch-action: none;
}

.touch-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

#touch-actions button {
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(12, 14, 20, 0.48);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 0 #000;
  touch-action: none;
}

#touch-actions button.touch-xl {
  width: 76px;
  height: 76px;
  font-size: 14px;
}

#touch-actions .touch-utils button {
  width: 46px;
  height: 40px;
  border-radius: 12px;
  font-size: 11px;
}

#touch-actions button.is-down,
#touch-actions button:active,
#touch-actions button.is-on {
  background: rgba(86, 166, 62, 0.82);
  border-color: rgba(220, 255, 210, 0.9);
}

body.touch-mode #hud-bottom {
  left: max(8px, env(safe-area-inset-left));
  transform: none;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  width: calc(100vw - 168px - env(safe-area-inset-right));
  align-items: stretch;
  pointer-events: none;
}

body.touch-mode #hotbar {
  pointer-events: auto;
  overflow-x: auto;
  max-width: 100%;
}

body.touch-mode .hotbar-slot {
  width: 42px;
  height: 46px;
  flex: 0 0 auto;
}

body.touch-mode #survival-bars {
  width: 100%;
}

@media (max-width: 720px) {
  .hotbar-slot,
  .inv-slot {
    width: 40px;
    height: 40px;
  }
  .hotbar-slot img,
  .inv-slot img {
    width: 28px;
    height: 28px;
  }
  .slot-grid.cols-9,
  #creative-grid {
    grid-template-columns: repeat(9, 40px);
  }
  .mc-options-grid,
  .mc-btn-row-4 {
    grid-template-columns: 1fr;
  }
  .container-layout {
    flex-direction: column;
  }
  #recipe-book-panel {
    width: 100%;
    max-height: 160px;
  }
  .mc-btn,
  .mc-input {
    min-height: 44px;
  }
  .mc-screen-title {
    font-size: 22px;
  }
  #chat-container {
    max-width: calc(100vw - 16px);
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  #touch-surface {
    right: 176px;
    bottom: calc(52px + env(safe-area-inset-bottom));
  }
  #touch-actions {
    bottom: calc(6px + env(safe-area-inset-bottom));
    gap: 5px;
  }
  #touch-actions button.touch-xl {
    width: 58px;
    height: 58px;
    font-size: 12px;
  }
  #touch-actions button {
    width: 42px;
    height: 42px;
  }
  #touch-actions .touch-utils button {
    width: 40px;
    height: 32px;
  }
  body.touch-mode #hud-bottom {
    left: max(8px, env(safe-area-inset-left));
    width: calc(100vw - 196px);
    bottom: calc(4px + env(safe-area-inset-bottom));
  }
  body.touch-mode .hotbar-slot {
    width: 36px;
    height: 40px;
  }
  body.touch-mode #selected-block-name,
  body.touch-mode #bars-armor-row {
    display: none;
  }
}

@media (max-width: 420px) {
  .hotbar-slot,
  .inv-slot {
    width: 32px;
    height: 40px;
  }
  .slot-grid.cols-9,
  #creative-grid {
    grid-template-columns: repeat(9, 32px);
  }
}
