* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #3b6b2a;
  font-family: "Sarabun", "Noto Sans Thai", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

canvas {
  display: block;
  touch-action: none;
}

#gear {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  z-index: 10;
}

#panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(620px, 72vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 25, 15, 0.88);
  color: #fff;
  font-size: 14px;
  z-index: 20;
}
#panel[hidden] { display: none; }

#panel .phead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 17px;
}
#panel button {
  border: 0;
  border-radius: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
}
#panel .pgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 18px;
}
#panel .prow { display: block; }
#panel .prow em { font-style: normal; color: #ffd23f; float: right; }
#panel input[type="range"] { width: 100%; margin-top: 4px; }
#panel .pfoot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

#gear[hidden], #editbar[hidden] { display: none; }

#editbar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(15, 25, 15, 0.88);
  color: #fff;
  font-size: 14px;
  z-index: 20;
}
#editbar button {
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 16px;
}
#editbar button.ok { background: #2f9e44; }
#editbar span { min-width: 84px; text-align: center; }
