/* Compact, repositionable single-row Sand toolbar. */
#tools {
  position: fixed; z-index: 8; left: 0; top: 0; right: auto; bottom: auto;
  transform: none; box-sizing: border-box; display: flex; flex-direction: row; gap: 5px;
  align-items: center; width: max-content; max-width: calc(100vw - 12px);
  padding: 6px; color: #f0eee9; background: rgb(25 25 23 / 91%);
  border: 1px solid #ffffff22; border-radius: 14px; box-shadow: 0 5px 28px #0006;
  font: 500 12px/1.1 system-ui, -apple-system, sans-serif;
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#tools.vertical { flex-direction: column; width: 62px; max-width: 62px; gap: 5px; }
#tools.dragging { box-shadow: 0 0 0 2px #f0d39a99, 0 10px 36px #0009; }
#tools.dragging button { pointer-events: none; }
#tools button.tool-button, .menu-actions button.tool-button {
  box-sizing: border-box; display: flex; position: static; flex: 0 0 auto;
  align-items: center; justify-content: center;
  height: 44px; min-height: 44px; min-width: 46px;
  border: 0; border-radius: 9px; margin: 0; padding: 0 9px;
  color: #f0eee9; background: #ffffff15;
  font: 550 12px/1 system-ui, -apple-system, sans-serif;
  opacity: 1; pointer-events: auto; transform: none; box-shadow: none;
  white-space: nowrap; touch-action: none;
}
#tools.vertical button.tool-button { width: 48px; padding: 0 5px; }
#tools button.on, .menu-actions button.on,
#tools #menuBtn.on, #tools #settingsBtn[aria-expanded="true"] {
  background: #f0d39a; color: #25241e;
}
#tools button:active:not(:disabled), .menu-actions button:active:not(:disabled) { filter: brightness(1.15); }
#tools button:focus-visible, .menu-actions button:focus-visible { outline: 2px solid #f0d39a; outline-offset: 1px; }
.menu-actions button:disabled { opacity: .38; }
#menu {
  position: fixed; left: 8px; top: 8px; right: auto; bottom: auto;
  max-width: calc(100vw - 16px); overflow-y: auto;
  overscroll-behavior: contain; touch-action: pan-y; z-index: 10;
  transform-origin: 50% 50%;
}
#menu h2 { margin-top: 5px; }
.sand-weight-card {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1px;
  width: 100%;
  min-height: 94px;
  padding: 11px 15px 12px;
  margin: 0 0 11px;
  border: 1px solid rgba(240, 211, 154, .18);
  border-radius: 15px;
  background: linear-gradient(140deg, rgba(240, 211, 154, .14), rgba(255, 255, 255, .055));
}
.sand-weight-label {
  color: #d6c6a7;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
}
#sandWeight {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 7px;
  max-width: 100%;
  color: #fff5e4;
  font-size: clamp(38px, 10vw, 46px);
  font-weight: 650;
  line-height: 1.16;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.035em;
  white-space: nowrap;
}
#sandWeightValue {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
}
#sandWeightUnit {
  color: #b8ac99;
  font-size: .44em;
  font-weight: 500;
  letter-spacing: 0;
}
.sand-menu-controls { margin-top: 12px; padding-top: 10px; border-top: 1px solid #ffffff24; }
.sand-menu-controls .amount { display: grid; gap: 8px; padding: 2px 1px 8px; }
.sand-menu-controls .amount label { display: flex; justify-content: space-between; gap: 10px; color: #e3e0d9; font-size: 12px; }
.sand-menu-controls #quantityValue { color: #f0d39a; font-variant-numeric: tabular-nums; }
.sand-menu-controls #quantity {
  width: 100%; height: 34px; margin: 0; accent-color: #f0d39a;
  touch-action: none; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
.sand-menu-controls #quantity::-webkit-slider-runnable-track { height: 12px; border-radius: 99px; background: #5c5d55; }
.sand-menu-controls #quantity::-moz-range-track { height: 12px; border-radius: 99px; background: #5c5d55; }
.sand-menu-controls #quantity::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; margin-top: -9px;
  border-radius: 50%; border: 2px solid #302b22; background: #f0d39a;
  box-shadow: 0 2px 6px #0008;
}
.sand-menu-controls #quantity::-moz-range-thumb {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid #302b22; background: #f0d39a; box-shadow: 0 2px 6px #0008;
}
.sand-menu-controls .menu-actions { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.menu-actions button.tool-button { min-width: 0; width: 100%; touch-action: manipulation; }
#fpsOverlay {
  position: fixed; z-index: 7; top: max(7px, env(safe-area-inset-top));
  right: max(9px, env(safe-area-inset-right)); background: none; margin: 0; padding: 0;
  min-width: 1ch; color: #fff; font: 700 18px/1.1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-text-stroke: .65px #000;
  text-shadow: -1px 0 #000, 1px 0 #000, 0 -1px #000, 0 1px #000;
  text-align: right; pointer-events: none;
}
#fpsOverlay[hidden] { display: none !important; }
html.sand-settings-open #tools { opacity: 0; pointer-events: none; }
@media (max-width: 340px) {
  #tools { gap: 3px; padding: 5px; }
  #tools button.tool-button { min-width: 42px; height: 42px; padding: 0 7px; }
  #tools.vertical { width: 56px; max-width: 56px; }
  #tools.vertical button.tool-button { width: 44px; }
}

#tools button.tool-button { padding: 0; }
#tools button.tool-button svg {
  display: block;
  flex: none;
  width: 22px;
  height: 22px;
  pointer-events: none;
}
